From fa93ce7fee194d765f6d3d8ee1ad4e2a94a1b7be Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Thu, 24 Jul 2014 05:04:56 +0200 Subject: [PATCH] - a module for IT services business - Mvc-like action binding in the WF web api ... ? * Yavsc.sln: * Web.csproj: * MvcActionValueBinder.cs: * yavscModel.csproj: * WFOrder.cs: * IWFOrder.cs: * BasketImpact.cs: * ProjectInfo.cs: * IWFModule.cs: * IWFCommand.cs: * WorkFlowController.cs: * NewProjectModel.cs: * IContentProvider.cs: * ITCPNpgsqlProvider.cs: * WorkFlowProvider.csproj: * ITContentProvider.csproj: * AssemblyInfo.cs: * OrderStatusChangedEventArgs.cs: * NpgsqlContentProvider.cs: --- ITContentProvider/ITCPNpgsqlProvider.cs | 79 +++++++++++++ ITContentProvider/ITContentProvider.csproj | 52 +++++++++ ITContentProvider/ProjectInfo.cs | 18 +++ ITContentProvider/Properties/AssemblyInfo.cs | 22 ++++ WorkFlowProvider/NpgsqlContentProvider.cs | 108 ++++-------------- WorkFlowProvider/WorkFlowProvider.csproj | 3 + Yavsc.sln | 6 + web/Controllers/BasketImpact.cs | 21 ++++ web/Controllers/WorkFlowController.cs | 11 +- web/MvcActionValueBinder.cs | 89 +++++++++++++++ web/Web.csproj | 25 ++-- yavscModel/WorkFlow/IContentProvider.cs | 14 ++- yavscModel/WorkFlow/IWFCommand.cs | 10 -- yavscModel/WorkFlow/IWFModule.cs | 18 ++- yavscModel/WorkFlow/IWFOrder.cs | 18 +++ yavscModel/WorkFlow/NewProjectModel.cs | 1 + .../WorkFlow/OrderStatusChangedEventArgs.cs | 17 +++ yavscModel/WorkFlow/WFOrder.cs | 17 ++- yavscModel/yavscModel.csproj | 5 +- 19 files changed, 412 insertions(+), 122 deletions(-) create mode 100644 ITContentProvider/ITCPNpgsqlProvider.cs create mode 100644 ITContentProvider/ITContentProvider.csproj create mode 100644 ITContentProvider/ProjectInfo.cs create mode 100644 ITContentProvider/Properties/AssemblyInfo.cs create mode 100644 web/Controllers/BasketImpact.cs create mode 100644 web/MvcActionValueBinder.cs delete mode 100644 yavscModel/WorkFlow/IWFCommand.cs create mode 100644 yavscModel/WorkFlow/IWFOrder.cs create mode 100644 yavscModel/WorkFlow/OrderStatusChangedEventArgs.cs diff --git a/ITContentProvider/ITCPNpgsqlProvider.cs b/ITContentProvider/ITCPNpgsqlProvider.cs new file mode 100644 index 00000000..5278b218 --- /dev/null +++ b/ITContentProvider/ITCPNpgsqlProvider.cs @@ -0,0 +1,79 @@ +using System; +using WorkFlowProvider; +using Npgsql; + +namespace ITContentProvider +{ + public class ITCPNpgsqlProvider :NpgsqlContentProvider + { + public ITCPNpgsqlProvider () + { + } + + public ProjectInfo GetProjectInfo(int projectid) + { + throw new NotImplementedException (); + } + + public ProjectInfo[] SearchProject(ProjectInfo pi) + { + throw new NotImplementedException (); + } + + public int NewTask (int projectId, string name, string desc) + { + throw new System.NotImplementedException (); + } + + + public void SetTaskName (int taskId, string name) + { + throw new System.NotImplementedException (); + } + + public void SetStartDate (int taskId, DateTime d) + { + throw new System.NotImplementedException (); + } + + public void SetEndDate (int taskId, DateTime d) + { + throw new System.NotImplementedException (); + } + + + public void RemoveProject (int prjId) + { + using (var cnx = CreateConnection()) { + cnx.Open (); + using (NpgsqlCommand cmd = cnx.CreateCommand()) { + cmd.CommandText = "delete from projets where id = @id"; + cmd.Parameters.Add ("@id", prjId); + cmd.ExecuteNonQuery(); + } + cnx.Close (); + } + } + + + public int NewProject (string name, string desc, string ownerId) + { + int id = 0; + using (var cnx = CreateConnection()) { + cnx.Open (); + using (NpgsqlCommand cmd = cnx.CreateCommand()) { + cmd.CommandText = "insert into projets (name,managerid,ApplicatonName,prdesc) values (@name,@mid,@appname,@pdesc)"; + cmd.Parameters.Add ("@name", name); + cmd.Parameters.Add ("@mid", ownerId); + cmd.Parameters.Add ("@appname", ApplicationName); + cmd.Parameters.Add ("@desc", desc); + id = (int)cmd.ExecuteScalar (); + } + cnx.Close (); + } + return id; + } + + } +} + diff --git a/ITContentProvider/ITContentProvider.csproj b/ITContentProvider/ITContentProvider.csproj new file mode 100644 index 00000000..187c7b5d --- /dev/null +++ b/ITContentProvider/ITContentProvider.csproj @@ -0,0 +1,52 @@ + + + + Debug + AnyCPU + 10.0.0 + 2.0 + {9D7D892E-9B77-4713-892D-C26E1E944119} + Library + ITContentProvider + ITContentProvider + + + true + full + false + bin\Debug + DEBUG; + prompt + 4 + false + + + full + true + bin\Release + prompt + 4 + false + + + + + + + + + + + + + + + {821FF72D-9F4B-4A2C-B95C-7B965291F119} + WorkFlowProvider + + + {68F5B80A-616E-4C3C-91A0-828AA40000BD} + yavscModel + + + \ No newline at end of file diff --git a/ITContentProvider/ProjectInfo.cs b/ITContentProvider/ProjectInfo.cs new file mode 100644 index 00000000..8ec33452 --- /dev/null +++ b/ITContentProvider/ProjectInfo.cs @@ -0,0 +1,18 @@ +using System; +using WorkFlowProvider; + +namespace ITContentProvider +{ + public class ProjectInfo + { + string Name { get; set; } + string Licence { get; set; } + string BBDescription { get; set; } + DateTime StartDate { get; set; } + string ProdVersion { get; set; } + string StableVersion { get; set; } + string TestingVersion { get; set; } + string WebSite { get; set; } + } +} + diff --git a/ITContentProvider/Properties/AssemblyInfo.cs b/ITContentProvider/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..1b2d13d3 --- /dev/null +++ b/ITContentProvider/Properties/AssemblyInfo.cs @@ -0,0 +1,22 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// Information about this assembly is defined by the following attributes. +// Change them to the values specific to your project. +[assembly: AssemblyTitle ("ITContentProvider")] +[assembly: AssemblyDescription ("")] +[assembly: AssemblyConfiguration ("")] +[assembly: AssemblyCompany ("")] +[assembly: AssemblyProduct ("")] +[assembly: AssemblyCopyright ("Paul Schneider")] +[assembly: AssemblyTrademark ("")] +[assembly: AssemblyCulture ("")] +// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". +// The form "{Major}.{Minor}.*" will automatically update the build and revision, +// and "{Major}.{Minor}.{Build}.*" will update just the revision. +[assembly: AssemblyVersion ("1.0.*")] +// The following attributes are used to specify the signing key for the assembly, +// if desired. See the Mono documentation for more information about signing. +//[assembly: AssemblyDelaySign(false)] +//[assembly: AssemblyKeyFile("")] + diff --git a/WorkFlowProvider/NpgsqlContentProvider.cs b/WorkFlowProvider/NpgsqlContentProvider.cs index ffcbb35b..dacb1472 100644 --- a/WorkFlowProvider/NpgsqlContentProvider.cs +++ b/WorkFlowProvider/NpgsqlContentProvider.cs @@ -4,36 +4,34 @@ using NpgsqlTypes; using System.Configuration; using System.Collections.Specialized; using yavscModel.WorkFlow; +using System.Web.Mvc; namespace WorkFlowProvider { public class NpgsqlContentProvider: IContentProvider { - public string Order (IWFCommand c) + public IWFOrder CreateOrder () { throw new NotImplementedException (); } - - public IContent Get (string orderId) + public IWFOrder ImapctOrder (string orderid, FormCollection col) { throw new NotImplementedException (); } - - public void AddDevRessource (int prjId, string userName) - { - throw new NotImplementedException (); + public bool[] IsFinalStatus { + get { + throw new NotImplementedException (); + } } - public void AddPrjRessource(int prjId, string owner) - { - } + string applicationName=null; - public void NewRelease (int projectId, string Version) - { - throw new NotImplementedException (); + public string ApplicationName { + get { + return applicationName; + } } - string applicationName=null; string cnxstr = null; public NpgsqlContentProvider () @@ -47,7 +45,7 @@ namespace WorkFlowProvider applicationName = config["applicationName"] ?? "/"; } - NpgsqlConnection CreateConnection () + protected NpgsqlConnection CreateConnection () { return new NpgsqlConnection (cnxstr); } @@ -59,88 +57,30 @@ namespace WorkFlowProvider } #endregion - #region IContentProvider implementation - - public int NewTask (int projectId, string name, string desc) - { - throw new System.NotImplementedException (); - } - - public void SetProjectName (int projectId, string name) - { - throw new System.NotImplementedException (); - } - - public void SetProjectDesc (int projectId, string desc) - { - throw new System.NotImplementedException (); - } - - public void SetTaskName (int taskId, string name) - { - throw new System.NotImplementedException (); - } - - public void SetStartDate (int taskId, DateTime d) + public string Order (IWFOrder c) { - throw new System.NotImplementedException (); + throw new NotImplementedException (); } - public void SetEndDate (int taskId, DateTime d) + public IContent GetBlob (string orderId) { - throw new System.NotImplementedException (); + throw new NotImplementedException (); } - public void SetTaskDesc (int taskId, string desc) + public int GetStatus (string orderId) { - throw new System.NotImplementedException (); + throw new NotImplementedException (); } - public void RemoveProject (int prjId) - { - using (var cnx = CreateConnection()) { - cnx.Open (); - using (NpgsqlCommand cmd = cnx.CreateCommand()) { - cmd.CommandText = "delete from projets where id = @id"; - cmd.Parameters.Add ("@id", prjId); - cmd.ExecuteNonQuery(); - } - cnx.Close (); + public string[] StatusLabels { + get { + throw new NotImplementedException (); } } - public void RemoveTask (int taskId) - { - throw new System.NotImplementedException (); - } - - public void SetManager (int projectId, string user) - { - throw new System.NotImplementedException (); - } - - public void RemoveUser (string user) - { - throw new System.NotImplementedException (); - } + #region IITContentProvider implementation - public int NewProject (string name, string desc, string ownerId) - { - int id = 0; - using (var cnx = CreateConnection()) { - cnx.Open (); - using (NpgsqlCommand cmd = cnx.CreateCommand()) { - cmd.CommandText = "insert into projets (name,managerid,ApplicatonName,prdesc) values (@name,@mid,@appname,@pdesc)"; - cmd.Parameters.Add ("@name", name); - cmd.Parameters.Add ("@mid", ownerId); - cmd.Parameters.Add ("@appname", applicationName); - cmd.Parameters.Add ("@desc", desc); - id = (int)cmd.ExecuteScalar (); - } - cnx.Close (); - } - return id; - } + #endregion } diff --git a/WorkFlowProvider/WorkFlowProvider.csproj b/WorkFlowProvider/WorkFlowProvider.csproj index f4713164..a568c9de 100644 --- a/WorkFlowProvider/WorkFlowProvider.csproj +++ b/WorkFlowProvider/WorkFlowProvider.csproj @@ -33,6 +33,9 @@ + + False + diff --git a/Yavsc.sln b/Yavsc.sln index 2aa90b95..bbfaa708 100644 --- a/Yavsc.sln +++ b/Yavsc.sln @@ -21,6 +21,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "vscadm", "vscadm\vscadm.csp EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ITContent", "ITContent\ITContent.csproj", "{88D83FC9-4158-4435-98A6-1F8F7F448B8F}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ITContentProvider", "ITContentProvider\ITContentProvider.csproj", "{9D7D892E-9B77-4713-892D-C26E1E944119}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -55,6 +57,10 @@ Global {90BF2234-7252-4CD5-B2A4-17501B19279B}.Debug|Any CPU.Build.0 = Debug|Any CPU {90BF2234-7252-4CD5-B2A4-17501B19279B}.Release|Any CPU.ActiveCfg = Release|Any CPU {90BF2234-7252-4CD5-B2A4-17501B19279B}.Release|Any CPU.Build.0 = Release|Any CPU + {9D7D892E-9B77-4713-892D-C26E1E944119}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9D7D892E-9B77-4713-892D-C26E1E944119}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9D7D892E-9B77-4713-892D-C26E1E944119}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9D7D892E-9B77-4713-892D-C26E1E944119}.Release|Any CPU.Build.0 = Release|Any CPU {BBA7175D-7F92-4278-96FC-84C495A2B5A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {BBA7175D-7F92-4278-96FC-84C495A2B5A6}.Debug|Any CPU.Build.0 = Debug|Any CPU {BBA7175D-7F92-4278-96FC-84C495A2B5A6}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/web/Controllers/BasketImpact.cs b/web/Controllers/BasketImpact.cs new file mode 100644 index 00000000..a57d6087 --- /dev/null +++ b/web/Controllers/BasketImpact.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +using System.Web.Http; +using WorkFlowProvider; +using yavscModel.WorkFlow; +using System.Web.Http.Controllers; +using System.Web.Http.ModelBinding; + +namespace Yavsc.ApiControllers +{ + + public class BasketImpact + { + public string ProductRef { get; set; } + public int count { get; set; } + } + +} diff --git a/web/Controllers/WorkFlowController.cs b/web/Controllers/WorkFlowController.cs index 27eb9f7c..ebc0e18f 100644 --- a/web/Controllers/WorkFlowController.cs +++ b/web/Controllers/WorkFlowController.cs @@ -6,9 +6,11 @@ using System.Web; using System.Web.Http; using WorkFlowProvider; using yavscModel.WorkFlow; +using System.Web.Http.Controllers; namespace Yavsc.ApiControllers { + [HttpControllerConfiguration(ActionValueBinder=typeof(Basic.MvcActionValueBinder))] public class WorkFlowController : ApiController { [HttpGet] @@ -17,7 +19,13 @@ namespace Yavsc.ApiControllers return new { test="Hello World" }; } + [HttpGet] + public object Order (BasketImpact bi) + { + return new { c="lmk,", message="Panier impacté", impactRef=bi.ProductRef, count=bi.count}; + } + /* public object Details(int id) { throw new NotImplementedException (); @@ -27,6 +35,7 @@ namespace Yavsc.ApiControllers { throw new NotImplementedException (); } + public object Edit(int id) { throw new NotImplementedException (); @@ -46,6 +55,6 @@ namespace Yavsc.ApiControllers } } - +*/ } } diff --git a/web/MvcActionValueBinder.cs b/web/MvcActionValueBinder.cs new file mode 100644 index 00000000..725dcf0f --- /dev/null +++ b/web/MvcActionValueBinder.cs @@ -0,0 +1,89 @@ +using System; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.Globalization; +using System.Linq; +using System.Net.Http; +using System.Net.Http.Formatting; +using System.Threading; +using System.Threading.Tasks; +using System.Web.Http; +using System.Web.Http.Controllers; +using System.Web.Http.ModelBinding; +using System.Web.Http.ValueProviders; +using System.Web.Http.ValueProviders.Providers; + +namespace Basic +{ + // Binder with MVC semantics. Treat the body as KeyValue pairs and model bind it. + public class MvcActionValueBinder : DefaultActionValueBinder + { + // Per-request storage, uses the Request.Properties bag. We need a unique key into the bag. + private const string Key = "5DC187FB-BFA0-462A-AB93-9E8036871EC8"; + + public override HttpActionBinding GetBinding (HttpActionDescriptor actionDescriptor) + { + + HttpActionBinding actionBinding = new HttpActionBinding (); + + HttpParameterDescriptor[] parameters = actionDescriptor.GetParameters ().ToArray (); + HttpParameterBinding[] binders = Array.ConvertAll (parameters, p => DetermineBinding (actionBinding, p)); + + actionBinding.ParameterBindings = binders; + return actionBinding; + } + + private HttpParameterBinding DetermineBinding (HttpActionBinding actionBinding, HttpParameterDescriptor parameter) + { + HttpConfiguration config = parameter.Configuration; + + var attr = new ModelBinderAttribute(); // use default settings + + ModelBinderProvider provider = attr.GetModelBinderProvider(config); + + // Alternatively, we could put this ValueProviderFactory in the global config. + List vpfs = new List(attr.GetValueProviderFactories(config)); + vpfs.Add(new BodyValueProviderFactory()); + //vpfs.Add (new RouteDataValueProviderFactory ()); + return new ModelBinderParameterBinding(parameter, provider, vpfs); + } + + // Derive from ActionBinding so that we have a chance to read the body once and then share that with all the parameters. + private class MvcActionBinding : HttpActionBinding + { + // Read the body upfront , add as a ValueProvider + public override Task ExecuteBindingAsync (HttpActionContext actionContext, CancellationToken cancellationToken) + { + HttpRequestMessage request = actionContext.ControllerContext.Request; + HttpContent content = request.Content; + if (content != null) { + // content.ReadAsStreamAsync ().Result; + FormDataCollection fd = content.ReadAsAsync ().Result; + if (fd != null) { + + NameValueCollection nvc = fd.ReadAsNameValueCollection (); + + System.Web.Http.ValueProviders.IValueProvider vp = new System.Web.Http.ValueProviders.Providers.NameValueCollectionValueProvider (nvc, CultureInfo.InvariantCulture); + + request.Properties.Add (Key, vp); + } + } + + return base.ExecuteBindingAsync (actionContext, cancellationToken); + } + } + // Get a value provider over the body. This can be shared by all parameters. + // This gets the values computed in MvcActionBinding. + private class BodyValueProviderFactory : System.Web.Http.ValueProviders.ValueProviderFactory + { + public override System.Web.Http.ValueProviders.IValueProvider GetValueProvider (HttpActionContext actionContext) + { + object vp; + actionContext.Request.Properties.TryGetValue (Key, out vp); + return (System.Web.Http.ValueProviders.IValueProvider)vp; // can be null + } + } + } +} + + diff --git a/web/Web.csproj b/web/Web.csproj index 25f1c718..fbcd8d6d 100644 --- a/web/Web.csproj +++ b/web/Web.csproj @@ -3,7 +3,7 @@ Debug AnyCPU - 10.0.0 + 8.0.30703 2.0 {77044C92-D2F1-45BD-80DD-AA25B311B027} {349C5851-65DF-11DA-9384-00065B846F21};{603C0E0B-DB56-11DC-BE95-000D561079B0};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} @@ -62,25 +62,18 @@ - - False - + lib\CodeKicker.BBCode.dll - - False - - - False - + + - False monodevelop @@ -89,10 +82,10 @@ - - False - - + + + + ..\..\..\..\..\usr\lib\mono\4.5\System.Net.Http.Formatting.dll False @@ -147,6 +140,8 @@ + + diff --git a/yavscModel/WorkFlow/IContentProvider.cs b/yavscModel/WorkFlow/IContentProvider.cs index 6d47549e..f98914d9 100644 --- a/yavscModel/WorkFlow/IContentProvider.cs +++ b/yavscModel/WorkFlow/IContentProvider.cs @@ -1,12 +1,22 @@ using System; using System.Collections.Generic; +using System.Web.Mvc; namespace yavscModel.WorkFlow { public interface IContentProvider: IDisposable { - string Order (IWFCommand c); - IContent Get (string orderId); + IWFOrder CreateOrder (); + IWFOrder ImapctOrder (string orderid, FormCollection col); + IContent GetBlob (string orderId); + int GetStatus (string orderId); + /// + /// Gets the status labels. + /// 0 is the starting status + /// + /// The status labels. + bool [] IsFinalStatus { get; } + string [] StatusLabels {get;} } } diff --git a/yavscModel/WorkFlow/IWFCommand.cs b/yavscModel/WorkFlow/IWFCommand.cs deleted file mode 100644 index 7de8dcb8..00000000 --- a/yavscModel/WorkFlow/IWFCommand.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace yavscModel.WorkFlow -{ - public interface IWFCommand - { - } -} - diff --git a/yavscModel/WorkFlow/IWFModule.cs b/yavscModel/WorkFlow/IWFModule.cs index 6b65ae02..0a1b105f 100644 --- a/yavscModel/WorkFlow/IWFModule.cs +++ b/yavscModel/WorkFlow/IWFModule.cs @@ -2,12 +2,24 @@ using System; using yavscModel.WorkFlow; using System.Web.Mvc; -namespace WorkFlow +namespace yavscModel.WorkFlow { public interface IWFModule { - int GetState (IWFCommand c); - int Handle (IWFCommand c,FormCollection collection); + /// + /// Gets the state for an order (assuming it was passed to Handle). + /// + /// The state. + /// C. + int GetState (IWFOrder c); + /// + /// Handle the specified order and form input value collection. + /// + /// l'ordre + /// La collection de valeur de champs d'entée de formulaires. + /// 0 when the module accepts to handle the order, non null value otherwize + int Handle (IWFOrder order,FormCollection collection); + } } diff --git a/yavscModel/WorkFlow/IWFOrder.cs b/yavscModel/WorkFlow/IWFOrder.cs new file mode 100644 index 00000000..ea4e6d31 --- /dev/null +++ b/yavscModel/WorkFlow/IWFOrder.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; + +namespace yavscModel.WorkFlow +{ + public interface IWFOrder + { + /// + /// Gets the unique Identifier for this order, in this application. + /// + /// The unique I. + string UniqueID { + get; + } + event EventHandler StatusChanged; + } +} + diff --git a/yavscModel/WorkFlow/NewProjectModel.cs b/yavscModel/WorkFlow/NewProjectModel.cs index 5daf7771..53f85633 100644 --- a/yavscModel/WorkFlow/NewProjectModel.cs +++ b/yavscModel/WorkFlow/NewProjectModel.cs @@ -4,6 +4,7 @@ using System.ComponentModel; namespace yavscModel.WorkFlow { + [Obsolete("This should be define in an IT specific module")] public class NewProjectModel { [DisplayName("Nom du projet")] diff --git a/yavscModel/WorkFlow/OrderStatusChangedEventArgs.cs b/yavscModel/WorkFlow/OrderStatusChangedEventArgs.cs new file mode 100644 index 00000000..c331f978 --- /dev/null +++ b/yavscModel/WorkFlow/OrderStatusChangedEventArgs.cs @@ -0,0 +1,17 @@ +using System; + +namespace yavscModel.WorkFlow +{ + public class OrderStatusChangedEventArgs: EventArgs + { + public OrderStatusChangedEventArgs (int oldstatus, int newstatus, string reason) + { + oldstat = oldstatus; + newstat = newstatus; + } + private int oldstat, newstat; + public int OldStatus { get { return oldstat; } } + public int NewStatus { get { return newstat; } } + } +} + diff --git a/yavscModel/WorkFlow/WFOrder.cs b/yavscModel/WorkFlow/WFOrder.cs index 77378a18..d000a787 100644 --- a/yavscModel/WorkFlow/WFOrder.cs +++ b/yavscModel/WorkFlow/WFOrder.cs @@ -2,28 +2,35 @@ using System; using SalesCatalog.Model; using yavscModel.WorkFlow; -namespace WorkFlow +namespace yavscModel.WorkFlow { - public class WFOrder : IWFCommand + public class WFOrder : IWFOrder { private Product p; private DateTime date; private string catref; + private string id = null; public WFOrder(Product prod,string catalogReference){ date = DateTime.Now; catref=catalogReference; p = prod; + id = Guid.NewGuid ().ToString(); } public override string ToString () { return string.Format ("[Commande date={0} prodref={1}, cat={2}]",date,p.Reference,catref); } - #region IWFCommand implementation + public event EventHandler StatusChanged; - public string CatalogReference { + #region IWFCommand implementation + /// + /// Gets the catalog reference, a unique id for the catalog (not a product id). + /// + /// The catalog reference. + public string UniqueID { get { - return catref; + return id; } } diff --git a/yavscModel/yavscModel.csproj b/yavscModel/yavscModel.csproj index 6737e2f5..525350cc 100644 --- a/yavscModel/yavscModel.csproj +++ b/yavscModel/yavscModel.csproj @@ -56,8 +56,9 @@ - + + @@ -81,7 +82,7 @@ - +