diff --git a/ChangeLog b/ChangeLog index 1fd8b17a..f6a52348 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2015-08-14 Paul Schneider + + * README.md: blanked: not clear enough + 2015-07-17 Paul Schneider * Yavsc.sln: diff --git a/README.md b/README.md index 24a2a394..7c897da6 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,4 @@ yavsc ===== -Yet Another Very Small Company - -For the moment, overall a little home made blogging system. - -Le but serait un SI gérant différents type de services, par exemple : - -- Dépannage informatique -- Développement logiciel -- Developpement Web -- Audit de sécurité -- Dématérialisation des documents - -Les livrables : - -- Un site web ASP.Net propulsé par Mono et Apache, et une application mobile pour - * demander un devis - * demander une intervention / saisir un ticket - * avoir un status des projets des clients - * avoir un status des ticket du client - -Les commandes : c'est une notion liée à celles -- de catalogue, d'article, d'options -- d'acteurs, de ressources humaines -- d'étapes inter dépendantes, de leurs attributs, de leurs états -- des dates butoires - -Voir aussi: - http://yavsc.pschneider.fr/Blogs/UserPost/paul/Documentation \ No newline at end of file +[doc-fr](http://yavsc.pschneider.fr/Blogs/UserPost/paul/Documentation) diff --git a/web/ChangeLog b/web/ChangeLog index 5a5f7064..457d3e58 100644 --- a/web/ChangeLog +++ b/web/ChangeLog @@ -1,3 +1,8 @@ +2015-08-14 Paul Schneider + + * FileSystemController.cs: Fixes the route to user's Files by + an Admin. + 2015-08-05 Paul Schneider * style.css: Gives a margin to the login panel diff --git a/web/Controllers/FileSystemController.cs b/web/Controllers/FileSystemController.cs index 8cc59001..cc448601 100644 --- a/web/Controllers/FileSystemController.cs +++ b/web/Controllers/FileSystemController.cs @@ -31,96 +31,37 @@ namespace Yavsc.Controllers /// Index this instance. /// [Authorize] - public ActionResult Index (string id) + public ActionResult Index (string user, string filename) { FileSystemManager fsmgr = new FileSystemManager (); - var files = fsmgr.GetFiles (id); - files.Owner = Membership.GetUser ().UserName; + var files = fsmgr.GetFiles (user,filename); return View (files); } /// - /// Details the specified id. + /// Post the specified id. /// /// Identifier. - public ActionResult Details (string id) + public ActionResult Post (string id) { - - foreach (char x in Path.GetInvalidPathChars()) { - if (id.Contains (x)) { - ViewData ["Message"] = - string.Format ( - "Something went wrong following the following path : {0} (\"{1}\")", - id, x); - return RedirectToAction ("Index"); - } - } - FileSystemManager fsmgr = new FileSystemManager (); - FileInfo fi = fsmgr.FileInfo (id); - - ViewData ["id"] = id; - // TODO : ensure that we use the default port for - // the used sheme - ViewData ["url"] = - string.Format( - "{0}://{1}/users/{2}/{3}", - Request.Url.Scheme, - Request.Url.Authority, - Membership.GetUser ().UserName , - id ); - return View (fi); + return View (); } /// - /// Create the specified id. + /// Details the specified user and filename. /// - /// Identifier. - [HttpPost] - [Authorize] - public ActionResult Create (string id) + /// User. + /// Filename. + public ActionResult Details (string user, string filename) { FileSystemManager fsmgr = new FileSystemManager (); - return View ("Index",fsmgr.GetFiles(id)); - } - - /// - /// Edit the specified id. - /// - /// Identifier. - public ActionResult Edit (int id) - { - throw new NotImplementedException (); - } - - /// - /// Edit the specified id and collection. - /// - /// Identifier. - /// Collection. - [HttpPost] - public ActionResult Edit (int id, FormCollection collection) - { - throw new NotImplementedException (); - } + FileInfo fi = fsmgr.FileInfo (filename); - /// - /// Delete the specified id. - /// - /// Identifier. - public ActionResult Delete (int id) - { - throw new NotImplementedException (); - } - - /// - /// Delete the specified id and collection. - /// - /// Identifier. - /// Collection. - [HttpPost] - public ActionResult Delete (int id, FormCollection collection) - { - throw new NotImplementedException (); + ViewData ["filename"] = filename; + // TODO : ensure that we use the default port for + // the used sheme + ViewData ["url"] = Url.Content("~/users/"+user+"/"+filename); + return View (fi); } } } \ No newline at end of file diff --git a/yavscModel/ChangeLog b/yavscModel/ChangeLog index c1c4323e..3185eb96 100644 --- a/yavscModel/ChangeLog +++ b/yavscModel/ChangeLog @@ -1,3 +1,14 @@ +2015-08-14 Paul Schneider + + * FileSystemManager.cs: * Fixes the dir separator usage + * Adds a method to validate a directory or file name + + * YavscModel.csproj: + * Commande.cs: FileInfoCollection is now removed + + * FileInfoCollection.cs: + * DirNotFoundException.cs: Removes useless code + 2015-08-05 Paul Schneider * BlogEntryCollection.cs: adds xml doc diff --git a/yavscModel/FileSystem/DirNotFoundException.cs b/yavscModel/FileSystem/DirNotFoundException.cs deleted file mode 100644 index f3979286..00000000 --- a/yavscModel/FileSystem/DirNotFoundException.cs +++ /dev/null @@ -1,46 +0,0 @@ -// -// DirNotFoundException.cs -// -// Author: -// Paul Schneider -// -// Copyright (c) 2015 Paul Schneider -// -// 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.IO; -using System.Web; -using System.Text.RegularExpressions; -using System.Text; -using System.Web.Security; - -namespace Yavsc.Model.FileSystem -{ - - /// - /// Dir not found exception. - /// - public class DirNotFoundException : Exception { - /// - /// Initializes a new instance of the class. - /// - /// Dir. - public DirNotFoundException(string dir) - : base(string.Format( "Directory not found : {0}", dir)) - { - } - } - -} diff --git a/yavscModel/FileSystem/FileInfoCollection.cs b/yavscModel/FileSystem/FileInfoCollection.cs deleted file mode 100644 index f29be3ab..00000000 --- a/yavscModel/FileSystem/FileInfoCollection.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using System.IO; -using System.Collections.Generic; - -namespace Yavsc.Model.FileSystem -{ - /// - /// File info collection. - /// - public class FileInfoCollection: List - { - /// - /// Gets or sets the owner. - /// - /// The owner. - public string Owner { get; set; } - /// - /// Initializes a new instance of the class. - /// - /// Files. - public FileInfoCollection (FileInfo [] files) - { - AddRange (files); - } - } -} - diff --git a/yavscModel/FileSystem/FileSystemManager.cs b/yavscModel/FileSystem/FileSystemManager.cs index d335ed33..4eaf8d29 100644 --- a/yavscModel/FileSystem/FileSystemManager.cs +++ b/yavscModel/FileSystem/FileSystemManager.cs @@ -56,18 +56,37 @@ namespace Yavsc.Model.FileSystem /// /// Initializes a new instance of the class. /// - public FileSystemManager (string rootDirectory="~/users/{0}", char dirSep = '/') + public FileSystemManager (string rootDirectory="~/users/{0}") { MembershipUser user = Membership.GetUser (); if (user == null) throw new Exception ("Not membership available"); Prefix = HttpContext.Current.Server.MapPath ( string.Format (rootDirectory, user.UserName)); - DirectorySeparator = dirSep; } + /// + /// Initializes a new instance of the class. + /// + public FileSystemManager (string username, string rootDirectory="~/users/{0}") + { + Prefix = HttpContext.Current.Server.MapPath ( + string.Format (rootDirectory, username)); + } string regexFileName = "^[A-Za-z0-9#^!+ _~\\-.]+$"; - + /// + /// Determines if the specified name is OK. + /// + /// true if is this name O the specified name; otherwise, false. + /// Name. + public static bool IsThisNameOK(string name) + { + foreach (char x in Path.GetInvalidPathChars()) { + if (name.Contains (x)) + return false; + } + return true; + } /// /// Put the specified files in destDir, as sub dir of the current user's home dir. /// @@ -86,7 +105,7 @@ namespace Yavsc.Model.FileSystem } // do the job - checkSubDir (destDir); + CheckSubDir (destDir); DirectoryInfo di = new DirectoryInfo ( Path.Combine (Prefix, destDir)); if (!di.Exists) @@ -114,45 +133,50 @@ namespace Yavsc.Model.FileSystem prefix = value; } } - /// - /// Gets or sets the directory name separator. - /// - /// The separator. - public char DirectorySeparator { get; set; } - - /// - /// Checks the sub dir name. + /// Checks the sub dir name against model specifications, + /// concerning the allowed character class. /// /// Subdir. - private void checkSubDir (string subdir) + private void CheckSubDir (string subdir) { - foreach (string dirname in subdir.Split(DirectorySeparator)) + foreach (string dirname in subdir.Split(Path.DirectorySeparatorChar)) { if (!Regex.Match (dirname, regexFileName).Success) throw new InvalidDirNameException (dirname); - foreach (char x in Path.GetInvalidPathChars()) - if (subdir.Contains (x)) - throw new InvalidDirNameException (subdir); + foreach (char x in dirname) + if (subdir.Contains (x)) + throw new InvalidDirNameException (subdir); + } } /// - /// Gets the files. + /// Gets the files owned by the current logged user. /// The web user must be authenticated, /// The given username must be registered. /// /// The files. /// Subdir. - public FileInfoCollection GetFiles (string subdir) + public IEnumerable GetFiles (string subdir) { string path = Prefix; if (subdir != null) { - checkSubDir (subdir); // checks for specification validity + CheckSubDir (subdir); // checks for specification validity path = Path.Combine (Prefix, subdir); } DirectoryInfo di = new DirectoryInfo (path); - FileInfoCollection res = new FileInfoCollection (di.GetFiles ()); - // TODO define an Owner - return res; + return (di.GetFiles ()); } + + public IEnumerable GetFiles (string username, string subdir) + { + string path = Prefix; + if (subdir != null) { + CheckSubDir (subdir); // checks for specification validity + path = Path.Combine (Prefix, subdir); + } + DirectoryInfo di = new DirectoryInfo (path); + return (di.GetFiles ()); + } + /// /// Files the info. /// @@ -160,7 +184,7 @@ namespace Yavsc.Model.FileSystem /// Identifier. public FileInfo FileInfo(string id) { - checkSubDir (id); + CheckSubDir (id); return new FileInfo(Path.Combine (Prefix, id)); } } diff --git a/yavscModel/FrontOffice/Commande.cs b/yavscModel/FrontOffice/Commande.cs index 2fd55c9e..bef3930b 100644 --- a/yavscModel/FrontOffice/Commande.cs +++ b/yavscModel/FrontOffice/Commande.cs @@ -5,6 +5,7 @@ using Yavsc.Model.WorkFlow; using Yavsc.Model.FileSystem; using System.Web; using System.Collections.Generic; +using System.IO; namespace Yavsc.Model.FrontOffice @@ -43,7 +44,7 @@ namespace Yavsc.Model.FrontOffice /// public Dictionary Parameters = new Dictionary (); - FileInfoCollection Files { + IEnumerable Files { get { return GetFSM().GetFiles (Id.ToString()); } diff --git a/yavscModel/YavscModel.csproj b/yavscModel/YavscModel.csproj index c6571bf5..9fdbfdb4 100644 --- a/yavscModel/YavscModel.csproj +++ b/yavscModel/YavscModel.csproj @@ -46,7 +46,6 @@ - @@ -113,7 +112,6 @@ -