Пример #1
0
        public ActionResult UploadFileNew(string uptype, string id)
        {
            FileInfoBLL            fileBll = new FileInfoBLL();
            IList <FileInfoEntity> fl      = fileBll.GetFilesByRecIdNew(id).Where(x => x.Description == uptype).ToList();

            foreach (FileInfoEntity fe in fl)
            {
                string filepath = fileBll.Delete(fe.FileId);
                if (!string.IsNullOrEmpty(filepath) && System.IO.File.Exists(Server.MapPath("~" + filepath)))
                {
                    System.IO.File.Delete(Server.MapPath("~" + filepath));
                }
            }
            HttpFileCollection files = System.Web.HttpContext.Current.Request.Files;

            //没有文件上传,直接返回
            if (files[0].ContentLength == 0 || string.IsNullOrEmpty(files[0].FileName))
            {
                return(HttpNotFound());
            }
            string FileEextension = Path.GetExtension(files[0].FileName);
            string type           = files[0].ContentType;

            if (uptype == "0" && !type.Contains("image"))  //图片
            {
                return(Success("1"));
            }

            if (uptype == "1" && !type.Contains("mp4"))
            {
                return(Success("1"));
            }
            string Id = OperatorProvider.Provider.Current().UserId;

            Id = Guid.NewGuid().ToString();
            string virtualPath  = string.Format("~/Content/AndroidMenufile/{0}{1}", Id, FileEextension);
            string fullFileName = Server.MapPath(virtualPath);
            //创建文件夹,保存文件
            string path = Path.GetDirectoryName(fullFileName);

            Directory.CreateDirectory(path);
            files[0].SaveAs(fullFileName);
            FileInfoEntity fi = new FileInfoEntity
            {
                FileId         = Id,
                FolderId       = id,
                RecId          = id,
                FileName       = System.IO.Path.GetFileName(files[0].FileName),
                FilePath       = virtualPath,
                FileType       = FileEextension.Substring(1, FileEextension.Length - 1),
                FileExtensions = FileEextension,
                FileSize       = files[0].ContentLength.ToString(),
                DeleteMark     = 0,
                Description    = uptype
            };

            fileBll.SaveForm(fi);
            return(Success("上传成功。", new { path = Url.Content(virtualPath), name = fi.FileName }));
        }
Пример #2
0
        public ActionResult RemoveForm(string keyValue)
        {
            packagebll.RemoveForm(keyValue);
            FileInfoBLL fileBll  = new FileInfoBLL();
            var         filelist = fileBll.GetFilesByRecIdNew(keyValue);

            foreach (var item in filelist)
            {
                string delPath = fileBll.Delete(item.FileId);
                System.IO.File.Delete(Server.MapPath(delPath));
            }
            return(Success("删除成功。"));
        }
Пример #3
0
        public ActionResult delEntity(string keyValue)
        {
            FileInfoBLL fileBll = new FileInfoBLL();

            try
            {
                string getDel = string.Empty;
                #region  除数据
                if (!string.IsNullOrEmpty(keyValue))
                {
                    var fileList = fileBll.GetFilesByRecIdNew(keyValue).ToList();
                    getDel = string.Join(",", fileList.Select(x => x.FileId));
                }
                #endregion
                #region 修改删除图片
                var    DelKeys = getDel.Split(',');
                string keys    = string.Empty;
                for (int i = 0; i < DelKeys.Length; i++)
                {
                    if (string.IsNullOrEmpty(DelKeys[i]))
                    {
                        continue;
                    }
                    FileInfoEntity fileList = fileBll.GetEntity(DelKeys[i]);
                    string         url      = Server.MapPath(fileList.FilePath);
                    if (!string.IsNullOrEmpty(fileList.FilePath) && System.IO.File.Exists(url))
                    {
                        System.IO.File.Delete(url);
                    }
                    fileBll.Delete(DelKeys[i]);
                }
                #endregion
                qcbll.delEntity(keyValue);

                return(Success("操作成功。"));
            }
            catch (Exception ex)
            {
                return(Error(ex.Message));
            }
        }
Пример #4
0
 public ActionResult RemoveForm(string keyValue)
 {
     try
     {
         var         del     = bll.delAndroidmenu(keyValue);
         FileInfoBLL fileBll = new FileInfoBLL();
         foreach (FileInfoEntity fe in del)
         {
             string filepath = fileBll.Delete(fe.FileId);
             if (!string.IsNullOrEmpty(filepath) && System.IO.File.Exists(Server.MapPath("~" + filepath)))
             {
                 System.IO.File.Delete(Server.MapPath("~" + filepath));
             }
         }
         return(Success("删除成功。"));
     }
     catch (Exception ex)
     {
         return(Success("删除失败。" + ex.Message));
     }
 }
Пример #5
0
        public ActionResult RemoveFile(string fileName, string recId)
        {
            FileInfoBLL     fileBll  = new FileInfoBLL();
            FileInfoEntity  entity   = fileBll.GetEntity(recId, fileName);
            QuestionBankBLL question = new QuestionBankBLL();

            try
            {
                if (entity != null)
                {
                    //res=fileBll.DeleteFile(recId,fileName,Server.MapPath(entity.FilePath));
                    fileBll.Delete(entity.FileId);
                    safetydaybll.RemoveFile(entity.FileId);
                    #region 清理试题下的fileid
                    question.DetailbyFileId(entity.FileId);
                    #endregion
                }
                return(Success("操作成功。"));
            }
            catch (Exception)
            {
                return(Error("操作失败"));
            }
        }