* Web.csproj:

* YavscModel.csproj:
* Basket.cs:
* Basket.aspx:
* Commande.cs:
* BasketController.cs:
* CommandSet.cs:
* NpgsqlWorkflow.csproj:
* FileSystemController.cs:
* FrontOfficeController.cs:
* NpgsqlContentProvider.cs: implementing a basket

* ProjectInfo.cs:
* ITCPNpgsqlProvider.cs:
* CommandStatus.cs:
* NpgsqlBlogProvider.cs: xml doc

* CalendarApi.cs: document formatting

* FileSystemManager.cs: refactoring

* WorkFlowManager.cs:
* IContentProvider.cs: provides a basket

* WebFileInfoCollection.cs: not used
This commit is contained in:
Paul Schneider 2015-02-18 13:32:25 +01:00
commit 75fe032822
19 changed files with 388 additions and 127 deletions

View file

@ -56,9 +56,9 @@ namespace Yavsc.Model.FileSystem
/// <summary>
/// Initializes a new instance of the <see cref="Yavsc.Model.FileSystem.FileSystemManager"/> class.
/// </summary>
public FileSystemManager (string usersDirectory="~/files", char dirSep = '/')
public FileSystemManager (string rootDirectory="~/files", char dirSep = '/')
{
prefix = usersDirectory;
prefix = rootDirectory;
DirectorySeparator = dirSep;
}
@ -150,8 +150,19 @@ namespace Yavsc.Model.FileSystem
}
DirectoryInfo di = new DirectoryInfo (path);
FileInfoCollection res = new FileInfoCollection (di.GetFiles ());
// TODO define an Owner
return res;
}
/// <summary>
/// Files the info.
/// </summary>
/// <returns>The info.</returns>
/// <param name="id">Identifier.</param>
public FileInfo FileInfo(string id)
{
checkSubDir (id);
return new FileInfo(Path.Combine (Prefix, id));
}
}
}

View file

@ -27,12 +27,12 @@ namespace Yavsc.Model.FrontOffice
/// <summary>
/// Basket.
/// </summary>
public class Basket: Dictionary<long,Commande>
public class CommandSet: Dictionary<long,Command>
{
/// <summary>
/// Initializes a new instance of the <see cref="Yavsc.Model.FrontOffice.Basket"/> class.
/// Initializes a new instance of the <see cref="Yavsc.Model.FrontOffice.CommandSet"/> class.
/// </summary>
public Basket ()
public CommandSet ()
{
}
/// <Docs>The item to add to the current collection.</Docs>
@ -43,7 +43,7 @@ namespace Yavsc.Model.FrontOffice
/// Add the specified cmd.
/// </summary>
/// <param name="cmd">Cmd.</param>
public void Add(Commande cmd)
public void Add(Command cmd)
{
Add (cmd.Id, cmd);
}

View file

@ -22,13 +22,34 @@ using System;
namespace Yavsc.Model.FrontOffice
{
/// <summary>
/// Command status.
/// </summary>
public enum CommandStatus:int
{
/// <summary>
/// The inserted.
/// </summary>
Inserted,
/// <summary>
/// The user validated.
/// </summary>
UserValidated,
/// <summary>
/// The user canceled.
/// </summary>
UserCanceled,
/// <summary>
/// The execution pending.
/// </summary>
ExecutionPending,
/// <summary>
/// The satisfied.
/// </summary>
Satisfied,
/// <summary>
/// The refunded.
/// </summary>
Refunded
}
}

View file

@ -11,24 +11,32 @@ namespace Yavsc.Model.FrontOffice
/// <summary>
/// Commande.
/// </summary>
public class Commande
public class Command
{
/// <summary>
/// Gets or sets the creation date.
/// </summary>
/// <value>The creation date.</value>
public DateTime CreationDate { get; set; }
/// <summary>
/// Gets or sets the identifier.
/// </summary>
/// <value>The identifier.</value>
public long Id { get; set; }
/// <summary>
/// Gets or sets the product reference.
/// </summary>
/// <value>The prod reference.</value>
public CommandStatus Status { get; set; }
/// <summary>
/// Gets or sets the product reference.
/// </summary>
/// <value>The product reference.</value>
public string ProductRef { get; set; }
/// <summary>
/// The parameters.
/// </summary>
@ -39,30 +47,46 @@ namespace Yavsc.Model.FrontOffice
return GetFSM().GetFiles (Id.ToString());
}
}
/// <summary>
/// Create a command using the specified collection
/// as command parameters, handles the request files.
/// Initializes a new instance of the <see cref="Yavsc.Model.FrontOffice.Command"/> class.
/// </summary>
public Command()
{
}
/// <summary>
/// Froms the post.
/// </summary>
/// <param name="collection">Collection.</param>
/// <param name="files">Files.</param>
public Commande (NameValueCollection collection, NameObjectCollectionBase files)
public void FromPost(NameValueCollection collection, NameObjectCollectionBase files)
{
// string catref=collection["catref"]; // Catalog Url from which formdata has been built
ProductRef=collection["ref"]; // Required product reference
CreationDate = DateTime.Now;
Status = CommandStatus.Inserted;
// stores the parameters:
Parameters.Clear ();
foreach (string key in collection.AllKeys) {
if (key!="ref")
Parameters.Add (key, collection [key]);
}
WorkFlowManager wfm = new WorkFlowManager ();
wfm.RegisterCommand (this); // sets this.Id
wfm.RegisterCommand (this); // overrides this.Id
string strcmdid = Id.ToString ();
GetFSM().Put (strcmdid, files);
}
/// <summary>
/// Creates a command using the specified collection
/// as command parameters, handles the files upload.
/// </summary>
/// <param name="collection">Collection.</param>
/// <param name="files">Files.</param>
public Command (NameValueCollection collection, NameObjectCollectionBase files)
{
FromPost (collection, files);
}
private FileSystemManager GetFSM() {
return new FileSystemManager ("~/commands");
}

View file

@ -1,24 +0,0 @@
using System;
using Yavsc;
using System.Collections.Specialized;
using Yavsc.Model.WorkFlow;
using Yavsc.Model.FileSystem;
using System.Web;
using System.Collections.Generic;
namespace Yavsc.Model.FrontOffice
{
public class WebFileInfoCollection: List<WebFileInfo>
{
public WebFileInfoCollection (
HttpContextBase context, string prefix)
{
}
}
}

View file

@ -119,8 +119,13 @@ namespace Yavsc.Model.WorkFlow
/// </summary>
/// <returns>The command id in db.</returns>
/// <param name="com">COM.</param>
long RegisterCommand (Commande com);
long RegisterCommand (Command com);
/// <summary>
/// Gets the commands.
/// </summary>
/// <returns>The commands.</returns>
/// <param name="username">Username.</param>
CommandSet GetCommands (string username);
/// <summary>
/// Gets the stock status.
/// </summary>

View file

@ -25,7 +25,7 @@ namespace Yavsc.Model.WorkFlow
/// </summary>
/// <returns>The command.</returns>
/// <param name="com">COM.</param>
public long RegisterCommand(Commande com)
public long RegisterCommand(Command com)
{
return ContentProvider.RegisterCommand (com);
}
@ -183,7 +183,15 @@ namespace Yavsc.Model.WorkFlow
{
ContentProvider.SetEstimateStatus (estid, status, username);
}
/// <summary>
/// Gets the commands.
/// </summary>
/// <returns>The commands.</returns>
/// <param name="username">Username.</param>
public CommandSet GetCommands(string username)
{
return ContentProvider.GetCommands (username);
}
}
}

View file

@ -96,7 +96,6 @@
<Compile Include="Google\GoogleErrorMessage.cs" />
<Compile Include="RssFeeds.cs" />
<Compile Include="FrontOffice\Commande.cs" />
<Compile Include="FrontOffice\Basket.cs" />
<Compile Include="FrontOffice\Catalog\Brand.cs" />
<Compile Include="FrontOffice\Catalog\Catalog.cs" />
<Compile Include="FrontOffice\Catalog\CheckBox.cs" />
@ -136,8 +135,8 @@
<Compile Include="FileSystem\InvalidDirNameException.cs" />
<Compile Include="FileSystem\WebFileInfo.cs" />
<Compile Include="Google\CalendarEntryList.cs" />
<Compile Include="FrontOffice\WebFileInfoCollection.cs" />
<Compile Include="FrontOffice\CommandStatus.cs" />
<Compile Include="FrontOffice\CommandSet.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>