* NewProjectModel.cs: * ITContentProvider.csproj: refactoring * WebApiConfig.cs: Web Api Config * IModule.cs: * RssFeeds.cs: * IRenderer.cs: * Blog.cs: * ITagHandler.cs: * ViewRenderer.cs: * Comment.cs: * IViewRenderer.cs: * People.cs: * SignIn.cs: * BlogEntry.cs: * AuthToken.cs: * BlogHelper.cs: * DataAccess.cs: * Estimate.cs: * BlogManager.cs: * Writting.cs: * AskForADate.cs: * RestoreQuery.cs: * Basket.cs: * BlogProvider.cs: * CalendarList.cs: * Commande.cs: * StatusChange.cs: * WebFileInfo.cs: * WorkFlowManager.cs: * Euro.cs: * Unit.cs: * Text.cs: * Profile.cs: * Note.cs: * Link.cs: * BlogEditEntryModel.cs: * FindBlogEntryFlags.cs: * NewProjectModel.cs: * CalendarListEntry.cs: * CalendarEntryList.cs: * IContentProvider.cs: * CommandStatus.cs: * Label.cs: * Price.cs: * BlogEntryCollection.cs: * Period.cs: * Scalar.cs: * BlogEditCommentModel.cs: * Option.cs: * NpgsqlContentProvider.cs: * Product.cs: * LoginModel.cs: * Service.cs: * Catalog.cs: * Currency.cs: * NewEstimateEvenArgs.cs: * CheckBox.cs: * SaleForm.cs: * FileSystemManager.cs: * FormInput.cs: * TextInput.cs: * NewRoleModel.cs: * FileInfoCollection.cs: * FilesInput.cs: * NewAdminModel.cs: * SelectItem.cs: * SelectInput.cs: * RadioButton.cs: * StockStatus.cs: * Provider.cs: * DirNotFoundException.cs: * FormElement.cs: * ProductImage.cs: * WebFileInfoCollection.cs: * CatalogHelper.cs: * CatalogManager.cs: * RegisterViewModel.cs: * InvalidDirNameException.cs: * PhysicalProduct.cs: * CatalogProvider.cs: * ProductCategory.cs: * OrderStatusChangedEventArgs.cs: * ProviderCollection.cs: * WorkflowConfiguration.cs: * BlogProviderConfigurationElement.cs: * BlogProvidersConfigurationSection.cs: * BlogProvidersConfigurationCollection.cs: * CatalogProviderConfigurationElement.cs: * CatalogProvidersConfigurationSection.cs: * CatalogProvidersConfigurationCollection.cs: xml doc * SalesCatalog.csproj: * XmlCatalogProvider.cs: Maps the catalog using System.Web * BasketController.cs: * FrontOfficeController.cs: a Basket controller * Global.asax.cs: Session in Web Api * App.master: WebApi bas url as Javascript var 'apiBaseUrl' * Index.aspx: !!not sure of this change. * Web.csproj: compiles now includes WebApiConfig.cs * style.css: link background color * FileSystemController.cs: a file system controller
132 lines
No EOL
3.1 KiB
C#
132 lines
No EOL
3.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.Mvc;
|
|
using System.IO;
|
|
using System.Web.Security;
|
|
using System.Text.RegularExpressions;
|
|
using Yavsc.Model.FileSystem;
|
|
|
|
namespace Yavsc.Controllers
|
|
{
|
|
/// <summary>
|
|
/// File system controller.
|
|
/// </summary>
|
|
public class FileSystemController : Controller
|
|
{
|
|
private string usersDir = "~/users";
|
|
|
|
/// <summary>
|
|
/// Gets the users base directory.
|
|
/// </summary>
|
|
/// <value>The users dir.</value>
|
|
public string UsersDir {
|
|
get {
|
|
return usersDir;
|
|
}
|
|
}
|
|
|
|
FileSystemManager mgr = null ;
|
|
|
|
/// <summary>
|
|
/// Initialize the specified requestContext.
|
|
/// </summary>
|
|
/// <param name="requestContext">Request context.</param>
|
|
protected override void Initialize (System.Web.Routing.RequestContext requestContext)
|
|
{
|
|
base.Initialize (requestContext);
|
|
mgr = new FileSystemManager (UsersDir);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Index this instance.
|
|
/// </summary>
|
|
[Authorize]
|
|
public ActionResult Index (string id)
|
|
{
|
|
return View (mgr.GetFiles (Membership.GetUser().UserName+"/"+id));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Details the specified id.
|
|
/// </summary>
|
|
/// <param name="id">Identifier.</param>
|
|
public ActionResult Details (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");
|
|
}
|
|
}
|
|
string fpath = Path.Combine (UserBaseDir, id);
|
|
ViewData ["Content"] = Url.Content (fpath);
|
|
FileInfo fi = new FileInfo (fpath);
|
|
|
|
return View (fi);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Create the specified id.
|
|
/// </summary>
|
|
/// <param name="id">Identifier.</param>
|
|
[HttpPost]
|
|
[Authorize]
|
|
public ActionResult Create (string id)
|
|
{
|
|
string path=Membership.GetUser().UserName+"/"+id;
|
|
mgr.Put ( path, Request.Files);
|
|
return View ("Index",mgr.GetFiles(path));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the user's base dir.
|
|
/// </summary>
|
|
/// <value>The base dir.</value>
|
|
public string UserBaseDir { get { return Path.Combine (UsersDir, Membership.GetUser ().UserName); } }
|
|
|
|
/// <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 ();
|
|
}
|
|
}
|
|
} |