- 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:
This commit is contained in:
79
ITContentProvider/ITCPNpgsqlProvider.cs
Normal file
79
ITContentProvider/ITCPNpgsqlProvider.cs
Normal file
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
52
ITContentProvider/ITContentProvider.csproj
Normal file
52
ITContentProvider/ITContentProvider.csproj
Normal file
@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>10.0.0</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{9D7D892E-9B77-4713-892D-C26E1E944119}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>ITContentProvider</RootNamespace>
|
||||
<AssemblyName>ITContentProvider</AssemblyName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="Npgsql" />
|
||||
<Reference Include="System.Data" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ProjectInfo.cs" />
|
||||
<Compile Include="ITCPNpgsqlProvider.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\WorkFlowProvider\WorkFlowProvider.csproj">
|
||||
<Project>{821FF72D-9F4B-4A2C-B95C-7B965291F119}</Project>
|
||||
<Name>WorkFlowProvider</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\yavscModel\yavscModel.csproj">
|
||||
<Project>{68F5B80A-616E-4C3C-91A0-828AA40000BD}</Project>
|
||||
<Name>yavscModel</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
</Project>
|
18
ITContentProvider/ProjectInfo.cs
Normal file
18
ITContentProvider/ProjectInfo.cs
Normal file
@ -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; }
|
||||
}
|
||||
}
|
||||
|
22
ITContentProvider/Properties/AssemblyInfo.cs
Normal file
22
ITContentProvider/Properties/AssemblyInfo.cs
Normal file
@ -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("")]
|
||||
|
@ -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 void AddPrjRessource(int prjId, string owner)
|
||||
{
|
||||
}
|
||||
|
||||
public void NewRelease (int projectId, string Version)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
public bool[] IsFinalStatus {
|
||||
get {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
|
||||
string applicationName=null;
|
||||
|
||||
public string ApplicationName {
|
||||
get {
|
||||
return applicationName;
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
public string Order (IWFOrder c)
|
||||
{
|
||||
throw new System.NotImplementedException ();
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public void SetProjectName (int projectId, string name)
|
||||
public IContent GetBlob (string orderId)
|
||||
{
|
||||
throw new System.NotImplementedException ();
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public void SetProjectDesc (int projectId, string desc)
|
||||
public int GetStatus (string orderId)
|
||||
{
|
||||
throw new System.NotImplementedException ();
|
||||
throw new 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 SetTaskDesc (int taskId, string desc)
|
||||
{
|
||||
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 string[] StatusLabels {
|
||||
get {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveTask (int taskId)
|
||||
{
|
||||
throw new System.NotImplementedException ();
|
||||
}
|
||||
#region IITContentProvider implementation
|
||||
|
||||
public void SetManager (int projectId, string user)
|
||||
{
|
||||
throw new System.NotImplementedException ();
|
||||
}
|
||||
|
||||
public void RemoveUser (string user)
|
||||
{
|
||||
throw new System.NotImplementedException ();
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
}
|
||||
|
@ -33,6 +33,9 @@
|
||||
<Reference Include="Npgsql" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
|
@ -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
|
||||
|
21
web/Controllers/BasketImpact.cs
Normal file
21
web/Controllers/BasketImpact.cs
Normal file
@ -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; }
|
||||
}
|
||||
|
||||
}
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
89
web/MvcActionValueBinder.cs
Normal file
89
web/MvcActionValueBinder.cs
Normal file
@ -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<ValueProviderFactory> vpfs = new List<ValueProviderFactory>(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<FormDataCollection> ().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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>10.0.0</ProductVersion>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{77044C92-D2F1-45BD-80DD-AA25B311B027}</ProjectGuid>
|
||||
<ProjectTypeGuids>{349C5851-65DF-11DA-9384-00065B846F21};{603C0E0B-DB56-11DC-BE95-000D561079B0};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
@ -62,25 +62,18 @@
|
||||
<Reference Include="Npgsql" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Security" />
|
||||
<Reference Include="nunit.framework, Version=2.6.0.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77">
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="nunit.framework, Version=2.6.0.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77" />
|
||||
<Reference Include="CodeKicker.BBCode">
|
||||
<HintPath>lib\CodeKicker.BBCode.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
|
||||
<Reference Include="System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
|
||||
<Reference Include="Mono.Posix" />
|
||||
<Reference Include="System.ServiceModel.Web" />
|
||||
<Reference Include="System.ServiceModel.Routing" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Net.Http.WebRequest" />
|
||||
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=c7439020c8fedf87">
|
||||
<Private>False</Private>
|
||||
<Package>monodevelop</Package>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Http.WebHost">
|
||||
@ -89,10 +82,10 @@
|
||||
</Reference>
|
||||
<Reference Include="System.Configuration.Install" />
|
||||
<Reference Include="System.Web.Services" />
|
||||
<Reference Include="System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.WebPages.Deployment, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
|
||||
<Reference Include="System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
|
||||
<Reference Include="System.Web.WebPages.Deployment, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
|
||||
<Reference Include="System.Net.Http.Formatting">
|
||||
<HintPath>..\..\..\..\..\usr\lib\mono\4.5\System.Net.Http.Formatting.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
@ -147,6 +140,8 @@
|
||||
<Compile Include="Controllers\BasketController.cs" />
|
||||
<Compile Include="Basket\Basket.cs" />
|
||||
<Compile Include="FileInfoCollection.cs" />
|
||||
<Compile Include="Controllers\BasketImpact.cs" />
|
||||
<Compile Include="MvcActionValueBinder.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\Web.config" />
|
||||
|
@ -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);
|
||||
/// <summary>
|
||||
/// Gets the status labels.
|
||||
/// 0 is the starting status
|
||||
/// </summary>
|
||||
/// <value>The status labels.</value>
|
||||
bool [] IsFinalStatus { get; }
|
||||
string [] StatusLabels {get;}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,10 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace yavscModel.WorkFlow
|
||||
{
|
||||
public interface IWFCommand
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
/// <summary>
|
||||
/// Gets the state for an order (assuming it was passed to <c>Handle</c>).
|
||||
/// </summary>
|
||||
/// <returns>The state.</returns>
|
||||
/// <param name="c">C.</param>
|
||||
int GetState (IWFOrder c);
|
||||
/// <summary>
|
||||
/// Handle the specified order and form input value collection.
|
||||
/// </summary>
|
||||
/// <param name="order">l'ordre</param>
|
||||
/// <param name="collection">La collection de valeur de champs d'entée de formulaires.</param>
|
||||
/// <returns>0 when the module accepts to handle the order, non null value otherwize<returns>
|
||||
int Handle (IWFOrder order,FormCollection collection);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
18
yavscModel/WorkFlow/IWFOrder.cs
Normal file
18
yavscModel/WorkFlow/IWFOrder.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace yavscModel.WorkFlow
|
||||
{
|
||||
public interface IWFOrder
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the unique Identifier for this order, in this application.
|
||||
/// </summary>
|
||||
/// <value>The unique I.</value>
|
||||
string UniqueID {
|
||||
get;
|
||||
}
|
||||
event EventHandler<OrderStatusChangedEventArgs> StatusChanged;
|
||||
}
|
||||
}
|
||||
|
@ -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")]
|
||||
|
17
yavscModel/WorkFlow/OrderStatusChangedEventArgs.cs
Normal file
17
yavscModel/WorkFlow/OrderStatusChangedEventArgs.cs
Normal file
@ -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; } }
|
||||
}
|
||||
}
|
||||
|
@ -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<OrderStatusChangedEventArgs> StatusChanged;
|
||||
|
||||
public string CatalogReference {
|
||||
#region IWFCommand implementation
|
||||
/// <summary>
|
||||
/// Gets the catalog reference, a unique id for the catalog (not a product id).
|
||||
/// </summary>
|
||||
/// <value>The catalog reference.</value>
|
||||
public string UniqueID {
|
||||
get {
|
||||
return catref;
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,8 +56,9 @@
|
||||
<Compile Include="WorkFlow\WFOrder.cs" />
|
||||
<Compile Include="WorkFlow\IContent.cs" />
|
||||
<Compile Include="WorkFlow\IContentProvider.cs" />
|
||||
<Compile Include="WorkFlow\IWFCommand.cs" />
|
||||
<Compile Include="WorkFlow\IWFModule.cs" />
|
||||
<Compile Include="WorkFlow\IWFOrder.cs" />
|
||||
<Compile Include="WorkFlow\OrderStatusChangedEventArgs.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
@ -81,7 +82,7 @@
|
||||
<MonoDevelop>
|
||||
<Properties>
|
||||
<Policies>
|
||||
<DotNetNamingPolicy DirectoryNamespaceAssociation="Flat" ResourceNamePolicy="FileFormatDefault" />
|
||||
<DotNetNamingPolicy DirectoryNamespaceAssociation="PrefixedFlat" ResourceNamePolicy="FileFormatDefault" />
|
||||
</Policies>
|
||||
</Properties>
|
||||
</MonoDevelop>
|
||||
|
Reference in New Issue
Block a user