Refactorisation du workflow:

le manager devient statique, et les procédures
relatives au fichiers utisateur sont uniformisée,
que l'utilisateur soit enregistré ou anonyme,
que ce soit pour le blogspot, le frontoffice ou le workflow.

* YavscModel.csproj:
* Commande.cs:
* WorkFlowManager.cs:
* WebFileSystemManager.cs:
* UserFileSystemManager.cs: refactorisation du code, en vue de la mise
  en place
de la commande sans enregistrement du client sur le site.

* BasketController.cs:
* WorkFlowController.cs:
* FrontOfficeController.cs:
* FrontOfficeController.cs: Le manager de flux de travaux est devient
  un objet statique.

* FileSystemController.cs: refactorisation du code, en vue de la mise
  en place
de la commande sans enregistrement du client sur le site.

* Web.csproj: ajoute les références au déployement des sites
* Totem prod
* Totem pré
Leur configuration n'est pas maintenue sous Git.
This commit is contained in:
Paul Schneider 2015-11-22 14:00:59 +01:00
commit 439759cb16
13 changed files with 233 additions and 166 deletions

View file

@ -17,20 +17,6 @@ namespace Yavsc.ApiControllers
/// </summary>
public class BasketController : ApiController
{
/// <summary>
/// The wfmgr.
/// </summary>
protected WorkFlowManager wfmgr = null;
/// <summary>
/// Initialize the specified controllerContext.
/// </summary>
/// <param name="controllerContext">Controller context.</param>
protected override void Initialize (System.Web.Http.Controllers.HttpControllerContext controllerContext)
{
base.Initialize (controllerContext);
wfmgr = new WorkFlowManager ();
}
/// <summary>
/// Gets the current basket, creates a new one, if it doesn't exist.
@ -38,7 +24,8 @@ namespace Yavsc.ApiControllers
/// <value>The current basket.</value>
protected CommandSet CurrentBasket {
get {
CommandSet b = wfmgr.GetCommands (Membership.GetUser ().UserName);
CommandSet b = WorkFlowManager.GetCommands (
Membership.GetUser ().UserName);
if (b == null) b = new CommandSet ();
return b;
}

View file

@ -24,20 +24,6 @@ namespace Yavsc.ApiControllers
/// </summary>
public class FrontOfficeController : YavscController
{
/// <summary>
/// The wfmgr.
/// </summary>
protected WorkFlowManager wfmgr = null;
/// <summary>
/// Initialize the specified controllerContext.
/// </summary>
/// <param name="controllerContext">Controller context.</param>
protected override void Initialize (System.Web.Http.Controllers.HttpControllerContext controllerContext)
{
base.Initialize (controllerContext);
wfmgr = new WorkFlowManager ();
}
/// <summary>
/// Catalog this instance.
@ -71,7 +57,7 @@ namespace Yavsc.ApiControllers
[HttpGet]
public Estimate GetEstimate (long id)
{
Estimate est = wfmgr.ContentProvider.Get (id);
Estimate est = WorkFlowManager.ContentProvider.Get (id);
string username = Membership.GetUser ().UserName;
if (est.Client != username)
if (!Roles.IsUserInRole("Admin"))
@ -109,7 +95,7 @@ namespace Yavsc.ApiControllers
private string estimateToTex (long estimid)
{
Yavsc.templates.Estim tmpe = new Yavsc.templates.Estim ();
Estimate e = wfmgr.GetEstimate (estimid);
Estimate e = WorkFlowManager.GetEstimate (estimid);
tmpe.Session = new Dictionary<string,object> ();
tmpe.Session.Add ("estim", e);
Profile prpro = new Profile (ProfileBase.Create (e.Responsible));

View file

@ -19,25 +19,6 @@ namespace Yavsc.ApiControllers
/// </summary>
public class WorkFlowController : ApiController
{
string adminRoleName="Admin";
/// <summary>
/// The wfmgr.
/// </summary>
protected WorkFlowManager wfmgr = null;
/// <summary>
/// Initialize the specified controllerContext.
/// </summary>
/// <param name="controllerContext">Controller context.</param>
protected override void Initialize (HttpControllerContext controllerContext)
{
// TODO move it in a module initialization
base.Initialize (controllerContext);
if (!Roles.RoleExists (adminRoleName)) {
Roles.CreateRole (adminRoleName);
}
wfmgr = new WorkFlowManager ();
}
/// <summary>
/// Creates the estimate.
/// </summary>
@ -49,7 +30,7 @@ namespace Yavsc.ApiControllers
[Authorize]
public Estimate CreateEstimate (string title,string client,string description)
{
return wfmgr.CreateEstimate (
return WorkFlowManager.CreateEstimate (
Membership.GetUser().UserName,client,title,description);
}
@ -102,7 +83,7 @@ namespace Yavsc.ApiControllers
[Authorize]
public void DropWritting(long wrid)
{
wfmgr.DropWritting (wrid);
WorkFlowManager.DropWritting (wrid);
}
/// <summary>
@ -114,14 +95,14 @@ namespace Yavsc.ApiControllers
public void DropEstimate(long estid)
{
string username = Membership.GetUser().UserName;
Estimate e = wfmgr.GetEstimate (estid);
Estimate e = WorkFlowManager.GetEstimate (estid);
if (e == null)
throw new InvalidOperationException("not an estimate id:"+estid);
if (username != e.Responsible
&& !Roles.IsUserInRole ("FrontOffice"))
throw new UnauthorizedAccessException ("You're not allowed to drop this estimate");
wfmgr.DropEstimate (estid);
WorkFlowManager.DropEstimate (estid);
}
/// <summary>
@ -146,7 +127,7 @@ namespace Yavsc.ApiControllers
[ValidateAjax]
public HttpResponseMessage UpdateWritting([FromBody] Writting wr)
{
wfmgr.UpdateWritting (wr);
WorkFlowManager.UpdateWritting (wr);
return Request.CreateResponse<string> (System.Net.HttpStatusCode.OK,"WrittingUpdated:"+wr.Id);
}
@ -166,7 +147,7 @@ namespace Yavsc.ApiControllers
}
try {
return Request.CreateResponse(System.Net.HttpStatusCode.OK,
wfmgr.Write(estid, wr.Description,
WorkFlowManager.Write(estid, wr.Description,
wr.UnitaryCost, wr.Count, wr.ProductReference));
}
catch (Exception ex) {