/*
Kooboo is a content management system based on ASP.NET MVC framework. Copyright 2009 Yardi Technology Limited.
This program is free software: you can redistribute it and/or modify it under the terms of the
GNU General Public License version 3 as published by the Free Software Foundation.
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 General Public License for more details.
You should have received a copy of the GNU General Public License along with this program.
If not, see http://www.kooboo.com/gpl3/.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Everest.Library.Mvc;
using Everest.Library.Extjs;
using Everest.Library.Json;
using Everest.Library.Extjs.Tree;
using Everest.Library.ExtensionMethod;
using Everest.Library.Data.Rule;
using Everest.CmsServices.Models;
using System.Web.Mvc;
using Everest.CmsServices.Services;
using System.IO;
namespace Everest.CmsServices.Controllers{
[PermissionFilter(Permission = FolderType.SitePackage)]
public class SitePackageController : CmsExtController
{
public virtual SitePackageManager PackageManager
{
get
{
return new SitePackageManager();
}
}
#region IStandardActions Members
[PermissionFilter(Permission = FolderType.SitePackage)]
public ActionResult GetList()
{
var sitePackages = PackageManager.GetList();
var queryable = sitePackages.AsQueryable<FolderFile>();
queryable = OrderByRequest(queryable);
ExtJsonReaderObject jsonReader = new ExtJsonReaderObject(queryable.Select(sp => new
{
sp.FileName,
sp.CreationDate,
FilePath = Url.Content(sp.FilePath),
sp.FileSize
}), queryable.Count());
return Json(jsonReader);
}
public System.Web.Mvc.ActionResult GetDetail()
{
throw new NotImplementedException();
}
public System.Web.Mvc.ActionResult Submit(bool add, bool? closeForm)
{
throw new NotImplementedException();
}
[PermissionFilter(Permission = FolderType.SitePackage)]
public System.Web.Mvc.ActionResult Delete(string fileName)
{
JsonResultData result = new JsonResultData();
PackageManager.Delete(fileName);
return Json(result);
}
[PermissionFilter(Permission = FolderType.SitePackage)]
public ActionResult Upload()
{
JsonResultData resultData = new JsonResultData();
foreach (string fileKey in Request.Files.AllKeys)
{
var fileName = Path.GetFileName(Request.Files[fileKey].FileName);
PackageManager.Save(fileName, Request.Files[fileKey].InputStream);
}
return Json(resultData);
}
#endregion
#region Combobox
public ActionResult GetPackages()
{
var packages = PackageManager.GetList();
var data = packages.ToComboboxItems<FolderFile>(f => f.FileName, f => f.FileName, false);
return Json(new ExtJsonReaderObject(data, data.Count));
}
#endregion
}
}
|