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.
main
Paul Schneider 10 years ago
parent 77eed811f5
commit 439759cb16
13 changed files with 233 additions and 166 deletions

@ -17,20 +17,6 @@ namespace Yavsc.ApiControllers
/// </summary> /// </summary>
public class BasketController : ApiController 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> /// <summary>
/// Gets the current basket, creates a new one, if it doesn't exist. /// 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> /// <value>The current basket.</value>
protected CommandSet CurrentBasket { protected CommandSet CurrentBasket {
get { get {
CommandSet b = wfmgr.GetCommands (Membership.GetUser ().UserName); CommandSet b = WorkFlowManager.GetCommands (
Membership.GetUser ().UserName);
if (b == null) b = new CommandSet (); if (b == null) b = new CommandSet ();
return b; return b;
} }

@ -24,20 +24,6 @@ namespace Yavsc.ApiControllers
/// </summary> /// </summary>
public class FrontOfficeController : YavscController 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> /// <summary>
/// Catalog this instance. /// Catalog this instance.
@ -71,7 +57,7 @@ namespace Yavsc.ApiControllers
[HttpGet] [HttpGet]
public Estimate GetEstimate (long id) public Estimate GetEstimate (long id)
{ {
Estimate est = wfmgr.ContentProvider.Get (id); Estimate est = WorkFlowManager.ContentProvider.Get (id);
string username = Membership.GetUser ().UserName; string username = Membership.GetUser ().UserName;
if (est.Client != username) if (est.Client != username)
if (!Roles.IsUserInRole("Admin")) if (!Roles.IsUserInRole("Admin"))
@ -109,7 +95,7 @@ namespace Yavsc.ApiControllers
private string estimateToTex (long estimid) private string estimateToTex (long estimid)
{ {
Yavsc.templates.Estim tmpe = new Yavsc.templates.Estim (); 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 = new Dictionary<string,object> ();
tmpe.Session.Add ("estim", e); tmpe.Session.Add ("estim", e);
Profile prpro = new Profile (ProfileBase.Create (e.Responsible)); Profile prpro = new Profile (ProfileBase.Create (e.Responsible));

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

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

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

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

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

@ -1,3 +1,13 @@
2015-11-22 Paul Schneider <paul@pschneider.fr>
* 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.
2015-11-21 Paul Schneider <paul@pschneider.fr> 2015-11-21 Paul Schneider <paul@pschneider.fr>
* UserNameBase.cs: Permet l'usage des espaces dans les noms * UserNameBase.cs: Permet l'usage des espaces dans les noms

@ -0,0 +1,131 @@
//
// UserFileSystemManager.cs
//
// Author:
// Paul Schneider <paul@pschneider.fr>
//
// Copyright (c) 2015 GNU GPL
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using System.IO;
using System.Web;
using System.Web.Security;
using System.Collections.Generic;
using System.Collections.Specialized;
namespace Yavsc.Model.FileSystem
{
/// <summary>
/// User file system.
/// </summary>
internal class UserFileSystem : WebFileSystemManager {
/// <summary>
/// Initializes a new instance of the <see cref="Yavsc.Model.FileSystem.UserFileSystem"/> class.
/// </summary>
/// <param name="username">Username.</param>
/// <param name="root">Root.</param>
public UserFileSystem(string username, string root="~/users") {
base.Prefix = UserFileSystemManager.UserFileRoot(username,root);
}
}
/// <summary>
/// User file system manager.
/// </summary>
public static class UserFileSystemManager
{
/// <summary>
/// Initializes a new instance of the <see cref="Yavsc.Model.FileSystem.UserFileSystemManager"/> class.
/// </summary>
/// <param name="rootDirectory">Root directory.</param>
public static string CurrentUserFileRoot (string rootDirectory="~/users")
{
if (!HttpContext.Current.User.Identity.IsAuthenticated)
throw new Exception ("Not membership available");
return UserFileRoot (HttpContext.Current.User.Identity.Name,rootDirectory);
}
/// <summary>
/// Users the file root.
/// </summary>
/// <returns>The file root.</returns>
/// <param name="username">Username.</param>
/// <param name="rootDirectory">Root directory.</param>
public static string UserFileRoot (string username, string rootDirectory="~/users")
{
string rootpath = HttpContext.Current.Server.MapPath (rootDirectory);
return Path.Combine(rootpath, username);
}
private static WebFileSystemManager manager=null;
/// <summary>
/// Gets or sets the file manager.
/// </summary>
/// <value>The file manager.</value>
public static WebFileSystemManager FileManager {
get
{
if (manager == null)
manager = new UserFileSystem (
HttpContext.Current.User.Identity.Name);
return manager;
}
set {
manager = value;
}
}
/// <summary>
/// Gets the files.
/// </summary>
/// <returns>The files.</returns>
/// <param name="subdir">Subdir.</param>
public static IEnumerable<FileInfo> GetFiles (string subdir)
{
return GetFiles (HttpContext.Current.User.Identity.Name, subdir);
}
/// <summary>
/// Gets the files.
/// </summary>
/// <returns>The files.</returns>
/// <param name="username">Username.</param>
/// <param name="subdir">Subdir.</param>
public static IEnumerable<FileInfo> GetFiles (string username, string subdir)
{
return FileManager.GetFiles (Path.Combine(UserFileRoot(username),subdir));
}
/// <summary>
/// Put the specified destDir and files.
/// </summary>
/// <param name="destDir">Destination dir.</param>
/// <param name="files">Files.</param>
public static void Put(string destDir, NameObjectCollectionBase files)
{
FileManager.ValidateSubDir (destDir);
FileManager.Put(
Path.Combine(CurrentUserFileRoot(),destDir),
files);
}
/// <summary>
/// Detail the specified filePath and username.
/// </summary>
/// <param name="filePath">File path.</param>
/// <param name="username">Username.</param>
public static FileInfo Detail(string filePath, string username=null)
{
return FileManager.FileInfo (UserFileRoot (username));
}
}
}

@ -38,7 +38,7 @@ namespace Yavsc.Model.FileSystem
/// It just provides simple method for a small set of /// It just provides simple method for a small set of
/// files, in a small tree of sub-folders . /// files, in a small tree of sub-folders .
/// </summary> /// </summary>
public class WebFileSystemManager public abstract class WebFileSystemManager
{ {
/// <summary> /// <summary>
/// Gets or sets the size of the max file. /// Gets or sets the size of the max file.
@ -53,35 +53,8 @@ namespace Yavsc.Model.FileSystem
public long MaxUserStorage { get; set; } public long MaxUserStorage { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="Yavsc.Model.FileSystem.FileSystemManager"/> class.
/// </summary>
public WebFileSystemManager (string rootDirectory="~/users")
{
string rootpath = HttpContext.Current.Server.MapPath (rootDirectory);
var rdi = new DirectoryInfo (rootpath);
if (!rdi.Exists)
rdi.Create ();
MembershipUser user = Membership.GetUser ();
if (user == null)
throw new Exception ("Not membership available");
Prefix = Path.Combine(rootpath, user.ProviderUserKey.ToString());
}
string regexFileName = "^[A-Za-z0-9#^!+ _~\\-.]+$"; string regexFileName = "^[A-Za-z0-9#^!+ _~\\-.]+$";
/// <summary>
/// Determines if the specified name is OK.
/// </summary>
/// <returns><c>true</c> if is this name O the specified name; otherwise, <c>false</c>.</returns>
/// <param name="name">Name.</param>
public static bool IsThisNameOK(string name)
{
foreach (char x in Path.GetInvalidPathChars()) {
if (name.Contains (x))
return false;
}
return true;
}
/// <summary> /// <summary>
/// Put the specified files in destDir, as sub dir of the current user's home dir. /// Put the specified files in destDir, as sub dir of the current user's home dir.
/// </summary> /// </summary>
@ -99,8 +72,7 @@ namespace Yavsc.Model.FileSystem
} }
} }
// do the job // do the job
ValidateSubDir (destDir,true);
CheckSubDir (destDir);
DirectoryInfo di = new DirectoryInfo ( DirectoryInfo di = new DirectoryInfo (
Path.Combine (Prefix, destDir)); Path.Combine (Prefix, destDir));
if (!di.Exists) if (!di.Exists)
@ -133,16 +105,26 @@ namespace Yavsc.Model.FileSystem
/// concerning the allowed character class. /// concerning the allowed character class.
/// </summary> /// </summary>
/// <param name="subdir">Subdir.</param> /// <param name="subdir">Subdir.</param>
private void CheckSubDir (string subdir) /// <param name="throwex">throw ex.</param>
public bool ValidateSubDir (string subdir, bool throwex = false)
{ {
foreach (string dirname in subdir.Split(Path.DirectorySeparatorChar)) { foreach (string dirname in subdir.Split(Path.DirectorySeparatorChar)) {
if (!Regex.Match (dirname, regexFileName).Success) if (!Regex.Match (dirname, regexFileName).Success) {
if (throwex)
throw new InvalidDirNameException (dirname); throw new InvalidDirNameException (dirname);
else
return false;
}
foreach (char x in dirname) foreach (char x in dirname)
if (subdir.Contains (x)) if (subdir.Contains (x)) {
if (throwex)
throw new InvalidDirNameException (subdir); throw new InvalidDirNameException (subdir);
else
return false;
} }
} }
return true;
}
/// <summary> /// <summary>
/// Gets the files owned by the current logged user. /// Gets the files owned by the current logged user.
/// The web user must be authenticated, /// The web user must be authenticated,
@ -150,40 +132,26 @@ namespace Yavsc.Model.FileSystem
/// </summary> /// </summary>
/// <returns>The files.</returns> /// <returns>The files.</returns>
/// <param name="subdir">Subdir.</param> /// <param name="subdir">Subdir.</param>
public IEnumerable<FileInfo> GetFiles (string subdir) public virtual IEnumerable<FileInfo> GetFiles (string subdir)
{ {
string path = Prefix; string path = Prefix;
if (subdir != null) { if (subdir != null) {
CheckSubDir (subdir); // checks for specification validity ValidateSubDir (subdir,true); // checks for specification validity
path = Path.Combine (Prefix, subdir); path = Path.Combine (Prefix, subdir);
} }
DirectoryInfo di = new DirectoryInfo (path); DirectoryInfo di = new DirectoryInfo (path);
return (di.GetFiles ()); return (di.GetFiles ());
} }
public FileInfo[] GetFiles (string username, string subdir)
{
string path = Prefix;
if (subdir != null) {
CheckSubDir (subdir); // checks for specification validity
path = Path.Combine (Prefix, subdir);
}
DirectoryInfo di = new DirectoryInfo (path);
if (!di.Exists)
return new FileInfo[0];
return (di.GetFiles ());
}
/// <summary> /// <summary>
/// Files the info. /// Files the info.
/// </summary> /// </summary>
/// <returns>The info.</returns> /// <returns>The info.</returns>
/// <param name="id">Identifier.</param> /// <param name="filePath">file Path.</param>
public FileInfo FileInfo(string id) public FileInfo FileInfo(string filePath)
{ {
CheckSubDir (id); ValidateSubDir (filePath,true);
return new FileInfo(Path.Combine (Prefix, id)); return new FileInfo(Path.Combine (Prefix, filePath));
} }
} }
} }

@ -46,7 +46,7 @@ namespace Yavsc.Model.FrontOffice
IEnumerable<FileInfo> Files { IEnumerable<FileInfo> Files {
get { get {
return GetFSM().GetFiles (Id.ToString()); return UserFileSystemManager.GetFiles (Id.ToString());
} }
} }
/// <summary> /// <summary>
@ -72,10 +72,9 @@ namespace Yavsc.Model.FrontOffice
if (key!="ref") if (key!="ref")
Parameters.Add (key, collection [key]); Parameters.Add (key, collection [key]);
} }
WorkFlowManager wfm = new WorkFlowManager (); WorkFlowManager.RegisterCommand (this); // gives a value to this.Id
wfm.RegisterCommand (this); // overrides this.Id
string strcmdid = Id.ToString (); string strcmdid = Id.ToString ();
GetFSM().Put (strcmdid, files); UserFileSystemManager.Put(Path.Combine("commandes",strcmdid),files);
} }
/// <summary> /// <summary>
@ -89,9 +88,6 @@ namespace Yavsc.Model.FrontOffice
FromPost (collection, files); FromPost (collection, files);
} }
private WebFileSystemManager GetFSM() {
return new WebFileSystemManager ("~/commands/{0}");
}
} }
} }

@ -13,7 +13,7 @@ namespace Yavsc.Model.WorkFlow
/// It takes orders store them and raise some events for modules /// It takes orders store them and raise some events for modules
/// It publishes estimates and invoices /// It publishes estimates and invoices
/// </summary> /// </summary>
public class WorkFlowManager public static class WorkFlowManager
{ {
/// <summary> /// <summary>
/// Gets or sets the catalog. /// Gets or sets the catalog.
@ -26,7 +26,7 @@ namespace Yavsc.Model.WorkFlow
/// </summary> /// </summary>
/// <returns>The command.</returns> /// <returns>The command.</returns>
/// <param name="com">COM.</param> /// <param name="com">COM.</param>
public long RegisterCommand(Command com) public static long RegisterCommand(Command com)
{ {
return ContentProvider.RegisterCommand (com); return ContentProvider.RegisterCommand (com);
} }
@ -35,7 +35,7 @@ namespace Yavsc.Model.WorkFlow
/// Updates the estimate. /// Updates the estimate.
/// </summary> /// </summary>
/// <param name="estim">Estim.</param> /// <param name="estim">Estim.</param>
public void UpdateEstimate (Estimate estim) public static void UpdateEstimate (Estimate estim)
{ {
ContentProvider.Update (estim); ContentProvider.Update (estim);
} }
@ -44,7 +44,7 @@ namespace Yavsc.Model.WorkFlow
/// </summary> /// </summary>
/// <returns>The estimate.</returns> /// <returns>The estimate.</returns>
/// <param name="estid">Estid.</param> /// <param name="estid">Estid.</param>
public Estimate GetEstimate (long estid) public static Estimate GetEstimate (long estid)
{ {
return ContentProvider.Get (estid); return ContentProvider.Get (estid);
} }
@ -54,7 +54,7 @@ namespace Yavsc.Model.WorkFlow
/// </summary> /// </summary>
/// <returns>The estimates.</returns> /// <returns>The estimates.</returns>
/// <param name="responsible">Responsible.</param> /// <param name="responsible">Responsible.</param>
public Estimate [] GetResponsibleEstimates (string responsible) public static Estimate [] GetResponsibleEstimates (string responsible)
{ {
return ContentProvider.GetEstimates (null, responsible); return ContentProvider.GetEstimates (null, responsible);
} }
@ -64,7 +64,7 @@ namespace Yavsc.Model.WorkFlow
/// </summary> /// </summary>
/// <returns>The client estimates.</returns> /// <returns>The client estimates.</returns>
/// <param name="client">Client.</param> /// <param name="client">Client.</param>
public Estimate [] GetClientEstimates (string client) public static Estimate [] GetClientEstimates (string client)
{ {
return ContentProvider.GetEstimates (client, null); return ContentProvider.GetEstimates (client, null);
} }
@ -74,7 +74,7 @@ namespace Yavsc.Model.WorkFlow
/// </summary> /// </summary>
/// <returns>The user estimates.</returns> /// <returns>The user estimates.</returns>
/// <param name="username">Username.</param> /// <param name="username">Username.</param>
public Estimate [] GetUserEstimates (string username) public static Estimate [] GetUserEstimates (string username)
{ {
return ContentProvider.GetEstimates (username); return ContentProvider.GetEstimates (username);
} }
@ -84,7 +84,7 @@ namespace Yavsc.Model.WorkFlow
/// </summary> /// </summary>
/// <returns>The stock status.</returns> /// <returns>The stock status.</returns>
/// <param name="productReference">Product reference.</param> /// <param name="productReference">Product reference.</param>
public StockStatus GetStock(string productReference) public static StockStatus GetStock(string productReference)
{ {
return ContentProvider.GetStockStatus (productReference); return ContentProvider.GetStockStatus (productReference);
} }
@ -93,7 +93,7 @@ namespace Yavsc.Model.WorkFlow
/// Updates the writting. /// Updates the writting.
/// </summary> /// </summary>
/// <param name="wr">Wr.</param> /// <param name="wr">Wr.</param>
public void UpdateWritting (Writting wr) public static void UpdateWritting (Writting wr)
{ {
ContentProvider.UpdateWritting (wr); ContentProvider.UpdateWritting (wr);
} }
@ -102,7 +102,7 @@ namespace Yavsc.Model.WorkFlow
/// Drops the writting. /// Drops the writting.
/// </summary> /// </summary>
/// <param name="wrid">Wrid.</param> /// <param name="wrid">Wrid.</param>
public void DropWritting (long wrid) public static void DropWritting (long wrid)
{ {
ContentProvider.DropWritting (wrid); ContentProvider.DropWritting (wrid);
} }
@ -110,19 +110,19 @@ namespace Yavsc.Model.WorkFlow
/// Drops the estimate. /// Drops the estimate.
/// </summary> /// </summary>
/// <param name="estid">Estid.</param> /// <param name="estid">Estid.</param>
public void DropEstimate (long estid) public static void DropEstimate (long estid)
{ {
ContentProvider.DropEstimate(estid); ContentProvider.DropEstimate(estid);
} }
IContentProvider contentProvider; static IContentProvider contentProvider;
/// <summary> /// <summary>
/// Gets the content provider. /// Gets the content provider.
/// </summary> /// </summary>
/// <value>The content provider.</value> /// <value>The content provider.</value>
public IContentProvider ContentProvider { public static IContentProvider ContentProvider {
get { get {
DataProviderConfigurationSection c = (DataProviderConfigurationSection) ConfigurationManager.GetSection ("system.web/workflow"); DataProviderConfigurationSection c = (DataProviderConfigurationSection) ConfigurationManager.GetSection ("system.web/workflow");
if (c == null) if (c == null)
@ -162,7 +162,7 @@ namespace Yavsc.Model.WorkFlow
/// <param name="client">Client.</param> /// <param name="client">Client.</param>
/// <param name="title">Title.</param> /// <param name="title">Title.</param>
/// <param name="description">Description.</param> /// <param name="description">Description.</param>
public Estimate CreateEstimate(string responsible, string client, string title, string description) public static Estimate CreateEstimate(string responsible, string client, string title, string description)
{ {
Estimate created = ContentProvider.CreateEstimate (responsible, client, title, description); Estimate created = ContentProvider.CreateEstimate (responsible, client, title, description);
return created; return created;
@ -176,7 +176,7 @@ namespace Yavsc.Model.WorkFlow
/// <param name="ucost">Ucost.</param> /// <param name="ucost">Ucost.</param>
/// <param name="count">Count.</param> /// <param name="count">Count.</param>
/// <param name="productid">Productid.</param> /// <param name="productid">Productid.</param>
public long Write(long estid, string desc, decimal ucost, int count, string productid) public static long Write(long estid, string desc, decimal ucost, int count, string productid)
{ {
if (!string.IsNullOrWhiteSpace(productid)) { if (!string.IsNullOrWhiteSpace(productid)) {
if (Catalog == null) if (Catalog == null)
@ -197,7 +197,7 @@ namespace Yavsc.Model.WorkFlow
/// <param name="estid">Estid.</param> /// <param name="estid">Estid.</param>
/// <param name="status">Status.</param> /// <param name="status">Status.</param>
/// <param name="username">Username.</param> /// <param name="username">Username.</param>
public void SetEstimateStatus(long estid, int status, string username) public static void SetEstimateStatus(long estid, int status, string username)
{ {
ContentProvider.SetEstimateStatus (estid, status, username); ContentProvider.SetEstimateStatus (estid, status, username);
} }
@ -206,10 +206,17 @@ namespace Yavsc.Model.WorkFlow
/// </summary> /// </summary>
/// <returns>The commands.</returns> /// <returns>The commands.</returns>
/// <param name="username">Username.</param> /// <param name="username">Username.</param>
public CommandSet GetCommands(string username) public static CommandSet GetCommands(string username)
{ {
return ContentProvider.GetCommands (username); return ContentProvider.GetCommands (username);
} }
public static string [] APEDisponibles
{
get {
return new string[]{ "Chanteur", "DJ", "Musicien", "Clown" };
}
}
} }
} }

@ -21,7 +21,6 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause> <ConsolePause>false</ConsolePause>
<DocumentationFile>bin\Debug\YavscModel.xml</DocumentationFile> <DocumentationFile>bin\Debug\YavscModel.xml</DocumentationFile>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>full</DebugType> <DebugType>full</DebugType>
@ -30,7 +29,6 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause> <ConsolePause>false</ConsolePause>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Lua|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Lua|AnyCPU' ">
<Optimize>false</Optimize> <Optimize>false</Optimize>
@ -201,6 +199,7 @@
<Compile Include="IRating.cs" /> <Compile Include="IRating.cs" />
<Compile Include="IAuthorized.cs" /> <Compile Include="IAuthorized.cs" />
<Compile Include="Skill\PerformerProfile.cs" /> <Compile Include="Skill\PerformerProfile.cs" />
<Compile Include="FileSystem\UserFileSystemManager.cs" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup> <ItemGroup>

Loading…