diff --git a/NpgsqlBlogProvider/NpgsqlBlogProvider.csproj b/NpgsqlBlogProvider/NpgsqlBlogProvider.csproj index 70a0e7bf..6992eeee 100644 --- a/NpgsqlBlogProvider/NpgsqlBlogProvider.csproj +++ b/NpgsqlBlogProvider/NpgsqlBlogProvider.csproj @@ -30,12 +30,6 @@ - - - - - - diff --git a/SalesCatalog/SalesCatalog.csproj b/SalesCatalog/SalesCatalog.csproj index ed2eb8bd..84c1e97f 100644 --- a/SalesCatalog/SalesCatalog.csproj +++ b/SalesCatalog/SalesCatalog.csproj @@ -31,9 +31,7 @@ - - nunit - + diff --git a/SalesCatalog/XmlImplementation/XmlCatalogProvider.cs b/SalesCatalog/XmlImplementation/XmlCatalogProvider.cs index bd410b76..95b18e5d 100644 --- a/SalesCatalog/XmlImplementation/XmlCatalogProvider.cs +++ b/SalesCatalog/XmlImplementation/XmlCatalogProvider.cs @@ -15,13 +15,16 @@ namespace SalesCatalog.XmlImplementation { // Assert fileName != null FileInfo fi = new FileInfo (fileName); + if (!fi.Exists) + throw new ConfigurationErrorsException( + string.Format("No catalog found ({0})",fileName)); if (fi.LastWriteTime > lastModification) LoadCatalog (); return catInstance; } protected XmlCatalog catInstance = null; - protected DateTime lastModification; + protected DateTime lastModification = new DateTime(0); protected string fileName = null; #endregion @@ -32,8 +35,9 @@ namespace SalesCatalog.XmlImplementation } private void LoadCatalog () { + try { FileInfo fi = new FileInfo (fileName); - if (!fi.Exists) + if (!fi.Exists) throw new Exception ( string.Format ("Le fichier Xml decrivant le catalogue n'existe pas ({0})", fi.FullName)); XmlSerializer xsr = new XmlSerializer (typeof(XmlCatalog),new Type[]{ @@ -49,6 +53,11 @@ namespace SalesCatalog.XmlImplementation } fileName = fi.FullName; lastModification = fi.LastWriteTime; + } + catch (Exception e) { + lastModification = new DateTime (0); + throw e; + } } } } diff --git a/WorkFlowProvider/WorkFlowProvider.csproj b/WorkFlowProvider/WorkFlowProvider.csproj index a202af3c..c8f6968e 100644 --- a/WorkFlowProvider/WorkFlowProvider.csproj +++ b/WorkFlowProvider/WorkFlowProvider.csproj @@ -38,10 +38,6 @@ - - - - @@ -50,7 +46,4 @@ YavscModel - - - \ No newline at end of file diff --git a/web/Controllers/AdminController.cs b/web/Controllers/AdminController.cs index 311d3e01..985f1fcc 100644 --- a/web/Controllers/AdminController.cs +++ b/web/Controllers/AdminController.cs @@ -6,11 +6,68 @@ using System.Web.Mvc; using System.Web.Mvc.Ajax; using System.Web.Security; using Yavsc.Model.RolesAndMembers; +using Yavsc.Model.Admin; namespace Yavsc.Controllers { public class AdminController : Controller { + [Authorize(Roles="Admin")] + public ActionResult Index(DataAccess model) + { + return View (model); + } + + [Authorize(Roles="Admin")] + public ActionResult Backups(DataAccess model) + { + return View (model); + } + + [Authorize(Roles="Admin")] + public ActionResult CreateBackup(DataAccess datac) + { + if (datac != null) { + if (ModelState.IsValid) { + if (string.IsNullOrEmpty (datac.Password)) + ModelState.AddModelError ("Password", "Invalid passord"); + DataManager ex = new DataManager (datac); + Export e = ex.CreateBackup (); + if (e.ExitCode > 0) + ModelState.AddModelError ("Password", "Operation Failed"); + return View ("BackupCreated", e); + } + } else { + datac = new DataAccess (); + } + return View (datac); + } + + [Authorize(Roles="Admin")] + public ActionResult CreateUserBackup(DataAccess datac,string username) + { + throw new NotImplementedException(); + } + + [Authorize(Roles="Admin")] + public ActionResult Upgrade(DataAccess datac) { + throw new NotImplementedException(); + } + + [Authorize(Roles="Admin")] + public ActionResult Restore(DataAccess datac,string backupName,bool dataOnly=true) + { + ViewData ["BackupName"] = backupName; + if (ModelState.IsValid) { + DataManager mgr = new DataManager (datac); + ViewData ["BackupName"] = backupName; + ViewData ["DataOnly"] = dataOnly; + TaskOutput t = mgr.Restore (backupName,dataOnly); + return View ("Restored", t); + } + return View (datac); + } + [Authorize(Roles="Admin")] public ActionResult RemoveFromRole(string username, string rolename, string returnUrl) { diff --git a/web/Controllers/BackOfficeController.cs b/web/Controllers/BackOfficeController.cs index ede9f896..85ba60ee 100644 --- a/web/Controllers/BackOfficeController.cs +++ b/web/Controllers/BackOfficeController.cs @@ -4,69 +4,18 @@ using System.Linq; using System.Web; using System.Web.Mvc; using Yavsc.Admin; -using Yavsc.Model.Admin; namespace Yavsc.Controllers { public class BackOfficeController : Controller { - [Authorize(Roles="Admin")] - public ActionResult Index(DataAccess model) + public ActionResult Estimate() { - return View (model); - } - [Authorize(Roles="Admin")] - public ActionResult Backups(DataAccess model) - { - return View (model); } - [Authorize(Roles="Admin")] - public ActionResult CreateBackup(DataAccess datac) + public ActionResult Index () { - if (datac != null) { - if (ModelState.IsValid) { - if (string.IsNullOrEmpty (datac.Password)) - ModelState.AddModelError ("Password", "Invalid passord"); - DataManager ex = new DataManager (datac); - Export e = ex.CreateBackup (); - if (e.ExitCode > 0) - ModelState.AddModelError ("Password", "Operation Failed"); - return View ("BackupCreated", e); - } - } else { - datac = new DataAccess (); - } - return View (datac); } - - [Authorize(Roles="Admin")] - public ActionResult CreateUserBackup(DataAccess datac,string username) - { - throw new NotImplementedException(); - } - - [Authorize(Roles="Admin")] - public ActionResult Upgrade(DataAccess datac) { - throw new NotImplementedException(); - } - - [Authorize(Roles="Admin")] - public ActionResult Restore(DataAccess datac,string backupName,bool dataOnly=true) - { - ViewData ["BackupName"] = backupName; - if (ModelState.IsValid) { - DataManager mgr = new DataManager (datac); - ViewData ["BackupName"] = backupName; - ViewData ["DataOnly"] = dataOnly; - TaskOutput t = mgr.Restore (backupName,dataOnly); - return View ("Restored", t); - } - return View (datac); - } - - /*[Authorize(Roles="Admin")] - public ActionResult Estimate*/ } } diff --git a/web/Controllers/BasketController.cs b/web/Controllers/BasketController.cs index 8dd99552..2b74b7a7 100644 --- a/web/Controllers/BasketController.cs +++ b/web/Controllers/BasketController.cs @@ -42,7 +42,7 @@ namespace Yavsc.ApiControllers [Authorize] public Estimate[] YourEstimates() { - return WorkFlowProvider.WFManager.GetEstimates ( + return WorkFlowManager.GetEstimates ( Membership.GetUser().UserName); } diff --git a/web/Controllers/FrontOfficeApiController.cs b/web/Controllers/FrontOfficeApiController.cs index 830f65b3..0b3a0e75 100644 --- a/web/Controllers/FrontOfficeApiController.cs +++ b/web/Controllers/FrontOfficeApiController.cs @@ -73,7 +73,7 @@ namespace Yavsc.ApiControllers /// Estid. public Estimate GetEstimate (long estid) { - Estimate est = WFManager.ContentProvider.GetEstimate (estid); + Estimate est = WorkFlowManager.ContentProvider.GetEstimate (estid); return est; } diff --git a/web/Controllers/FrontOfficeController.cs b/web/Controllers/FrontOfficeController.cs index 1518e7e2..43b011d4 100644 --- a/web/Controllers/FrontOfficeController.cs +++ b/web/Controllers/FrontOfficeController.cs @@ -22,7 +22,7 @@ namespace Yavsc.Controllers { if (ModelState.IsValid) { if (e.Id > 0) { - Estimate f = WFManager.GetEstimate (e.Id); + Estimate f = WorkFlowManager.GetEstimate (e.Id); if (e.Owner != f.Owner) if (!Roles.IsUserInRole ("FrontOffice")) throw new UnauthorizedAccessException ("You're not allowed to modify this estimate"); diff --git a/web/Controllers/WorkFlowController.cs b/web/Controllers/WorkFlowController.cs index 6e06f6c4..80d85b03 100644 --- a/web/Controllers/WorkFlowController.cs +++ b/web/Controllers/WorkFlowController.cs @@ -29,7 +29,7 @@ namespace Yavsc.ApiControllers [Authorize] public long CreateEstimate (string title) { - return WFManager.CreateEstimate ( + return WorkFlowManager.CreateEstimate ( Membership.GetUser().UserName,title); } @@ -37,20 +37,20 @@ namespace Yavsc.ApiControllers [Authorize] public void DropWritting(long wrid) { - WFManager.DropWritting (wrid); + WorkFlowManager.DropWritting (wrid); } [HttpGet] [Authorize] public void UpdateWritting(Writting wr) { - WFManager.UpdateWritting (wr); + WorkFlowManager.UpdateWritting (wr); } [HttpGet] [Authorize] public void DropEstimate(long estid) { - WFManager.DropEstimate (estid); + WorkFlowManager.DropEstimate (estid); } [HttpGet] [Authorize] @@ -68,7 +68,7 @@ namespace Yavsc.ApiControllers public long Write (long estid, string desc, decimal ucost, int count, long productid=0) { // TODO ensure estid owner matches the current one - return WFManager.Write(estid, desc, ucost, count, productid); + return WorkFlowManager.Write(estid, desc, ucost, count, productid); } diff --git a/web/Views/Account/AddRole.aspx b/web/Views/Admin/AddRole.aspx similarity index 89% rename from web/Views/Account/AddRole.aspx rename to web/Views/Admin/AddRole.aspx index 772712ac..a4a0003c 100644 --- a/web/Views/Account/AddRole.aspx +++ b/web/Views/Admin/AddRole.aspx @@ -2,7 +2,7 @@ <%= Html.ValidationSummary() %> -<% using(Html.BeginForm("DoAddRole", "Account")) %> +<% using(Html.BeginForm("DoAddRole")) %> <% { %> Nom du rôle : <%= Html.TextBox( "RoleName" ) %> diff --git a/web/Views/Account/Admin.aspx b/web/Views/Admin/Admin.aspx similarity index 94% rename from web/Views/Account/Admin.aspx rename to web/Views/Admin/Admin.aspx index a50a8f0a..36e5186a 100644 --- a/web/Views/Account/Admin.aspx +++ b/web/Views/Admin/Admin.aspx @@ -17,7 +17,7 @@

<%= Html.ValidationSummary() %>

-<% using ( Html.BeginForm("Admin", "Account") ) { %> +<% using ( Html.BeginForm("Admin", "Admin") ) { %> <%= Html.LabelFor(model => model.UserName) %> : <%= Html.DropDownListFor(model => model.UserName, (List)ViewData["useritems"] ) %> diff --git a/web/Views/BackOffice/BackupCreated.aspx b/web/Views/Admin/BackupCreated.aspx similarity index 100% rename from web/Views/BackOffice/BackupCreated.aspx rename to web/Views/Admin/BackupCreated.aspx diff --git a/web/Views/BackOffice/Backups.aspx b/web/Views/Admin/Backups.aspx similarity index 58% rename from web/Views/BackOffice/Backups.aspx rename to web/Views/Admin/Backups.aspx index a11783cd..45f6437f 100644 --- a/web/Views/BackOffice/Backups.aspx +++ b/web/Views/Admin/Backups.aspx @@ -1,6 +1,6 @@ <%@ Page Language="C#" MasterPageFile="~/Models/App.master" Inherits="System.Web.Mvc.ViewPage" %> -<%=Html.ActionLink("Create a database backup", "CreateBackup", "BackOffice")%>
-<%=Html.ActionLink("Restaurations", "Restore", "BackOffice")%>
+<%=Html.ActionLink("Create a database backup", "CreateBackup")%>
+<%=Html.ActionLink("Restaurations", "Restore")%>
diff --git a/web/Views/BackOffice/CreateBackup.aspx b/web/Views/Admin/CreateBackup.aspx similarity index 94% rename from web/Views/BackOffice/CreateBackup.aspx rename to web/Views/Admin/CreateBackup.aspx index c9d9ab6e..0f2f22c1 100644 --- a/web/Views/BackOffice/CreateBackup.aspx +++ b/web/Views/Admin/CreateBackup.aspx @@ -1,7 +1,7 @@ <%@ Page Title="Backup creation" Language="C#" MasterPageFile="~/Models/App.master" Inherits="System.Web.Mvc.ViewPage" %> <%= Html.ValidationSummary("CreateBackup") %> -<% using (Html.BeginForm("CreateBackup","BackOffice")) { %> +<% using (Html.BeginForm("CreateBackup")) { %> <%= Html.LabelFor(model => model.Host) %>: <%= Html.TextBox( "Host" ) %> diff --git a/web/Views/BackOffice/Index.aspx b/web/Views/Admin/Index.aspx similarity index 79% rename from web/Views/BackOffice/Index.aspx rename to web/Views/Admin/Index.aspx index 4840f5bd..a97e5e3a 100644 --- a/web/Views/BackOffice/Index.aspx +++ b/web/Views/Admin/Index.aspx @@ -1,4 +1,4 @@ <%@ Page Language="C#" MasterPageFile="~/Models/App.master" Inherits="System.Web.Mvc.ViewPage" %> -<%= Html.ActionLink("Backups","Backups","BackOffice") %> +<%= Html.ActionLink("Backups","Backups") %> diff --git a/web/Views/Account/RemoveRoleQuery.aspx b/web/Views/Admin/RemoveRoleQuery.aspx similarity index 100% rename from web/Views/Account/RemoveRoleQuery.aspx rename to web/Views/Admin/RemoveRoleQuery.aspx diff --git a/web/Views/Account/RemoveUserQuery.aspx b/web/Views/Admin/RemoveUserQuery.aspx similarity index 93% rename from web/Views/Account/RemoveUserQuery.aspx rename to web/Views/Admin/RemoveUserQuery.aspx index 8e5fd740..235d212d 100644 --- a/web/Views/Account/RemoveUserQuery.aspx +++ b/web/Views/Admin/RemoveUserQuery.aspx @@ -7,7 +7,7 @@
<%= Html.ValidationSummary() %> -<% using ( Html.BeginForm("RemoveUser","Account") ) { %> +<% using ( Html.BeginForm("RemoveUser") ) { %> Supprimer l'utilisateur <%= Html.Encode( ViewData["usertoremove"] ) %> ?
diff --git a/web/Views/BackOffice/Restore.aspx b/web/Views/Admin/Restore.aspx similarity index 95% rename from web/Views/BackOffice/Restore.aspx rename to web/Views/Admin/Restore.aspx index ce2c1ba4..2e6853b2 100644 --- a/web/Views/BackOffice/Restore.aspx +++ b/web/Views/Admin/Restore.aspx @@ -1,7 +1,7 @@ <%@ Page Language="C#" MasterPageFile="~/Models/App.master" Inherits="System.Web.Mvc.ViewPage" %> <%= Html.ValidationSummary("Restore a database backup") %> -<% using (Html.BeginForm("Restore","BackOffice")) { %> +<% using (Html.BeginForm("Restore")) { %> <% string [] bckdirs = Model.GetBackupDirs(); %>