Beispiel #1
0
        private void upLoad()
        {
            string json = Request["json"];

            FEnt = JsonHelper.GetObject <FileItem>(json);
            PEnt = Project.Find(FEnt.ProjectId);
            IList <FileFolder> ffEnts = FileFolder.FindAllByProperty(FileFolder.Prop_FolderKey, PEnt.ZiXunCode);

            if (ffEnts.Count == 0)
            {
                ffEnt            = new FileFolder();
                ffEnt.Name       = PEnt.ZiXunCode;
                ffEnt.FolderKey  = PEnt.ZiXunCode;
                ffEnt.Path       = PEnt.ZiXunCode;
                ffEnt.ParentId   = "1";
                ffEnt.CreateTime = DateTime.Now;
                ffEnt.ModuleId   = "1";
                ffEnt.DoCreate();
                ffEnt.FullId = "1." + ffEnt.Id;
                ffEnt.DoUpdate();
            }
            else
            {
                ffEnt = ffEnts[0];
            }
            if (!Directory.Exists(@"D:\RW\Files\AppFiles\Portal\" + PEnt.ZiXunCode))
            {
                Directory.CreateDirectory(@"D:\RW\Files\AppFiles\Portal\" + PEnt.ZiXunCode);
            }
            HttpPostedFile postedFile = Request.Files["File"];

            FEnt.Name        = Path.GetFileName(postedFile.FileName); //获取文件名称
            FEnt.GroupId     = "267";
            FEnt.FolderId    = ffEnt.Id;
            FEnt.CreatorId   = WebPortalService.CurrentUserInfo.UserID;
            FEnt.CreatorName = WebPortalService.CurrentUserInfo.Name;
            FEnt.CreateTime  = DateTime.Now;
            FEnt.DoCreate();
            postedFile.SaveAs(@"D:\RW\Files\AppFiles\Portal\" + PEnt.ZiXunCode + @"/" + FEnt.Id + "_" + FEnt.Name);//保存到这个地址
            Response.Write("{success:true}");
            Response.End();
        }
Beispiel #2
0
        private void UpdateFileItem(string filename)
        {
            IList <FileItem> fiEnts = FileItem.FindAllByProperties(FileItem.Prop_ProjectId, pEnt.Id, FileItem.Prop_Path, "导出", FileItem.Prop_Name, filename);

            if (fiEnts.Count == 0)
            {
                FileItem fiEnt = new FileItem();
                fiEnt.ProjectId  = pEnt.Id;
                fiEnt.Name       = filename;
                fiEnt.FolderId   = "1";
                fiEnt.CreateTime = DateTime.Now;
                fiEnt.Path       = "导出";
                fiEnt.DoCreate();
            }
            else
            {
                fiEnts[0].CreateTime = DateTime.Now;
                fiEnts[0].DoUpdate();
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                Aim.Portal.Web.WebPortalService.CheckLogon();
            }
            catch
            {
                Response.Write("<script> window.parent.location.href = '/Login.aspx';</script>");
                Response.End();
            }
            string             action   = Request["action"];
            string             id       = Request["id"];
            Document           srcDoc   = null;
            BookmarkCollection marks    = null;
            string             filename = "";

            switch (action)
            {
            case "DoSelect":
                DoSelect();
                break;

            case "delete":
                Delete();
                break;

            case "Recycle":
                Recycle();
                break;

            case "exporthegeshu":
                pEnt   = Project.Find(id);
                srcDoc = new Document(@"D:\中国瑞林\NCRL_SupervisionProject\Web\Supervision.Web\Template\审查合格书_市政工程_房屋建筑.doc");
                marks  = srcDoc.Range.Bookmarks;
                for (int j = 0; j < marks.Count; j++)
                {
                    Bookmark mark = marks[j];
                    if (ContainProperty(pEnt, mark.Name))
                    {
                        mark.Text = pEnt.GetValue <string>(mark.Name);
                    }
                }
                string sql = @"select a.MajorName,(select top 1 SortIndex from SysEnumeration where ParentId='b640c40c-e2a9-41a8-bd28-d8ff9d71ff94' and Name=a.MajorName) as SortIndex
                                 from NCRL_SP..ProjectUser a where a.ProjectId='" + pEnt.Id + "' order by SortIndex asc";
                IList <EasyDictionary> dics = DataHelper.QueryDictList(sql);
                int i = 1;
                foreach (EasyDictionary dic in dics)
                {
                    if (dic.Get <string>("MajorName") != "勘察")
                    {
                        if (marks["Major" + i] != null)
                        {
                            marks["Major" + i].Text = dic.Get <string>("MajorName");
                        }
                        i++;
                    }
                }
                string fileName = System.Guid.NewGuid().ToString() + ".docx";
                srcDoc.Save(@"D:\中国瑞林\NCRL_SupervisionProject\Web\Supervision.Web\Template\" + fileName);
                break;

            case "exportqingkuangjilu":
                pEnt   = Project.Find(id);
                srcDoc = new Document(@"D:\中国瑞林\NCRL_SupervisionProject\Web\Supervision.Web\Template\附件6房屋建筑和市政基础设施工程施工图设计文件审查情况记录.doc");
                marks  = srcDoc.Range.Bookmarks;
                for (int j = 0; j < marks.Count; j++)
                {
                    Bookmark mark = marks[j];
                    if (ContainProperty(pEnt, mark.Name))
                    {
                        mark.Text = pEnt.GetValue <string>(mark.Name);
                    }
                }
                filename = pEnt.ProjectName + "_审查情况记录_" + DateTime.Now.ToString();
                srcDoc.Save(@"D:\RW\Files\AppFiles\Portal\Default\" + filename + ".docx");
                FileItem fiEnt = new FileItem();
                fiEnt.ProjectId  = pEnt.Id;
                fiEnt.Name       = filename;
                fiEnt.CreateTime = DateTime.Now;
                fiEnt.Path       = "导出";
                fiEnt.DoCreate();
                break;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                Aim.Portal.Web.WebPortalService.CheckLogon();
            }
            catch
            {
                Response.Write("<script> window.parent.location.href = '/Login.aspx';</script>");
                Response.End();
            }
            string     action    = Request["action"];
            string     groupid   = Request["groupid"];
            string     projectId = Request["projectid"];
            FileFolder ffEnt     = null;
            Project    pEnt      = null;

            switch (action)
            {
            case "upload":
                //如果是项目文档  上传项目编号文件夹 如果是部门文档上传到DEFAULT文件夹
                if (!string.IsNullOrEmpty(projectId))
                {
                    pEnt = Project.Find(projectId);
                    IList <FileFolder> ffEnts = FileFolder.FindAllByProperty(FileFolder.Prop_FolderKey, pEnt.ProjectCode);
                    if (ffEnts.Count == 0)
                    {
                        ffEnt            = new FileFolder();
                        ffEnt.Name       = pEnt.ProjectCode;
                        ffEnt.FolderKey  = pEnt.ProjectCode;
                        ffEnt.Path       = pEnt.ProjectCode;
                        ffEnt.ParentId   = "1";
                        ffEnt.CreateTime = DateTime.Now;
                        ffEnt.ModuleId   = "1";
                        ffEnt.DoCreate();
                        ffEnt.FullId = "1." + ffEnt.Id;
                        ffEnt.DoUpdate();
                    }
                    else
                    {
                        ffEnt = ffEnts[0];
                    }
                    if (!Directory.Exists(@"D:\RW\Files\AppFiles\Portal\" + pEnt.ProjectCode))
                    {
                        Directory.CreateDirectory(@"D:\RW\Files\AppFiles\Portal\" + pEnt.ProjectCode);
                    }
                }
                else
                {
                    ffEnt = FileFolder.Find("1");    //如果是非项目文档,上传到默认文件夹
                }
                string   formdata = Request["formdata"];
                JObject  json     = Aim.JsonHelper.GetObject <JObject>(formdata);
                FileItem fiEnt    = new FileItem();
                fiEnt.GroupId      = groupid;
                fiEnt.ProjectId    = projectId;
                fiEnt.FirstTypeId  = json.Value <string>("FirstTypeId");
                fiEnt.SecondTypeId = json.Value <string>("SecondTypeId");
                HttpPostedFile postedFile = Request.Files["projectfile"];    //获取上传信息对象
                string         fileName   = Path.GetFileName(postedFile.FileName);
                fiEnt.Name        = fileName;
                fiEnt.FolderId    = ffEnt.Id;
                fiEnt.CreatorId   = Aim.Portal.Web.WebPortalService.CurrentUserInfo.UserID;
                fiEnt.CreatorName = Aim.Portal.Web.WebPortalService.CurrentUserInfo.Name;
                fiEnt.CreateTime  = DateTime.Now;
                fiEnt.DoCreate();
                // string filename = postedFile.FileName;//获取上传的文件路径
                // string tempPath = System.Configuration.ConfigurationManager.AppSettings["NewsFolderPath"];//获取保存文件夹路径,我是设置在webconfig中了。
                // string savepath = Server.MapPath(@"D:\RW\Files\AppFiles\Portal\" + pEnt.ProjectCode + "\\");//获取保存路径
                // string sExtension = filename.Substring(filename.LastIndexOf('.'));//获取拓展名
                //if (!Directory.Exists(savepath))
                //Directory.CreateDirectory(savepath);
                //string sNewFileName = DateTime.Now.ToString("yyyyMMddhhmmsfff"); + fiEnt.Id + "_"" + seEnt.IsLeaf + "
                postedFile.SaveAs(@"D:\RW\Files\AppFiles\Portal\" + ffEnt.Path + @"/" + fiEnt.Id + "_" + fileName);    //保存
                Response.Write("{success:true}");
                Response.End();
                break;

            case "loadfiletype":
                string id = Request["id"];
                if (string.IsNullOrEmpty(id))
                {
                    id = "cf38bd7a-79d1-46fb-bf06-640b30f61654";
                }
                IList <SysEnumeration> seEnts = SysEnumeration.FindAllByProperty("SortIndex", SysEnumeration.Prop_ParentID, id);
                int    i      = 0;
                string result = "[";
                foreach (SysEnumeration seEnt in seEnts)
                {
                    if (i != seEnts.Count - 1)
                    {
                        result += "{'id':'" + seEnt.EnumerationID + "','text':'" + seEnt.Name + "','leaf':" + (seEnt.IsLeaf.Value ? "true" : "false") + ",'parentid':'" + seEnt.ParentID + "'},";
                    }
                    else
                    {
                        result += "{'id':'" + seEnt.EnumerationID + "','text':'" + seEnt.Name + "','leaf':" + (seEnt.IsLeaf.Value ? "true" : "false") + ",'parentid':'" + seEnt.ParentID + "'}";
                    }
                    i++;
                }
                result += "]";
                Response.Write(result);
                Response.End();
                break;

            case "getprojectname":
                string temp = "{";
                if (!string.IsNullOrEmpty(projectId))
                {
                    pEnt  = Project.Find(projectId);
                    temp += "ProjectName:'" + pEnt.ProjectName + "'";
                }
                if (!string.IsNullOrEmpty(groupid))
                {
                    SysGroup sgEnt = SysGroup.Find(groupid);
                    temp += (temp.Length > 1 ? ",GroupName:'" : "GroupName:'") + sgEnt.Name + "'";
                }
                Response.Write(temp + "}");
                Response.End();
                break;
            }
        }