diff --git a/NpgsqlContentProvider/ChangeLog b/NpgsqlContentProvider/ChangeLog index bb6c6c91..8252d469 100644 --- a/NpgsqlContentProvider/ChangeLog +++ b/NpgsqlContentProvider/ChangeLog @@ -1,3 +1,8 @@ +2015-11-25 Paul Schneider + + * NpgsqlContentProvider.cs: implemente la gestion des + activités côté base de donnée Npgsql + 2015-11-23 Paul Schneider * NpgsqlSkillProvider.cs: refactorisation (-Skill+SkillEntity) diff --git a/NpgsqlContentProvider/NpgsqlContentProvider.cs b/NpgsqlContentProvider/NpgsqlContentProvider.cs index fc3cf861..039aec01 100644 --- a/NpgsqlContentProvider/NpgsqlContentProvider.cs +++ b/NpgsqlContentProvider/NpgsqlContentProvider.cs @@ -21,7 +21,105 @@ namespace Yavsc /// public class NpgsqlContentProvider: ProviderBase, IContentProvider { - + /// + /// Gets the activity. + /// + /// The activity. + /// MEA code. + public Activity GetActivity (string MEACode) + { + Activity result = null; + using (NpgsqlConnection cnx = CreateConnection ()) { + cnx.Open (); + using (NpgsqlCommand cmd = cnx.CreateCommand ()) { + cmd.CommandText = @"select meacode, title, cmnt + from activity where meacode = :code and applicationname = :app"; + cmd.Parameters.AddWithValue ("code", MEACode); + cmd.Parameters.AddWithValue ("app", applicationName); + using (var rdr = cmd.ExecuteReader ()) { + if (rdr.HasRows) { + rdr.Read (); + result = new Activity () { + Id = rdr.GetString (0), + Title = rdr.GetString (1), + Comment = rdr.GetString (2) + }; + } + } + } + cnx.Close (); + } + return result; + } + + /// + /// Finds the activity. + /// + /// The activity. + /// Pattern. + /// If set to true exerted. + public Activity[] FindActivity (string pattern, bool exerted) + { + List acties = new List (); + using (NpgsqlConnection cnx = CreateConnection ()) { + cnx.Open (); + using (NpgsqlCommand cmd = cnx.CreateCommand ()) { + cmd.CommandText = (exerted) ? + @"SELECT a.meacode, a.title, a.cmnt + FROM activity a, profiledata d, profiles p, users u + WHERE u.username = p.username + AND u.applicationname = p.applicationname + AND p.uniqueid = d.uniqueid + AND d.meacode = a.meacode + AND u.isapproved = TRUE + AND u.islockedout = FALSE + AND a.title like :pat + ORDER BY a.meacode " : + @"SELECT meacode, title, cmnt + FROM activity + WHERE title LIKE :pat + ORDER BY meacode "; + cmd.Parameters.AddWithValue ("pat", pattern); + using (var rdr = cmd.ExecuteReader ()) { + if (!rdr.HasRows) + return new Activity[0]; + new List (); + while (rdr.Read ()) { + acties.Add (new Activity () { + Id = rdr.GetString (0), + Title = rdr.GetString (1), + Comment = rdr.GetString (2) + }); + } + } + } + + cnx.Close (); + } + return acties.ToArray(); + } + + /// + /// Registers the activity. + /// + /// Activity. + /// Code. + public void RegisterActivity (string activity, string code, string comment) + { + using (NpgsqlConnection cnx = CreateConnection ()) { + cnx.Open (); + using (NpgsqlCommand cmd = cnx.CreateCommand ()) { + cmd.CommandText = "insert into activity (meacode,title,applicationname,cmnt) " + + " values (:code,:title,:app,:cmt)"; + cmd.Parameters.AddWithValue ("code", code); + cmd.Parameters.AddWithValue ("title", activity); + cmd.Parameters.AddWithValue ("app", applicationName); + cmd.Parameters.AddWithValue ("cmt", comment); + cmd.ExecuteNonQuery (); + } + cnx.Close (); + } + } /// /// Registers the command. @@ -38,8 +136,8 @@ namespace Yavsc "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 ("@prms", JsonConvert.SerializeObject (com.Parameters)); + cmd.Parameters.AddWithValue ("@cli", Membership.GetUser ().UserName); cmd.Parameters.AddWithValue ("@app", ApplicationName); cnx.Open (); com.Id = id = (long)cmd.ExecuteScalar (); @@ -53,7 +151,7 @@ namespace Yavsc /// /// The commands. /// Username. - public CommandSet GetCommands (string username ) + public CommandSet GetCommands (string username) { // Check the user's authorisations MembershipUser user = Membership.GetUser (); @@ -72,13 +170,13 @@ namespace Yavsc 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); + Command ycmd = new Command (); + 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 ; + object prms = JsonConvert.DeserializeObject> (rdr.GetString (3)); + ycmd.Parameters = prms as Dictionary; cmds.Add (ycmd); } @@ -109,6 +207,7 @@ namespace Yavsc { throw new NotImplementedException (); } + /// /// Gets the estimate status changes. /// @@ -118,6 +217,7 @@ namespace Yavsc { throw new NotImplementedException (); } + /// /// Tags the writting. /// @@ -137,6 +237,7 @@ namespace Yavsc { throw new NotImplementedException (); } + /// /// Sets the writting status. /// @@ -147,6 +248,7 @@ namespace Yavsc { throw new NotImplementedException (); } + /// /// Sets the estimate status. /// @@ -169,6 +271,7 @@ namespace Yavsc { throw new NotImplementedException (); } + /// /// Install the model in database using the specified cnx. /// @@ -235,6 +338,7 @@ namespace Yavsc return new bool[] { false, false, true, true }; } } + /// /// Gets the estimates created by /// or for the given user by user name. @@ -265,11 +369,12 @@ namespace Yavsc } cnx.Close (); } - foreach (long id in ids) - ests.Add(Get(id)); - return ests.ToArray(); + foreach (long id in ids) + ests.Add (Get (id)); + return ests.ToArray (); } } + /// /// Gets the estimates. /// @@ -294,7 +399,7 @@ namespace Yavsc if (responsible != null) cmd.CommandText += " and "; cmd.Parameters.AddWithValue ("@clid", client); - } + } if (responsible != null) { cmd.CommandText += "username = @resp"; cmd.Parameters.AddWithValue ("@resp", responsible); @@ -308,9 +413,9 @@ namespace Yavsc } rdr.Close (); } - foreach (long id in ids) - ests.Add(Get(id)); - return ests.ToArray(); + foreach (long id in ids) + ests.Add (Get (id)); + return ests.ToArray (); } } } @@ -372,11 +477,11 @@ namespace Yavsc return null; } est = new Estimate (); - est.Title = rdr.GetString( - rdr.GetOrdinal("title")); + est.Title = rdr.GetString ( + rdr.GetOrdinal ("title")); - est.Responsible = rdr.GetString( - rdr.GetOrdinal("username")); + est.Responsible = rdr.GetString ( + rdr.GetOrdinal ("username")); int clientidx = rdr.GetOrdinal ("client"); if (!rdr.IsDBNull (clientidx)) est.Client = rdr.GetString (clientidx); @@ -390,7 +495,7 @@ namespace Yavsc } // assert est != null using (NpgsqlCommand cmdw = new NpgsqlCommand ("select _id, productid, ucost, count, description from writtings where estimid = @estid", cnx)) { - cmdw.Parameters.AddWithValue("@estid", estimid); + cmdw.Parameters.AddWithValue ("@estid", estimid); using (NpgsqlDataReader rdrw = cmdw.ExecuteReader ()) { List lw = null; if (rdrw.HasRows) { @@ -402,7 +507,7 @@ namespace Yavsc w.Description = rdrw.GetString (dei); int opi = rdrw.GetOrdinal ("productid"); if (!rdrw.IsDBNull (opi)) - w.ProductReference = rdrw.GetString(opi); + w.ProductReference = rdrw.GetString (opi); int oco = rdrw.GetOrdinal ("count"); if (!rdrw.IsDBNull (oco)) w.Count = rdrw.GetInt32 (oco); @@ -430,11 +535,11 @@ namespace Yavsc using (NpgsqlCommand cmd = cnx.CreateCommand ()) { cmd.CommandText = "update writtings set " + - "description = @desc, " + - "ucost = @ucost, " + - "count = @count, " + - "productid = @prdid " + - "where _id = @wrid"; + "description = @desc, " + + "ucost = @ucost, " + + "count = @count, " + + "productid = @prdid " + + "where _id = @wrid"; cmd.Parameters.AddWithValue ("@wrid", wr.Id); cmd.Parameters.AddWithValue ("@desc", wr.Description); cmd.Parameters.AddWithValue ("@ucost", wr.UnitaryCost); @@ -446,7 +551,7 @@ namespace Yavsc } } } - + /// /// Saves the given Estimate object in database. /// @@ -457,7 +562,7 @@ namespace Yavsc using (NpgsqlCommand cmd = cnx.CreateCommand ()) { cmd.CommandText = "update estimate set title = @tit, username = @un, " + - "description = @descr, client = @cli where _id = @estid"; + "description = @descr, client = @cli where _id = @estid"; cmd.Parameters.AddWithValue ("@tit", estim.Title); cmd.Parameters.AddWithValue ("@un", estim.Responsible); cmd.Parameters.AddWithValue ("@descr", estim.Description); @@ -486,14 +591,14 @@ namespace Yavsc cmd.CommandText = "insert into writtings (description, estimid, ucost, count, productid) VALUES (@dscr,@estid,@ucost,@count,@prdid) returning _id"; cmd.Parameters.AddWithValue ("@dscr", desc); - cmd.Parameters.AddWithValue("@estid", estid); + cmd.Parameters.AddWithValue ("@estid", estid); - cmd.Parameters.AddWithValue("@ucost", ucost); - cmd.Parameters.AddWithValue("@count", count); - cmd.Parameters.AddWithValue("@prdid", productid); + cmd.Parameters.AddWithValue ("@ucost", ucost); + cmd.Parameters.AddWithValue ("@count", count); + cmd.Parameters.AddWithValue ("@prdid", productid); cnx.Open (); - long res = (long) cmd.ExecuteScalar (); + long res = (long)cmd.ExecuteScalar (); cnx.Close (); return res; } @@ -539,10 +644,10 @@ namespace Yavsc cmd.Parameters.AddWithValue ("@un", client); cmd.Parameters.AddWithValue ("@resp", responsible); cmd.Parameters.AddWithValue ("@descr", description); - cmd.Parameters.AddWithValue("@app", ApplicationName); + cmd.Parameters.AddWithValue ("@app", ApplicationName); cnx.Open (); Estimate created = new Estimate (); - created.Id = (long) cmd.ExecuteScalar (); + created.Id = (long)cmd.ExecuteScalar (); cnx.Close (); created.Title = title; created.Description = description; @@ -553,7 +658,8 @@ namespace Yavsc } } - string applicationName=null; + string applicationName = null; + /// /// Gets or sets the name of the application. /// @@ -568,6 +674,7 @@ namespace Yavsc } string cnxstr = null; + /// /// Initialize this object using the specified name and config. /// @@ -575,11 +682,11 @@ namespace Yavsc /// Config. public override void Initialize (string name, NameValueCollection config) { - if ( string.IsNullOrWhiteSpace(config ["connectionStringName"])) + if (string.IsNullOrWhiteSpace (config ["connectionStringName"])) throw new ConfigurationErrorsException ("No name for Npgsql connection string found"); cnxstr = ConfigurationManager.ConnectionStrings [config ["connectionStringName"]].ConnectionString; - applicationName = config["applicationName"] ?? "/"; + applicationName = config ["applicationName"] ?? "/"; } diff --git a/TestAPI/ChangeLog b/TestAPI/ChangeLog index 66eb25ca..a84e530a 100644 --- a/TestAPI/ChangeLog +++ b/TestAPI/ChangeLog @@ -1,3 +1,8 @@ +2015-11-25 Paul Schneider + + * TestAPI.csproj: ... une référence au framework 4.5.1 en + moins ... + 2015-11-19 Paul Schneider * TestAPI.csproj: adds a build target named "Lua" diff --git a/TestAPI/TestAPI.csproj b/TestAPI/TestAPI.csproj index a10e578b..19963100 100644 --- a/TestAPI/TestAPI.csproj +++ b/TestAPI/TestAPI.csproj @@ -20,7 +20,6 @@ prompt 4 false - v4.5.1 full @@ -29,7 +28,6 @@ prompt 4 false - v4.5.1 false diff --git a/web/ApiControllers/FrontOfficeController.cs b/web/ApiControllers/FrontOfficeController.cs index 223d4744..7560c639 100644 --- a/web/ApiControllers/FrontOfficeController.cs +++ b/web/ApiControllers/FrontOfficeController.cs @@ -25,6 +25,27 @@ namespace Yavsc.ApiControllers /// public class FrontOfficeController : YavscController { + /// + /// search the specified Activities. + /// + /// Search. + + public Activity[] Activities (string search) + { + if (search == null) + search = "%"; + return WorkFlowManager.FindActivity(search,true); + } + /// + /// Registers the activity. + /// + /// Act. + [HttpPost,ValidateAjax] + public void RegisterActivity(Activity act) + { + if (ModelState.IsValid) + WorkFlowManager.RegisterActivity (act.Title, act.Id, act.Comment); + } /// /// Catalog this instance. @@ -58,7 +79,7 @@ namespace Yavsc.ApiControllers [HttpGet] public Estimate GetEstimate (long id) { - Estimate est = WorkFlowManager.ContentProvider.Get (id); + Estimate est = WorkFlowManager.DefaultProvider.Get (id); string username = Membership.GetUser ().UserName; if (est.Client != username) if (!Roles.IsUserInRole("Admin")) diff --git a/web/App_Code/Global.asax.cs b/web/App_Code/Global.asax.cs index 74a4ddee..b159a86c 100644 --- a/web/App_Code/Global.asax.cs +++ b/web/App_Code/Global.asax.cs @@ -19,7 +19,7 @@ namespace Yavsc /// /// Mvc application. /// - public class MvcApplication : System.Web.HttpApplication + public class MvcApplication : HttpApplication { /// diff --git a/web/App_Code/Sql/activity.sql b/web/App_Code/Sql/activity.sql index 6acd3835..c766f789 100644 --- a/web/App_Code/Sql/activity.sql +++ b/web/App_Code/Sql/activity.sql @@ -4,17 +4,20 @@ CREATE TABLE activity ( - "MAECode" character varying(512) NOT NULL, -- Identifiant de l'activité, à terme, il faudrait ajouter un champ à cette id: le code pays.... + meacode character varying(512) NOT NULL, -- Identifiant de l'activité, à terme, il faudrait ajouter un champ à cette id: le code pays.... title character varying(2048) NOT NULL, -- Description textuelle du code APE applicationname character varying(255) NOT NULL, - CONSTRAINT activity_pkey PRIMARY KEY ("MAECode", applicationname) + cmnt character varying, -- a long description for this activity + CONSTRAINT activity_pkey PRIMARY KEY (meacode, applicationname) ) WITH ( OIDS=FALSE ); +ALTER TABLE activity + OWNER TO yavscdev; COMMENT ON TABLE activity IS 'Activités prises en charge par l''application désignée'; -COMMENT ON COLUMN activity."MAECode" IS 'Identifiant de l''activité, à terme, il faudrait ajouter un champ à cette id: le code pays. +COMMENT ON COLUMN activity.meacode IS 'Identifiant de l''activité, à terme, il faudrait ajouter un champ à cette id: le code pays. Definition francaise: un code NACE sur les quatre première lettre (code européen), @@ -23,5 +26,5 @@ une lettre en cinquième position. Exemple: ''71.12B'' => "Ingénierie, études techniques" '; COMMENT ON COLUMN activity.title IS 'Description textuelle du code APE'; - +COMMENT ON COLUMN activity.cmnt IS 'a long description for this activity'; diff --git a/web/App_Themes/style.css b/web/App_Themes/style.css index e7217093..921dc1d2 100644 --- a/web/App_Themes/style.css +++ b/web/App_Themes/style.css @@ -55,8 +55,7 @@ main video, main img { footer { transition: margin 2s, padding 2s; - margin: 0; - margin-top: 2em; + margin: 2em; padding: 2em; display: block; clear: both; @@ -342,7 +341,6 @@ ul.editablelist>li:hover:before { header { padding-top:1em; padding-bottom:1em; - background: url("/App_Themes/images/star-939235_1280.s.jpg") 0 0 no-repeat fixed; } #avatar { @@ -354,15 +352,14 @@ header h1, header a , .actionlink, .menuitem, a { padding:.5em;} nav { margin: 1em; padding: 1em; - background: url("/App_Themes/images/helix-nebula-1400x1400.s.jpg") 50% 10% repeat fixed ; } main { margin: 1em; padding: 1em; - background: url("/App_Themes/images/p8-av4.s.jpg") 50% 20em no-repeat fixed ; } footer { - background: url("/App_Themes/images/helix-nebula-1400x1400.s.jpg") 50% 90% repeat fixed ; + margin: 1em; + padding: 1em; } footer a { border-radius:.5em; @@ -400,7 +397,6 @@ header h1, header a , .actionlink, .menuitem, a { padding:.5em;} header { padding-top:.5em; padding-bottom:.5em; - background: url("/App_Themes/images/star-939235_1280.xxs.jpg") 0 0 no-repeat fixed; } header h1, header a { padding:.2em;} @@ -408,15 +404,14 @@ header h1, header a { padding:.2em;} nav { margin: .5em; padding: .5em; - background: url("/App_Themes/images/helix-nebula-1400x1400.xxs.jpg") 50% 10% repeat fixed ; } main { margin: .5em; padding: .5em; - background: url("/App_Themes/images/p8-av4.xxs.jpg") 50% 20em repeat fixed ; } footer { - background: url("/App_Themes/images/helix-nebula-1400x1400.xxs.jpg") 50% 10% repeat fixed ; + margin: .5em; + padding: .5em; } footer a { border-radius:.2em; diff --git a/web/ChangeLog b/web/ChangeLog index 429a296b..3cad5fc0 100644 --- a/web/ChangeLog +++ b/web/ChangeLog @@ -1,3 +1,56 @@ +2015-11-25 Paul Schneider + + * Activities.aspx: implémente la vue Html de la liste éditable + des activités + + * Activity.ascx: implémente la vue Html d'une activité + + * FrontOfficeController.cs: Le contrôleur du FrontOffice gére + les activités + + * Global.asax.cs: nettoyage du code + + * activity.sql: Typo corrigée sur le terme "MEACode" + + * style.css: enlève des images qui n'ont plus rien à faire + ici, tant ce fichier + concerne maintenant uniquement la disposition ou les éléments + de base. + + + * AccountController.cs: implémente le contrôle par + l'utilisateur du paramêtre de l'activité principale + associé à son profile. + + * FrontOfficeController.cs: Implemente le contrôle de la page + des activités, + et simplifie le contrôle de la page des compétences. + + * HomeController.cs: formattage du code + + * ModuleController.cs: inutilisé + + * App.master: Theming explicite en page maître + + * Profile.aspx: Propose maintenant l'édition de l'activité + principalement éxercée + + * Skills.aspx: supprime une ligne de log + + * Index.aspx: RAZ en home page + + * MarkdownDeep.dll: remplace le tag englobant les + transformations, + il était un "

", il est maintenant un "". + + + * Web.csproj: reference les nouveaux éléments du projet + relatifs au activités + + * Web.config: references manquante en cas d'utilisation du + paramértrage global du thème via la section system.web/pages + du fichier de configuration. + 2015-11-23 Paul Schneider * activity.sql: definit les activités en base de données. diff --git a/web/Controllers/AccountController.cs b/web/Controllers/AccountController.cs index 75592258..69bd7815 100644 --- a/web/Controllers/AccountController.cs +++ b/web/Controllers/AccountController.cs @@ -17,6 +17,7 @@ using System.Text; using System.Net; using System.Configuration; using Yavsc.Model; +using Yavsc.Model.WorkFlow; namespace Yavsc.Controllers { @@ -251,11 +252,24 @@ namespace Yavsc.Controllers if (id == null) id = Membership.GetUser ().UserName; ViewData ["UserName"] = id; + ProfileEdition model = new ProfileEdition (ProfileBase.Create (id)); model.RememberMe = FormsAuthentication.GetAuthCookie (id, true) == null; + SetMEACodeViewData (model); return View (model); } + private void SetMEACodeViewData(Profile model) { + var activities = WorkFlowManager.FindActivity ("%", false); + var items = new List (); + items.Add (new SelectListItem () { Selected = model.MEACode == null, Text = LocalizedText.DoNotPublishMyActivity, Value=null }); + foreach (var a in activities) { + items.Add(new SelectListItem() { Selected = model.MEACode == a.Id, + Text = string.Format("{1} : {0}",a.Title,a.Id), + Value = a.Id }); + } + ViewData ["MEACode"] = items; + } ///

@@ -336,6 +350,7 @@ namespace Yavsc.Controllers prf.SetPropertyValue ("BankedKey", model.BankedKey); prf.SetPropertyValue ("gcalid", model.GoogleCalendar); prf.SetPropertyValue ("UITheme", model.UITheme); + prf.SetPropertyValue ("MEACode", model.MEACode); prf.Save (); if (editsTheUserName) { @@ -345,6 +360,7 @@ namespace Yavsc.Controllers } YavscHelpers.Notify(ViewData, "Profile enregistré"+((editsTheUserName)?", nom public inclu.":"")); } + SetMEACodeViewData (model); return View (model); } /// diff --git a/web/Controllers/FrontOfficeController.cs b/web/Controllers/FrontOfficeController.cs index 9de5f814..27fb83e2 100644 --- a/web/Controllers/FrontOfficeController.cs +++ b/web/Controllers/FrontOfficeController.cs @@ -266,6 +266,18 @@ namespace Yavsc.Controllers return View (skills); } + public ActionResult Activities (string search, bool toPower = false) + { + if (search == null) + search = "%"; + var activities = WorkFlowManager.FindActivity(search,!toPower); + return View (activities); + } + + public ActionResult Activity(string id) + { + return View(WorkFlowManager.GetActivity (id)); + } /// /// Display and should /// offer Ajax edition of @@ -273,20 +285,16 @@ namespace Yavsc.Controllers /// /// the User Skills Profile. [Authorize()] - public ActionResult UserSkills (PerformerProfile usp) + public ActionResult UserSkills (string id) { - if (usp.UserName == null) - // this is not a call to update, - // and this can not concern another user - // than the current logged one. - usp = new PerformerProfile( User.Identity.Name ); - // if (usp.UserName was null) { - usp = SkillManager.GetUserSkills (usp.UserName); + if (id == null) + id = User.Identity.Name ; + // TODO or not to do, handle a skills profile update, + // actually performed via the Web API :-° + // else if (ModelState.IsValid) {} + var usp = SkillManager.GetUserSkills (id); var skills = SkillManager.FindSkill ("%"); ViewData ["SiteSkills"] = skills; - // TODO or not to do, handle a skills profile update, - // actually performed via the Web API :-° - // } else if (ModelState.IsValid) {} return View (usp); } diff --git a/web/Controllers/HomeController.cs b/web/Controllers/HomeController.cs index 35bb3cbb..2140e154 100644 --- a/web/Controllers/HomeController.cs +++ b/web/Controllers/HomeController.cs @@ -91,6 +91,7 @@ namespace Yavsc.Controllers // TODO specialyze BlogEntry creating a PhotoEntry ViewData [tagname] = ti; } + return View (); } /// diff --git a/web/Controllers/ModuleController.cs b/web/Controllers/ModuleController.cs deleted file mode 100644 index 4aae72c1..00000000 --- a/web/Controllers/ModuleController.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; -using System.Web.Mvc; -using Yavsc.Model; -using System.Configuration; - -namespace Yavsc.Controllers -{ - /// - /// Module controller. - /// - public class ModuleController : Controller - { - /// - /// Initialize the specified requestContext. - /// - /// Request context. - protected override void Initialize (System.Web.Routing.RequestContext requestContext) - { - base.Initialize (requestContext); - ConfigurationManager.GetSection ("ymodules"); - - } - - // List modules = new List (); - /// - /// Index this instance. - /// - public ActionResult Index() - { - return View (); - } - } -} diff --git a/web/Models/App.master b/web/Models/App.master index 8099d811..0a17dcd2 100644 --- a/web/Models/App.master +++ b/web/Models/App.master @@ -1,4 +1,4 @@ -<%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %> +<%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" EnableTheming="true"%> <% ViewState["orgtitle"] = Html.Translate(Page.Title); %> diff --git a/web/Views/Account/Profile.aspx b/web/Views/Account/Profile.aspx index 3e0310e7..f61eb055 100644 --- a/web/Views/Account/Profile.aspx +++ b/web/Views/Account/Profile.aspx @@ -5,26 +5,19 @@ - - - + <% if (Roles.IsUserInRole((string)ViewData ["UserName"],"Admin")) { + // TODO View all roles + %> + <% } %> public interface IContentProvider : IDbModule, IDisposable, IDataProvider { - /// /// Gets the different status labels. /// 0 is the starting status. Each status is an integer and the 0-based index @@ -25,6 +24,52 @@ namespace Yavsc.Model.WorkFlow /// /// The final statuses. bool [] FinalStatuses { get; } + + string Name { get; } + /// + /// Creates the estimate. + /// + /// The estimate. + /// Responsible. + /// Client. + /// Title. + /// Description. + Estimate CreateEstimate (string responsible, string client, string title, string description); + + /// + /// Drops the writting. + /// + /// Wrid. + void DropWritting (long wrid); + + /// + /// Drops the estimate. + /// + /// Estid. + void DropEstimate (long estid); + + /// + /// Drops the tag writting. + /// + /// Wrid. + /// Tag. + void DropWrittingTag (long wrid,string tag); + + /// + /// Finds the activity. + /// + /// The activity. + /// Pattern. + /// If set to true exerted. + Activity [] FindActivity (string pattern, bool exerted); + + /// + /// Gets the activity. + /// + /// The activity. + /// MAE code. + Activity GetActivity (string MEACode); + /// /// Gets the writting status changes. /// @@ -36,17 +81,80 @@ namespace Yavsc.Model.WorkFlow /// /// The estimate statuses. /// Estid. - StatusChange[] GetEstimateStatuses (long estid); + StatusChange[] GetEstimateStatuses (long estid); /// + /// - /// Creates the estimate. + /// Gets the estimates. /// - /// The estimate. - /// Responsible. - /// Client. - /// Title. - /// Description. - Estimate CreateEstimate (string responsible, string client, string title, string description); + /// The estimates. + /// Username. + Estimate [] GetEstimates(string username); + /// + /// Registers the activity. + /// + /// Activity. + /// Code. + void RegisterActivity (string activityName, string meacode, string comment); + + /// + /// Gets the estimates. + /// + /// The estimates. + /// Client. + /// Responsible. + Estimate [] GetEstimates(string client, string responsible); + + + /// + /// Gets the commands. + /// + /// The commands. + /// Username. + CommandSet GetCommands (string username); + + /// + /// Gets the stock status. + /// + /// The stock status. + /// Product reference. + StockStatus GetStockStatus (string productReference); + + /// + /// Registers the command. + /// + /// The command id in db. + /// COM. + long RegisterCommand (Command com); + /// + /// Sets the writting status. + /// + /// Wrtid. + /// Status. + /// Username. + void SetWrittingStatus (long wrtid,int status,string username); + + /// + /// Sets the estimate status. + /// + /// Estid. + /// Status. + /// Username. + void SetEstimateStatus (long estid,int status,string username); + + /// + /// Tags the writting. + /// + /// Wrid. + /// Tag. + void TagWritting (long wrid,string tag); + + /// + /// Updates the writting. + /// + /// Wr. + void UpdateWritting (Writting wr); + /// Add a line to the specified estimate by id, /// using the specified desc, ucost, count and productid. /// @@ -57,79 +165,6 @@ namespace Yavsc.Model.WorkFlow /// Product identifier. long Write (long estid, string desc, decimal ucost, int count, string productid); - /// - /// Gets the estimates created by - /// or for the given user by user name. - /// - /// The estimates. - /// user name. - Estimate [] GetEstimates(string username); - /// - /// Gets the estimates. - /// - /// The estimates. - /// Client. - /// Responsible. - Estimate [] GetEstimates(string client, string responsible); - /// - /// Drops the writting. - /// - /// Wrid. - void DropWritting (long wrid); - /// - /// Drops the estimate. - /// - /// Estid. - void DropEstimate (long estid); - /// - /// Tags the writting. - /// - /// Wrid. - /// Tag. - void TagWritting (long wrid,string tag); - /// - /// Drops the tag writting. - /// - /// Wrid. - /// Tag. - void DropWrittingTag (long wrid,string tag); - /// - /// Updates the writting. - /// - /// Wr. - void UpdateWritting (Writting wr); - /// - /// Sets the writting status. - /// - /// Wrtid. - /// Status. - /// Username. - void SetWrittingStatus (long wrtid,int status,string username); - /// - /// Sets the estimate status. - /// - /// Estid. - /// Status. - /// Username. - void SetEstimateStatus (long estid,int status,string username); - /// - /// Registers the command. - /// - /// The command id in db. - /// COM. - long RegisterCommand (Command com); - /// - /// Gets the commands. - /// - /// The commands. - /// Username. - CommandSet GetCommands (string username); - /// - /// Gets the stock status. - /// - /// The stock status. - /// Product reference. - StockStatus GetStockStatus (string productReference); } } diff --git a/yavscModel/WorkFlow/WorkFlowManager.cs b/yavscModel/WorkFlow/WorkFlowManager.cs index f51185e5..05052fea 100644 --- a/yavscModel/WorkFlow/WorkFlowManager.cs +++ b/yavscModel/WorkFlow/WorkFlowManager.cs @@ -21,19 +21,26 @@ namespace Yavsc.Model.WorkFlow /// /// The activity. /// Pattern. - public static IEnumerable FindActivity(string pattern = "%") + /// If set to true exerted. + public static Activity[] FindActivity(string pattern = "%", bool exerted=true) { - throw new NotImplementedException (); + List activities = new List (); + foreach (var provider in Providers) { + foreach (var act in provider.FindActivity (pattern, exerted)) + if (!activities.Contains(act)) + activities.Add(act); + } + return activities.ToArray(); } /// /// Gets the activity. /// /// The activity. - /// MAE code. - public static Activity GetActivity (string MAECode) + /// MAE code. + public static Activity GetActivity (string meacode) { - throw new NotImplementedException (); + return DefaultProvider.GetActivity (meacode); } /// @@ -49,7 +56,7 @@ namespace Yavsc.Model.WorkFlow /// COM. public static long RegisterCommand(Command com) { - return ContentProvider.RegisterCommand (com); + return DefaultProvider.RegisterCommand (com); } /// @@ -58,7 +65,7 @@ namespace Yavsc.Model.WorkFlow /// Estim. public static void UpdateEstimate (Estimate estim) { - ContentProvider.Update (estim); + DefaultProvider.Update (estim); } /// /// Gets the estimate. @@ -67,7 +74,7 @@ namespace Yavsc.Model.WorkFlow /// Estid. public static Estimate GetEstimate (long estid) { - return ContentProvider.Get (estid); + return DefaultProvider.Get (estid); } /// /// Gets the estimates, refering the @@ -77,7 +84,7 @@ namespace Yavsc.Model.WorkFlow /// Responsible. public static Estimate [] GetResponsibleEstimates (string responsible) { - return ContentProvider.GetEstimates (null, responsible); + return DefaultProvider.GetEstimates (null, responsible); } /// @@ -87,7 +94,7 @@ namespace Yavsc.Model.WorkFlow /// Client. public static Estimate [] GetClientEstimates (string client) { - return ContentProvider.GetEstimates (client, null); + return DefaultProvider.GetEstimates (client, null); } /// @@ -97,7 +104,7 @@ namespace Yavsc.Model.WorkFlow /// Username. public static Estimate [] GetUserEstimates (string username) { - return ContentProvider.GetEstimates (username); + return DefaultProvider.GetEstimates (username); } /// @@ -107,7 +114,7 @@ namespace Yavsc.Model.WorkFlow /// Product reference. public static StockStatus GetStock(string productReference) { - return ContentProvider.GetStockStatus (productReference); + return DefaultProvider.GetStockStatus (productReference); } /// @@ -116,7 +123,7 @@ namespace Yavsc.Model.WorkFlow /// Wr. public static void UpdateWritting (Writting wr) { - ContentProvider.UpdateWritting (wr); + DefaultProvider.UpdateWritting (wr); } /// @@ -125,7 +132,7 @@ namespace Yavsc.Model.WorkFlow /// Wrid. public static void DropWritting (long wrid) { - ContentProvider.DropWritting (wrid); + DefaultProvider.DropWritting (wrid); } /// /// Drops the estimate. @@ -133,25 +140,38 @@ namespace Yavsc.Model.WorkFlow /// Estid. public static void DropEstimate (long estid) { - ContentProvider.DropEstimate(estid); + DefaultProvider.DropEstimate(estid); } - - - static IContentProvider contentProvider; + static IContentProvider defaultProvider; /// /// Gets the content provider. /// /// The content provider. - public static IContentProvider ContentProvider { + public static IContentProvider DefaultProvider { get { - if (contentProvider == null) - contentProvider = ManagerHelper.GetDefaultProvider + if (defaultProvider == null) + defaultProvider = ManagerHelper.CreateDefaultProvider ("system.web/workflow") as IContentProvider; - return contentProvider; + return defaultProvider; } } + public static IContentProvider [] Providers { + + get { + if (providers == null) { + var pbs = ManagerHelper.CreateProviders + ("system.web/workflow"); + providers = new IContentProvider [pbs.Length]; + for (var i=0;i /// Creates the estimate. @@ -163,7 +183,7 @@ namespace Yavsc.Model.WorkFlow /// Description. public static Estimate CreateEstimate(string responsible, string client, string title, string description) { - Estimate created = ContentProvider.CreateEstimate (responsible, client, title, description); + Estimate created = DefaultProvider.CreateEstimate (responsible, client, title, description); return created; } @@ -187,7 +207,7 @@ namespace Yavsc.Model.WorkFlow throw new Exception ("Product not found"); // TODO new EstimateChange Event } - return ContentProvider.Write(estid, desc, ucost, count, productid); + return DefaultProvider.Write(estid, desc, ucost, count, productid); } /// @@ -198,7 +218,7 @@ namespace Yavsc.Model.WorkFlow /// Username. public static void SetEstimateStatus(long estid, int status, string username) { - ContentProvider.SetEstimateStatus (estid, status, username); + DefaultProvider.SetEstimateStatus (estid, status, username); } /// /// Gets the commands. @@ -207,14 +227,12 @@ namespace Yavsc.Model.WorkFlow /// Username. public static CommandSet GetCommands(string username) { - return ContentProvider.GetCommands (username); + return DefaultProvider.GetCommands (username); } - public static string [] APEDisponibles + public static void RegisterActivity (string activityName, string meacode, string comment) { - get { - return new string[]{ "Chanteur", "DJ", "Musicien", "Clown" }; - } + DefaultProvider.RegisterActivity (activityName, meacode, comment); } } } diff --git a/yavscModel/YavscModel.csproj b/yavscModel/YavscModel.csproj index f002e892..95aa1d0f 100644 --- a/yavscModel/YavscModel.csproj +++ b/yavscModel/YavscModel.csproj @@ -183,7 +183,6 @@ - @@ -201,6 +200,7 @@ +