* 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
parent b505ad90e7
commit 75fe032822
19 changed files with 388 additions and 127 deletions

View File

@ -4,6 +4,9 @@ using Npgsql;
namespace ITContentProvider
{
/// <summary>
/// ITCP npgsql provider.
/// </summary>
public class ITCPNpgsqlProvider : NpgsqlContentProvider
{
/* TODO
@ -19,42 +22,79 @@ namespace ITContentProvider
void SetTaskDesc(int taskId, string desc);
void NewRelease(int projectId, string Version);
*/
/// <summary>
/// Initializes a new instance of the <see cref="ITContentProvider.ITCPNpgsqlProvider"/> class.
/// </summary>
public ITCPNpgsqlProvider ()
{
}
/// <summary>
/// Gets the project info.
/// </summary>
/// <returns>The project info.</returns>
/// <param name="projectid">Projectid.</param>
public ProjectInfo GetProjectInfo(int projectid)
{
throw new NotImplementedException ();
}
/// <summary>
/// Searchs the project.
/// </summary>
/// <returns>The project.</returns>
/// <param name="pi">Pi.</param>
public ProjectInfo[] SearchProject(ProjectInfo pi)
{
throw new NotImplementedException ();
}
/// <summary>
/// News the task.
/// </summary>
/// <returns>The task.</returns>
/// <param name="projectId">Project identifier.</param>
/// <param name="name">Name.</param>
/// <param name="desc">Desc.</param>
public int NewTask (int projectId, string name, string desc)
{
throw new System.NotImplementedException ();
}
/// <summary>
/// Sets the name of the task.
/// </summary>
/// <param name="taskId">Task identifier.</param>
/// <param name="name">Name.</param>
public void SetTaskName (int taskId, string name)
{
throw new System.NotImplementedException ();
}
/// <summary>
/// Sets the start date.
/// </summary>
/// <param name="taskId">Task identifier.</param>
/// <param name="d">D.</param>
public void SetStartDate (int taskId, DateTime d)
{
throw new System.NotImplementedException ();
}
/// <summary>
/// Sets the end date.
/// </summary>
/// <param name="taskId">Task identifier.</param>
/// <param name="d">D.</param>
public void SetEndDate (int taskId, DateTime d)
{
throw new System.NotImplementedException ();
}
/// <summary>
/// Removes the project.
/// </summary>
/// <param name="prjId">Prj identifier.</param>
public void RemoveProject (int prjId)
{
using (var cnx = CreateConnection()) {
@ -68,7 +108,13 @@ namespace ITContentProvider
}
}
/// <summary>
/// News the project.
/// </summary>
/// <returns>The project.</returns>
/// <param name="name">Name.</param>
/// <param name="desc">Desc.</param>
/// <param name="ownerId">Owner identifier.</param>
public int NewProject (string name, string desc, string ownerId)
{
int id = 0;

View File

@ -3,15 +3,50 @@ using WorkFlowProvider;
namespace ITContentProvider
{
/// <summary>
/// Project info.
/// </summary>
public class ProjectInfo
{
/// <summary>
/// Gets or sets the name.
/// </summary>
/// <value>The name.</value>
string Name { get; set; }
/// <summary>
/// Gets or sets the licence.
/// </summary>
/// <value>The licence.</value>
string Licence { get; set; }
/// <summary>
/// Gets or sets the BB description.
/// </summary>
/// <value>The BB description.</value>
string BBDescription { get; set; }
/// <summary>
/// Gets or sets the start date.
/// </summary>
/// <value>The start date.</value>
DateTime StartDate { get; set; }
/// <summary>
/// Gets or sets the prod version.
/// </summary>
/// <value>The prod version.</value>
string ProdVersion { get; set; }
/// <summary>
/// Gets or sets the stable version.
/// </summary>
/// <value>The stable version.</value>
string StableVersion { get; set; }
/// <summary>
/// Gets or sets the testing version.
/// </summary>
/// <value>The testing version.</value>
string TestingVersion { get; set; }
/// <summary>
/// Gets or sets the web site.
/// </summary>
/// <value>The web site.</value>
string WebSite { get; set; }
}
}

View File

@ -7,13 +7,20 @@ using Yavsc.Model.Blogs;
namespace Npgsql.Web.Blog
{
/// <summary>
/// Npgsql blog provider.
/// </summary>
public class NpgsqlBlogProvider : BlogProvider
{
string applicationName;
string connectionString;
#region implemented abstract members of BlogProvider
/// <summary>
/// Tag the specified postid and tag.
/// </summary>
/// <param name="postid">Postid.</param>
/// <param name="tag">Tag.</param>
public override long Tag (long postid, string tag)
{
using (NpgsqlConnection cnx = new NpgsqlConnection (connectionString))
@ -24,7 +31,10 @@ namespace Npgsql.Web.Blog
return (long) cmd.ExecuteScalar ();
}
}
/// <summary>
/// Removes the tag.
/// </summary>
/// <param name="tagid">Tagid.</param>
public override void RemoveTag (long tagid)
{
using (NpgsqlConnection cnx = new NpgsqlConnection (connectionString))
@ -34,10 +44,22 @@ namespace Npgsql.Web.Blog
cmd.ExecuteNonQuery ();
}
}
/// <summary>
/// Gets the post identifier.
/// </summary>
/// <returns>The post identifier.</returns>
/// <param name="username">Username.</param>
/// <param name="title">Title.</param>
public override long GetPostId (string username, string title)
{
throw new NotImplementedException ();
}
/// <summary>
/// Gets the comments.
/// </summary>
/// <returns>The comments.</returns>
/// <param name="postid">Postid.</param>
/// <param name="getHidden">If set to <c>true</c> get hidden.</param>
public override Comment[] GetComments (long postid, bool getHidden)
{
List<Comment> cmts = new List<Comment> ();
@ -68,6 +90,13 @@ namespace Npgsql.Web.Blog
}
return cmts.ToArray();
}
/// <summary>
/// Updates the post.
/// </summary>
/// <param name="postid">Postid.</param>
/// <param name="title">Title.</param>
/// <param name="content">Content.</param>
/// <param name="visible">If set to <c>true</c> visible.</param>
public override void UpdatePost (long postid, string title, string content, bool visible)
{
using (NpgsqlConnection cnx = new NpgsqlConnection(connectionString))
@ -89,12 +118,20 @@ namespace Npgsql.Web.Blog
cnx.Close();
}
}
/// <summary>
/// Removes the post.
/// </summary>
/// <param name="postid">Postid.</param>
public override void RemovePost (long postid)
{
throw new NotImplementedException ();
}
/// <summary>
/// Comment the specified from, postid and content.
/// </summary>
/// <param name="from">From.</param>
/// <param name="postid">Postid.</param>
/// <param name="content">Content.</param>
public override long Comment (string from, long postid, string content)
{
if (from == null)
@ -121,12 +158,20 @@ namespace Npgsql.Web.Blog
return (long) cmd.ExecuteScalar();
}
}
/// <summary>
/// Validates the comment.
/// </summary>
/// <param name="cmtid">Cmtid.</param>
public override void ValidateComment (long cmtid)
{
throw new NotImplementedException ();
}
/// <summary>
/// Updates the comment.
/// </summary>
/// <param name="cmtid">Cmtid.</param>
/// <param name="content">Content.</param>
/// <param name="visible">If set to <c>true</c> visible.</param>
public override void UpdateComment
(long cmtid, string content, bool visible)
{
@ -134,7 +179,10 @@ namespace Npgsql.Web.Blog
}
private bool autoValidateComment = true;
/// <summary>
/// Gets or sets a value indicating whether this <see cref="Npgsql.Web.Blog.NpgsqlBlogProvider"/> auto validate comment.
/// </summary>
/// <value><c>true</c> if auto validate comment; otherwise, <c>false</c>.</value>
public override bool AutoValidateComment {
get {
return autoValidateComment;
@ -144,7 +192,11 @@ namespace Npgsql.Web.Blog
}
}
/// <summary>
/// Blogs the title.
/// </summary>
/// <returns>The title.</returns>
/// <param name="username">Username.</param>
public override string BlogTitle
(string username)
{
@ -152,7 +204,11 @@ namespace Npgsql.Web.Blog
}
#endregion
/// <summary>
/// Initialize the specified name and config.
/// </summary>
/// <param name="name">Name.</param>
/// <param name="config">Config.</param>
public override void Initialize
(string name, System.Collections.Specialized.NameValueCollection config)
{
@ -165,6 +221,11 @@ namespace Npgsql.Web.Blog
base.Initialize (name, config);
}
#region implemented abstract members of BlogProvider
/// <summary>
/// Gets the post.
/// </summary>
/// <returns>The post.</returns>
/// <param name="postid">Postid.</param>
public override BlogEntry GetPost (long postid)
{
BlogEntry be = null;
@ -190,6 +251,11 @@ namespace Npgsql.Web.Blog
}
return be;
}
/// <summary>
/// Removes the comment.
/// </summary>
/// <returns>The comment.</returns>
/// <param name="cmtid">Cmtid.</param>
public override long RemoveComment (long cmtid)
{
long postid = 0;
@ -202,6 +268,12 @@ namespace Npgsql.Web.Blog
}
return postid;
}
/// <summary>
/// Gets the post.
/// </summary>
/// <returns>The post.</returns>
/// <param name="username">Username.</param>
/// <param name="title">Title.</param>
public override BlogEntry GetPost (string username, string title)
{
BlogEntry be = null;
@ -239,7 +311,13 @@ namespace Npgsql.Web.Blog
}
return be;
}
/// <summary>
/// Post the specified username, title, content and visible.
/// </summary>
/// <param name="username">Username.</param>
/// <param name="title">Title.</param>
/// <param name="content">Content.</param>
/// <param name="visible">If set to <c>true</c> visible.</param>
public override long Post (string username, string title, string content, bool visible)
{
if (username == null)
@ -264,7 +342,15 @@ namespace Npgsql.Web.Blog
return (long) cmd.ExecuteScalar();
}
}
/// <summary>
/// Finds the post.
/// </summary>
/// <returns>The post.</returns>
/// <param name="pattern">Pattern.</param>
/// <param name="searchflags">Searchflags.</param>
/// <param name="pageIndex">Page index.</param>
/// <param name="pageSize">Page size.</param>
/// <param name="totalRecords">Total records.</param>
public override BlogEntryCollection FindPost (string pattern, FindBlogEntryFlags searchflags, int pageIndex, int pageSize, out int totalRecords)
{
BlogEntryCollection c = new BlogEntryCollection ();
@ -313,7 +399,11 @@ namespace Npgsql.Web.Blog
}
return c;
}
/// <summary>
/// Removes the post.
/// </summary>
/// <param name="username">Username.</param>
/// <param name="title">Title.</param>
public override void RemovePost (string username, string title)
{
using (NpgsqlConnection cnx=new NpgsqlConnection(connectionString))
@ -330,7 +420,13 @@ namespace Npgsql.Web.Blog
int defaultPageSize = 10;
/// <summary>
/// Lasts the posts.
/// </summary>
/// <returns>The posts.</returns>
/// <param name="pageIndex">Page index.</param>
/// <param name="pageSize">Page size.</param>
/// <param name="totalRecords">Total records.</param>
public override BlogEntryCollection LastPosts(int pageIndex, int pageSize, out int totalRecords)
{
BlogEntryCollection c = new BlogEntryCollection ();

View File

@ -8,6 +8,7 @@ using System.Configuration.Provider;
using System.Collections.Generic;
using Yavsc.Model.FrontOffice;
using Newtonsoft.Json;
using System.Web.Security;
namespace WorkFlowProvider
{
@ -16,22 +17,12 @@ namespace WorkFlowProvider
/// </summary>
public class NpgsqlContentProvider: ProviderBase, IContentProvider
{
/// <summary>
/// Gets the stock status.
/// </summary>
/// <returns>The stock status.</returns>
/// <param name="productReference">Product reference.</param>
public virtual StockStatus GetStockStatus (string productReference)
{
return StockStatus.NonExistent;
}
/// <summary>
/// Registers the command.
/// </summary>
/// <returns>The command id in db.</returns>
/// <param name="com">COM.</param>
public long RegisterCommand (Commande com)
public long RegisterCommand (Command com)
{
long id;
using (NpgsqlConnection cnx = CreateConnection ()) {
@ -47,6 +38,56 @@ namespace WorkFlowProvider
}
return id;
}
/// <summary>
/// Gets the commands.
/// </summary>
/// <returns>The commands.</returns>
/// <param name="username">Username.</param>
public CommandSet GetCommands (string username )
{
// Check the user's authorisations
MembershipUser user = Membership.GetUser ();
if (user.UserName != username)
if (!Roles.IsUserInRole ("Admin"))
if (!Roles.IsUserInRole ("FrontOffice"))
throw new Exception ("Not allowed");
CommandSet cmds = new CommandSet ();
using (NpgsqlConnection cnx = CreateConnection ()) {
using (NpgsqlCommand cmd = cnx.CreateCommand ()) {
cmd.CommandText =
"select id,prdref,creation,params from commandes where @user = clientname and applicationname = @app";
cmd.Parameters.Add ("@user", username);
cmd.Parameters.Add ("@app", this.ApplicationName);
cnx.Open ();
using (NpgsqlDataReader rdr = cmd.ExecuteReader ()) {
while (rdr.Read ()) {
Command ycmd = new Command();
ycmd.Id = rdr.GetInt64(0);
ycmd.CreationDate = rdr.GetDateTime(1);
ycmd.ProductRef = rdr.GetString(2);
ycmd.Parameters = JsonConvert.DeserializeObject(rdr.GetString(3)) as StringDictionary;
cmds.Add (ycmd);
}
}
}
cnx.Close ();
}
return cmds;
}
/// <summary>
/// Gets the stock status.
/// </summary>
/// <returns>The stock status.</returns>
/// <param name="productReference">Product reference.</param>
public virtual StockStatus GetStockStatus (string productReference)
{
return StockStatus.NonExistent;
}
/// <summary>
/// Gets the writting status changes.
/// </summary>

View File

@ -40,6 +40,8 @@
<HintPath>..\..\..\..\..\usr\lib\mono\4.5\System.Net.Http.Formatting.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.Web" />
<Reference Include="System.Web.ApplicationServices" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />

View File

@ -7,7 +7,6 @@ using System.Web.Http;
using Yavsc.Model.WorkFlow;
using System.Collections.Specialized;
using Yavsc.Model.FrontOffice;
using System.Web.SessionState;
namespace Yavsc.ApiControllers
{
@ -37,12 +36,10 @@ namespace Yavsc.ApiControllers
/// Gets the current basket, creates a new one, if it doesn't exist.
/// </summary>
/// <value>The current basket.</value>
protected Basket CurrentBasket {
protected CommandSet CurrentBasket {
get {
HttpSessionState session = HttpContext.Current.Session;
Basket b = (Basket) session ["Basket"];
if (b == null)
session ["Basket"] = b = new Basket ();
CommandSet b = wfmgr.GetCommands (Membership.GetUser ().UserName);
if (b == null) b = new CommandSet ();
return b;
}
}
@ -55,7 +52,7 @@ namespace Yavsc.ApiControllers
public long Create(NameValueCollection cmdParams)
{
// HttpContext.Current.Request.Files
Commande cmd = new Commande(cmdParams, HttpContext.Current.Request.Files);
Command cmd = new Command(cmdParams, HttpContext.Current.Request.Files);
CurrentBasket.Add (cmd);
return cmd.Id;
}
@ -65,7 +62,7 @@ namespace Yavsc.ApiControllers
/// </summary>
/// <param name="itemid">Itemid.</param>
[Authorize]
Commande Read(long itemid){
Command Read(long itemid){
return CurrentBasket[itemid];
}

View File

@ -15,15 +15,13 @@ namespace Yavsc.Controllers
/// </summary>
public class FileSystemController : Controller
{
private string usersDir = "~/users";
/// <summary>
/// Gets the users base directory.
/// </summary>
/// <value>The users dir.</value>
public string UsersDir {
public string RootDir {
get {
return usersDir;
return mgr.Prefix;
}
}
@ -36,7 +34,8 @@ namespace Yavsc.Controllers
protected override void Initialize (System.Web.Routing.RequestContext requestContext)
{
base.Initialize (requestContext);
mgr = new FileSystemManager (UsersDir);
mgr = new FileSystemManager (
string.Format("~/users/{0}",Membership.GetUser().UserName));
}
/// <summary>
@ -45,7 +44,7 @@ namespace Yavsc.Controllers
[Authorize]
public ActionResult Index (string id)
{
return View (mgr.GetFiles (Membership.GetUser().UserName+"/"+id));
return View (mgr.GetFiles (id));
}
/// <summary>
@ -63,9 +62,9 @@ namespace Yavsc.Controllers
return RedirectToAction ("Index");
}
}
string fpath = Path.Combine (UserBaseDir, id);
ViewData ["Content"] = Url.Content (fpath);
FileInfo fi = new FileInfo (fpath);
FileInfo fi = mgr.FileInfo (id);
ViewData ["Content"] = Url.Content (fi.FullName);
return View (fi);
}
@ -78,16 +77,15 @@ namespace Yavsc.Controllers
[Authorize]
public ActionResult Create (string id)
{
string path=Membership.GetUser().UserName+"/"+id;
mgr.Put ( path, Request.Files);
return View ("Index",mgr.GetFiles(path));
mgr.Put ( id, Request.Files);
return View ("Index",mgr.GetFiles(id));
}
/// <summary>
/// Gets the user's base dir.
/// </summary>
/// <value>The base dir.</value>
public string UserBaseDir { get { return Path.Combine (UsersDir, Membership.GetUser ().UserName); } }
public string UserBaseDir { get { return Path.Combine (RootDir, Membership.GetUser ().UserName); } }
/// <summary>
/// Edit the specified id.

View File

@ -181,19 +181,14 @@ namespace Yavsc.Controllers
}
/// <summary>
/// Command this instance.
/// Basket this instance.
/// </summary>
public ActionResult Command ()
[Authorize]
public ActionResult Basket ()
{
return View ();
return View (wfmgr.GetCommands(Membership.GetUser().UserName));
}
private Basket GetBasket ()
{
if (Session ["Basket"] == null)
Session ["Basket"] = new Basket();
return Session ["Basket"] as Basket;
}
/// <summary>
/// Command the specified collection.
@ -204,29 +199,9 @@ namespace Yavsc.Controllers
public ActionResult Command (FormCollection collection)
{
try {
// get files from the request
string fnre = "[A-Za-z0-9~\\-.]+";
HttpFileCollectionBase hfc = Request.Files;
// TODO mime-magic on content, and file name filter
foreach (String h in hfc.AllKeys) {
if (!Regex.Match (hfc [h].FileName, fnre).Success) {
ViewData ["Message"] = "File name refused";
ModelState.AddModelError (
h,
string.Format (
"The file name {0} dosn't match an acceptable file name {1}",
hfc [h].FileName, fnre));
return View (collection);
}
}
string usersdir = Server.MapPath("~/users");
FileSystemManager fsmgr = new FileSystemManager(usersdir);
foreach (String h in hfc.AllKeys) {
// TODO Limit with hfc[h].ContentLength
hfc [h].SaveAs (Path.Combine (usersdir, hfc [h].FileName));
}
// Add specified product command to the basket,
GetBasket().Add (new Commande(collection,HttpContext.Request.Files));
// saves it in db
new Command(collection,HttpContext.Request.Files);
ViewData ["Message"] = LocalizedText.Item_added_to_basket;
return View (collection);
} catch (Exception e) {

View File

@ -103,13 +103,13 @@ namespace Yavsc.Helpers.Google
try {
using (WebResponse resp = webreq.GetResponse ()) {
using (Stream respstream = resp.GetResponseStream ()) {
try {
try {
res = (CalendarEntryList) new DataContractJsonSerializer(typeof(CalendarEntryList)).ReadObject (respstream);
} catch (Exception ex) {
respstream.Close ();
resp.Close ();
} catch (Exception ex) {
respstream.Close ();
resp.Close ();
webreq.Abort ();
throw new GoogleErrorException(ex);
throw ex;
}
}
resp.Close ();

View File

@ -0,0 +1,26 @@
<%@ Page Title="Basket" Language="C#" Inherits="System.Web.Mvc.ViewPage<Basket>" MasterPageFile="~/Models/App.master" %>
<asp:Content ContentPlaceHolderID="init" ID="init1" runat="server">
<% Title = Title +" "+ Model.Count+" article(s)"; %>
</asp:Content>
<asp:Content ContentPlaceHolderID="MainContent" ID="mainContent" runat="server">
<ul>
<% foreach (Commande cmd in Model.Values) { %>
<li>
<%= cmd.Id %>
<%= cmd.CreationDate %>
<%= cmd.Status %>
<%= cmd.ProductRef %>
<ul>
<% foreach (string key in cmd.Parameters.Keys) { %>
<li><%=key%>: <%=cmd.Parameters[key]%></li>
<% } %>
</ul>
</li>
<% } %>
</ul>
</asp:Content>

View File

@ -673,6 +673,7 @@
<Content Include="Scripts\jquery.googlemaps.js" />
<Content Include="Scripts\jquery.googlemaps.min.js" />
<Content Include="Views\Account\MyProfile.aspx" />
<Content Include="Views\FrontOffice\Basket.aspx" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />

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>