* README.md: blanked: not clear enough
* FileSystemController.cs: Fixes the route to user's Files by an Admin. * 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
This commit is contained in:
parent
679a249faf
commit
3fa55acf2e
10 changed files with 86 additions and 202 deletions
|
|
@ -1,3 +1,7 @@
|
||||||
|
2015-08-14 Paul Schneider <paul@pschneider.fr>
|
||||||
|
|
||||||
|
* README.md: blanked: not clear enough
|
||||||
|
|
||||||
2015-07-17 Paul Schneider <paul@pschneider.fr>
|
2015-07-17 Paul Schneider <paul@pschneider.fr>
|
||||||
|
|
||||||
* Yavsc.sln:
|
* Yavsc.sln:
|
||||||
|
|
|
||||||
29
README.md
29
README.md
|
|
@ -1,31 +1,4 @@
|
||||||
yavsc
|
yavsc
|
||||||
=====
|
=====
|
||||||
|
|
||||||
Yet Another Very Small Company
|
[doc-fr](http://yavsc.pschneider.fr/Blogs/UserPost/paul/Documentation)
|
||||||
|
|
||||||
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
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,8 @@
|
||||||
|
2015-08-14 Paul Schneider <paul@pschneider.fr>
|
||||||
|
|
||||||
|
* FileSystemController.cs: Fixes the route to user's Files by
|
||||||
|
an Admin.
|
||||||
|
|
||||||
2015-08-05 Paul Schneider <paul@pschneider.fr>
|
2015-08-05 Paul Schneider <paul@pschneider.fr>
|
||||||
|
|
||||||
* style.css: Gives a margin to the login panel
|
* style.css: Gives a margin to the login panel
|
||||||
|
|
|
||||||
|
|
@ -31,96 +31,37 @@ namespace Yavsc.Controllers
|
||||||
/// Index this instance.
|
/// Index this instance.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public ActionResult Index (string id)
|
public ActionResult Index (string user, string filename)
|
||||||
{
|
{
|
||||||
FileSystemManager fsmgr = new FileSystemManager ();
|
FileSystemManager fsmgr = new FileSystemManager ();
|
||||||
var files = fsmgr.GetFiles (id);
|
var files = fsmgr.GetFiles (user,filename);
|
||||||
files.Owner = Membership.GetUser ().UserName;
|
|
||||||
return View (files);
|
return View (files);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Details the specified id.
|
/// Post the specified id.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id">Identifier.</param>
|
/// <param name="id">Identifier.</param>
|
||||||
public ActionResult Details (string id)
|
public ActionResult Post (string id)
|
||||||
{
|
{
|
||||||
|
return View ();
|
||||||
|
}
|
||||||
|
|
||||||
foreach (char x in Path.GetInvalidPathChars()) {
|
/// <summary>
|
||||||
if (id.Contains (x)) {
|
/// Details the specified user and filename.
|
||||||
ViewData ["Message"] =
|
/// </summary>
|
||||||
string.Format (
|
/// <param name="user">User.</param>
|
||||||
"Something went wrong following the following path : {0} (\"{1}\")",
|
/// <param name="filename">Filename.</param>
|
||||||
id, x);
|
public ActionResult Details (string user, string filename)
|
||||||
return RedirectToAction ("Index");
|
{
|
||||||
}
|
|
||||||
}
|
|
||||||
FileSystemManager fsmgr = new FileSystemManager ();
|
FileSystemManager fsmgr = new FileSystemManager ();
|
||||||
FileInfo fi = fsmgr.FileInfo (id);
|
FileInfo fi = fsmgr.FileInfo (filename);
|
||||||
|
|
||||||
ViewData ["id"] = id;
|
ViewData ["filename"] = filename;
|
||||||
// TODO : ensure that we use the default port for
|
// TODO : ensure that we use the default port for
|
||||||
// the used sheme
|
// the used sheme
|
||||||
ViewData ["url"] =
|
ViewData ["url"] = Url.Content("~/users/"+user+"/"+filename);
|
||||||
string.Format(
|
|
||||||
"{0}://{1}/users/{2}/{3}",
|
|
||||||
Request.Url.Scheme,
|
|
||||||
Request.Url.Authority,
|
|
||||||
Membership.GetUser ().UserName ,
|
|
||||||
id );
|
|
||||||
return View (fi);
|
return View (fi);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Create the specified id.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id">Identifier.</param>
|
|
||||||
[HttpPost]
|
|
||||||
[Authorize]
|
|
||||||
public ActionResult Create (string id)
|
|
||||||
{
|
|
||||||
FileSystemManager fsmgr = new FileSystemManager ();
|
|
||||||
return View ("Index",fsmgr.GetFiles(id));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Edit the specified id.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id">Identifier.</param>
|
|
||||||
public ActionResult Edit (int id)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException ();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Edit the specified id and collection.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id">Identifier.</param>
|
|
||||||
/// <param name="collection">Collection.</param>
|
|
||||||
[HttpPost]
|
|
||||||
public ActionResult Edit (int id, FormCollection collection)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException ();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Delete the specified id.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id">Identifier.</param>
|
|
||||||
public ActionResult Delete (int id)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException ();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Delete the specified id and collection.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id">Identifier.</param>
|
|
||||||
/// <param name="collection">Collection.</param>
|
|
||||||
[HttpPost]
|
|
||||||
public ActionResult Delete (int id, FormCollection collection)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException ();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,3 +1,14 @@
|
||||||
|
2015-08-14 Paul Schneider <paul@pschneider.fr>
|
||||||
|
|
||||||
|
* 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 <paul@pschneider.fr>
|
2015-08-05 Paul Schneider <paul@pschneider.fr>
|
||||||
|
|
||||||
* BlogEntryCollection.cs: adds xml doc
|
* BlogEntryCollection.cs: adds xml doc
|
||||||
|
|
|
||||||
|
|
@ -1,46 +0,0 @@
|
||||||
//
|
|
||||||
// DirNotFoundException.cs
|
|
||||||
//
|
|
||||||
// Author:
|
|
||||||
// Paul Schneider <paulschneider@free.fr>
|
|
||||||
//
|
|
||||||
// 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 <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
using System.Web;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using System.Text;
|
|
||||||
using System.Web.Security;
|
|
||||||
|
|
||||||
namespace Yavsc.Model.FileSystem
|
|
||||||
{
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Dir not found exception.
|
|
||||||
/// </summary>
|
|
||||||
public class DirNotFoundException : Exception {
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="Yavsc.Model.FileSystem.DirNotFoundException"/> class.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="dir">Dir.</param>
|
|
||||||
public DirNotFoundException(string dir)
|
|
||||||
: base(string.Format( "Directory not found : {0}", dir))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace Yavsc.Model.FileSystem
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// File info collection.
|
|
||||||
/// </summary>
|
|
||||||
public class FileInfoCollection: List<FileInfo>
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the owner.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The owner.</value>
|
|
||||||
public string Owner { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="Yavsc.Model.FileSystem.FileInfoCollection"/> class.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="files">Files.</param>
|
|
||||||
public FileInfoCollection (FileInfo [] files)
|
|
||||||
{
|
|
||||||
AddRange (files);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -56,18 +56,37 @@ namespace Yavsc.Model.FileSystem
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="Yavsc.Model.FileSystem.FileSystemManager"/> class.
|
/// Initializes a new instance of the <see cref="Yavsc.Model.FileSystem.FileSystemManager"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public FileSystemManager (string rootDirectory="~/users/{0}", char dirSep = '/')
|
public FileSystemManager (string rootDirectory="~/users/{0}")
|
||||||
{
|
{
|
||||||
MembershipUser user = Membership.GetUser ();
|
MembershipUser user = Membership.GetUser ();
|
||||||
if (user == null)
|
if (user == null)
|
||||||
throw new Exception ("Not membership available");
|
throw new Exception ("Not membership available");
|
||||||
Prefix = HttpContext.Current.Server.MapPath (
|
Prefix = HttpContext.Current.Server.MapPath (
|
||||||
string.Format (rootDirectory, user.UserName));
|
string.Format (rootDirectory, user.UserName));
|
||||||
DirectorySeparator = dirSep;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="Yavsc.Model.FileSystem.FileSystemManager"/> class.
|
||||||
|
/// </summary>
|
||||||
|
public FileSystemManager (string username, string rootDirectory="~/users/{0}")
|
||||||
|
{
|
||||||
|
Prefix = HttpContext.Current.Server.MapPath (
|
||||||
|
string.Format (rootDirectory, username));
|
||||||
|
}
|
||||||
string regexFileName = "^[A-Za-z0-9#^!+ _~\\-.]+$";
|
string regexFileName = "^[A-Za-z0-9#^!+ _~\\-.]+$";
|
||||||
|
/// <summary>
|
||||||
|
/// Determines if the specified name is OK.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns><c>true</c> if is this name O the specified name; otherwise, <c>false</c>.</returns>
|
||||||
|
/// <param name="name">Name.</param>
|
||||||
|
public static bool IsThisNameOK(string name)
|
||||||
|
{
|
||||||
|
foreach (char x in Path.GetInvalidPathChars()) {
|
||||||
|
if (name.Contains (x))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Put the specified files in destDir, as sub dir of the current user's home dir.
|
/// Put the specified files in destDir, as sub dir of the current user's home dir.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -86,7 +105,7 @@ namespace Yavsc.Model.FileSystem
|
||||||
}
|
}
|
||||||
// do the job
|
// do the job
|
||||||
|
|
||||||
checkSubDir (destDir);
|
CheckSubDir (destDir);
|
||||||
DirectoryInfo di = new DirectoryInfo (
|
DirectoryInfo di = new DirectoryInfo (
|
||||||
Path.Combine (Prefix, destDir));
|
Path.Combine (Prefix, destDir));
|
||||||
if (!di.Exists)
|
if (!di.Exists)
|
||||||
|
|
@ -114,45 +133,50 @@ namespace Yavsc.Model.FileSystem
|
||||||
prefix = value;
|
prefix = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the directory name separator.
|
/// Checks the sub dir name against model specifications,
|
||||||
/// </summary>
|
/// concerning the allowed character class.
|
||||||
/// <value>The separator.</value>
|
|
||||||
public char DirectorySeparator { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Checks the sub dir name.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="subdir">Subdir.</param>
|
/// <param name="subdir">Subdir.</param>
|
||||||
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)
|
if (!Regex.Match (dirname, regexFileName).Success)
|
||||||
throw new InvalidDirNameException (dirname);
|
throw new InvalidDirNameException (dirname);
|
||||||
foreach (char x in Path.GetInvalidPathChars())
|
foreach (char x in dirname)
|
||||||
if (subdir.Contains (x))
|
if (subdir.Contains (x))
|
||||||
throw new InvalidDirNameException (subdir);
|
throw new InvalidDirNameException (subdir);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the files.
|
/// Gets the files owned by the current logged user.
|
||||||
/// The web user must be authenticated,
|
/// The web user must be authenticated,
|
||||||
/// The given username must be registered.
|
/// The given username must be registered.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>The files.</returns>
|
/// <returns>The files.</returns>
|
||||||
/// <param name="subdir">Subdir.</param>
|
/// <param name="subdir">Subdir.</param>
|
||||||
public FileInfoCollection GetFiles (string subdir)
|
public IEnumerable<FileInfo> GetFiles (string subdir)
|
||||||
{
|
{
|
||||||
string path = Prefix;
|
string path = Prefix;
|
||||||
if (subdir != null) {
|
if (subdir != null) {
|
||||||
checkSubDir (subdir); // checks for specification validity
|
CheckSubDir (subdir); // checks for specification validity
|
||||||
path = Path.Combine (Prefix, subdir);
|
path = Path.Combine (Prefix, subdir);
|
||||||
}
|
}
|
||||||
DirectoryInfo di = new DirectoryInfo (path);
|
DirectoryInfo di = new DirectoryInfo (path);
|
||||||
FileInfoCollection res = new FileInfoCollection (di.GetFiles ());
|
return (di.GetFiles ());
|
||||||
// TODO define an Owner
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IEnumerable<FileInfo> 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 ());
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Files the info.
|
/// Files the info.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -160,7 +184,7 @@ namespace Yavsc.Model.FileSystem
|
||||||
/// <param name="id">Identifier.</param>
|
/// <param name="id">Identifier.</param>
|
||||||
public FileInfo FileInfo(string id)
|
public FileInfo FileInfo(string id)
|
||||||
{
|
{
|
||||||
checkSubDir (id);
|
CheckSubDir (id);
|
||||||
return new FileInfo(Path.Combine (Prefix, id));
|
return new FileInfo(Path.Combine (Prefix, id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ using Yavsc.Model.WorkFlow;
|
||||||
using Yavsc.Model.FileSystem;
|
using Yavsc.Model.FileSystem;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
|
||||||
namespace Yavsc.Model.FrontOffice
|
namespace Yavsc.Model.FrontOffice
|
||||||
|
|
@ -43,7 +44,7 @@ namespace Yavsc.Model.FrontOffice
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Dictionary<string,string> Parameters = new Dictionary<string,string> ();
|
public Dictionary<string,string> Parameters = new Dictionary<string,string> ();
|
||||||
|
|
||||||
FileInfoCollection Files {
|
IEnumerable<FileInfo> Files {
|
||||||
get {
|
get {
|
||||||
return GetFSM().GetFiles (Id.ToString());
|
return GetFSM().GetFiles (Id.ToString());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,6 @@
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Admin\RestoreQuery.cs" />
|
<Compile Include="Admin\RestoreQuery.cs" />
|
||||||
<Compile Include="Admin\DataAccess.cs" />
|
<Compile Include="Admin\DataAccess.cs" />
|
||||||
<Compile Include="FileSystem\FileInfoCollection.cs" />
|
|
||||||
<Compile Include="WorkFlow\Writting.cs" />
|
<Compile Include="WorkFlow\Writting.cs" />
|
||||||
<Compile Include="WorkFlow\Estimate.cs" />
|
<Compile Include="WorkFlow\Estimate.cs" />
|
||||||
<Compile Include="WorkFlow\IContentProvider.cs" />
|
<Compile Include="WorkFlow\IContentProvider.cs" />
|
||||||
|
|
@ -113,7 +112,6 @@
|
||||||
<Compile Include="FrontOffice\Catalog\CatalogManager.cs" />
|
<Compile Include="FrontOffice\Catalog\CatalogManager.cs" />
|
||||||
<Compile Include="FrontOffice\Catalog\CatalogProvider.cs" />
|
<Compile Include="FrontOffice\Catalog\CatalogProvider.cs" />
|
||||||
<Compile Include="FileSystem\FileSystemManager.cs" />
|
<Compile Include="FileSystem\FileSystemManager.cs" />
|
||||||
<Compile Include="FileSystem\DirNotFoundException.cs" />
|
|
||||||
<Compile Include="FileSystem\InvalidDirNameException.cs" />
|
<Compile Include="FileSystem\InvalidDirNameException.cs" />
|
||||||
<Compile Include="FileSystem\WebFileInfo.cs" />
|
<Compile Include="FileSystem\WebFileInfo.cs" />
|
||||||
<Compile Include="FrontOffice\CommandStatus.cs" />
|
<Compile Include="FrontOffice\CommandStatus.cs" />
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue