示例#1
0
        /// <summary>
        /// 附件添加
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public static List <Attachment> AttachmentUpload()
        {
            HttpFileCollection files          = HttpContext.Current.Request.Files;
            List <Attachment>  attachmentlist = new List <Attachment>();

            for (int i = 0; i < files.Count; i++)
            {
                IESFile file = Upload(files[i]);
                if (file.FileGuid != null && file.FileGuid != string.Empty)
                {
                    if (RemoteFileExists(file))
                    {
                        AttachmentBLL bll = new AttachmentBLL();

                        Attachment attachment = new Attachment
                        {
                            FileName  = file.FileName,
                            ServerID  = file.ServerID,
                            FileSize  = file.FileSize,
                            Title     = file.FileTitle,
                            Guid      = file.FileGuid,
                            Source    = string.Empty,
                            SourceID  = 0,
                            RefFileID = "0"
                        };
                        if (bll.Attachment_ADD(attachment))
                        {
                            attachmentlist.Add(attachment);
                        }
                    }
                }
            }
            return(attachmentlist);
        }
        private string EditAttachment(NameValueCollection rParams)
        {
            string res = "{success:false,msg:'编辑失败'}";

            //组装参数
            AttachmentEntity entity = new AttachmentEntity();

            if (!string.IsNullOrEmpty(rParams["id"]))
            {
                entity = new AttachmentBLL(CurrentUserInfo).GetByID(rParams["id"]);
            }
            entity = DataLoader.LoadFrom <AttachmentEntity>(rParams, entity);

            entity.ClientID = CurrentUserInfo.ClientID;
            if (!string.IsNullOrEmpty(rParams["id"]))
            {
                new AttachmentBLL(CurrentUserInfo).Update(entity);
            }
            else
            {
                new AttachmentBLL(CurrentUserInfo).Create(entity);
            }
            res = "{success:true,msg:'编辑成功',id:'" + entity.AttachmentID + "'}";
            return(res);
        }
示例#3
0
        /// <summary>
        /// 附件添加
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public static Attachment AttachmentUpload(HttpPostedFileBase postfile)
        {
            IESFile file = Upload(postfile);

            if (file.FileGuid != null && file.FileGuid != string.Empty)
            {
                if (RemoteFileExists(file))
                {
                    AttachmentBLL bll        = new AttachmentBLL();
                    Attachment    attachment = new Attachment
                    {
                        FileName  = file.FileName,
                        ServerID  = file.ServerID,
                        FileSize  = file.FileSize,
                        Title     = file.FileTitle,
                        Guid      = file.FileGuid,
                        Source    = string.Empty,
                        SourceID  = 0,
                        RefFileID = "0"
                    };
                    if (bll.Attachment_ADD(attachment))
                    {
                        return(attachment);
                    }
                }
            }
            return(new Attachment());
        }
示例#4
0
 public static List<Attachment> Attachment_NoCache_List(int SourceID)
 {
     Attachment model = new Attachment();
     model.Source = "OC";
     model.SourceID = SourceID;
     AttachmentBLL attachmentbll = new AttachmentBLL();
     return attachmentbll.Attachment_NoCache_List(model);
 }
        private string DeleteAttachment(string id)
        {
            string           res    = "{success:false}";
            AttachmentEntity entity = new AttachmentBLL(CurrentUserInfo).GetByID(Guid.Parse(id));

            new AttachmentBLL(CurrentUserInfo).Delete(entity);
            res = "{success:true}";
            return(res);
        }
示例#6
0
        /// <summary>
        /// 获取用户图片列表
        /// </summary>
        /// <returns></returns>
        public static List <Attachment> Attachment_UserIMG_List()
        {
            Attachment model = new Attachment {
                Source = "User"
            };
            AttachmentBLL attachmentBLL = new AttachmentBLL();

            return(attachmentBLL.Attachment_List(model));
        }
示例#7
0
        public static List <Attachment> Attachment_NoCache_List(int SourceID)
        {
            Attachment model = new Attachment();

            model.Source   = "OC";
            model.SourceID = SourceID;
            AttachmentBLL attachmentbll = new AttachmentBLL();

            return(attachmentbll.Attachment_NoCache_List(model));
        }
示例#8
0
        public ActionResult GetFormJsonFile(string keyValue)
        {
            AttachmentBLL att      = new AttachmentBLL(); //附件
            var           data     = creditmoneybll.GetEntity(keyValue);
            var           attach   = att.GetFormList(data.filesPath);
            var           jsonData = new
            {
                entitys = data,
                attachs = attach
            };

            return(ToJsonResult(jsonData));
        }
示例#9
0
 public static bool Attachment_SourceID_Upd(Attachment model)
 {
     return(AttachmentBLL.Attachment_SourceID_Upd(model));
 }
 public AttachmentApiController(AttachmentBLL bll)
 {
     m_BLL = bll;
 }
示例#11
0
        /// <summary>
        /// 获取附件列表
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static List <Attachment> Attachment_List(Attachment model)
        {
            AttachmentBLL attachmentBLL = new AttachmentBLL();

            return(attachmentBLL.Attachment_List(model));
        }
示例#12
0
        public static Attachment Attachment_Get(string FileID)
        {
            AttachmentBLL attachmentbll = new AttachmentBLL();

            return(attachmentbll.Attachment_Get(FileID));
        }
示例#13
0
        private void DoFileUpload()
        {
            DirectoryInfo theFolder = new DirectoryInfo(Url);
            //获取年
            string Year = DateTime.Now.Year.ToString();
            //获取月
            string Month = DateTime.Now.Month.ToString();
            //获取日
            string Day       = DateTime.Now.Day.ToString();
            string hm        = DateTime.Now.Hour.ToString() + "" + DateTime.Now.Minute.ToString();
            string timestamp = Year + Month + Day + hm;

            string day             = DateTime.Now.Day.ToString();
            string strDirectory    = ConfigurationSettings.AppSettings["SavePath"].ToString(); //存放的路径 固定写死  参见配置文件
            string DictoryFileName = Year + @"\" + Month + @"\" + day + @"\";
            string LogDirectory    = strDirectory + "Log";                                     //日志文件
            //定义名称为当天日期的文件夹的路径
            string path = strDirectory + @"\" + DictoryFileName;

            int NumSuccess = 0;
            int NumError   = 0;
            int NumAll     = FilePaths.Count();

            startDate = DateTime.Now;//开始导入数据时间
            foreach (FileInfo fi in FilePaths)
            {
                //虚拟路径
                string tempVirtualPath = fi.FullName.Replace(Url.Remove(Url.LastIndexOf('\\')), string.Empty).Remove(0, 1);
                at.VirtualPath = tempVirtualPath.Remove(tempVirtualPath.LastIndexOf('\\'));
                try
                {
                    bool   ConvertResult = false;
                    string destFileName  = path + at.VirtualPath + "\\" + fi.Name.Remove(fi.Name.LastIndexOf('.')) + ".pdf";
                    //创建文件夹
                    if (!Directory.Exists(path + at.VirtualPath))
                    {
                        Directory.CreateDirectory(path + at.VirtualPath);
                    }
                    if (".pdf".Contains(fi.Extension))
                    {
                        try
                        {
                            File.Copy(fi.FullName, destFileName, true);
                            ConvertResult = true;
                        }
                        catch (Exception ex)
                        {
                            ConvertResult = false;
                        }
                    }
                    else if (".doc.docx".Contains(fi.Extension))
                    {
                        ConvertResult = FileConversion.WordToPDF(fi.FullName, destFileName);
                    }
                    else if (".xls.xlsx".Contains(fi.Extension))
                    {
                        ConvertResult = FileConversion.ExcelToPDF(fi.FullName, destFileName);
                    }
                    else if (".ppt.pptx".Contains(fi.Extension))
                    {
                        ConvertResult = FileConversion.PowerPointToPDF(fi.FullName, destFileName);
                    }
                    //判断文件复制、转换是否成功
                    if (ConvertResult)
                    {
                        //写入数据库
                        at.Suffix     = fi.Extension;
                        at.FileName   = fi.Name.Remove(fi.Name.LastIndexOf('.'));
                        at.CreateDate = DateTime.Now;
                        at.BateSize   = decimal.Round(decimal.Round(fi.Length) / (1024 * 1024), 2);
                        at.BatchNo    = timestamp;
                        at.FtpPath    = path.Replace(@"E:\", string.Empty);
                        at.FtpName    = fi.Name;
                        at.CreateBy   = BaseForm.UserName;
                        at.filetag    = "0";
                        if (new Sino.Bll.AttachmentBLL().Add(at))
                        {
                            //删除源文件
                            File.Delete(fi.FullName);
                            //kill进程
                            KillProcess("WINWORD");
                            KillProcess("EXCEL");
                            NumSuccess++;
                        }
                    }
                    else
                    {
                        NumError++;
                        string Text = "【PDF转换失败】:" + fi.FullName + "\r\n【操作时间】:" + DateTime.Now + "\r\n【操作人】:" + BaseForm.UserName + "\r\n===========================================";
                        WritfLogText(LogDirectory, timestamp, Text);
                    }
                    //更新归档状态和进度条更新
                    this.Invoke(new Action <int, int>((numSuccess, numError) =>
                    {
                        progressBar1.Value = (numSuccess + numError) * 100 / NumAll;
                        label1.Text        = "成功导入:" + numSuccess + "个文件\r\n\r\n失败:" + NumError + "个文件";
                    }), NumSuccess, NumError);
                }
                catch
                { }
            }
            //批量加入关键字数据
            if (!string.IsNullOrWhiteSpace(this.txtKeyWord.Text.Trim()))
            {
                try
                {
                    DataTable dtAtt = new AttachmentBLL().GetListID(startDate, UserName);
                    DataTable dtEva = new DataTable();
                    dtEva.Columns.Add("UserName", typeof(string));
                    dtEva.Columns.Add("OperateTime", typeof(string));
                    dtEva.Columns.Add("UserName", typeof(string));
                    dtEva.Columns.Add("Fid", typeof(int));
                    if (dtAtt != null)
                    {
                        foreach (DataRow row in dtAtt.Rows)
                        {
                            DataRow rowEva = dtEva.NewRow();
                            rowEva["UserName"]    = UserName;
                            rowEva["Fid"]         = int.Parse(row["ID"].ToString());
                            rowEva["KeyWords"]    = this.txtKeyWord.Text.Trim();;
                            rowEva["OperateTime"] = DateTime.Now.ToShortDateString();
                            dtEva.Rows.Add(rowEva);
                        }
                    }
                    new EvaluateBLL().InserDataTable(dtEva, "BT_Evaluate");
                }
                catch
                {
                }
            }
            this.Invoke(new Action(() =>
            {
                MessageBox.Show("上传文件成功!", "提示", MessageBoxButtons.OK);
            }));
        }
示例#14
0
 public static Attachment Attachment_Get(string FileID)
 {
     AttachmentBLL attachmentbll = new AttachmentBLL();
     return attachmentbll.Attachment_Get(FileID);
 }
示例#15
0
 public static bool Attachment_Del(Attachment model)
 {
     return(AttachmentBLL.Attachment_Del(model));
 }