diff --git a/ChangeLog b/ChangeLog index 429cb6a4..1fef97c6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2015-11-30 Paul Schneider + + * Makefile: Fixe: ne pas déployer sans hôte de destination + Ajoute: le déployement de tous des sites en prod, avec la + cible `syncall` + + 2015-11-26 Paul Schneider * Makefile: diff --git a/Makefile b/Makefile index 1280ce90..60647877 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,7 @@ VERSION=1.1 CONFIG=Debug LDYDESTDIR=dist/web/$(CONFIG) COPYUNCHANGED="false" +SHELL=/bin/bash HOST_rsync_dev=lua.pschneider.fr DESTDIR_rsync_dev=/srv/www/yavscdev @@ -46,6 +47,7 @@ rsync_% : HOST = $(HOST_$@) rsync_% : DESTDIR = $(DESTDIR_$@) rsync_% : deploy + if [[ "x$(HOST)" == "x" ]]; then echo "no host given, aborting"; exit 1; fi echo "!Deploying to $(HOST) using $(CONFIG) config!" $(RSYNCCMD) dist/web/$(CONFIG)/ root@$(HOST):$(DESTDIR) @@ -90,5 +92,7 @@ nuget_restore: nuget_update: for prj in ITContentProvider NpgsqlBlogProvider NpgsqlContentProvider NpgsqlMRPProviders Presta SalesCatalog TestAPI web WebControls yavscclient yavscModel; do nuget update "$${prj}/packages.config" ; done +syncall: rsync_lua rsync_pre rsync_prod rsync_totempre rsync_totemprod + diff --git a/NpgsqlContentProvider/ChangeLog b/NpgsqlContentProvider/ChangeLog index bed69b58..2ca38b25 100644 --- a/NpgsqlContentProvider/ChangeLog +++ b/NpgsqlContentProvider/ChangeLog @@ -1,3 +1,10 @@ +2015-11-30 Paul Schneider + + * NpgsqlContentProvider.cs: Renseigne le code APE et la côte + au profile préstataire + + * NpgsqlSkillProvider.cs: refabrication + 2015-11-28 Paul Schneider * NpgsqlContentProvider.cs: implemente un listing des diff --git a/NpgsqlContentProvider/NpgsqlContentProvider.cs b/NpgsqlContentProvider/NpgsqlContentProvider.cs index 2ee8fd71..9a2f2e0f 100644 --- a/NpgsqlContentProvider/NpgsqlContentProvider.cs +++ b/NpgsqlContentProvider/NpgsqlContentProvider.cs @@ -54,6 +54,8 @@ namespace Yavsc profile.Id = rdr.GetInt64 (0); profile.UserName = rdr.GetString (1); profile.EMail = rdr.GetString (2); + profile.MEACode = MEACode; + profile.Rate = rdr.GetInt32 (3); result.Add (profile); } } @@ -154,11 +156,11 @@ namespace Yavsc cnx.Open (); using (NpgsqlCommand cmd = cnx.CreateCommand ()) { cmd.CommandText = "insert into activity (meacode,title,applicationname,cmnt) " + - " values (:code,:title,:app,:cmt)"; + " values (:code,:title,:app,:cmnt)"; cmd.Parameters.AddWithValue ("code", code); cmd.Parameters.AddWithValue ("title", activity); cmd.Parameters.AddWithValue ("app", applicationName); - cmd.Parameters.AddWithValue ("cmt", comment); + cmd.Parameters.AddWithValue ("cmnt", comment); cmd.ExecuteNonQuery (); } cnx.Close (); diff --git a/NpgsqlContentProvider/NpgsqlSkillProvider.cs b/NpgsqlContentProvider/NpgsqlSkillProvider.cs index 4447d582..6242cd88 100644 --- a/NpgsqlContentProvider/NpgsqlSkillProvider.cs +++ b/NpgsqlContentProvider/NpgsqlSkillProvider.cs @@ -72,6 +72,27 @@ namespace WorkFlowProvider var profile = new PerformerProfile (username); using (NpgsqlConnection cnx = new NpgsqlConnection (connectionString)) { cnx.Open (); + + using (NpgsqlCommand cmd = cnx.CreateCommand ()) { + cmd.CommandText = + "select p.uniqueid, d.rate, d.MEACode, u.email " + + " from users u, profiles p, profiledata d where " + + " u.username = :user and u.applicationname = :app " + + " and p.username = u.username " + + " and p.applicationname = u.applicationname " + + " and p.uniqueid = d.uniqueid "; + cmd.Parameters.AddWithValue ("user", NpgsqlTypes.NpgsqlDbType.Varchar, username); + cmd.Parameters.AddWithValue ("app", NpgsqlTypes.NpgsqlDbType.Varchar, applicationName); + + using (var rdr = cmd.ExecuteReader ()) { + rdr.Read (); + profile.Id = rdr.GetInt64 (0); + profile.Rate = rdr.GetInt32 (1); + profile.MEACode = rdr.GetString (2); + profile.EMail = rdr.GetString (3); + } + } + using (NpgsqlCommand cmd = cnx.CreateCommand ()) { cmd.CommandText = " select u._id, u.skillid, s.name, " + @@ -79,10 +100,13 @@ namespace WorkFlowProvider " skill s " + " where u.skillid = s._id and " + " u.username = :uname " + - " and applicationname = :app " + - " order by u.rate desc"; + " and s.applicationname = u.applicationname " + + " and s.applicationname = :app " + + " and s.meacode = :mea " + + " order by u.rate desc "; cmd.Parameters.AddWithValue ("uname", NpgsqlTypes.NpgsqlDbType.Varchar, username); cmd.Parameters.AddWithValue ("app", NpgsqlTypes.NpgsqlDbType.Varchar, applicationName); + cmd.Parameters.AddWithValue ("mea", NpgsqlTypes.NpgsqlDbType.Varchar, profile.MEACode); cmd.Prepare (); using (var rdr = cmd.ExecuteReader ()) { if (rdr.HasRows) @@ -98,20 +122,7 @@ namespace WorkFlowProvider profile.Skills = skills.ToArray (); } } - using (NpgsqlCommand cmd = cnx.CreateCommand ()) { - cmd.CommandText = - "select p.uniqueid, d.rate from profiles p, profiledata d where " + - " username = :user and applicationname = :app " + - " and p.uniqueid = d.uniqueid "; - cmd.Parameters.AddWithValue ("user", NpgsqlTypes.NpgsqlDbType.Varchar, username); - cmd.Parameters.AddWithValue ("app", NpgsqlTypes.NpgsqlDbType.Varchar, applicationName); - using (var rdr = cmd.ExecuteReader ()) { - rdr.Read (); - profile.Id = rdr.GetInt64 (0); - profile.Rate = rdr.GetInt32 (1); - } - } cnx.Close (); } return profile; @@ -164,6 +175,8 @@ namespace WorkFlowProvider cnx.Open (); if (userskill.Id == 0) { using (NpgsqlCommand cmd = cnx.CreateCommand ()) { + if (userskill.Comment == null) + userskill.Comment = ""; cmd.CommandText = "insert into userskills" + " (username, applicationname, skillid, rate, comment) " + " values (:uname,:app,:sid,:rate,:cmnt) returning _id"; @@ -185,7 +198,7 @@ namespace WorkFlowProvider " set rate = :rate," + " comment = :cmnt) " + " where _id = :usid "; - cmd.Parameters.AddWithValue ("comment", + cmd.Parameters.AddWithValue ("cmnt", NpgsqlTypes.NpgsqlDbType.Varchar, userskill.Comment); cmd.Parameters.AddWithValue ("rate", NpgsqlTypes.NpgsqlDbType.Integer, userskill.Rate); @@ -247,7 +260,7 @@ namespace WorkFlowProvider /// or a rating engine /// /// Skill. - public override void Rate (SkillRating skill) + public override void Rate (AuthentificatedSkillRating skill) { // TODO Use the Author value to choose // between a global setting for the application @@ -316,56 +329,73 @@ namespace WorkFlowProvider /// Finds the performer. /// /// The performer. - /// Skill identifiers. - public override string[] FindPerformer (long[] skillIds) + /// MEACode. + /// Skills. + public override string[] FindPerformer (string MEACode, SkillRating [] skills) { var res = new List (); using (NpgsqlConnection cnx = new NpgsqlConnection (connectionString)) { cnx.Open (); - using (NpgsqlCommand cmd = cnx.CreateCommand ()) { - - cmd.CommandText = " select u.username " + - " from userskills s, profiledata p, profile q, users u " + - " where s.username = u.username " + - " and s.applicationname = u.applicationanme " + - " and s.skillid = :sid " + - " and u.username = q.username " + - " and u.applicationname = q.applicationanme " + - " and p.uniqueid = q.uniqueid " + - " and u.applicationanme = :app " + - " and u.islockedout = FALSE " + - " and u.isapproved = TRUE " + - " order by s.rate desc "; - + if (skills != null) { + using (NpgsqlCommand cmd = cnx.CreateCommand ()) { - cmd.Parameters.AddWithValue ("sid", NpgsqlDbType.Bigint, 0); - cmd.Prepare (); + // on cherche ici simplement les prestataires + // ayant déclaré les compétences spécifiées. - foreach (long sid in skillIds) { - cmd.Parameters ["sid"].Value = sid; - using (var rdr = cmd.ExecuteReader ()) { - string uname = rdr.GetString (0); - if (!res.Contains (uname)) - res.Add (uname); + cmd.CommandText = @" select u.username + from userskills s, profiledata p, profiles q, users u + where s.username = u.username + and s.applicationname = u.applicationname + and s.skillid = :sid + and p.meacode = :mea + and u.username = q.username + and u.applicationname = q.applicationname + and p.uniqueid = q.uniqueid + and u.applicationname = :app + and u.islockedout = FALSE + and u.isapproved = TRUE +order by s.rate desc "; + cmd.Parameters.AddWithValue ("sid", NpgsqlDbType.Bigint, 0); + cmd.Parameters.AddWithValue ("app", NpgsqlDbType.Varchar, applicationName); + cmd.Parameters.AddWithValue ("mea", NpgsqlDbType.Varchar, MEACode); + cmd.Prepare (); + foreach (SkillRating skill in skills) { + cmd.Parameters ["sid"].Value = skill.Id; + using (var rdr = cmd.ExecuteReader ()) { + while (rdr.Read ()) { + string uname = rdr.GetString (0); + if (!res.Contains (uname)) + res.Add (uname); + } + } } } - // TODO implement a configuration parameter - if (res.Count < 10) { + } + if (res.Count < 10) { + using (NpgsqlCommand cmd = cnx.CreateCommand ()) { + // Si on a trouvé trop peu de prestataire ayant + // déclaré ces compétences (moins de 10), + // On en cherche un ayant + // simplement déclaré avoir l'activité + // concernée. + // TODO implement a configuration parameter : + cmd.CommandText = " select u.username " + - " from skill s, profiledata p , profile q, users u " + + " from profiledata p, profiles q, users u " + " where u.username = q.username " + - " and u.applicationname = q.applicationanme " + + " and u.applicationname = q.applicationname " + " and p.uniqueid = q.uniqueid " + - " and p.meacode = s.meacode " + - " and s._id = :sid " + - " and u.applicationanme = :app " + + " and p.meacode = :mea " + + " and u.applicationname = :app " + " and u.islockedout = FALSE " + - " and u.isapproved = TRUE" + - " order by s.rate desc " ; - foreach (long sid in skillIds) { - cmd.Parameters ["sid"].Value = sid; - using (var rdr = cmd.ExecuteReader ()) { + " and u.isapproved = TRUE " + + " order by p.rate desc " ; + cmd.Parameters.AddWithValue ("app", NpgsqlDbType.Varchar, applicationName); + cmd.Parameters.AddWithValue ("mea", NpgsqlDbType.Varchar, MEACode); + + using (var rdr = cmd.ExecuteReader ()) { + while (rdr.Read ()) { string uname = rdr.GetString (0); if (!res.Contains (uname)) res.Add (uname); diff --git a/WebControls/ChangeLog b/WebControls/ChangeLog index 9fe72373..4b1d0a14 100644 --- a/WebControls/ChangeLog +++ b/WebControls/ChangeLog @@ -1,3 +1,8 @@ +2015-11-30 Paul Schneider + + * ResultPages.cs: ajoute une classe css au bloc de liens vers + les autres pages de resultat + 2015-11-26 Paul Schneider * WebControls.csproj: nouvelles configurations de déploiement diff --git a/WebControls/ResultPages.cs b/WebControls/ResultPages.cs index 46e756fb..9d58a809 100644 --- a/WebControls/ResultPages.cs +++ b/WebControls/ResultPages.cs @@ -17,7 +17,6 @@ namespace Yavsc.WebControls AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal), ParseChildren (true), - ToolboxData ("<{0}:ResultPages runat=\"server\"> ") ] public class ResultPages: WebControl @@ -156,10 +155,17 @@ namespace Yavsc.WebControls /// Writer. protected override void RenderContents (HtmlTextWriter writer) { + // avoids a division by zero + if (PageSize <= 0) + PageSize = 5; + if (ResultCount > 0 && ResultCount > PageSize ) { writer.WriteEncodedText (Text); int pageCount = ((ResultCount-1) / PageSize) + 1; if ( pageCount > 1 ) { + if (!string.IsNullOrWhiteSpace(CssClass)) + writer.AddAttribute ("class", this.CssClass); + writer.RenderBeginTag ("div"); writer.Write (PagesLabel); for (int pi = (PageIndex < 5) ? 0 : PageIndex - 5; pi < pageCount && pi < PageIndex + 5; pi++) { if (PageIndex == pi) @@ -173,6 +179,8 @@ namespace Yavsc.WebControls writer.RenderEndTag (); writer.Write (" "); } + RenderChildren (writer); + writer.RenderEndTag (); } else { writer.Write (SinglePage); @@ -181,7 +189,6 @@ namespace Yavsc.WebControls if (ResultCount == 0) { writer.Write (None); } - } } } diff --git a/web/ApiControllers/FrontOfficeController.cs b/web/ApiControllers/FrontOfficeController.cs index 082cd526..f3f05158 100644 --- a/web/ApiControllers/FrontOfficeController.cs +++ b/web/ApiControllers/FrontOfficeController.cs @@ -202,7 +202,7 @@ namespace Yavsc.ApiControllers /// /// Skill rating. [Authorize()] - public void RateSkill (SkillRating rate) { + public void RateSkill (AuthentificatedSkillRating rate) { throw new NotImplementedException (); } } diff --git a/web/ApiControllers/SkillController.cs b/web/ApiControllers/SkillController.cs index fac24dd7..b7cebda6 100644 --- a/web/ApiControllers/SkillController.cs +++ b/web/ApiControllers/SkillController.cs @@ -74,7 +74,7 @@ namespace Yavsc.ApiControllers /// /// Skill rating. [Authorize()] - public void RateSkill (SkillRating rate) { + public void RateSkill (AuthentificatedSkillRating rate) { SkillManager.RateSkill(User.Identity.Name,rate); } @@ -91,9 +91,11 @@ namespace Yavsc.ApiControllers /// Finds the performer. /// /// The performer. - /// Skill identifiers. - public string [] FindPerformer (long []skillIds){ - return SkillManager.FindPerformer(skillIds); + /// MEA Code. + /// Skill ratings. + public string [] FindPerformer (string MEACode, SkillRating []skills) + { + return SkillManager.FindPerformer(MEACode, skills); } /// /// Deletes the skill. diff --git a/web/App_Themes/dark/style.css b/web/App_Themes/dark/style.css index 3a45b06a..6594a297 100644 --- a/web/App_Themes/dark/style.css +++ b/web/App_Themes/dark/style.css @@ -17,6 +17,7 @@ body { background-color: rgba(20,20,20,.8); color: yellow; } + .rate:hover { border-color: green; background-color:rgba(30,0,124,0.9); } @@ -181,6 +182,7 @@ header h1, header a , .actionlink, .menuitem, a { padding:.5em;} .usertitleref{ padding:.3em; } + .bshpanel { cursor:zoom-in; } .c2 { display:initial; } diff --git a/web/App_Themes/style.css b/web/App_Themes/style.css index fc9ab5e0..65f836c0 100644 --- a/web/App_Themes/style.css +++ b/web/App_Themes/style.css @@ -14,6 +14,8 @@ body.loading .modal { border-radius:1em; border-style: solid; border-width: 1px; + padding:.2em; + display: inline-block; } header { @@ -273,7 +275,7 @@ input, select, textarea { padding:5px; margin:5px; background-color: rgba(0,0,40,.8); } -.skillname { +.skillname, .performer, .usercard, .pagelink { padding:.5em; margin:.25em; max-width: 24em; @@ -282,6 +284,7 @@ input, select, textarea { border-radius:1em; border-style: solid; border-width: 1px; + font-size: large; } .input-validation-error { border: solid 1px red; background-color: rgba(180,256,256,.5); } diff --git a/web/ChangeLog b/web/ChangeLog index efacd404..396e7c96 100644 --- a/web/ChangeLog +++ b/web/ChangeLog @@ -1,3 +1,21 @@ +2015-11-30 Paul Schneider + + * SkillController.cs: + * FrontOfficeController.cs: refabrication + + * style.css: mise en forme du code + + * style.css: du style + + * Booking.aspx: + * FrontOfficeController.cs: Modifie la recherche des + prestataire, pour qu'un resultat soit donné dès qu'un + utilisateur est déclaré prestataire. + + * Title.aspx: + * YavscHelpers.cs: ajoute une classe css au bloc de liens vers + les autres pages de resultat + 2015-11-28 Paul Schneider * p8-av4.xxs.jpg: diff --git a/web/Controllers/FrontOfficeController.cs b/web/Controllers/FrontOfficeController.cs index 9c1e9f82..b6c59bb7 100644 --- a/web/Controllers/FrontOfficeController.cs +++ b/web/Controllers/FrontOfficeController.cs @@ -321,7 +321,7 @@ namespace Yavsc.Controllers // actually performed via the Web API :-° // else if (ModelState.IsValid) {} var usp = SkillManager.GetUserSkills (id); - var skills = SkillManager.FindSkill ("%"); + var skills = SkillManager.FindSkill ("%",usp.MEACode); ViewData ["SiteSkills"] = skills; return View (usp); } @@ -346,7 +346,8 @@ namespace Yavsc.Controllers var result = new List (); foreach (string meacode in model.MEACodes) { - foreach (PerformerProfile profile in WorkFlowManager.FindPerformer(meacode)) { + foreach (PerformerProfile profile in WorkFlowManager.FindPerformer(meacode,null)) { + if (profile.HasCalendar()) try { var events = ProfileBase.Create (profile.UserName).GetEvents (model.StartDate, model.EndDate); if (events.items.Length == 0) @@ -376,25 +377,34 @@ namespace Yavsc.Controllers /// /// Booking the specified model. /// - /// MEA Code. /// Model. public ActionResult Booking (SimpleBookingQuery model) { - + // assert (model.MEACode!=null), since it's the required part of the route data + var needs = SkillManager.FindSkill ("%", model.MEACode); + var specification = new List (); + ViewData ["Needs"] = needs; + if (model.Need != null) { + if (model.Need != "none") + foreach (string specitem in model.Need.Split(',')) { + string[] specvals = specitem.Split (' '); + specification.Add (new SkillRating () { Id = long.Parse (specvals [0]), + Rate = int.Parse (specvals [1]) + }); + } + } // In order to present this form // with no need selected and without // validation error display, // we only check the need here, not at validation time. // Although, the need is indeed cruxial requirement, // but we already have got a MEA code - if (ModelState.IsValid) - if (model.Needs != null) { + if (ModelState.IsValid && model.Need!=null) { var result = new List (); - foreach (PerformerProfile profile in WorkFlowManager.FindPerformer(model.MEACode)) { + foreach (PerformerProfile profile in WorkFlowManager.FindPerformer(model.MEACode,specification.ToArray())) if (profile.HasCalendar ()) { try { - var events = ProfileBase.Create (profile.UserName) - .GetEvents ( + var events = ProfileBase.Create (profile.UserName).GetEvents ( model.PreferedDate.Date, model.PreferedDate.AddDays (1).Date); // TODO replace (events.items.Length == 0) @@ -406,17 +416,17 @@ namespace Yavsc.Controllers } } else result.Add (profile.CreateAvailability (model.PreferedDate, false)); - - } return View ("Performers", result.ToArray ()); - } else { - // A first Get - var needs = SkillManager.FindSkill ("%", model.MEACode); - ViewData ["Needs"] = needs; - model.Needs = needs.Select ( - x => string.Format ("{0}:{1}", x.Id, x.Rate)).ToArray (); + } + if (model.Need==null) { + // A first Get, or no skill available + model.Need = + string.Join(",", needs.Select (x => string.Format ("{0}:{1}", x.Id, x.Rate)).ToArray ()); + if (string.IsNullOrWhiteSpace (model.Need)) + model.Need = "none"; + } - + var activity = WorkFlowManager.GetActivity (model.MEACode); ViewData ["Activity"] = activity; ViewData ["Title"] = activity.Title; diff --git a/web/Helpers/YavscHelpers.cs b/web/Helpers/YavscHelpers.cs index 6bdeeb70..46a750c0 100644 --- a/web/Helpers/YavscHelpers.cs +++ b/web/Helpers/YavscHelpers.cs @@ -299,23 +299,33 @@ namespace Yavsc.Helpers /// /// The page links. /// Helper. - /// Result count. - /// Page size. /// Page index. + /// Page size. + /// Result count. + /// Arguments. + /// Pages label. + /// Single page. + /// None. + /// Css class. public static IHtmlString RenderPageLinks ( this HtmlHelper helper, int PageIndex, int PageSize, int ResultCount, string args="?PageIndex={0}", string pagesLabel="Pages: ", string singlePage="", - string none="néant" + string none="néant", string cssClass = "pagelink" ) { StringWriter strwr = new StringWriter (); HtmlTextWriter writer = new HtmlTextWriter(strwr); - + if (PageSize <= 0) + PageSize = 0; if (ResultCount > 0 && ResultCount > PageSize ) { int pageCount = ((ResultCount-1) / PageSize) + 1; if ( pageCount > 1 ) { + + if (cssClass!=null) + writer.AddAttribute ("class", cssClass); + writer.RenderBeginTag ("div"); writer.WriteEncodedText (pagesLabel); for (int pi = (PageIndex < 5) ? 0 : PageIndex - 5; pi < pageCount && pi < PageIndex + 5; pi++) { if (PageIndex == pi) @@ -329,6 +339,7 @@ namespace Yavsc.Helpers writer.RenderEndTag (); writer.Write (" "); } + writer.RenderEndTag (); } else { writer.Write (singlePage); diff --git a/web/Views/Blogs/Title.aspx b/web/Views/Blogs/Title.aspx index c86c08bd..b1ee2344 100644 --- a/web/Views/Blogs/Title.aspx +++ b/web/Views/Blogs/Title.aspx @@ -18,7 +18,7 @@ if (((int) ViewData["ResultCount"]) > ((int) ViewData["PageSize"])) { rp1.PageIndex = (int) ViewData["PageIndex"]; rp1.PageSize = (int) ViewData["PageSize"]; %>