Beispiel #1
0
        /// <summary>
        /// 文件附件数据库操作
        /// </summary>
        /// <param name="att">DocAttachFile类</param>
        /// <param name="DocID">文件ID</param>
        public void AddAttach(DocAttachFile att, int DocID)
        {
            Database data = new Database();

            SqlParameter[] prams =
            {
                data.MakeInParam("@DocID",          SqlDbType.Int,       20, DocID),
                data.MakeInParam("@FileName",       SqlDbType.VarChar,  300, att.FileName),
                data.MakeInParam("@FileSize",       SqlDbType.Int,       20, att.FileSize),
                data.MakeInParam("@FileAttribute",  SqlDbType.SmallInt,  20, att.FileAttribute),
                data.MakeInParam("@FileVisualPath", SqlDbType.NVarChar, 200, att.FileVisualPath),
                data.MakeInParam("@FileAuthor",     SqlDbType.NVarChar,  50, att.FileAuthor),
                data.MakeInParam("@FileCatlog",     SqlDbType.NVarChar,  20, att.FileCatlog),
                data.MakeInParam("@FileAddedDate",  SqlDbType.DateTime,  30, DateTime.Parse(att.FileAddedDate))
            };
            try
            {
                data.RunProc("SP_Ext_AddFile", prams);
            }
            catch (Exception ex)
            {
                Error.Log(ex.ToString());
                throw new Exception("文件附件发送出错!", ex);
            }
        }
Beispiel #2
0
        /// <summary>
        /// �����ϴ�����,������������ʽ���
        /// </summary>
        private ArrayList AttUpload()
        {
            HtmlForm FrmCompose   = (HtmlForm)this.Page.FindControl("DeliverDocument");
            Random TempNameInt    = new Random();
            string NewDocDirName  = TempNameInt.Next(100000000).ToString();
            ArrayList listattfile = (ArrayList)Session["listattfile"];

            // ��Ÿ������ύ��Ŀ¼�У��������Ŀ¼��

            string FileName       = "";
            try
            {
                if(Directory.Exists(Server.MapPath(".")+"\\AttachFiles\\tmp"))
                {
                    Directory.CreateDirectory(Server.MapPath(".")+"\\AttachFiles\\tmp\\"+NewDocDirName+Username);
                    for (int i=0;i<FrmCompose.Controls.Count;i++)
                    {
                        if(FrmCompose.Controls [i].GetType().ToString()=="System.Web.UI.HtmlControls.HtmlInputFile")
                        {

                            HtmlInputFile hif = ((HtmlInputFile)(FrmCompose.Controls[i]));
                            if(hif.PostedFile.FileName.Trim()!="")
                            {
                                FileName = System.IO .Path.GetFileName(hif.PostedFile.FileName);
                                UDS.Components.DocAttachFile att = new UDS.Components.DocAttachFile();
                                // ��ʼ��
                                att.FileAttribute  = 0;
                                att.FileSize       = hif.PostedFile.ContentLength;
                                att.FileName	   = FileName;
                                att.FileAuthor     = Username;
                                att.FileCatlog     = "�ĵ�";
                                att.FileVisualPath = "AttachFiles\\tmp\\"+NewDocDirName+Username+"\\"+FileName;
                                hif.PostedFile.SaveAs(Server.MapPath(".")+"\\AttachFiles\\tmp\\"+NewDocDirName+Username+"\\"+FileName);
                                listattfile.Add(att);

                            }
                            hif=null;
                        }
                    }

                }
                else
                {
                    Directory.CreateDirectory(Server.MapPath(".")+"\\AttachFiles\\tmp");
                    AttUpload();
                }

            }
            catch(Exception ioex)
            {
                UDS.Components.Error.Log(ioex.ToString());
                Server.Transfer("../../Error.aspx");
            }

            Session["listattfile"] = listattfile;
            return listattfile;
        }
Beispiel #3
0
        /// <summary>
        /// 处理上传操作,附件以链接形式存放
        /// </summary>
        private ArrayList AttUpload()
        {
            HtmlForm  FrmCompose    = (HtmlForm)this.Page.FindControl("DeliverDocument");
            Random    TempNameInt   = new Random();
            string    NewDocDirName = TempNameInt.Next(100000000).ToString();
            ArrayList listattfile   = (ArrayList)Session["listattfile"];

            // 存放附件至提交人目录中,随机生成目录名

            string FileName = "";

            try
            {
                if (Directory.Exists(Server.MapPath(".") + "\\AttachFiles\\tmp"))
                {
                    Directory.CreateDirectory(Server.MapPath(".") + "\\AttachFiles\\tmp\\" + NewDocDirName + Username);
                    for (int i = 0; i < FrmCompose.Controls.Count; i++)
                    {
                        if (FrmCompose.Controls [i].GetType().ToString() == "System.Web.UI.HtmlControls.HtmlInputFile")
                        {
                            HtmlInputFile hif = ((HtmlInputFile)(FrmCompose.Controls[i]));
                            if (hif.PostedFile.FileName.Trim() != "")
                            {
                                FileName = System.IO.Path.GetFileName(hif.PostedFile.FileName);
                                UDS.Components.DocAttachFile att = new UDS.Components.DocAttachFile();
                                // 初始化
                                att.FileAttribute  = 0;
                                att.FileSize       = hif.PostedFile.ContentLength;
                                att.FileName       = FileName;
                                att.FileAuthor     = Username;
                                att.FileCatlog     = "文档";
                                att.FileVisualPath = "AttachFiles\\tmp\\" + NewDocDirName + Username + "\\" + FileName;
                                hif.PostedFile.SaveAs(Server.MapPath(".") + "\\AttachFiles\\tmp\\" + NewDocDirName + Username + "\\" + FileName);
                                listattfile.Add(att);
                            }
                            hif = null;
                        }
                    }
                }
                else
                {
                    Directory.CreateDirectory(Server.MapPath(".") + "\\AttachFiles\\tmp");
                    AttUpload();
                }
            }
            catch (Exception ioex)
            {
                UDS.Components.Error.Log(ioex.ToString());
                Server.Transfer("../../Error.aspx");
            }

            Session["listattfile"] = listattfile;
            return(listattfile);
        }
Beispiel #4
0
 /// <summary>
 /// �ļ��������ݿ����
 /// </summary>
 /// <param name="att">DocAttachFile��</param>
 /// <param name="DocID">�ļ�ID</param>
 public void AddAttach(DocAttachFile att,int DocID)
 {
     Database data = new Database();
     SqlParameter[] prams = {
                                data.MakeInParam("@DocID",  SqlDbType.Int, 20, DocID),
                                data.MakeInParam("@FileName",  SqlDbType.VarChar, 300, att.FileName),
                                data.MakeInParam("@FileSize",  SqlDbType.Int, 20, att.FileSize),
                                data.MakeInParam("@FileAttribute",  SqlDbType.SmallInt,20, att.FileAttribute),
                                data.MakeInParam("@FileVisualPath",  SqlDbType.NVarChar, 200, att.FileVisualPath),
                                data.MakeInParam("@FileAuthor",  SqlDbType.NVarChar, 50, att.FileAuthor),
                                data.MakeInParam("@FileCatlog",  SqlDbType.NVarChar, 20, att.FileCatlog),
                                data.MakeInParam("@FileAddedDate", SqlDbType.DateTime, 30, DateTime.Parse(att.FileAddedDate))
                            };
     try
     {
         data.RunProc("SP_Ext_AddFile", prams);
     }
     catch (Exception ex)
     {
         Error.Log(ex.ToString());
         throw new Exception("�ļ��������ͳ���!",ex);
     }
     finally
     {
         if (data != null)
         {
             data.Close();
             data.Dispose();
         }
     }
 }
Beispiel #5
0
        private void UploadFile(long DocID)
        {
            string   FileName   = "";
            HtmlForm FrmCompose = (HtmlForm)this.Page.FindControl("NewDocument");

            //生成附件目录
            if (!System.IO.Directory.Exists(Server.MapPath(".") + "\\AttachFiles"))
            {
                System.IO.Directory.CreateDirectory(Server.MapPath(".") + "\\AttachFiles");
            }

            try
            {
                HtmlInputFile hif = ((HtmlInputFile)(FrmCompose.FindControl("fileTemplate")));
                if (hif.PostedFile != null)
                {
                    if (hif.PostedFile.FileName.Trim() != "")
                    {
                        FileName = System.IO.Path.GetFileName(hif.PostedFile.FileName);

                        //生成用户目录
                        if (!System.IO.Directory.Exists(Server.MapPath(".") + "\\AttachFiles\\" + UserName))
                        {
                            System.IO.Directory.CreateDirectory(Server.MapPath(".") + "\\AttachFiles\\" + UserName);
                        }

                        Random TempNameInt   = new Random();
                        string NewDocDirName = TempNameInt.Next(100000000).ToString();
                        //生成随机目录
                        if (!System.IO.Directory.Exists(Server.MapPath(".") + "\\AttachFiles\\" + UserName + "\\" + NewDocDirName))
                        {
                            System.IO.Directory.CreateDirectory(Server.MapPath(".") + "\\AttachFiles\\" + UserName + "\\" + NewDocDirName);
                        }

                        TempNameInt = null;

                        //保存文件
                        hif.PostedFile.SaveAs(Server.MapPath(".") + "\\AttachFiles\\" + UserName + "\\" + NewDocDirName + "\\" + FileName);

                        UDS.Components.DocAttachFile att = new UDS.Components.DocAttachFile();
                        UDS.Components.DocumentFlow  df  = new UDS.Components.DocumentFlow();

                        // 初始化
                        att.FileAttribute  = 0;
                        att.FileSize       = hif.PostedFile.ContentLength;
                        att.FileName       = FileName;
                        att.FileAuthor     = UserName;
                        att.FileCatlog     = "公文";
                        att.FileVisualPath = "\\AttachFiles\\" + UserName + "\\" + NewDocDirName + "\\";
                        att.FileAddedDate  = DateTime.Now.ToString();;

                        df.AddAttach(att, DocID);

                        df  = null;
                        att = null;
                    }
                    hif = null;
                }
            }
            catch (Exception ex)
            {
                UDS.Components.Error.Log(ex.ToString());
            }
            finally
            {
            }
        }
Beispiel #6
0
        /// <summary>
        /// �ĵ��������������ĵ��������������
        /// </summary>
        private void DocProcess(MailMainBody mailbody,ArrayList upattlist)
        {
            string DocID = "";
            int cstRightToApproveDocument = 2;
            ProjectClass pjt = new ProjectClass();
            DocBody docbody = new DocBody();
            docbody.DocTitle			= mailbody.MailSubject;
            docbody.DocContent			= mailbody.MailBody;
            docbody.DocAddedBy			= mailbody.MailSender;
            docbody.DocClassID			= mailbody.MailClassID;
            docbody.DocAddedDate        = DateTime.Now.ToString();
            docbody.DocApprover			= (pjt.GetAccessPermission(Int32.Parse(ClassID),Username,cstRightToApproveDocument))?Username:"";
            docbody.DocApproveDate		= (pjt.GetAccessPermission(Int32.Parse(ClassID),Username,cstRightToApproveDocument))?DateTime.Now.ToString():"";
            docbody.DocApproved         = (docbody.DocApprover =="")?0:1;
            docbody.DocAttribute        = 0;
            docbody.DocType				= 0;

            DocumentClass doc = new DocumentClass();
            // ����ĵ�,������ID

            DocID = doc.AddDocBody(docbody);
            foreach(UDS.Components.MailAttachFile  att in upattlist)
            {
                try
                {
                    DocAttachFile docatt = new DocAttachFile();
                    //  Mail Attach File ��ת��ΪDoc Attach File
                    docatt.FileAttribute  = 0;
                    docatt.FileSize       = att.FileSize;
                    docatt.FileName	      = att.FileName;
                    docatt.FileAuthor     = Username;
                    docatt.FileCatlog     = "�ĵ�";
                    docatt.FileVisualPath = "Mail"+att.FileVisualPath;
                    docatt.FileAddedDate  = DateTime.Now.ToString();
                    docatt.DocID          = Int32.Parse(DocID);
                    // ת������

                    // �������ݿ⴦��
                    doc.AddAttach(docatt,Int32.Parse(DocID));

                }
                catch(Exception ioex)
                {
                    UDS.Components.Error.Log(ioex.ToString());
                    Server.Transfer("../../Error.aspx");
                }
            }
        }
Beispiel #7
0
        private void UploadFile(long DocID)
        {
            string FileName = "";
            HtmlForm FrmCompose   = (HtmlForm)this.Page.FindControl("NewDocument");

            //���ɸ���Ŀ¼
            if(!System.IO.Directory.Exists(Server.MapPath(".")+"\\AttachFiles"))
            {
                System.IO.Directory.CreateDirectory(Server.MapPath(".")+"\\AttachFiles");
            }

            try
            {
                HtmlInputFile hif = ((HtmlInputFile)(FrmCompose.FindControl("fileTemplate")));
                if(hif.PostedFile!=null)
                {
                    if(hif.PostedFile.FileName.Trim()!="")
                    {
                        FileName = System.IO.Path.GetFileName(hif.PostedFile.FileName);

                        //�����û�Ŀ¼
                        if(!System.IO.Directory.Exists(Server.MapPath(".")+"\\AttachFiles\\" + UserName))
                        {
                            System.IO.Directory.CreateDirectory(Server.MapPath(".")+"\\AttachFiles\\"+ UserName);
                        }

                        Random TempNameInt    = new Random();
                        string NewDocDirName  = TempNameInt.Next(100000000).ToString();
                        //�������Ŀ¼
                        if(!System.IO.Directory.Exists(Server.MapPath(".")+"\\AttachFiles\\" + UserName + "\\" + NewDocDirName))
                        {
                            System.IO.Directory.CreateDirectory(Server.MapPath(".")+"\\AttachFiles\\" + UserName  + "\\" + NewDocDirName);
                        }

                        TempNameInt = null;

                        //�����ļ�
                        hif.PostedFile.SaveAs(Server.MapPath(".")+"\\AttachFiles\\" + UserName  + "\\" + NewDocDirName + "\\" + FileName);

                        UDS.Components.DocAttachFile att = new UDS.Components.DocAttachFile();
                        UDS.Components.DocumentFlow  df  = new UDS.Components.DocumentFlow();

                        // ��ʼ��
                        att.FileAttribute	= 0;
                        att.FileSize		= hif.PostedFile.ContentLength;
                        att.FileName		= FileName;
                        att.FileAuthor		= UserName;
                        att.FileCatlog		= "����";
                        att.FileVisualPath	= "\\AttachFiles\\" + UserName  + "\\" + NewDocDirName + "\\";
                        att.FileAddedDate	= DateTime.Now.ToString();;

                        df.AddAttach(att,DocID);

                        df = null;
                        att = null;

                    }
                    hif=null;
                }
            }
            catch(Exception ex)
            {
                UDS.Components.Error.Log(ex.ToString());
            }
            finally
            {

            }
        }
Beispiel #8
0
        public void MailIncoming(string MailID,string ClassID)
        {
            SqlDataReader dataReader = null;

            if(MailID!=""&&ClassID!="")
            {
                try
                {
                    throw new Exception("�������");

                    String Username = Request.Cookies["Username"].Value.ToString();
                    MailClass mailclass = new MailClass();
                    ProjectClass pjt = new ProjectClass();
                    DocBody docbody = new DocBody();
                    DocumentClass doc = new DocumentClass();

                    dataReader = mailclass.GetMailCompleteInfoDbreader(MailID);
                    if (dataReader.Read())
                    {
                        int cstRightToApproveDocument = 2;

                        docbody.DocTitle = dataReader["MailSubject"].ToString();
                        docbody.DocContent = dataReader["MailBody"].ToString(); ;
                        docbody.DocAddedBy = dataReader["MailSender"].ToString(); ;
                        docbody.DocClassID = Int32.Parse(ClassID);
                        docbody.DocAddedDate = DateTime.Now.ToString();
                        docbody.DocApprover = (pjt.GetAccessPermission(Int32.Parse(ClassID), Username, cstRightToApproveDocument)) ? Username : "";
                        docbody.DocApproveDate = (pjt.GetAccessPermission(Int32.Parse(ClassID), Username, cstRightToApproveDocument)) ? DateTime.Now.ToString() : "";
                        docbody.DocApproved = (docbody.DocApprover == "") ? 0 : 1;
                        docbody.DocAttribute = 0;
                        docbody.DocType = 0;

                    }
                    dataReader.Close();
                    string DocID = doc.AddDocBody(docbody);

                    dataReader = mailclass.GetMailAttInfoDbreader(MailID);
                    while (dataReader.Read())
                    {
                        DocAttachFile docatt = new DocAttachFile();
                        docatt.FileAttribute = 0;
                        docatt.FileSize = Int32.Parse(dataReader["FileSize"].ToString());
                        docatt.FileName = dataReader["FileName"].ToString();
                        docatt.FileAuthor = Username;
                        docatt.FileCatlog = "�ĵ�";
                        docatt.FileVisualPath = "Mail" + dataReader["FileVisualPath"].ToString();
                        docatt.FileAddedDate = DateTime.Now.ToString();
                        docatt.DocID = Int32.Parse(DocID);
                        doc.AddAttach(docatt, Int32.Parse(DocID));
                    }

                    dataReader = null;
                    pjt = null;
                    docbody = null;
                }
                catch (Exception oe)
                {
                    throw new Exception(oe.Message);
                }
                finally
                {
                    if(null != dataReader)
                        if (!dataReader.IsClosed)
                        {
                            dataReader.Close();
                        }
                }
            }
        }
Beispiel #9
0
        public void MailIncoming(string MailID,string ClassID)
        {
            if(MailID!=""&&ClassID!="")
            {
                SqlDataReader dataReader = null;
                try
                {
                    String Username = Server.UrlDecode(Request.Cookies["UserName"].Value);
                    MailClass mailclass = new MailClass();

                    ProjectClass pjt = new ProjectClass();
                    DocBody docbody = new DocBody();
                    DocumentClass doc = new DocumentClass();

                    dataReader = mailclass.GetMailCompleteInfoDbreader(MailID);
                    if (dataReader.Read())
                    {
                        int cstRightToApproveDocument = 2;

                        docbody.DocTitle = dataReader["MailSubject"].ToString();
                        docbody.DocContent = dataReader["MailBody"].ToString(); ;
                        docbody.DocAddedBy = dataReader["MailSender"].ToString(); ;
                        docbody.DocClassID = Int32.Parse(ClassID);
                        docbody.DocAddedDate = DateTime.Now.ToString();
                        docbody.DocApprover = (pjt.GetAccessPermission(Int32.Parse(ClassID), Username, cstRightToApproveDocument)) ? Username : "";
                        docbody.DocApproveDate = (pjt.GetAccessPermission(Int32.Parse(ClassID), Username, cstRightToApproveDocument)) ? DateTime.Now.ToString() : "";
                        docbody.DocApproved = (docbody.DocApprover == "") ? 0 : 1;
                        docbody.DocAttribute = 0;
                        docbody.DocType = 0;

                    }
                    dataReader.Close();
                    string DocID = doc.AddDocBody(docbody);

                    dataReader = mailclass.GetMailAttInfoDbreader(MailID);
                    while (dataReader.Read())
                    {
                        DocAttachFile docatt = new DocAttachFile();
                        docatt.FileAttribute = 0;
                        docatt.FileSize = Int32.Parse(dataReader["FileSize"].ToString());
                        docatt.FileName = dataReader["FileName"].ToString();
                        docatt.FileAuthor = Username;
                        docatt.FileCatlog = "�ĵ�";
                        docatt.FileVisualPath = "Mail" + dataReader["FileVisualPath"].ToString();
                        docatt.FileAddedDate = DateTime.Now.ToString();
                        docatt.DocID = Int32.Parse(DocID);
                        doc.AddAttach(docatt, Int32.Parse(DocID));
                    }

                   // dataReader = null;
                    if (dataReader != null)
                    {
                        dataReader.Close();
                    }
                    pjt = null;
                    docbody = null;

                    Response.Write("<script language=javascript>alert('�鵵�ɹ�!');</script>");
                }
                catch (Exception oe)
                {
                    UDS.Components.Error.Log(oe.ToString());
                    Server.Transfer("../Error.aspx");
                }
                finally
                {
                    if (dataReader != null)
                    {
                        dataReader.Close();
                    }
                }
            }
        }