Ejemplo n.º 1
0
        private string GetZipFileName(string fullName)
        {
            string name = "Files";

            name += string.IsNullOrEmpty(fullName) ? "" : "_" + string.Join("_", CustomDirectoryHelper.SplitFullName(fullName));
            name  = string.Join(".", name, "zip");
            return(name);
        }
Ejemplo n.º 2
0
 public virtual void SaveFile(Site site, string fullName, string fileName, Stream fileSream)
 {
     if (!string.IsNullOrEmpty(fullName))
     {
         var             nameArr = CustomDirectoryHelper.SplitFullName(fullName);
         CustomDirectory di      = new CustomDirectory(site, nameArr);
         CustomFile      file    = new CustomFile(di, fileName);
         file.Save(fileSream);
     }
     else
     {
         CustomFile file = new CustomFile(site, fileName);
         file.Save(fileSream);
     }
 }
Ejemplo n.º 3
0
        public virtual void Delete(Site site, string fullName, string fileName)
        {
            var nameArr = CustomDirectoryHelper.SplitFullName(fullName);
            var count   = nameArr.Count();

            if (count <= 1)//0级目录
            {
                //CustomDirectory di = new CustomDirectory(site, nameArr.Take(count - 1).ToArray());
                CustomFile imgFile = new CustomFile(site, fileName);
                imgFile.Delete();
            }
            else
            {
                CustomDirectory di      = new CustomDirectory(site, nameArr.Take(count - 1).ToArray());
                CustomFile      imgFile = new CustomFile(di, fileName);
                imgFile.Delete();
            }
        }
Ejemplo n.º 4
0
 public virtual ActionResult Delete(string fullName, string fileName, string fileType)
 {
     try
     {
         Manager.Delete(Site, fullName, fileName);
         if (!string.IsNullOrEmpty(fullName))
         {
             var arr    = CustomDirectoryHelper.SplitFullName(fullName);
             var aCount = arr.Count();
             fullName = CustomDirectoryHelper.CombineFullName(arr.Take(aCount - 1));
         }
     }
     catch (FriendlyException e)
     {
         ModelState.AddModelError("", e.Message);
     }
     return(RedirectToAction("Index", new { fullName = fullName }));
 }
Ejemplo n.º 5
0
        public string CreateDirectory(string fullName)
        {
            Msg msg = new Msg();

            try
            {
                string          folderName = Request.Form["folderName"];
                var             nameArr    = !string.IsNullOrEmpty(fullName) ? CustomDirectoryHelper.SplitFullName(fullName) : new string[] { };
                CustomDirectory di         = !string.IsNullOrEmpty(fullName) ? new CustomDirectory(this.Site, nameArr) : null;
                Manager.CreateDirectory(this.Site, di, folderName);
                msg.Success = true;
            }
            catch (Exception e)
            {
                msg.Success = false;
                msg.ErrMsg  = e.Message;
            }
            return(msg.ToJSON());
        }
Ejemplo n.º 6
0
        public IHtmlString Render(object dataItem, object value, System.Web.Mvc.ViewContext viewContext)
        {
            string path = value.ToString();

            if (path.EndsWith(".jpg") || path.EndsWith(".png") || path.EndsWith(".gif"))
            {
                return(new HtmlString(string.Format(@"<a href='{0}' alt='preview' rel='{0}' >preview</a>", Kooboo.Web.Url.UrlUtility.ResolveUrl(value.ToString()))));
            }
            return(new HtmlString(string.Format(@"<a href='{0}' alt='open' rel='{0}' >open</a><input type=""hidden"" rel='paths' value=""{1}""/>", Kooboo.Web.Url.UrlUtility.ResolveUrl(value.ToString()), CustomDirectoryHelper.VirtualPathToFullName(value.ToString()))));
        }