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) {

View file

@ -1,3 +1,21 @@
2015-11-22 Paul Schneider <paul@pschneider.fr>
* 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.
2015-11-21 Paul Schneider <paul@pschneider.fr>
* Microsoft.Web.XmlTransform.dll: Copié de l'import Nuget de

View file

@ -31,10 +31,9 @@ namespace Yavsc.Controllers
/// Index this instance.
/// </summary>
[Authorize]
public ActionResult Index (string user, string filename)
public ActionResult Index (string username, string filename)
{
WebFileSystemManager fsmgr = new WebFileSystemManager ();
var files = fsmgr.GetFiles (user,filename);
var files = UserFileSystemManager.GetFiles (username,filename);
return View (files);
}
@ -54,14 +53,12 @@ namespace Yavsc.Controllers
/// <param name="filename">Filename.</param>
public ActionResult Details (string user, string filename)
{
WebFileSystemManager fsmgr = new WebFileSystemManager ();
FileInfo fi = fsmgr.FileInfo (filename);
ViewData ["filename"] = filename;
// TODO : ensure that we use the default port for
// the used sheme
ViewData ["url"] = Url.Content("~/users/"+user+"/"+filename);
return View (fi);
return View (UserFileSystemManager.Detail(user,filename));
}
}
}

View file

@ -26,21 +26,6 @@ namespace Yavsc.Controllers
/// </summary>
public class FrontOfficeController : Controller
{
/// <summary>
/// The wfmgr.
/// </summary>
protected WorkFlowManager wfmgr = null;
/// <summary>
/// Initialize the specified requestContext.
/// </summary>
/// <param name="requestContext">Request context.</param>
protected override void Initialize (System.Web.Routing.RequestContext requestContext)
{
base.Initialize (requestContext);
wfmgr = new WorkFlowManager ();
}
/// <summary>
/// Index this instance.
/// </summary>
@ -68,7 +53,7 @@ namespace Yavsc.Controllers
throw new ConfigurationErrorsException ("no redirection to any login page");
string username = u.UserName;
Estimate [] estims = wfmgr.GetUserEstimates (username);
Estimate [] estims = WorkFlowManager.GetUserEstimates (username);
ViewData ["UserName"] = username;
ViewData ["ResponsibleCount"] =
Array.FindAll (
@ -88,7 +73,7 @@ namespace Yavsc.Controllers
/// <param name="id">Identifier.</param>
public ActionResult Get (long estimid)
{
Estimate f = wfmgr.GetEstimate (estimid);
Estimate f = WorkFlowManager.GetEstimate (estimid);
if (f == null) {
ModelState.AddModelError ("Id", "Wrong Id");
return View (new Estimate () { Id=estimid } );
@ -110,7 +95,7 @@ namespace Yavsc.Controllers
ViewData ["WABASEWF"] = ViewData ["WebApiBase"] + "/WorkFlow";
if (submit == null) {
if (model.Id > 0) {
Estimate f = wfmgr.GetEstimate (model.Id);
Estimate f = WorkFlowManager.GetEstimate (model.Id);
if (f == null) {
ModelState.AddModelError ("Id", "Wrong Id");
return View (model);
@ -136,12 +121,12 @@ namespace Yavsc.Controllers
if (ModelState.IsValid) {
if (model.Id == 0)
model = wfmgr.CreateEstimate (
model = WorkFlowManager.CreateEstimate (
username,
model.Client, model.Title, model.Description);
else {
wfmgr.UpdateEstimate (model);
model = wfmgr.GetEstimate (model.Id);
WorkFlowManager.UpdateEstimate (model);
model = WorkFlowManager.GetEstimate (model.Id);
}
}
}
@ -237,7 +222,7 @@ namespace Yavsc.Controllers
[Authorize]
public ActionResult Basket ()
{
return View (wfmgr.GetCommands (Membership.GetUser ().UserName));
return View (WorkFlowManager.GetCommands (Membership.GetUser ().UserName));
}
/// <summary>

View file

@ -506,6 +506,8 @@
<Content Include="Views\FileSystem\RestrictedArea.aspx" />
<Content Include="Views\BackOffice\RestrictedArea.aspx" />
<Content Include="Views\Account\RestrictedArea.aspx" />
<Content Include="Web.TotemProd.config" />
<Content Include="Web.TotemPre.config" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />