Exemple #1
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);
                }
            }
        }
 public ActionResult GetFiles(string fileIdlist)
 {
     if (!string.IsNullOrEmpty(fileIdlist) && fileIdlist != "undefined")
     {
         FileInfoEntity entity = fileInfoBLL.GetEntity(fileIdlist);
         //return Content(entity.ToJson());
         string json = "[{\"FileId\":\"" + entity.FileId + "\",\"FileType\":\"" + entity.FileType + "\",\"FileName\":\"" + entity.FileName + "\"}]";
         return(Content(json));
     }
     return(Content("[]"));
 }
Exemple #3
0
        public ActionResult GetFilePath(string recId, string filename)
        {
            var data = fileInfoBLL.GetEntity(recId, filename);

            if (data != null)
            {
                string url = new ERCHTMS.Busines.SystemManage.DataItemDetailBLL().GetItemValue("imgUrl");
                return(Success(data.FilePath, url + data.FilePath.Replace("~", "")));
            }
            else
            {
                return(Error("获取文件信息失败"));
            }
        }
Exemple #4
0
        /// <summary>
        /// 删除附件
        /// </summary>
        /// <param name="fileInfoIds"></param>
        public bool DeleteFile(string fileInfoIds)
        {
            bool result = false;

            if (!string.IsNullOrEmpty(fileInfoIds))
            {
                string ids = "";

                string[] strArray = fileInfoIds.Split(',');

                foreach (string s in strArray)
                {
                    ids += "'" + s + "',";
                    var entity = fileinfobll.GetEntity(s);
                    if (entity != null)
                    {
                        var filePath = ctx.Server.MapPath(entity.FilePath);
                        if (File.Exists(filePath))
                        {
                            File.Delete(filePath);
                        }
                    }
                }

                if (!string.IsNullOrEmpty(ids))
                {
                    ids = ids.Substring(0, ids.Length - 1);
                }
                int count = fileinfobll.DeleteFileForm(ids);

                result = count > 0 ? true : false;
            }

            return(result);
        }
        /// <summary>
        /// 删除附件
        /// </summary>
        /// <param name="fileInfoIds"></param>
        public bool DeleteFile(string fileInfoIds)
        {
            bool result = false;

            if (!string.IsNullOrEmpty(fileInfoIds))
            {
                string ids = "";

                string[] strArray = fileInfoIds.Split(',');

                foreach (string s in strArray)
                {
                    ids += "'" + s + "',";
                    var entity = fileInfoBLL.GetEntity(s);
                    if (entity != null)
                    {
                        var filePath = dataitemdetailbll.GetItemValue("imgPath") + entity.FilePath.Replace("~", "");
                        if (File.Exists(filePath))
                        {
                            File.Delete(filePath);
                        }
                    }
                }

                if (!string.IsNullOrEmpty(ids))
                {
                    ids = ids.Substring(0, ids.Length - 1);
                }
                int count = fileInfoBLL.DeleteFileForm(ids);

                result = count > 0 ? true : false;
            }

            return(result);
        }
        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"));
        }
        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("操作失败"));
        }
Exemple #8
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));
        }
        /// <summary>
        /// 输出图片
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="table"></param>
        /// <param name="setText"></param>
        /// <param name="textpos"></param>
        /// <param name="model"></param>
        /// <returns></returns>
        public XWPFParagraph SetCellText1(XWPFDocument doc, XWPFTable table, string setText, int textpos, LllegalEntity model)
        {
            CT_P          para  = new CT_P();
            XWPFParagraph pcell = new XWPFParagraph(para, table.Body);

            pcell.Alignment         = NPOI.XWPF.UserModel.ParagraphAlignment.LEFT;
            pcell.VerticalAlignment = TextAlignment.CENTER;
            if (setText == null)
            {
                setText = "";
            }
            XWPFRun r1c1 = pcell.CreateRun();

            for (int i = 0; i < model.Files.Count; i++)
            {
                var    data     = fileInfoBLL.GetEntity(model.Files[i].FileId);
                string filename = Server.UrlDecode(data.FileName);//返回客户端文件名称
                string filepath = this.Server.MapPath(data.FilePath);

                var img        = Image.FromFile(filepath);
                var widthEmus  = (int)(400.0 * 9526);
                var heightEmus = (int)(500.0 * 9526);
                using (FileStream picData = new FileStream(filepath, FileMode.Open, FileAccess.Read))
                {
                    r1c1.AddPicture(picData, (int)NPOI.XWPF.UserModel.PictureType.PNG, filename, widthEmus, heightEmus);
                }
            }

            //var data = fileInfoBLL.GetEntity("");
            //    string filename = Server.UrlDecode(data.FileName);//返回客户端文件名称
            //    string filepath = this.Server.MapPath(data.FilePath);

            //    var img = Image.FromFile(filepath);
            //    var widthEmus = (int)(1000.0 * 1000);
            //    var heightEmus = (int)(1000.0 * 1000);
            //    using (FileStream picData = new FileStream(filepath, FileMode.Open, FileAccess.Read))
            //    {
            //        r1c1.AddPicture(picData, (int)NPOI.XWPF.UserModel.PictureType.PNG, filename, widthEmus, heightEmus);
            //    }

            return(pcell);
        }
Exemple #10
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));
            }
        }
Exemple #11
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("操作失败"));
            }
        }
 public object SaveForm()
 {
     try
     {
         string             res   = HttpContext.Current.Request["json"];
         HttpFileCollection files = HttpContext.Current.Request.Files;
         var dy = JsonConvert.DeserializeAnonymousType(res, new
         {
             userid = string.Empty,
             data   = new LifthoistViewModel()
         });
         //获取用户Id
         string userId = dy.userid;
         OperatorProvider.AppUserId = userId;  //设置当前用户
         Operator curUser = OperatorProvider.Provider.Current();
         if (null == curUser)
         {
             return(new { code = -1, info = "请求失败,请登录!" });
         }
         if (dy.data == null)
         {
             return(new { code = -1, info = "请求失败,data参数为空!" });
         }
         //如果ID为空,则重新生成一个
         if (string.IsNullOrEmpty(dy.data.id))
         {
             dy.data.id        = Guid.NewGuid().ToString();
             dy.data.fazlfiles = Guid.NewGuid().ToString();
         }
         else
         {
             dy.data.fazlfiles = lifthoistjobbll.GetEntity(dy.data.id) == null?Guid.NewGuid().ToString() : lifthoistjobbll.GetEntity(dy.data.id).FAZLFILES;  //方案资料附件关联ID
         }
         //删除文件
         if (!string.IsNullOrEmpty(dy.data.deletefileids))
         {
             DeleteFile(dy.data.deletefileids);
         }
         if (dy.data.pagetype == "1")
         {
             //起吊证
             LifthoistcertEntity certEntity = JsonConvert.DeserializeObject <LifthoistcertEntity>(JsonConvert.SerializeObject(dy.data));
             lifthoistcertbll.SaveForm(certEntity.ID, certEntity);
             //上传人员资料、设备资料
             UploadifyFile(certEntity.ID + "1", "persondata", files);
             UploadifyFile(certEntity.ID + "2", "driverdata", files);
         }
         else
         {
             //起重吊装作业
             LifthoistjobEntity jobEntity = JsonConvert.DeserializeObject <LifthoistjobEntity>(JsonConvert.SerializeObject(dy.data));
             lifthoistjobbll.SaveForm(jobEntity.ID, jobEntity);
             //上传起吊方案
             UploadifyFile(jobEntity.ID, "liftscheme", files);
             UploadifyFile(jobEntity.FAZLFILES, "liftfazl", files);
             highriskrecordbll.RemoveFormByWorkId(dy.data.id);
             if (dy.data.riskrecord != null)
             {
                 var num = 0;
                 foreach (var item in dy.data.riskrecord)
                 {
                     item.CreateDate = DateTime.Now.AddSeconds(-num);
                     item.WorkId     = dy.data.id;
                     highriskrecordbll.SaveForm("", item);
                     num++;
                 }
             }
             lifthoistpersonbll.RemoveFormByWorkId(dy.data.id);
             if (dy.data.lifthoistperson != null)
             {
                 var num = 0;
                 for (int i = 0; i < dy.data.lifthoistperson.Count; i++)
                 {
                     var item = dy.data.lifthoistperson[i];
                     item.CreateDate = DateTime.Now.AddSeconds(-num);
                     item.RecId      = dy.data.id;
                     item.Id         = Guid.NewGuid().ToString();
                     lifthoistpersonbll.SaveForm(item.Id, item);
                     UploadifyFile(item.Id, "pic_" + i, files);//上传人员信息附件
                     if (item.lifthoistpersonfile != null)
                     {
                         foreach (var personfile in item.lifthoistpersonfile)
                         {
                             var fileinfo = fileInfoBLL.GetEntity(personfile.fileid);
                             fileinfo.RecId = item.Id;
                             fileInfoBLL.SaveForm(personfile.fileid, fileinfo);
                         }
                     }
                     num++;
                 }
             }
         }
         return(new { code = 0, info = "操作成功" });
     }
     catch (Exception ex)
     {
         return(new { code = -1, info = ex.Message });
     }
 }
        public ActionResult GetFileFormJson(string keyValue)
        {
            var data = fileInfoBLL.GetEntity(keyValue);

            return(ToJsonResult(data));
        }
Exemple #14
0
        public HttpResponseMessage SaveTrailRecord(string ticket, string keyValue, TrailRecordModel model)
        {
            UserEntity userEntity = GetCurrent(ticket);

            if (userEntity != null)
            {
                try
                {
                    TrailRecordEntity entity = new TrailRecordEntity();
                    entity.Contact       = model.Contact;
                    entity.StartTime     = model.StartTime;
                    entity.EndTime       = model.EndTime;
                    entity.FollowUpMode  = model.FollowUpMode;
                    entity.ObjectId      = model.ObjectId;
                    entity.ObjectName    = model.ObjectName;
                    entity.ObjectSort    = model.ObjectSort;
                    entity.SaleStageName = model.SaleStageName;
                    entity.SaleStageId   = model.SaleStageId;
                    entity.TrackContent  = model.TrackContent;
                    entity.Description   = model.Description;
                    entity.TrailType     = model.TrailType;//跟进类型

                    #region 新增客户
                    if (string.IsNullOrWhiteSpace(keyValue))
                    {
                        entity.TrailId        = Guid.NewGuid().ToString();
                        entity.EnabledMark    = 1;
                        entity.DeleteMark     = 0;
                        entity.CreateDate     = DateTime.Now;
                        entity.CreateUserId   = userEntity.UserId;
                        entity.CreateUserName = userEntity.RealName;
                        entity.ModifyDate     = DateTime.Now;

                        if (model.ObjectSort == 2)
                        {
                            entity.ObjectName = customerBLL.GetEntity(model.ObjectId).FullName;
                        }
                    }
                    #endregion

                    #region 更新客户信息
                    else
                    {
                        entity.TrailId        = keyValue;
                        entity.ModifyDate     = DateTime.Now;
                        entity.ModifyUserId   = userEntity.UserId;
                        entity.ModifyUserName = userEntity.RealName;
                    }

                    #endregion

                    trailRecordBLL.AppSaveForm(keyValue, entity);
                    if (!string.IsNullOrWhiteSpace(model.FilesPath))
                    {
                        //相关文件
                        string[] files = model.FilesPath.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                        foreach (var item in files)
                        {
                            var fileInfoEntity = fileInfoBLL.GetEntity(item);
                            if (fileInfoEntity != null)
                            {
                                fileInfoEntity.ObjectId = entity.TrailId;
                                fileInfoBLL.SaveForm(fileInfoEntity.FileId, fileInfoEntity);
                            }
                        }
                    }
                    return(Success("成功"));
                }
                catch (Exception ex)
                {
                    return(Error(ex.Message));
                }
            }
            else
            {
                return(Error("票据验证失败"));
            }
        }