2014-10-06 04:58:47 +02:00
|
|
|
using System;
|
|
|
|
|
using Yavsc;
|
|
|
|
|
using System.Collections.Specialized;
|
2015-01-27 14:17:33 +01:00
|
|
|
using Yavsc.Model.WorkFlow;
|
2015-02-17 13:57:39 +01:00
|
|
|
using Yavsc.Model.FileSystem;
|
|
|
|
|
using System.Web;
|
2015-02-18 16:32:22 +01:00
|
|
|
using System.Collections.Generic;
|
2015-08-14 01:43:55 +02:00
|
|
|
using System.IO;
|
2014-10-06 04:58:47 +02:00
|
|
|
|
2014-10-10 11:54:18 +02:00
|
|
|
|
2015-01-27 14:17:33 +01:00
|
|
|
namespace Yavsc.Model.FrontOffice
|
2014-10-06 04:58:47 +02:00
|
|
|
{
|
2015-02-12 16:08:16 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Commande.
|
|
|
|
|
/// </summary>
|
2015-02-18 13:32:25 +01:00
|
|
|
public class Command
|
2014-10-06 04:58:47 +02:00
|
|
|
{
|
2015-02-12 16:08:16 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the creation date.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The creation date.</value>
|
2014-10-10 11:54:18 +02:00
|
|
|
public DateTime CreationDate { get; set; }
|
2015-02-18 13:32:25 +01:00
|
|
|
|
2015-02-12 16:08:16 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the identifier.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The identifier.</value>
|
2015-01-26 16:44:41 +01:00
|
|
|
public long Id { get; set; }
|
2015-02-18 13:32:25 +01:00
|
|
|
|
2015-02-12 16:08:16 +01:00
|
|
|
/// <summary>
|
2015-02-17 13:57:39 +01:00
|
|
|
/// Gets or sets the product reference.
|
2015-02-12 16:08:16 +01:00
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The prod reference.</value>
|
2015-02-17 13:57:39 +01:00
|
|
|
public CommandStatus Status { get; set; }
|
2015-02-18 13:32:25 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the product reference.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The product reference.</value>
|
2015-02-17 13:57:39 +01:00
|
|
|
public string ProductRef { get; set; }
|
2015-02-18 13:32:25 +01:00
|
|
|
|
2015-02-12 16:08:16 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// The parameters.
|
|
|
|
|
/// </summary>
|
2015-02-18 16:32:22 +01:00
|
|
|
public Dictionary<string,string> Parameters = new Dictionary<string,string> ();
|
2015-02-17 13:57:39 +01:00
|
|
|
|
2015-08-14 01:43:55 +02:00
|
|
|
IEnumerable<FileInfo> Files {
|
2015-02-17 13:57:39 +01:00
|
|
|
get {
|
2015-11-22 14:00:59 +01:00
|
|
|
return UserFileSystemManager.GetFiles (Id.ToString());
|
2015-02-17 13:57:39 +01:00
|
|
|
}
|
2015-01-26 16:44:41 +01:00
|
|
|
}
|
2015-02-12 16:08:16 +01:00
|
|
|
/// <summary>
|
2015-02-18 13:32:25 +01:00
|
|
|
/// Initializes a new instance of the <see cref="Yavsc.Model.FrontOffice.Command"/> class.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public Command()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Froms the post.
|
2015-02-12 16:08:16 +01:00
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="collection">Collection.</param>
|
2015-02-17 13:57:39 +01:00
|
|
|
/// <param name="files">Files.</param>
|
2015-02-18 13:32:25 +01:00
|
|
|
public void FromPost(NameValueCollection collection, NameObjectCollectionBase files)
|
2014-10-06 04:58:47 +02:00
|
|
|
{
|
2015-01-26 16:44:41 +01:00
|
|
|
// string catref=collection["catref"]; // Catalog Url from which formdata has been built
|
2015-02-17 13:57:39 +01:00
|
|
|
ProductRef=collection["ref"]; // Required product reference
|
|
|
|
|
CreationDate = DateTime.Now;
|
|
|
|
|
Status = CommandStatus.Inserted;
|
2015-01-28 15:04:07 +01:00
|
|
|
// stores the parameters:
|
2015-02-18 13:32:25 +01:00
|
|
|
Parameters.Clear ();
|
2015-01-28 15:04:07 +01:00
|
|
|
foreach (string key in collection.AllKeys) {
|
2015-02-17 13:57:39 +01:00
|
|
|
if (key!="ref")
|
|
|
|
|
Parameters.Add (key, collection [key]);
|
2015-01-28 15:04:07 +01:00
|
|
|
}
|
2015-11-22 14:00:59 +01:00
|
|
|
WorkFlowManager.RegisterCommand (this); // gives a value to this.Id
|
2015-02-17 13:57:39 +01:00
|
|
|
string strcmdid = Id.ToString ();
|
2015-11-22 14:00:59 +01:00
|
|
|
UserFileSystemManager.Put(Path.Combine("commandes",strcmdid),files);
|
2015-02-17 13:57:39 +01:00
|
|
|
}
|
|
|
|
|
|
2015-02-18 13:32:25 +01:00
|
|
|
/// <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);
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-06 04:58:47 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|