diff --git a/ITContentProvider/ITContentProvider.csproj b/ITContentProvider/ITContentProvider.csproj
index 67706942..8bdb3ff1 100644
--- a/ITContentProvider/ITContentProvider.csproj
+++ b/ITContentProvider/ITContentProvider.csproj
@@ -35,11 +35,13 @@
+
+
@@ -52,4 +54,7 @@
NpgsqlWorkflow
+
+
+
\ No newline at end of file
diff --git a/yavscModel/WorkFlow/NewProjectModel.cs b/ITContentProvider/Model/NewProjectModel.cs
similarity index 50%
rename from yavscModel/WorkFlow/NewProjectModel.cs
rename to ITContentProvider/Model/NewProjectModel.cs
index fa74ccf5..a777d3f9 100644
--- a/yavscModel/WorkFlow/NewProjectModel.cs
+++ b/ITContentProvider/Model/NewProjectModel.cs
@@ -2,19 +2,33 @@ using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel;
-namespace Yavsc.Model.WorkFlow
+namespace ITContentProvider.Model
{
- [Obsolete("This should be define in an IT specific module")]
+ ///
+ /// New project model.
+ ///
public class NewProjectModel
{
+ ///
+ /// Gets or sets the name.
+ ///
+ /// The name.
[DisplayName("Nom du projet")]
[Required()]
public string Name { get; set; }
+ ///
+ /// Gets or sets the manager.
+ ///
+ /// The manager.
[DisplayName("Manager du projet")]
[Required]
public string Manager { get; set; }
+ ///
+ /// Gets or sets the description.
+ ///
+ /// The description.
[DisplayName("Description du projet")]
[Required]
public string Description { get; set; }
diff --git a/SalesCatalog/SalesCatalog.csproj b/SalesCatalog/SalesCatalog.csproj
index 9f56e70e..09ed11c4 100644
--- a/SalesCatalog/SalesCatalog.csproj
+++ b/SalesCatalog/SalesCatalog.csproj
@@ -35,6 +35,7 @@
+
diff --git a/SalesCatalog/XmlImplementation/XmlCatalogProvider.cs b/SalesCatalog/XmlImplementation/XmlCatalogProvider.cs
index f65c435b..989a7c58 100644
--- a/SalesCatalog/XmlImplementation/XmlCatalogProvider.cs
+++ b/SalesCatalog/XmlImplementation/XmlCatalogProvider.cs
@@ -4,6 +4,7 @@ using System.Configuration;
using System.IO;
using System.Xml;
using Yavsc.Model.FrontOffice;
+using System.Web;
namespace SalesCatalog.XmlImplementation
{
@@ -48,6 +49,9 @@ namespace SalesCatalog.XmlImplementation
///
/// Initialize the catalog
/// using the specified name and config.
+ /// The config object contains under the key
+ /// connection the path to the Xml Catalog file
+ /// at server side.
///
/// Name.
/// Config.
@@ -56,9 +60,12 @@ namespace SalesCatalog.XmlImplementation
if (config ["connection"] == null)
throw new Exception ("the 'connection' parameter is null " +
"(it should be the absolute path to the xml catalog)");
- string basedir = AppDomain.CurrentDomain.BaseDirectory;
// config ["connection"] starts with "~/"
- fileName = Path.Combine(basedir, config ["connection"].Substring (2));
+ fileName = (string) config ["connection"];
+ if (fileName.StartsWith ("~/")) {
+ fileName = HttpContext.Current.Server.MapPath(
+ config ["connection"]);
+ }
LoadCatalog ();
}
diff --git a/WorkFlowProvider/NpgsqlContentProvider.cs b/WorkFlowProvider/NpgsqlContentProvider.cs
index c2fb3f0f..cb1e1e55 100644
--- a/WorkFlowProvider/NpgsqlContentProvider.cs
+++ b/WorkFlowProvider/NpgsqlContentProvider.cs
@@ -11,8 +11,26 @@ using Newtonsoft.Json;
namespace WorkFlowProvider
{
+ ///
+ /// Npgsql content provider.
+ ///
public class NpgsqlContentProvider: ProviderBase, IContentProvider
{
+ ///
+ /// Gets the stock status.
+ ///
+ /// The stock status.
+ /// Product reference.
+ public virtual StockStatus GetStockStatus (string productReference)
+ {
+ return StockStatus.NonExistent;
+ }
+
+ ///
+ /// Registers the command.
+ ///
+ /// The command id in db.
+ /// COM.
public long RegisterCommand (Commande com)
{
long id;
@@ -20,7 +38,7 @@ namespace WorkFlowProvider
using (NpgsqlCommand cmd = cnx.CreateCommand ()) {
cmd.CommandText =
"insert into commandes (prdref,creation,params) values (@pref,@creat,@prs) returning id";
- cmd.Parameters.Add ("@pref", com.ProdRef);
+ cmd.Parameters.Add ("@pref", com.ProductRef);
cmd.Parameters.Add ("@creat", com.CreationDate);
cmd.Parameters.Add ("@prs", JsonConvert.SerializeObject(com.Parameters));
cnx.Open ();
@@ -29,47 +47,110 @@ namespace WorkFlowProvider
}
return id;
}
-
+ ///
+ /// Gets the writting status changes.
+ ///
+ /// The writting statuses.
+ /// Wrid.
public StatusChange[] GetWrittingStatuses (long wrid)
{
throw new NotImplementedException ();
}
+ ///
+ /// Gets the estimate status changes.
+ ///
+ /// The estimate statuses.
+ /// Estid.
public StatusChange[] GetEstimateStatuses (long estid)
{
throw new NotImplementedException ();
}
+ ///
+ /// Tags the writting.
+ ///
+ /// Wrid.
+ /// Tag.
public void TagWritting (long wrid, string tag)
{
throw new NotImplementedException ();
}
- public void DropTagWritting (long wrid, string tag)
+
+ ///
+ /// Drops the writting tag .
+ ///
+ /// Wrid.
+ /// Tag.
+ public void DropWrittingTag (long wrid, string tag)
{
throw new NotImplementedException ();
}
+ ///
+ /// Sets the writting status.
+ ///
+ /// Wrtid.
+ /// Status.
+ /// Username.
public void SetWrittingStatus (long wrtid, int status, string username)
{
throw new NotImplementedException ();
}
+ ///
+ /// Sets the estimate status.
+ ///
+ /// Estid.
+ /// Status.
+ /// Username.
public void SetEstimateStatus (long estid, int status, string username)
{
throw new NotImplementedException ();
}
+ ///
+ /// Releases all resource used by the object.
+ ///
+ /// Call when you are finished using the .
+ /// The method leaves the in an unusable
+ /// state. After calling , you must release all references to the
+ /// so the garbage collector can reclaim the memory that the
+ /// was occupying.
public void Dispose ()
{
throw new NotImplementedException ();
}
+ ///
+ /// Install the model in database using the specified cnx.
+ ///
+ /// Cnx.
public void Install (System.Data.IDbConnection cnx)
{
throw new NotImplementedException ();
}
+
+ ///
+ /// Uninstall the module data and data model from
+ /// database, using the specified connection.
+ ///
+ /// Cnx.
+ /// If set to true remove config.
public void Uninstall (System.Data.IDbConnection cnx, bool removeConfig)
{
throw new NotImplementedException ();
}
+
+ ///
+ /// Defaults the config.
+ ///
+ /// The config.
+ /// App name.
+ /// Cnx string.
public ConfigurationSection DefaultConfig (string appName, string cnxStr)
{
throw new NotImplementedException ();
}
+
+ ///
+ /// Gets or sets a value indicating whether this is active.
+ ///
+ /// true if active; otherwise, false.
public bool Active {
get {
throw new NotImplementedException ();
@@ -79,16 +160,33 @@ namespace WorkFlowProvider
}
}
+ ///
+ /// Gets the different status labels.
+ /// 0 is the starting status. Each status is an integer and the 0-based index
+ /// of a string in this array.
+ ///
+ /// The status labels.
public string[] Statuses {
get {
return new string[] { "Created", "Validated", "Success", "Error" };
}
}
+
+ ///
+ /// Gets the final statuses.
+ ///
+ /// The final statuses.
public bool[] FinalStatuses {
get {
return new bool[] { false, false, true, true };
}
}
+
+ ///
+ /// Gets the estimates created for a specified client.
+ ///
+ /// The estimates.
+ /// Client.
public Estimate[] GetEstimates (string client)
{
using (NpgsqlConnection cnx = CreateConnection ()) {
@@ -108,6 +206,10 @@ namespace WorkFlowProvider
}
}
+ ///
+ /// Drops the writting.
+ ///
+ /// Wrid.
public void DropWritting (long wrid)
{
@@ -123,6 +225,10 @@ namespace WorkFlowProvider
}
}
+ ///
+ /// Drops the estimate.
+ ///
+ /// Estid.
public void DropEstimate (long estid)
{
using (NpgsqlConnection cnx = CreateConnection ()) {
@@ -137,6 +243,11 @@ namespace WorkFlowProvider
}
}
+ ///
+ /// Gets the estimate by identifier.
+ ///
+ /// The estimate.
+ /// Estimid.
public Estimate GetEstimate (long estimid)
{
using (NpgsqlConnection cnx = CreateConnection ()) {
@@ -198,7 +309,10 @@ namespace WorkFlowProvider
}
}
-
+ ///
+ /// Updates the writting.
+ ///
+ /// Wr.
public void UpdateWritting (Writting wr)
{
using (NpgsqlConnection cnx = CreateConnection ()) {
@@ -222,6 +336,10 @@ namespace WorkFlowProvider
}
}
+ ///
+ /// Saves the given Estimate object in database.
+ ///
+ /// the Estimate object.
public void UpdateEstimate (Estimate estim)
{
using (NpgsqlConnection cnx = CreateConnection ()) {
@@ -241,6 +359,15 @@ namespace WorkFlowProvider
}
}
+ ///
+ /// Add a line to the specified estimate by id,
+ /// using the specified desc, ucost, count and productid.
+ ///
+ /// Estimate identifier.
+ /// Textual description for this line.
+ /// Unitary cost.
+ /// Cost multiplier.
+ /// Product identifier.
public long Write (long estid, string desc, decimal ucost, int count, string productid)
{
using (NpgsqlConnection cnx = CreateConnection ()) {
@@ -262,6 +389,11 @@ namespace WorkFlowProvider
}
}
+ ///
+ /// Sets the desc.
+ ///
+ /// Writid.
+ /// New desc.
public void SetDesc (long writid, string newDesc)
{
using (NpgsqlConnection cnx = CreateConnection ()) {
@@ -277,7 +409,14 @@ namespace WorkFlowProvider
}
}
-
+ ///
+ /// Creates the estimate.
+ ///
+ /// The estimate.
+ /// Client.
+ /// Title.
+ /// Responsible.
+ /// Description.
public Estimate CreateEstimate (string responsible, string client, string title, string description)
{
using (NpgsqlConnection cnx = CreateConnection ()) {
@@ -304,7 +443,10 @@ namespace WorkFlowProvider
}
string applicationName=null;
-
+ ///
+ /// Gets or sets the name of the application.
+ ///
+ /// The name of the application.
public string ApplicationName {
get {
return applicationName;
@@ -315,7 +457,11 @@ namespace WorkFlowProvider
}
string cnxstr = null;
-
+ ///
+ /// Initialize this object using the specified name and config.
+ ///
+ /// Name.
+ /// Config.
public override void Initialize (string name, NameValueCollection config)
{
if ( string.IsNullOrWhiteSpace(config ["connectionStringName"]))
@@ -328,6 +474,10 @@ namespace WorkFlowProvider
}
+ ///
+ /// Creates the connection.
+ ///
+ /// The connection.
protected NpgsqlConnection CreateConnection ()
{
return new NpgsqlConnection (cnxstr);
diff --git a/web/Controllers/BasketController.cs b/web/Controllers/BasketController.cs
index 0dff26a7..325d51e5 100644
--- a/web/Controllers/BasketController.cs
+++ b/web/Controllers/BasketController.cs
@@ -7,6 +7,7 @@ using System.Web.Http;
using Yavsc.Model.WorkFlow;
using System.Collections.Specialized;
using Yavsc.Model.FrontOffice;
+using System.Web.SessionState;
namespace Yavsc.ApiControllers
{
@@ -32,23 +33,40 @@ namespace Yavsc.ApiControllers
wfmgr = new WorkFlowManager ();
}
+ ///
+ /// Gets the current basket, creates a new one, if it doesn't exist.
+ ///
+ /// The current basket.
+ protected Basket CurrentBasket {
+ get {
+ HttpSessionState session = HttpContext.Current.Session;
+ Basket b = (Basket) session ["Basket"];
+ if (b == null)
+ session ["Basket"] = b = new Basket ();
+ return b;
+ }
+ }
+
///
/// Create the specified basket item using specified command parameters.
///
/// Command parameters.
- [AcceptVerbs("CREATE")]
+ [Authorize]
public long Create(NameValueCollection cmdParams)
{
- throw new NotImplementedException ();
+ // HttpContext.Current.Request.Files
+ Commande cmd = new Commande(cmdParams, HttpContext.Current.Request.Files);
+ CurrentBasket.Add (cmd);
+ return cmd.Id;
}
///
/// Read the specified basket item.
///
/// Itemid.
- [AcceptVerbs("READ")]
+ [Authorize]
Commande Read(long itemid){
- throw new NotImplementedException ();
+ return CurrentBasket[itemid];
}
///
@@ -57,29 +75,21 @@ namespace Yavsc.ApiControllers
/// Item identifier.
/// Parameter name.
/// Value.
- [AcceptVerbs("UPDATE")]
- public void Update(long itemid, string param, string value)
+ [Authorize]
+ public void UpdateParam(long itemid, string param, string value)
{
- throw new NotImplementedException ();
+ CurrentBasket [itemid].Parameters [param] = value;
}
///
/// Delete the specified item.
///
/// Item identifier.
+ [Authorize]
public void Delete(long itemid)
{
- throw new NotImplementedException ();
+ CurrentBasket.Remove (itemid);
}
- ///
- /// Post a file, as attached document to the specified
- /// Item
- ///
- [AcceptVerbs("POST")]
- public void Post(long itemId)
- {
- throw new NotImplementedException ();
- }
}
}
\ No newline at end of file
diff --git a/web/Controllers/FileSystemController.cs b/web/Controllers/FileSystemController.cs
index 5318db27..434de7b4 100644
--- a/web/Controllers/FileSystemController.cs
+++ b/web/Controllers/FileSystemController.cs
@@ -6,6 +6,7 @@ using System.Web.Mvc;
using System.IO;
using System.Web.Security;
using System.Text.RegularExpressions;
+using Yavsc.Model.FileSystem;
namespace Yavsc.Controllers
{
@@ -14,34 +15,37 @@ namespace Yavsc.Controllers
///
public class FileSystemController : Controller
{
- private static string usersDir = "~/users";
+ private string usersDir = "~/users";
///
- /// Gets the users dir.
+ /// Gets the users base directory.
///
/// The users dir.
- public static string UsersDir {
+ public string UsersDir {
get {
return usersDir;
}
}
+ FileSystemManager mgr = null ;
+
+ ///
+ /// Initialize the specified requestContext.
+ ///
+ /// Request context.
+ protected override void Initialize (System.Web.Routing.RequestContext requestContext)
+ {
+ base.Initialize (requestContext);
+ mgr = new FileSystemManager (UsersDir);
+ }
+
///
/// Index this instance.
///
[Authorize]
- public ActionResult Index ()
+ public ActionResult Index (string id)
{
- string user = Membership.GetUser ().UserName;
- ViewData ["UserName"] = user;
-
- DirectoryInfo di = new DirectoryInfo (
- Path.Combine (
- Server.MapPath (UsersDir),
- user));
- if (!di.Exists)
- di.Create ();
- return View (new FileInfoCollection (di.GetFiles ()));
+ return View (mgr.GetFiles (Membership.GetUser().UserName+"/"+id));
}
///
@@ -59,7 +63,7 @@ namespace Yavsc.Controllers
return RedirectToAction ("Index");
}
}
- string fpath = Path.Combine (BaseDir, id);
+ string fpath = Path.Combine (UserBaseDir, id);
ViewData ["Content"] = Url.Content (fpath);
FileInfo fi = new FileInfo (fpath);
@@ -67,54 +71,23 @@ namespace Yavsc.Controllers
}
///
- /// Create this instance.
- ///
- public ActionResult Create ()
- {
- return View ();
- }
-
- ///
- /// Create the specified collection.
+ /// Create the specified id.
///
- /// Collection.
+ /// Identifier.
[HttpPost]
[Authorize]
- public ActionResult Create (FormCollection collection)
+ public ActionResult Create (string id)
{
- try {
- string fnre = "[A-Za-z0-9~\\-.]+";
- HttpFileCollectionBase hfc = Request.Files;
-
- for (int i = 0; i < hfc.Count; i++) {
- if (!Regex.Match (hfc [i].FileName, fnre).Success) {
- ViewData ["Message"] += string.Format ("File name '{0}' refused
", hfc [i].FileName);
- ModelState.AddModelError (
- "AFile",
- string.Format (
- "The file name {0} dosn't match an acceptable file name {1}",
- hfc [i].FileName, fnre));
- return View ();
- }
- }
- for (int i = 0; i < hfc.Count; i++) {
- // TODO Limit with hfc[h].ContentLength
- string filename = Path.Combine (Server.MapPath (BaseDir), hfc [i].FileName);
- hfc [i].SaveAs (filename);
- ViewData ["Message"] += string.Format ("File name '{0}' saved
", hfc [i].FileName);
- }
- return RedirectToAction ("Index", "FileSystem");
- } catch (Exception e) {
- ViewData ["Message"] = "Exception:" + e.Message;
- return View ();
- }
+ string path=Membership.GetUser().UserName+"/"+id;
+ mgr.Put ( path, Request.Files);
+ return View ("Index",mgr.GetFiles(path));
}
///
- /// Gets the base dir.
+ /// Gets the user's base dir.
///
/// The base dir.
- public static string BaseDir { get { return Path.Combine (UsersDir, Membership.GetUser ().UserName); } }
+ public string UserBaseDir { get { return Path.Combine (UsersDir, Membership.GetUser ().UserName); } }
///
/// Edit the specified id.
@@ -122,7 +95,7 @@ namespace Yavsc.Controllers
/// Identifier.
public ActionResult Edit (int id)
{
- return View ();
+ throw new NotImplementedException ();
}
///
@@ -133,11 +106,7 @@ namespace Yavsc.Controllers
[HttpPost]
public ActionResult Edit (int id, FormCollection collection)
{
- try {
- return RedirectToAction ("Index");
- } catch {
- return View ();
- }
+ throw new NotImplementedException ();
}
///
@@ -146,7 +115,7 @@ namespace Yavsc.Controllers
/// Identifier.
public ActionResult Delete (int id)
{
- return View ();
+ throw new NotImplementedException ();
}
///
@@ -157,11 +126,7 @@ namespace Yavsc.Controllers
[HttpPost]
public ActionResult Delete (int id, FormCollection collection)
{
- try {
- return RedirectToAction ("Index");
- } catch {
- return View ();
- }
+ throw new NotImplementedException ();
}
}
}
\ No newline at end of file
diff --git a/web/Controllers/FrontOfficeController.cs b/web/Controllers/FrontOfficeController.cs
index 5755b7bb..8cc9d33d 100644
--- a/web/Controllers/FrontOfficeController.cs
+++ b/web/Controllers/FrontOfficeController.cs
@@ -12,6 +12,7 @@ using WorkFlowProvider;
using System.Web.Security;
using System.Threading;
using Yavsc.Model.FrontOffice;
+using Yavsc.Model.FileSystem;
namespace Yavsc.Controllers
{
@@ -218,12 +219,14 @@ namespace Yavsc.Controllers
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 (FileSystemController.BaseDir, hfc [h].FileName));
+ hfc [h].SaveAs (Path.Combine (usersdir, hfc [h].FileName));
}
// Add specified product command to the basket,
- GetBasket().Add (Commande.Create (collection));
+ GetBasket().Add (new Commande(collection,HttpContext.Request.Files));
ViewData ["Message"] = LocalizedText.Item_added_to_basket;
return View (collection);
} catch (Exception e) {
diff --git a/web/Global.asax.cs b/web/Global.asax.cs
index 8fd9f0f1..eed3c48b 100644
--- a/web/Global.asax.cs
+++ b/web/Global.asax.cs
@@ -9,9 +9,11 @@ using System.Web.Routing;
using Yavsc.Formatters;
using Yavsc.Model.FrontOffice;
using System.Web.Http;
+using System.Web.SessionState;
namespace Yavsc
{
+
///
/// Mvc application.
///
@@ -28,6 +30,9 @@ namespace Yavsc
routes.IgnoreRoute ("Scripts/{*pathInfo}");
routes.IgnoreRoute ("Theme/{*pathInfo}");
routes.IgnoreRoute ("images/{*pathInfo}");
+ routes.IgnoreRoute ("users/{*pathInfo}");
+ routes.IgnoreRoute ("files/{*pathInfo}");
+ routes.IgnoreRoute ("avatars/{*pathInfo}");
routes.IgnoreRoute ("xmldoc/{*pathInfo}"); // xml doc
routes.IgnoreRoute ("htmldoc/{*pathInfo}"); // html doc
routes.IgnoreRoute ("favicon.ico");
@@ -56,13 +61,25 @@ namespace Yavsc
protected void Application_Start ()
{
AreaRegistration.RegisterAllAreas ();
- GlobalConfiguration.Configuration.Routes.MapHttpRoute(
- name: "DefaultApi",
- routeTemplate: "api/{controller}/{action}/{*id}",
- defaults: new { controller = "WorkFlow", action="Index", id=0 }
- );
-
+ WebApiConfig.Register (GlobalConfiguration.Configuration);
RegisterRoutes (RouteTable.Routes);
}
+
+ ///
+ /// Applications the post authorize request.
+ ///
+ protected void Application_PostAuthorizeRequest()
+ {
+ if (IsWebApiRequest())
+ {
+ HttpContext.Current.SetSessionStateBehavior(SessionStateBehavior.Required);
+ }
+ }
+
+ private bool IsWebApiRequest()
+ {
+ return HttpContext.Current.Request.AppRelativeCurrentExecutionFilePath.StartsWith(WebApiConfig.UrlPrefixRelative);
+ }
+
}
}
diff --git a/web/Models/App.master b/web/Models/App.master
index 7c5db7f0..71e73312 100644
--- a/web/Models/App.master
+++ b/web/Models/App.master
@@ -73,6 +73,9 @@
<%= link %>
<% } %>
+