Example #1
0
        public JsonResult DeleteItem(string id)
        {
            var success = true;
            var message = "删除成功";

            try
            {
                var         user        = OperatorProvider.Provider.Current();
                FileInfoBLL fileInfoBLL = new FileInfoBLL();
                var         fileList    = fileInfoBLL.GetFilesByRecIdNew(id);
                for (int i = 0; i < fileList.Count; i++)
                {
                    fileInfoBLL.DeleteFile(fileList[i].RecId, fileList[i].FileName, Server.MapPath(fileList[i].FilePath));
                }
                ebll.DeleteItem(id);
            }
            catch (Exception ex)
            {
                success = false;
                message = ex.Message;
            }

            return(Json(new AjaxResult {
                type = success ? ResultType.success : ResultType.error, message = HttpUtility.JavaScriptStringEncode(message)
            }));
        }
Example #2
0
        public ActionResult GetFiles(string keyValue)
        {
            FileInfoBLL file = new FileInfoBLL();
            var         dt   = file.GetFiles(keyValue);//先获取上传的附件

            return(ToJsonResult(dt));
        }
Example #3
0
        public ActionResult PostFile(string postData, string keyValue)
        {
            FileInfoEntity fileInfoEntity = new FileInfoEntity();
            FileInfoBLL    fileInfoBLL    = new FileInfoBLL();

            var dt = JsonConvert.DeserializeObject <List <FileInfoEntity> >(postData);
            List <FileInfoEntity> projects = dt;
            string dir = string.Format("~/Resource/{0}/{1}", "ht/images", DateTime.Now.ToString("yyyyMMdd"));

            foreach (FileInfoEntity item in dt)
            {
                var filepath = Server.MapPath(item.FilePath);
                if (System.IO.File.Exists(filepath))
                {
                    string newFileName = Guid.NewGuid().ToString() + item.FileExtensions;
                    string newFilePath = dir + "/" + newFileName;
                    System.IO.File.Copy(filepath, Server.MapPath(newFilePath));
                }
                item.RecId  = keyValue;
                item.FileId = Guid.NewGuid().ToString();
                fileInfoBLL.SaveForm("", item);
            }
            //fileInfoBLL.SaveForm("", fileInfoEntity);
            return(Success("操作成功。"));
        }
        public ActionResult CopyForm(string keyValue, string Fileid)
        {
            StaffinformcardEntity data = staffinformcardbll.GetEntity(keyValue);//先根据id获取实体

            data.CardType = 0;
            data.Id       = System.Guid.NewGuid().ToString();
            staffinformcardbll.SaveForm("", data);                                                   //进行新增
            FileInfoBLL    file        = new FileInfoBLL();
            FileInfoEntity fi          = file.GetEntity(Fileid);                                     //获取文件信息
            string         oldfilename = fi.FilePath.Substring(fi.FilePath.LastIndexOf('/') + 1);
            string         url         = fi.FilePath.Substring(1, fi.FilePath.LastIndexOf('/') + 1); //不要~

            string[] filenames = oldfilename.Split('.');
            if (filenames.Length > 1)
            {
                string hz          = filenames[filenames.Length - 1];//后缀名
                string newfilename = System.Guid.NewGuid().ToString() + "." + hz;
                string newUrl      = url + newfilename;
                string oldPath     = fi.FilePath.Substring(1);
                CopyFile(oldPath, newUrl);//复制到新地址
                fi.FileId   = "";
                fi.RecId    = data.Id;
                fi.FilePath = "~" + newUrl; //加入记录时加上~
                file.SaveForm("", fi);      //生成新的文件记录
                return(Success("true"));
            }
            return(Success("false"));
        }
Example #5
0
        /// <summary>
        /// 添加信息
        /// </summary>
        /// <param name="entity"></param>
        public void addMedical(MedicalEntity entity)
        {
            FileInfoBLL fb    = new FileInfoBLL();
            var         flist = fb.GetFilebyDescription(entity.createuserid, "职业健康二维码");

            service.addMedical(entity, flist);
        }
Example #6
0
        /// <summary>
        /// 下载
        /// </summary>
        /// <param name="keyValue"></param>
        /// <param name="filename"></param>
        /// <param name="recId"></param>
        public void DownloadFile(string keyValue, string filename, string recId)
        {
            var fileFolderBLL = new FileFolderBLL();
            var fileInfoBLL   = new FileInfoBLL();

            if (string.IsNullOrEmpty(keyValue))
            {
                return;
            }
            FileInfoEntity data = null;

            if (!string.IsNullOrEmpty(filename))
            {
                data = fileInfoBLL.GetEntity(recId, Server.UrlDecode(filename));
            }
            else
            {
                data = fileInfoBLL.GetEntity(keyValue);
            }
            if (data != null)
            {
                string name     = string.IsNullOrEmpty(filename) ? Server.UrlDecode(data.FileName) : Server.UrlDecode(filename);//返回客户端文件名称
                string filepath = this.Server.MapPath(data.FilePath);
                if (FileDownHelper.FileExists(filepath))
                {
                    FileDownHelper.DownLoadold(filepath, name);
                }
            }
        }
Example #7
0
 public object GetListByOutengineerId([FromBody] JObject json)
 {
     try
     {
         string  path       = new DataItemDetailBLL().GetItemValue("imgUrl");
         string  res        = json.Value <string>("json");
         dynamic dy         = JsonConvert.DeserializeObject <ExpandoObject>(res);
         string  engineerId = dy.data; //外包工程Id
         string  userId     = dy.userid;
         AptitudeinvestigateinfoBLL AptitudeinvestigateinfoBLL = new AptitudeinvestigateinfoBLL();
         var data      = AptitudeinvestigateinfoBLL.GetListByOutengineerId(engineerId);
         var fileList1 = new FileInfoBLL().GetFileList(data.ID + "01");
         var fileList2 = new FileInfoBLL().GetFileList(data.ID + "02");
         var fileList3 = new FileInfoBLL().GetFileList(data.ID + "03");
         var fileList4 = new FileInfoBLL().GetFileList(data.ID + "04");
         var fileList5 = new FileInfoBLL().GetFileList(data.ID + "05");
         var fileList6 = new FileInfoBLL().GetFileList(data.ID + "06");
         var fileList7 = new FileInfoBLL().GetFileList(data.ID + "07");
         if (data.ID == null)
         {
             return(new { Code = -1, Count = 0, Info = "没有数据" });
         }
         else
         {
             return(new { Code = 0, Count = 1, Info = "获取数据成功", data = data, fileList01 = fileList1, fileList02 = fileList2, fileList03 = fileList3, fileList04 = fileList4, fileList05 = fileList5, fileList06 = fileList6, fileList07 = fileList7 });
         }
     }
     catch (Exception ex)
     {
         return(new { Code = -1, Count = 0, Info = ex.Message });
     }
 }
Example #8
0
        public object GetMessageInfo([FromBody] JObject json)
        {
            try
            {
                string        res       = json.Value <string>("json");
                dynamic       dy        = JsonConvert.DeserializeObject <ExpandoObject>(res);
                string        userId    = dy.userid;
                string        messageId = dy.data.messageId;
                MessageEntity entity    = messagebll.GetEntity(messageId);

                //获取相关附件
                var    files  = new FileInfoBLL().GetFiles(messageId);
                string webUrl = new DataItemDetailBLL().GetItemValue("imgUrl");
                foreach (DataRow dr in files.Rows)
                {
                    dr["filepath"] = dr["filepath"].ToString().Replace("~/", webUrl + "/");
                }
                var result = new
                {
                    message = entity,
                    files   = files
                };
                return(new
                {
                    code = 0,
                    count = 1,
                    info = "获取数据成功",
                    data = result
                });
            }
            catch (Exception ex)
            {
                return(new { code = -1, count = 0, info = ex.Message });
            }
        }
Example #9
0
        public ActionResult PostFile(string postData, string keyValue)
        {
            FileInfoEntity fileInfoEntity = new FileInfoEntity();
            FileInfoBLL    fileInfoBLL    = new FileInfoBLL();

            fileInfoBLL.DeleteFileByRecId(keyValue);//删除原有附件

            var dt = JsonConvert.DeserializeObject <List <FileInfoEntity> >(postData);
            List <FileInfoEntity> projects = dt;
            string dir = string.Format("~/Resource/{0}/{1}", "ht/images", DateTime.Now.ToString("yyyyMMdd"));

            if (Directory.Exists(Server.MapPath(dir)) == false)//如果不存在就创建文件夹
            {
                Directory.CreateDirectory(Server.MapPath(dir));
            }
            foreach (FileInfoEntity item in dt)
            {
                var filepath = Server.MapPath(item.FilePath);
                if (System.IO.File.Exists(filepath))
                {
                    string sufx        = System.IO.Path.GetExtension(filepath);
                    string newFileName = Guid.NewGuid().ToString() + sufx;
                    string newFilePath = dir + "/" + newFileName;
                    System.IO.File.Copy(filepath, Server.MapPath(newFilePath));
                    item.FilePath = newFilePath;
                }
                item.RecId  = keyValue;
                item.FileId = Guid.NewGuid().ToString();
                fileInfoBLL.SaveForm("", item);
            }
            fileInfoBLL.SaveForm("", fileInfoEntity);
            return(Success("操作成功。"));
        }
Example #10
0
        public JsonResult Remove(string id)
        {
            var success = true;
            var message = "保存成功!";

            try
            {
                var costbll = new CostBLL();
                costbll.Remove(id);

                var filebll = new FileInfoBLL();
                var files   = filebll.DeleteByRecId(id);
                foreach (var item in files)
                {
                    System.IO.File.Delete(Server.MapPath(item.FilePath));
                }
            }
            catch (Exception e)
            {
                success = false;
                message = e.Message;
            }
            return(Json(new AjaxResult()
            {
                type = success ? ResultType.success : ResultType.error, message = message
            }));
        }
Example #11
0
        public JsonResult GetFiles(string id)
        {
            var files = new FileInfoBLL().GetFileList(id);

            files.ForEach(x => x.FilePath = Url.Content(x.FilePath));
            return(Json(files, JsonRequestBehavior.AllowGet));
        }
Example #12
0
 public object GetObsInfo([FromBody] JObject json)
 {
     try
     {
         string              res       = json.Value <string>("json");
         dynamic             dy        = JsonConvert.DeserializeObject <ExpandoObject>(res);
         string              userId    = dy.userid;
         string              obsid     = dy.data.obsid;
         ObserverecordEntity obsRecord = observerecordbll.GetEntity(obsid);
         //观察类别
         var typeData = observerecordbll.GetObsTypeData(obsid);
         //安全行为
         List <object> SafeData = new List <object>();
         //不安全行为
         List <object> NotSafeData = new List <object>();
         var           data        = dataitemdetailbll.GetDataItemListByItemCode("'ObsType'").ToList();
         for (int i = 0; i < data.Count; i++)
         {
             var safeData = observesafetybll.GetDataByType("1", data[i].ItemName, obsid);
             if (safeData.Rows.Count > 0)
             {
                 var item = new { name = data[i].ItemName, list = safeData };
                 SafeData.Add(item);
             }
             var notSafe = observesafetybll.GetDataByType("0", data[i].ItemName, obsid);
             if (notSafe.Rows.Count > 0)
             {
                 var notItem = new { name = data[i].ItemName, list = notSafe };
                 NotSafeData.Add(notItem);
             }
         }
         //获取相关附件
         var    files  = new FileInfoBLL().GetFiles(obsid);
         string webUrl = new DataItemDetailBLL().GetItemValue("imgUrl");
         foreach (DataRow dr in files.Rows)
         {
             dr["filepath"] = dr["filepath"].ToString().Replace("~/", webUrl + "/");
         }
         var result = new
         {
             obsRecordEntity = obsRecord,
             obsTypeData     = typeData,
             SafeData        = SafeData,
             NotSafeData     = NotSafeData,
             files           = files
         };
         return(new
         {
             Code = 0,
             Count = 1,
             Info = "获取数据成功",
             data = result
         });
     }
     catch (Exception ex)
     {
         return(new { Code = -1, Count = 0, Info = ex.Message });
     }
 }
        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 }));
        }
Example #14
0
        public ActionResult GetFileListJson(string keyValue)
        {
            var         data = safetydaybll.GetEntity(keyValue);
            FileInfoBLL fi   = new FileInfoBLL();
            var         list = fi.GetFilesByRecIdNew(keyValue);

            return(ToJsonResult(new { formData = data, files = list }));
        }
Example #15
0
        public ActionResult GetFormJson(string keyValue)
        {
            var         data = noticeBLL.GetEntity(keyValue);
            FileInfoBLL fi   = new FileInfoBLL();
            IList       list = fi.GetFilesByRecId(keyValue);

            return(ToJsonResult(new { formData = data, files = list }));
        }
        /// <summary>
        /// 获取数据
        /// </summary>
        /// <param name="keyvalue"></param>
        /// <returns></returns>
        public ActionResult getCPEntity(string keyvalue)
        {
            var cpBll   = new CustomParameterBLL();
            var fileBll = new FileInfoBLL();
            var data    = cpBll.getEntity(keyvalue);

            data.Files = fileBll.GetFilesByRecIdNew(keyvalue).ToList();
            return(Content(data.ToJson()));
        }
Example #17
0
        public ActionResult NewDetail(string keyValue)
        {
            var         model = noticeBLL.GetEntity(keyValue);
            FileInfoBLL fi    = new FileInfoBLL();
            var         list  = fi.GetFilesByRecIdNew(keyValue);

            ViewData["files"] = list;
            return(View(model));
        }
Example #18
0
        public JsonResult ImportEditPush(string keyvalue)
        {
            var success = true;
            var message = string.Empty;

            try
            {
                string newFilePath = "";
                if (this.Request.Files.Count == 0)
                {
                    throw new Exception("请上传文件");
                }
                var    file     = this.Request.Files[0];
                string fileName = System.IO.Path.GetFileName(file.FileName);
                if (!fileName.Contains(".pdf"))
                {
                    throw new Exception("请检查文件格式!");
                }
                string fileGuid       = Guid.NewGuid().ToString();
                long   filesize       = file.ContentLength;
                string FileEextension = Path.GetExtension(fileName);
                string uploadDate     = DateTime.Now.ToString("yyyyMMdd");
                string dir            = string.Format("~/Resource/{0}/{1}", "SevenS", uploadDate);
                string newFileName    = fileGuid + FileEextension;
                newFilePath = dir + "/" + newFileName;
                if (!Directory.Exists(Server.MapPath(dir)))
                {
                    Directory.CreateDirectory(Server.MapPath(dir));
                }

                FileInfoEntity fileInfoEntity = new FileInfoEntity();
                if (!System.IO.File.Exists(Server.MapPath(newFilePath)))
                {
                    //保存文件
                    file.SaveAs(Server.MapPath(newFilePath));
                    //文件信息写入数据库
                    fileInfoEntity.Create();
                    fileInfoEntity.FolderId       = "SevenS";
                    fileInfoEntity.FileId         = fileGuid;
                    fileInfoEntity.RecId          = keyvalue;
                    fileInfoEntity.FileName       = fileName;
                    fileInfoEntity.FilePath       = dir + "/" + newFileName;
                    fileInfoEntity.FileSize       = (Math.Round(decimal.Parse(filesize.ToString()) / decimal.Parse("1024"), 2)).ToString();//文件大小(kb)
                    fileInfoEntity.FileExtensions = FileEextension;
                    fileInfoEntity.FileType       = FileEextension.TrimStart('.');
                    FileInfoBLL fileInfoBLL = new FileInfoBLL();
                    fileInfoBLL.SaveForm("", fileInfoEntity);
                }
                message = fileInfoEntity.FileName;
            }
            catch (Exception ex)
            {
                success = false;
                message = HttpUtility.JavaScriptStringEncode(ex.Message);
            }
            return(Json(new { success, message }));
        }
Example #19
0
        public ActionResult SaveForm(string keyValue, string strentity, string Users, string UserIds, bool isNew)
        {
            OccupatioalstaffEntity userEntity = strentity.ToObject <OccupatioalstaffEntity>();

            #region 处理体检员工表
            //先查询出患病的用户
            OccupationalstaffdetailBLL occupationalstaffdetailbll = new OccupationalstaffdetailBLL();
            IEnumerable <OccupationalstaffdetailEntity> odlist    = occupationalstaffdetailbll.GetList(keyValue, 1); //查询出所有填写的患病记录
            IEnumerable <OccupationalstaffdetailEntity> yclist    = occupationalstaffdetailbll.GetList(keyValue, 2); //查询出所有填写的异常记录
            occupationalstaffdetailbll.UpdateTime((DateTime)(userEntity.InspectionTime), keyValue);                  //先将所有的病人体检时间纠正过来
            if (!isNew)                                                                                              //修改模式
            {
                occupationalstaffdetailbll.Delete(keyValue, 0);                                                      //先把健康人员记录删除再重新添加
            }
            //获取到所有体检用户
            string[] UserGroup  = UserIds.Split(',');
            string[] UsersGroup = Users.Split(',');
            if (odlist != null)
            {
                for (int i = 0; i < UserGroup.Length; i++)
                {
                    if (!IsTrue(odlist, yclist, UserGroup[i]))
                    {
                        //判断为健康员工
                        OccupationalstaffdetailEntity occ = new OccupationalstaffdetailEntity();
                        occ.UserId         = UserGroup[i];
                        occ.UserName       = UsersGroup[i];
                        occ.UserNamePinYin = Str.PinYin(UsersGroup[i]);
                        occ.Note           = "";
                        occ.Issick         = 0;
                        occ.InspectionTime = userEntity.InspectionTime;
                        occ.OccId          = keyValue;
                        occ.SickType       = "无";
                        occupationalstaffdetailbll.SaveForm("", occ);
                    }
                }
            }
            #endregion
            FileInfoBLL file = new FileInfoBLL();
            DataTable   dt   = file.GetFiles(keyValue);//先获取上传的附件
            if (dt != null && dt.Rows.Count > 0)
            {
                userEntity.IsAnnex = 1;//有附件
            }
            else
            {
                userEntity.IsAnnex = 0;//没有附件
            }
            userEntity.OccId         = keyValue;
            userEntity.InspectionNum = UserGroup.Length;
            userEntity.PatientNum    = odlist.Count();
            userEntity.UnusualNum    = yclist.Count();

            occupatioalstaffbll.SaveForm(isNew, userEntity);
            return(Success("操作成功。"));
        }
Example #20
0
        public ActionResult UploadFileNew(string keyValue, int packType)
        {
            FileInfoBLL        fileBll = new FileInfoBLL();
            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);

            if (!FileEextension.Contains("apk"))
            {
                return(Success("1"));
            }
            string Id           = Guid.NewGuid().ToString();
            string virtualPath  = string.Format("~/Resource/Package/{0}/{1}{2}", packType, Id, FileEextension);
            string fullFileName = Server.MapPath(virtualPath);
            //创建文件夹,保存文件
            string path = Path.GetDirectoryName(fullFileName);

            Directory.CreateDirectory(path);
            files[0].SaveAs(fullFileName);
            //保存一个固定的路径
            string staticFileName = string.Empty;

            staticFileName = packType == 0 ? "bzapp.apk" : "bzzdapp.apk";
            string staticFilePath = Server.MapPath(string.Format("~/Resource/Package/{0}/{1}", packType, staticFileName));

            files[0].SaveAs(staticFilePath);

            FileInfoEntity fi = new FileInfoEntity
            {
                FileId         = Id,
                FolderId       = keyValue,
                RecId          = keyValue,
                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    = packType == 0 ? "安卓APP" : "安卓终端"
            };

            fileBll.SaveForm(fi);

            var filelist = fileBll.GetFilesByRecIdNew(keyValue);

            foreach (FileInfoEntity f in filelist)
            {
                f.FilePath = Url.Content(f.FilePath);
            }
            return(Success("上传成功。", new { path = virtualPath.TrimStart('~'), name = fi.FileName, files = filelist, newpath = Url.Content(virtualPath) }));
        }
        /// <summary>
        /// 附件显示
        /// </summary>
        /// <param name="recid">主键Id</param>
        /// <returns></returns>
        public ActionResult ShowFile(string recid)
        {
            List <FileInfoEntity> fileList = new FileInfoBLL().GetFilesByRecIdNew(recid).ToList();

            fileList.ForEach(x =>
            {
                x.FilePath = Url.Content(x.FilePath);
            });
            return(View(fileList));
        }
Example #22
0
 /// <summary>
 /// 上传证件照片
 /// </summary>
 /// <param name="userId"></param>
 /// <returns></returns>
 public object UploadCertImages()
 {
     try
     {
         string             res         = HttpContext.Current.Request["json"];
         dynamic            dy          = JsonConvert.DeserializeObject <ExpandoObject>(res);
         string             id          = dy.data.id;
         string             path        = itemBll.GetItemValue("imgPath");
         FileInfoBLL        fileInfoBLL = new FileInfoBLL();
         HttpFileCollection files       = HttpContext.Current.Request.Files;
         if (res.Contains("remark"))
         {
             string remark = dy.data.remark;
             deptBll.ExecuteSql(string.Format("delete from base_fileinfo where recid='{0}' and fileid in('{1}')", id, remark.Replace(",", "','")));
         }
         for (int i = 0; i < files.AllKeys.Length; i++)
         {
             HttpPostedFile file = files[i];
             //获取文件完整文件名(包含绝对路径)
             //文件存放路径格式:/Resource/ResourceFile/{userId}{data}/{guid}.{后缀名}
             string fileGuid       = Guid.NewGuid().ToString();
             long   filesize       = file.ContentLength;
             string FileEextension = Path.GetExtension(file.FileName);
             string uploadDate     = DateTime.Now.ToString("yyyyMMdd");
             string virtualPath    = string.Format("~/Resource/cert/{0}/{1}{2}", uploadDate, fileGuid, FileEextension);
             string virtualPath1   = string.Format("\\Resource/cert\\{0}\\{1}{2}", uploadDate, fileGuid, FileEextension);
             string fullFileName   = path + virtualPath1;
             //创建文件夹
             string path1 = Path.GetDirectoryName(fullFileName);
             Directory.CreateDirectory(path1);
             FileInfoEntity fileInfoEntity = new FileInfoEntity();
             if (!System.IO.File.Exists(fullFileName))
             {
                 //保存文件
                 file.SaveAs(fullFileName);
             }
             //文件信息写入数据库
             fileInfoEntity.FileId         = fileGuid;
             fileInfoEntity.RecId          = id; //关联ID
             fileInfoEntity.FolderId       = "cert";
             fileInfoEntity.FileName       = file.FileName;
             fileInfoEntity.FilePath       = virtualPath;
             fileInfoEntity.FileSize       = filesize.ToString();
             fileInfoEntity.FileExtensions = FileEextension;
             fileInfoEntity.FileType       = FileEextension.Replace(".", "");
             fileInfoBLL.SaveForm("", fileInfoEntity);
         }
         return(new { code = 0, info = "操作成功", data = id });
     }
     catch (Exception ex)
     {
         return(new { code = 1, info = ex.Message });
     }
 }
Example #23
0
        public ActionResult RemoveListFile(string recId)
        {
            FileInfoBLL fileBll = new FileInfoBLL();
            int         res     = 0;

            if (recId != null)
            {
                res = fileBll.DeleteFileByRecId(recId);
            }
            return(res > 0 ? Success("操作成功。") : Error("操作失败"));
        }
Example #24
0
        public ActionResult RemoveFile(string fileName, string recId)
        {
            FileInfoBLL    fileBll = new FileInfoBLL();
            FileInfoEntity entity  = fileBll.GetEntity(recId, fileName);
            int            res     = 0;

            if (entity != null)
            {
                res = fileBll.DeleteFile(recId, fileName, Server.MapPath(entity.FilePath));
            }
            return(res > 0 ? Success("操作成功。") : Error("操作失败"));
        }
Example #25
0
        public ActionResult GetFormAndFile(string keyValue)
        {
            var data     = outcommitfilebll.GetEntity(keyValue);
            var fileList = new FileInfoBLL().GetFileList(data.ID);
            var jsonData = new
            {
                data     = data,
                fileList = fileList,
            };

            return(ToJsonResult(jsonData));
        }
        public ActionResult GetFormAndFile(string keyValue)
        {
            var data     = announcementbll.GetEntity(keyValue);
            var fileList = new FileInfoBLL().GetFileList(keyValue);
            var jsonData = new
            {
                data     = data,
                fileList = fileList,
            };

            return(ToJsonResult(jsonData));
        }
Example #27
0
        public string PostFile([System.Web.Http.FromUri] string filePath, [System.Web.Http.FromUri] string recId, [System.Web.Http.FromUri] string Description, [System.Web.Http.FromUri] int isDate = 0)
        {
            string newFilePath = "";

            if (Request.Files.Count > 0)
            {
                foreach (string key in Request.Files.Keys)
                {
                    HttpPostedFileBase file = Request.Files[key];
                    //原始文件名
                    string fileName       = System.IO.Path.GetFileName(file.FileName);
                    string fileGuid       = Guid.NewGuid().ToString();
                    long   filesize       = file.ContentLength;
                    string FileEextension = Path.GetExtension(fileName);
                    string uploadDate     = DateTime.Now.ToString("yyyyMMdd");
                    string dir            = isDate == 0 ? string.Format("~/Resource/{0}", filePath) : string.Format("~/Resource/{0}/{1}", filePath, uploadDate);
                    string newFileName    = fileGuid + FileEextension;
                    newFilePath = dir + "/" + newFileName;
                    if (!Directory.Exists(Server.MapPath(dir)))
                    {
                        Directory.CreateDirectory(Server.MapPath(dir));
                    }

                    FileInfoEntity fileInfoEntity = new FileInfoEntity();
                    if (!System.IO.File.Exists(Server.MapPath(newFilePath)))
                    {
                        //保存文件
                        file.SaveAs(Server.MapPath(newFilePath));
                        //文件信息写入数据库
                        fileInfoEntity.Create();
                        fileInfoEntity.FileId = fileGuid;
                        if (!string.IsNullOrEmpty(filePath))
                        {
                            fileInfoEntity.FolderId = filePath;
                        }
                        else
                        {
                            fileInfoEntity.FolderId = "0";
                        }
                        fileInfoEntity.RecId          = recId;
                        fileInfoEntity.Description    = Description;
                        fileInfoEntity.FileName       = fileName;
                        fileInfoEntity.FilePath       = dir + "/" + newFileName;
                        fileInfoEntity.FileSize       = (Math.Round(decimal.Parse(filesize.ToString()) / decimal.Parse("1024"), 2)).ToString();//文件大小(kb)
                        fileInfoEntity.FileExtensions = FileEextension;
                        fileInfoEntity.FileType       = FileEextension.TrimStart('.');
                        FileInfoBLL fileInfoBLL = new FileInfoBLL();
                        fileInfoBLL.SaveForm("", fileInfoEntity);
                    }
                }
            }
            return(newFilePath);
        }
Example #28
0
        public ActionResult GetFiles(string fileId)
        {
            FileInfoBLL fi   = new FileInfoBLL();
            var         data = fi.GetFiles(fileId);

            foreach (DataRow item in data.Rows)
            {
                var path = item.Field <string>("FilePath");
                var url  = Url.Content(path);
                item.SetField <string>("FilePath", url);
            }
            return(ToJsonResult(data));
        }
Example #29
0
 /// <summary>
 /// 添加用户证件信息
 /// </summary>
 /// <param name="entity"></param>
 public void addUserCertificate(UserCertificateEntity entity)
 {
     try
     {
         FileInfoBLL fb    = new FileInfoBLL();
         var         flist = fb.GetFilebyDescription(entity.createuserid, "成员证书二维码");
         bll.addUserCertificate(entity, flist);
     }
     catch (Exception)
     {
         throw;
     }
 }
Example #30
0
        /// <summary>
        /// 获取类别
        /// </summary>
        /// <returns></returns>
        public ActionResult GetFilePath(string keyvalue, string filename)
        {
            FileInfoBLL fileInfoBLL = new FileInfoBLL();
            var         data        = fileInfoBLL.GetEntity(keyvalue, filename);

            if (data == null)
            {
                return(Success(""));
            }
            var path = Url.Content(data.FilePath);

            return(Success(path));
        }