Example #1
0
        private Entity.BASE_ARTICLE UpLoadAnnex(Entity.BASE_ARTICLE model)
        {
            BLL.BASE_ARTICLE_ANNEX bllAnnex = new BLL.BASE_ARTICLE_ANNEX();
            for (int index = 0; index < Request.Files.Count; index++)
            {
                if (!string.IsNullOrEmpty(Request.Files[index].FileName))
                {
                    Entity.BASE_ARTICLE_ANNEX annex = new Entity.BASE_ARTICLE_ANNEX();
                    annex.SERVERNAME = Guid.NewGuid().ToString();                        //服务器存储文件名
                    annex.SOURCENAME = Path.GetFileName(Request.Files[index].FileName);  //原文件名称
                    annex.EXTENSION  = Path.GetExtension(Request.Files[index].FileName); //文件扩展名
                    annex.STATUS     = 0;                                                //存储状态:0正常
                    annex.UPAUTHOR   = userSession.USERID;                               //上传者用户ID
                    annex.UPTIME     = DateTime.Now;                                     //文件上传时间
                    annex.SERVERPATH = string.Format("Document/{0}/", DateTime.Now.ToString("yyyyMMdd"));

                    //判断服务器存储目录路径是否存在
                    if (!Directory.Exists(Server.MapPath("~/") + annex.SERVERPATH))
                    {
                        Directory.CreateDirectory(Server.MapPath("~/") + annex.SERVERPATH);
                    }

                    //保存附件(服务器存储路径)
                    Request.Files[index].SaveAs(Server.MapPath("~/") + annex.SERVERPATH + annex.SERVERNAME + annex.EXTENSION);

                    //加入数据库
                    bllAnnex.Add(annex);

                    //公文附件示例:12,56,87,96,56
                    model.ANNEX += bllAnnex.GetMaxId().ToString() + ",";
                }
            }

            return(model);
        }
Example #2
0
        //添加公文
        private void Creates(Entity.BASE_ARTICLE model)
        {
            #region   附件
            BLL.BASE_ARTICLE_ANNEX bllAnnex = new BLL.BASE_ARTICLE_ANNEX();
            for (int index = 0; index < Request.Files.Count; index++)
            {
                if (!string.IsNullOrEmpty(Request.Files[index].FileName))
                {
                    Entity.BASE_ARTICLE_ANNEX annex = new Entity.BASE_ARTICLE_ANNEX();
                    annex.SERVERNAME = Guid.NewGuid().ToString();                        //服务器存储文件名
                    annex.SOURCENAME = Path.GetFileName(Request.Files[index].FileName);  //原文件名称
                    annex.EXTENSION  = Path.GetExtension(Request.Files[index].FileName); //文件扩展名
                    annex.STATUS     = 0;                                                //存储状态:0正常
                    annex.UPAUTHOR   = userSession.USERID;                               //上传者用户ID
                    annex.UPTIME     = DateTime.Now;                                     //文件上传时间
                    annex.SERVERPATH = string.Format("Document/{0}/", DateTime.Now.ToString("yyyyMMdd"));

                    //判断服务器存储目录路径是否存在
                    if (!Directory.Exists(Server.MapPath("~/") + annex.SERVERPATH))
                    {
                        Directory.CreateDirectory(Server.MapPath("~/") + annex.SERVERPATH);
                    }

                    //保存附件(服务器存储路径)
                    Request.Files[index].SaveAs(Server.MapPath("~/") + annex.SERVERPATH + annex.SERVERNAME + annex.EXTENSION);

                    //加入数据库
                    bllAnnex.Add(annex);

                    //公文附件示例:12,56,87,96,56
                    model.ANNEX += bllAnnex.GetMaxId().ToString() + ",";
                }
            }
            #endregion

            //保存公文到数据库
            bll.Add(model);

            /*回复模式不需要添加收文单位*/
            if (hidParentPrimary.Value.Equals("0"))
            {
                //获取出刚添加的公文ID编号
                string where = string.Format("TITLE='{0}'", model.TITLE);
                int id = Convert.ToInt32(bll.GetList(where).Rows[0]["ID"].ToString());

                //增加公文接收部门记录
                foreach (TreeNode node in TreeViewAcceptUnit.Nodes)
                {
                    RecursiveSubNode(node, id);
                }
            }
        }