From 2a1301d93c90f7c9b7bb0e1343c514e7c55649cc Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Wed, 23 Dec 2015 13:14:50 +0100 Subject: [PATCH] Un bouton "Demander un devis" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * INominative.cs: Interface d'un objet destiné à un préstataire spécifié, par une propriété `PerformerName` * NominativeSimpleBookingQuery.cs: implémente l'interface INominative * packages.config: * packages.config: * packages.config: * ITContentProvider.csproj: * NpgsqlBlogProvider.csproj: * NpgsqlContentProvider.csproj: mise à niveau Npgsql * NpgsqlContentProvider.cs: stocke la classe de commande * AccountController.cs: implémente la methode de login de l'API * BasketController.cs: implémente la methode de recupération du panier * AccountController.cs: enléve un commaentaire obsolète * YavscHelpers.cs: * FrontOfficeController.cs: refabrication de l'ajout au panier * yavsc.user.js: enlève un message de debuggage js * Performer.ascx: formattage * Performers.aspx: implémente le bouton de demande de reservation * Yavsc.csproj: validate unobtrusive * packages.config: référence M$ Owin * UserFileSystemManager.cs: Fixe: Ne pas créer un dossier de destination si on a aucun fichier à recevoir. * Commande.cs: * Ajoute le nom du client dans l'objet commande * Factorise le positionnement des paramêtres * La commande est une instance du type spécifié à la commande, dans son paramêtre `type` * SimpleBookingQuery.cs: refabrication * LocalizedText.resx: * LocalizedText.fr.resx: traducations * UserNameBase.cs: implemente l'interface `IUserName` * IContentProvider.cs: doc xml * YavscModel.csproj: reference le nouveau code source * Web.config: retour à une version d'équère * IUserName.cs: Définit l'interface d'un objet associé à un utilisateur. --- ITContentProvider/ChangeLog | 5 ++ ITContentProvider/ITContentProvider.csproj | 2 +- ITContentProvider/packages.config | 2 +- NpgsqlBlogProvider/ChangeLog | 5 ++ NpgsqlBlogProvider/NpgsqlBlogProvider.csproj | 2 +- NpgsqlBlogProvider/packages.config | 2 +- NpgsqlContentProvider/ChangeLog | 7 ++ .../NpgsqlContentProvider.cs | 25 ++++--- .../NpgsqlContentProvider.csproj | 2 +- NpgsqlContentProvider/packages.config | 2 +- web/ApiControllers/AccountController.cs | 10 +++ web/ApiControllers/BasketController.cs | 20 ++--- web/ChangeLog | 26 +++++++ web/Controllers/AccountController.cs | 1 - web/Controllers/FrontOfficeController.cs | 21 ++++-- web/Helpers/YavscHelpers.cs | 40 +++++++++- web/Scripts/yavsc.user.js | 1 - web/Views/FrontOffice/Performer.ascx | 2 + web/Views/FrontOffice/Performers.aspx | 15 ++++ web/Web.config | 21 +++--- web/Yavsc.csproj | 22 +++--- web/packages.config | 10 +-- yavscModel/ChangeLog | 33 ++++++++ .../FileSystem/UserFileSystemManager.cs | 2 + yavscModel/FrontOffice/Commande.cs | 75 +++++++++++++++---- yavscModel/FrontOffice/INominative.cs | 35 +++++++++ .../NominativeSimpleBookingQuery.cs | 49 ++++++++++++ yavscModel/FrontOffice/SimpleBookingQuery.cs | 2 + yavscModel/LocalizedText.fr.resx | 4 +- yavscModel/LocalizedText.resx | 1 + yavscModel/RolesAndMembers/IUserName.cs | 32 ++++++++ yavscModel/RolesAndMembers/UserNameBase.cs | 2 +- yavscModel/WorkFlow/IContentProvider.cs | 5 ++ yavscModel/YavscModel.csproj | 3 + 34 files changed, 409 insertions(+), 77 deletions(-) create mode 100644 yavscModel/FrontOffice/INominative.cs create mode 100644 yavscModel/FrontOffice/NominativeSimpleBookingQuery.cs create mode 100644 yavscModel/RolesAndMembers/IUserName.cs diff --git a/ITContentProvider/ChangeLog b/ITContentProvider/ChangeLog index 2274b1d1..fed632a5 100644 --- a/ITContentProvider/ChangeLog +++ b/ITContentProvider/ChangeLog @@ -1,3 +1,8 @@ +2015-12-23 Paul Schneider + + * packages.config: + * ITContentProvider.csproj: mise à niveau Npgsql + 2015-11-30 Paul Schneider * ITContentProvider.csproj: ... diff --git a/ITContentProvider/ITContentProvider.csproj b/ITContentProvider/ITContentProvider.csproj index 576bb965..0331a557 100644 --- a/ITContentProvider/ITContentProvider.csproj +++ b/ITContentProvider/ITContentProvider.csproj @@ -65,7 +65,7 @@ - ..\packages\Npgsql.3.0.3\lib\net45\Npgsql.dll + ..\packages\Npgsql.3.0.4\lib\net45\Npgsql.dll diff --git a/ITContentProvider/packages.config b/ITContentProvider/packages.config index ba123222..7dcb0d3b 100644 --- a/ITContentProvider/packages.config +++ b/ITContentProvider/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/NpgsqlBlogProvider/ChangeLog b/NpgsqlBlogProvider/ChangeLog index 7d853bcc..ea24c6b4 100644 --- a/NpgsqlBlogProvider/ChangeLog +++ b/NpgsqlBlogProvider/ChangeLog @@ -1,3 +1,8 @@ +2015-12-23 Paul Schneider + + * packages.config: + * NpgsqlBlogProvider.csproj: mise à niveau Npgsql + 2015-12-09 Paul Schneider * NpgsqlBlogProvider.cs: Corrige la méthode pour enlever un diff --git a/NpgsqlBlogProvider/NpgsqlBlogProvider.csproj b/NpgsqlBlogProvider/NpgsqlBlogProvider.csproj index 07a3013f..c0a8f111 100644 --- a/NpgsqlBlogProvider/NpgsqlBlogProvider.csproj +++ b/NpgsqlBlogProvider/NpgsqlBlogProvider.csproj @@ -69,7 +69,7 @@ - ..\packages\Npgsql.3.0.3\lib\net45\Npgsql.dll + ..\packages\Npgsql.3.0.4\lib\net45\Npgsql.dll diff --git a/NpgsqlBlogProvider/packages.config b/NpgsqlBlogProvider/packages.config index ba123222..8ed80a18 100644 --- a/NpgsqlBlogProvider/packages.config +++ b/NpgsqlBlogProvider/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/NpgsqlContentProvider/ChangeLog b/NpgsqlContentProvider/ChangeLog index ba774c8f..ca840c3d 100644 --- a/NpgsqlContentProvider/ChangeLog +++ b/NpgsqlContentProvider/ChangeLog @@ -1,3 +1,10 @@ +2015-12-23 Paul Schneider + + * NpgsqlContentProvider.cs: stocke la classe de commande + + * packages.config: + * NpgsqlContentProvider.csproj: mise à niveau Npgsql + 2015-12-15 Paul Schneider * NpgsqlContentProvider.cs: bug fix diff --git a/NpgsqlContentProvider/NpgsqlContentProvider.cs b/NpgsqlContentProvider/NpgsqlContentProvider.cs index af10e4e8..98720446 100644 --- a/NpgsqlContentProvider/NpgsqlContentProvider.cs +++ b/NpgsqlContentProvider/NpgsqlContentProvider.cs @@ -178,12 +178,15 @@ namespace Yavsc using (NpgsqlConnection cnx = CreateConnection ()) { using (NpgsqlCommand cmd = cnx.CreateCommand ()) { cmd.CommandText = - "insert into commandes (prdref,creation,params,clientname,applicationname) values (@pref,@creat,@prms,@cli,@app) returning id"; - cmd.Parameters.AddWithValue ("@pref", com.ProductRef); - cmd.Parameters.AddWithValue ("@creat", com.CreationDate); - cmd.Parameters.AddWithValue ("@prms", JsonConvert.SerializeObject (com.Parameters)); - cmd.Parameters.AddWithValue ("@cli", Membership.GetUser ().UserName); - cmd.Parameters.AddWithValue ("@app", ApplicationName); + "insert into commandes (prdref,creation,params,class,clientname,applicationname) values (:pref,:creat,:prms,:cls,:cli,:app) returning id"; + cmd.Parameters.AddWithValue ("pref", com.ProductRef); + cmd.Parameters.AddWithValue ("creat", com.CreationDate); + cmd.Parameters.AddWithValue ("prms", NpgsqlTypes.NpgsqlDbType.Jsonb, + JsonConvert.SerializeObject( + com.Parameters)); + cmd.Parameters.AddWithValue ("cls", com.GetType().FullName); + cmd.Parameters.AddWithValue ("cli", com.ClientName); + cmd.Parameters.AddWithValue ("app", ApplicationName); cnx.Open (); com.Id = id = (long)cmd.ExecuteScalar (); } @@ -209,7 +212,7 @@ namespace Yavsc using (NpgsqlConnection cnx = CreateConnection ()) { using (NpgsqlCommand cmd = cnx.CreateCommand ()) { cmd.CommandText = - "select id,creation,prdref,params,class from commandes where @user = clientname and applicationname = @app"; + "select id,creation,prdref,params::TEXT,class from commandes where @user = clientname and applicationname = @app"; cmd.Parameters.AddWithValue ("@user", username); cmd.Parameters.AddWithValue ("@app", this.ApplicationName); cnx.Open (); @@ -220,10 +223,10 @@ namespace Yavsc ycmd.Id = rdr.GetInt64 (0); ycmd.CreationDate = rdr.GetDateTime (1); ycmd.ProductRef = rdr.GetString (2); - - object prms = JsonConvert.DeserializeObject> (rdr.GetString (3)); - ycmd.Parameters = prms as Dictionary; - + ycmd.ClientName = username; + var prms = rdr.GetString (3); + var obj = JsonConvert.DeserializeObject> (prms); + ycmd.SetParameters(obj as Dictionary); cmds.Add (ycmd); } } diff --git a/NpgsqlContentProvider/NpgsqlContentProvider.csproj b/NpgsqlContentProvider/NpgsqlContentProvider.csproj index 43f4ad3a..dce04340 100644 --- a/NpgsqlContentProvider/NpgsqlContentProvider.csproj +++ b/NpgsqlContentProvider/NpgsqlContentProvider.csproj @@ -66,7 +66,7 @@ - ..\packages\Npgsql.3.0.3\lib\net45\Npgsql.dll + ..\packages\Npgsql.3.0.4\lib\net45\Npgsql.dll diff --git a/NpgsqlContentProvider/packages.config b/NpgsqlContentProvider/packages.config index ba123222..7dcb0d3b 100644 --- a/NpgsqlContentProvider/packages.config +++ b/NpgsqlContentProvider/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/web/ApiControllers/AccountController.cs b/web/ApiControllers/AccountController.cs index f794bec6..a0d50d7f 100644 --- a/web/ApiControllers/AccountController.cs +++ b/web/ApiControllers/AccountController.cs @@ -107,6 +107,16 @@ namespace Yavsc.ApiControllers } } + [ValidateAjax] + public void Login(LoginModel model) + { + if (ModelState.IsValid) { + if (Membership.ValidateUser (model.UserName, model.Password)) { + FormsAuthentication.SetAuthCookie (model.UserName, model.RememberMe); + } + } + } + /// /// Adds the user to role. /// diff --git a/web/ApiControllers/BasketController.cs b/web/ApiControllers/BasketController.cs index b70dfb8e..bf70c086 100644 --- a/web/ApiControllers/BasketController.cs +++ b/web/ApiControllers/BasketController.cs @@ -7,6 +7,7 @@ using System.Web.Http; using Yavsc.Model.WorkFlow; using System.Collections.Specialized; using Yavsc.Model.FrontOffice; +using Yavsc.Helpers; namespace Yavsc.ApiControllers { @@ -15,6 +16,7 @@ namespace Yavsc.ApiControllers /// Maintains a collection of articles /// qualified with name value pairs /// + [Authorize] public class BasketController : ApiController { @@ -30,25 +32,25 @@ namespace Yavsc.ApiControllers return b; } } + /// + /// Get the basket. + /// + public CommandSet Get() { + return CurrentBasket; + } /// /// Create the specified basket item using specified command parameters. /// - /// Command parameters. - [Authorize] - public long Create(NameValueCollection cmdParams) + public long Create() { - // HttpContext.Current.Request.Files - Command cmd = Command.CreateCommand(cmdParams, HttpContext.Current.Request.Files); - CurrentBasket.Add (cmd); - return cmd.Id; + return YavscHelpers.CreateCommandFromRequest (); } /// /// Read the specified basket item. /// /// Itemid. - [Authorize] Command Read(long itemid){ return CurrentBasket[itemid]; } @@ -59,7 +61,6 @@ namespace Yavsc.ApiControllers /// Item identifier. /// Parameter name. /// Value. - [Authorize] public void UpdateParam(long itemid, string param, string value) { CurrentBasket [itemid].Parameters [param] = value; @@ -69,7 +70,6 @@ namespace Yavsc.ApiControllers /// Delete the specified item. /// /// Item identifier. - [Authorize] public void Delete(long itemid) { CurrentBasket.Remove (itemid); diff --git a/web/ChangeLog b/web/ChangeLog index d5ce7d65..d452e0b3 100644 --- a/web/ChangeLog +++ b/web/ChangeLog @@ -1,3 +1,29 @@ +2015-12-23 Paul Schneider + + * AccountController.cs: implémente la methode de login de + l'API + + * BasketController.cs: implémente la methode de recupération + du panier + + * AccountController.cs: enléve un commaentaire obsolète + + * YavscHelpers.cs: + * FrontOfficeController.cs: refabrication de l'ajout au panier + + * yavsc.user.js: enlève un message de debuggage js + + * Performer.ascx: formattage + + * Performers.aspx: implémente le bouton de demande de + reservation + + * Yavsc.csproj: validate unobtrusive + + * packages.config: référence M$ Owin + + * Web.config: retour à une version d'équère + 2015-12-16 Paul Schneider * input.css: diff --git a/web/Controllers/AccountController.cs b/web/Controllers/AccountController.cs index 8a130c59..ff417245 100644 --- a/web/Controllers/AccountController.cs +++ b/web/Controllers/AccountController.cs @@ -56,7 +56,6 @@ namespace Yavsc.Controllers return View (); } - // TODO [ValidateAntiForgeryToken] /// /// Does login. /// diff --git a/web/Controllers/FrontOfficeController.cs b/web/Controllers/FrontOfficeController.cs index edf010c4..579f8be0 100644 --- a/web/Controllers/FrontOfficeController.cs +++ b/web/Controllers/FrontOfficeController.cs @@ -40,6 +40,11 @@ namespace Yavsc.Controllers return View (); } + public ActionResult AskForAnEstimate() + { + return View(); + } + /// /// Pub the Event /// @@ -251,11 +256,13 @@ namespace Yavsc.Controllers // * instanciate the given command type, passing it the form data // * Make the workflow register this command // * Render the resulting basket - var cmd = Command.CreateCommand (collection, HttpContext.Request.Files); - ViewData["Commanded"] = cmd; + + long cmdid = YavscHelpers.CreateCommandFromRequest (); + var basket = WorkFlowManager.GetCommands (User.Identity.Name); + ViewData["Commanded"] = basket[cmdid]; YavscHelpers.Notify (ViewData, LocalizedText.Item_added_to_basket); - return View ("Basket",WorkFlowManager.GetCommands (User.Identity.Name)); + return View ("Basket",basket); } catch (Exception e) { YavscHelpers.Notify (ViewData, "Exception:" + e.Message); return View (collection); @@ -263,7 +270,7 @@ namespace Yavsc.Controllers } /// - /// Booking the specified model. + /// Book the specified model. /// /// Model. public ActionResult EavyBooking (BookingQuery model) @@ -295,7 +302,7 @@ namespace Yavsc.Controllers /// /// Performers on this MEA. - /// fr + /// [fr] /// Liste des prestataires dont /// l'activité principale est celle spécifiée /// @@ -450,6 +457,10 @@ namespace Yavsc.Controllers } else result.Add (profile.CreateAvailability (model.PreferedDate, false)); ViewData["Circles"] = CircleManager.ListAvailableCircles(); + ViewBag.SimpleBookingQuery = model; + ViewBag.ClientName = User.Identity.IsAuthenticated ? + User.Identity.Name : User.Identity.Name; + return View ("Performers", result.ToArray ()); } if (model.Need==null) { diff --git a/web/Helpers/YavscHelpers.cs b/web/Helpers/YavscHelpers.cs index 2fc3c620..973c9b0a 100644 --- a/web/Helpers/YavscHelpers.cs +++ b/web/Helpers/YavscHelpers.cs @@ -19,6 +19,7 @@ using Yavsc.Model.Messaging; using System.Linq; using System.Reflection; using System.Web.Routing; +using Yavsc.Model.FrontOffice; namespace Yavsc.Helpers { @@ -28,7 +29,44 @@ namespace Yavsc.Helpers /// public static class YavscHelpers { - + /* {"Need": "11 21,10 14", "MEACode": "6829C", "AUTH_USER": "Paul Schneider", "REMOTE_ADDR": "127.0.0.1", + * "REMOTE_PORT": "43376", "REMOTE_USER": "", "PreferedDate": "22/12/2015 00:00:00", + * "PerformerName": "Paul Schneider"} */ + public static string[] FilteredKeys = { + "URL", "HTTPS", "ALL_RAW", "ALL_HTTP", "ALL_RAW", "HTTP_DNT", "PATH_INFO", + ".ASPXFORM$", "CERT_FLAGS", "LOCAL_ADDR", + "LOGON_USER", "CERT_COOKIE", "CERT_ISSUER", "HTTP_ACCEPT", "HTTP_COOKIE", "INSTANCE_ID", + // "REMOTE_ADDR", + "REMOTE_HOST", + "REMOTE_PORT", + "REMOTE_USER", + "SCRIPT_NAME", "SERVER_NAME", "SERVER_PORT", "APPL_MD_PATH", "CERT_KEYSIZE", + "CERT_SUBJECT", "CONTENT_TYPE", "HTTP_REFERER", + "AUTH_PASSWORD", "HTTPS_KEYSIZE", ".ASPXANONYMOUS", "CONTENT_LENGTH", + "REQUEST_METHOD", "HTTP_CONNECTION", "HTTP_USER_AGENT", "PATH_TRANSLATED", + "SERVER_PROTOCOL", "HTTP_ACCEPT_LANGUAGE", "AUTH_TYPE", + // "AUTH_USER", + "HTTP_HOST", "QUERY_STRING", "SERVER_SOFTWARE", "ASP.NET_SessionId", + "CERT_SERIALNUMBER", "GATEWAY_INTERFACE", "HTTP_CONTENT_TYPE", + "APPL_PHYSICAL_PATH", "CERT_SECRETKEYSIZE", "CERT_SERVER_ISSUER", + "INSTANCE_META_PATH", "SERVER_PORT_SECURE", + "CERT_SERVER_SUBJECT", "HTTPS_SECRETKEYSIZE", "HTTPS_SERVER_ISSUER", + "HTTP_CONTENT_LENGTH", "HTTPS_SERVER_SUBJECT", "HTTP_ACCEPT_ENCODING", "HTTP_ACCEPT_LANGUAGE" + }; + public static long CreateCommandFromRequest() + { + var keys = HttpContext.Current.Request.Params.AllKeys.Where ( + x => !YavscHelpers.FilteredKeys.Contains (x)).ToArray(); + var prms = new Dictionary (); + + foreach (var key in keys) { + prms.Add (key, HttpContext.Current.Request.Params [key]); + } + Command cmd = Command.CreateCommand( + prms, + HttpContext.Current.Request.Files); + return cmd.Id; + } private static string siteName = null; /// diff --git a/web/Scripts/yavsc.user.js b/web/Scripts/yavsc.user.js index f9ee67a4..f8f94256 100644 --- a/web/Scripts/yavsc.user.js +++ b/web/Scripts/yavsc.user.js @@ -19,7 +19,6 @@ var roles = $this.data('roles'); var bcounter = $this.data('blog-counter'); var circlesspec = $this.data('circles'); - console.log('here'); if (bcounter) if (bcounter>0) { _this.buttonBlog = $(''); diff --git a/web/Views/FrontOffice/Performer.ascx b/web/Views/FrontOffice/Performer.ascx index 49f5cceb..c0aa20dc 100644 --- a/web/Views/FrontOffice/Performer.ascx +++ b/web/Views/FrontOffice/Performer.ascx @@ -1,4 +1,6 @@ <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %> + +

diff --git a/web/Views/FrontOffice/Performers.aspx b/web/Views/FrontOffice/Performers.aspx index d7ebf6ed..a000f20e 100644 --- a/web/Views/FrontOffice/Performers.aspx +++ b/web/Views/FrontOffice/Performers.aspx @@ -1,7 +1,9 @@ <%@ Page Language="C#" Title="Performers" MasterPageFile="~/Models/App.master" Inherits="System.Web.Mvc.ViewPage>" %> + + @@ -18,6 +20,19 @@ <% } else {%> <%= Html.Translate("ThisPerformerDoesntGiveAccessToHisCalendar") %> <% } %> + +
+
+ + + + + + + +"> +
+

<% } %> diff --git a/web/Web.config b/web/Web.config index 3bf37066..d6c86d9a 100644 --- a/web/Web.config +++ b/web/Web.config @@ -221,7 +221,7 @@ http://msdn2.microsoft.com/en-us/library/b5ysx397.aspx - + @@ -244,9 +244,9 @@ http://msdn2.microsoft.com/en-us/library/b5ysx397.aspx - + - + @@ -265,22 +265,21 @@ http://msdn2.microsoft.com/en-us/library/b5ysx397.aspx - + - - - - + + + - - - + + + diff --git a/web/Yavsc.csproj b/web/Yavsc.csproj index fa7942a4..35ab2754 100644 --- a/web/Yavsc.csproj +++ b/web/Yavsc.csproj @@ -95,9 +95,6 @@ ..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll - - ..\packages\PayPalButtonManagerSDK.2.9.109\lib\net20\PayPalButtonManagerSDK.dll - ..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll @@ -113,12 +110,6 @@ ..\packages\xunit.assert.2.1.0\lib\portable-net45+win8+wp8+wpa81\xunit.assert.dll - - ..\packages\PayPalCoreSDK.1.6.3\lib\net451\PayPalCoreSDK.dll - - - ..\packages\log4net.2.0.4\lib\net45-full\log4net.dll - ..\packages\Mono.Web.Xdt.1.0.0\lib\Net40\Microsoft.Web.XmlTransform.dll @@ -138,6 +129,15 @@ ..\packages\Npgsql.3.0.4\lib\net45\Npgsql.dll + + ..\packages\PayPalCoreSDK.1.7.0\lib\net451\PayPalCoreSDK.dll + + + ..\packages\PayPalButtonManagerSDK.2.10.109\lib\net20\PayPalButtonManagerSDK.dll + + + ..\packages\log4net.2.0.5\lib\net45-full\log4net.dll + @@ -772,6 +772,10 @@ + + + + diff --git a/web/packages.config b/web/packages.config index b4381817..90bbef00 100644 --- a/web/packages.config +++ b/web/packages.config @@ -7,15 +7,15 @@ - + - + - - + + @@ -23,4 +23,4 @@ - + \ No newline at end of file diff --git a/yavscModel/ChangeLog b/yavscModel/ChangeLog index 066531c4..abb3f7a7 100644 --- a/yavscModel/ChangeLog +++ b/yavscModel/ChangeLog @@ -1,3 +1,36 @@ +2015-12-23 Paul Schneider + + * INominative.cs: Interface d'un objet destiné à un + préstataire spécifié, + par une propriété `PerformerName` + + + * NominativeSimpleBookingQuery.cs: implémente l'interface + INominative + + * UserFileSystemManager.cs: Fixe: Ne pas créer un dossier de + destination si on a aucun fichier à recevoir. + + * Commande.cs: * Ajoute le nom du client dans l'objet commande + * Factorise le positionnement des paramêtres + * La commande est une instance du type spécifié à la commande, + dans son paramêtre `type` + + * SimpleBookingQuery.cs: refabrication + + * LocalizedText.resx: + * LocalizedText.fr.resx: traducations + + * UserNameBase.cs: implemente l'interface `IUserName` + + + * IContentProvider.cs: doc xml + + * YavscModel.csproj: reference le nouveau code source + + * IUserName.cs: Définit l'interface d'un objet associé à un + utilisateur. + 2015-12-15 Paul Schneider * CircleMember.cs: un membre de cercle est un nom diff --git a/yavscModel/FileSystem/UserFileSystemManager.cs b/yavscModel/FileSystem/UserFileSystemManager.cs index 1faff5ef..a37b404c 100644 --- a/yavscModel/FileSystem/UserFileSystemManager.cs +++ b/yavscModel/FileSystem/UserFileSystemManager.cs @@ -111,6 +111,8 @@ namespace Yavsc.Model.FileSystem /// Files. public static void Put(string destDir, NameObjectCollectionBase files) { + if (files.Count == 0) + return; FileManager.ValidateSubDir (destDir); FileManager.Put( Path.Combine(CurrentUserFileRoot(),destDir), diff --git a/yavscModel/FrontOffice/Commande.cs b/yavscModel/FrontOffice/Commande.cs index 391f5375..093f7d6b 100644 --- a/yavscModel/FrontOffice/Commande.cs +++ b/yavscModel/FrontOffice/Commande.cs @@ -8,7 +8,6 @@ using System.Collections.Generic; using System.IO; using System.Reflection; - namespace Yavsc.Model.FrontOffice { /// @@ -28,6 +27,12 @@ namespace Yavsc.Model.FrontOffice /// The identifier. public long Id { get; set; } + /// + /// Gets or sets the name of the client. + /// + /// The name of the client. + public string ClientName { get; set; } + /// /// Gets or sets the product reference. /// @@ -50,30 +55,55 @@ namespace Yavsc.Model.FrontOffice return UserFileSystemManager.GetFiles (Id.ToString()); } } + /// /// Initializes a new instance of the class. /// public Command() { } + public void SetParameters(Dictionary collection) + { + Parameters.Clear (); + foreach (string key in collection.Keys) { + if (key != "productref" && key != "type" && key != "clientname" ) { + + Parameters.Add (key, collection [key]); + foreach (var prop in this.GetType().GetRuntimeProperties()) + { + if (prop.Name == key && prop.CanWrite) { + System.ComponentModel.TypeConverter tc = System.ComponentModel.TypeDescriptor.GetConverter(prop.PropertyType); + prop.SetValue(this,tc.ConvertFromString(collection [key])); + } + } + } + } + } /// - /// Froms the post. + /// Creates a command from the http post request. + /// This methods applies to one product reference, + /// given in a required value "ref" in the given + /// collection of name value couples. /// /// Collection. /// Files. - private void FromPost(NameValueCollection collection, NameObjectCollectionBase files) + private void FromPost(Dictionary collection, NameObjectCollectionBase files) { // string catref=collection["catref"]; // Catalog Url from which formdata has been built - ProductRef=collection["ref"]; // Required product reference + ProductRef = collection ["productref"]; + if (ProductRef == null) + throw new InvalidOperationException ( + "A product reference cannot be blank at command time"); + ClientName = collection ["clientname"]; + if (ClientName == null) + throw new InvalidOperationException ( + "A client name cannot be blank at command time"); + 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]); - } + SetParameters(collection); WorkFlowManager.RegisterCommand (this); // gives a value to this.Id string strcmdid = Id.ToString (); UserFileSystemManager.Put(Path.Combine("commandes",strcmdid),files); @@ -82,12 +112,22 @@ namespace Yavsc.Model.FrontOffice /// /// Creates a command using the specified collection /// as command parameters, handles the files upload. + /// + /// Required values in the command parameters : + /// + /// * ref: the product reference, + /// * type: the command concrete class name. + /// /// /// Collection. /// Files. - public static Command CreateCommand (NameValueCollection collection, NameObjectCollectionBase files) + public static Command CreateCommand (Dictionary collection, NameObjectCollectionBase files) { - var cmd = CreateCommand (collection ["type"]); + string type = collection ["type"]; + if (type == null) + throw new InvalidOperationException ( + "A command type cannot be blank"); + var cmd = CreateCommand (type); cmd.FromPost (collection, files); return cmd; } @@ -100,9 +140,18 @@ namespace Yavsc.Model.FrontOffice public static Command CreateCommand (string className) { var type = Type.GetType (className); + + if (type == null) + throw new InvalidOperationException ( + "Cannot find the command class " + className); + + if (!typeof(Command).IsAssignableFrom(type)) + throw new InvalidOperationException ( + "No command is assignable from a " + className); + ConstructorInfo ci = type.GetConstructor(new Type[]{}); - var cmd = ci.Invoke (new object[]{}) as Command; - return cmd; + var cmd = ci.Invoke (new object[]{ }); + return cmd as Command; } } } diff --git a/yavscModel/FrontOffice/INominative.cs b/yavscModel/FrontOffice/INominative.cs new file mode 100644 index 00000000..50e2a938 --- /dev/null +++ b/yavscModel/FrontOffice/INominative.cs @@ -0,0 +1,35 @@ +// +// INominative.cs +// +// Author: +// Paul Schneider +// +// Copyright (c) 2015 GNU GPL +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . + +using System; +using System.ComponentModel.DataAnnotations; +using Yavsc.Model.Skill; +using Yavsc.Model.WorkFlow; +using System.Linq; +using Yavsc.Model.RolesAndMembers; + +namespace Yavsc.Model.FrontOffice +{ + public interface INominative { + string PerformerName { get; set; } + } + +} diff --git a/yavscModel/FrontOffice/NominativeSimpleBookingQuery.cs b/yavscModel/FrontOffice/NominativeSimpleBookingQuery.cs new file mode 100644 index 00000000..19d464de --- /dev/null +++ b/yavscModel/FrontOffice/NominativeSimpleBookingQuery.cs @@ -0,0 +1,49 @@ +// +// NominativeSimpleBookingQuery.cs +// +// Author: +// Paul Schneider +// +// Copyright (c) 2015 GNU GPL +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . + +using System; +using System.ComponentModel.DataAnnotations; +using Yavsc.Model.Skill; +using Yavsc.Model.WorkFlow; +using System.Linq; +using Yavsc.Model.RolesAndMembers; + +namespace Yavsc.Model.FrontOffice +{ + /// + /// Nominative simple booking query. + /// + public class NominativeSimpleBookingQuery : SimpleBookingQuery, INominative { + #region IUserName implementation + /// + /// Gets or sets the name of the performer. + /// + /// The name of the user. + public string PerformerName { + get; + set; + } + + #endregion + + } + +} diff --git a/yavscModel/FrontOffice/SimpleBookingQuery.cs b/yavscModel/FrontOffice/SimpleBookingQuery.cs index a9fa7501..2d8d7d36 100644 --- a/yavscModel/FrontOffice/SimpleBookingQuery.cs +++ b/yavscModel/FrontOffice/SimpleBookingQuery.cs @@ -23,9 +23,11 @@ using System.ComponentModel.DataAnnotations; using Yavsc.Model.Skill; using Yavsc.Model.WorkFlow; using System.Linq; +using Yavsc.Model.RolesAndMembers; namespace Yavsc.Model.FrontOffice { + /// /// Simple booking query. /// diff --git a/yavscModel/LocalizedText.fr.resx b/yavscModel/LocalizedText.fr.resx index 18a4d467..149a68fc 100644 --- a/yavscModel/LocalizedText.fr.resx +++ b/yavscModel/LocalizedText.fr.resx @@ -14,14 +14,12 @@ À propos - Je suis développeur indépendant à Suresnes depuis quelque mois. - Je démarre une activité dans le domaine de l'edition logicielle, - et je délivre principalement des applications pour mobiles. de plus Accès refusé Activités Un message instantané a été envoyé à {0}, lui présentant votre demande. Vous devriez être contacté très rapidement. + Demander un devis disponible Seuls les utilisateurs authentifiés peuvent accèder à cette information. Panier diff --git a/yavscModel/LocalizedText.resx b/yavscModel/LocalizedText.resx index 6c2a7695..5c3c60bb 100644 --- a/yavscModel/LocalizedText.resx +++ b/yavscModel/LocalizedText.resx @@ -21,6 +21,7 @@ Activities An instant message has been sent to {0}, showing to him your query. You should be contacted very soon. + Ask for an estimate available You must be authenticated in order to access this information Bill edition diff --git a/yavscModel/RolesAndMembers/IUserName.cs b/yavscModel/RolesAndMembers/IUserName.cs new file mode 100644 index 00000000..3908af5c --- /dev/null +++ b/yavscModel/RolesAndMembers/IUserName.cs @@ -0,0 +1,32 @@ +// +// IUserName.cs +// +// Author: +// Paul Schneider +// +// Copyright (c) 2015 GNU GPL +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . + +using System; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; + +namespace Yavsc.Model.RolesAndMembers +{ + public interface IUserName { + string UserName { get; set; } + } + +} diff --git a/yavscModel/RolesAndMembers/UserNameBase.cs b/yavscModel/RolesAndMembers/UserNameBase.cs index 994e94da..01fb2ef4 100644 --- a/yavscModel/RolesAndMembers/UserNameBase.cs +++ b/yavscModel/RolesAndMembers/UserNameBase.cs @@ -28,7 +28,7 @@ namespace Yavsc.Model.RolesAndMembers /// /// User name base. /// - public class UserNameBase : IIdentified { + public class UserNameBase : IUserName, IIdentified { /// /// Gets or sets the name of the user. /// diff --git a/yavscModel/WorkFlow/IContentProvider.cs b/yavscModel/WorkFlow/IContentProvider.cs index 253f9a38..50deba65 100644 --- a/yavscModel/WorkFlow/IContentProvider.cs +++ b/yavscModel/WorkFlow/IContentProvider.cs @@ -25,6 +25,10 @@ namespace Yavsc.Model.WorkFlow /// The final statuses. bool [] FinalStatuses { get; } + /// + /// Gets the name. + /// + /// The name. string Name { get; } /// /// Creates the estimate. @@ -133,6 +137,7 @@ namespace Yavsc.Model.WorkFlow /// The command id in db. /// COM. long RegisterCommand (Command com); + /// /// Sets the writting status. /// diff --git a/yavscModel/YavscModel.csproj b/yavscModel/YavscModel.csproj index 25a346eb..76b3df04 100644 --- a/yavscModel/YavscModel.csproj +++ b/yavscModel/YavscModel.csproj @@ -243,6 +243,9 @@ + + +