Ejemplo n.º 1
0
        /// <summary>
        /// 保存ReceiveFileManager
        /// </summary>
        /// <param name="newItem">来文信息</param>
        /// <returns></returns>
        public static void SaveReceiveFileManager(Model.ReceiveFileManagerItem newItem)
        {
            Model.SUBHSSEDB db     = Funs.DB;
            string          menuId = string.Empty;

            Model.InformationProject_ReceiveFileManager newReceiveFile = new Model.InformationProject_ReceiveFileManager
            {
                FileType             = newItem.FileType,
                ReceiveFileManagerId = newItem.ReceiveFileManagerId,
                ProjectId            = newItem.ProjectId,
                ReceiveFileCode      = newItem.ReceiveFileCode,
                ReceiveFileName      = newItem.ReceiveFileName,
                Version     = newItem.Version,
                FileCode    = newItem.FileCode,
                FilePageNum = newItem.FilePageNum,
                GetFileDate = Funs.GetNewDateTime(newItem.GetFileDate),
                MainContent = System.Web.HttpUtility.HtmlEncode(newItem.MainContent),
                UnitIds     = newItem.UnitIds,
                States      = Const.State_2,
            };
            if (!string.IsNullOrEmpty(newItem.FileUnitId))
            {
                newReceiveFile.FileUnitId = newItem.FileUnitId;
            }
            if (!string.IsNullOrEmpty(newItem.SendPersonId))
            {
                newReceiveFile.SendPersonId = newItem.SendPersonId;
            }
            if (newItem.States != "1")
            {
                newReceiveFile.States = Const.State_0;
            }

            var updateFile = Funs.DB.InformationProject_ReceiveFileManager.FirstOrDefault(x => x.ReceiveFileManagerId == newItem.ReceiveFileManagerId);

            if (updateFile == null)
            {
                newItem.ReceiveFileManagerId   = newReceiveFile.ReceiveFileManagerId = SQLHelper.GetNewID();
                newReceiveFile.ReceiveFileCode = CodeRecordsService.ReturnCodeByMenuIdProjectId(Const.ReceiveFileManagerMenuId, newReceiveFile.ProjectId, null);
                ReceiveFileManagerService.AddReceiveFileManager(newReceiveFile);
            }
            else
            {
                ReceiveFileManagerService.UpdateReceiveFileManager(newReceiveFile);
            }
            if (newItem.States == "1")
            {
                CommonService.btnSaveData(newItem.ProjectId, Const.ReceiveFileManagerMenuId, newReceiveFile.ReceiveFileManagerId, newReceiveFile.SendPersonId, true, newReceiveFile.ReceiveFileName, "../ReceiveFileManager/ReceiveFileManagerView.aspx?ReceiveFileManagerId={0}");
            }

            ////保存附件
            if (!string.IsNullOrEmpty(newItem.FileAttachUrl))
            {
                UploadFileService.SaveAttachUrl(UploadFileService.GetSourceByAttachUrl(newItem.FileAttachUrl, 10, null), newItem.FileAttachUrl, Const.ReceiveFileManagerMenuId, newItem.ReceiveFileManagerId);
            }
            else
            {
                CommonService.DeleteAttachFileById(Const.ReceiveFileManagerMenuId, newItem.ReceiveFileManagerId);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        ///  根据通知生成一般来文
        /// </summary>
        public static void CreateReceiveFile(Model.InformationProject_Notice notice)
        {
            var    getProjects = Funs.GetStrListByStr(notice.AccessProjectId, ',');
            string unitId      = CommonService.GetIsThisUnitId();
            var    getAtt      = Funs.DB.AttachFile.FirstOrDefault(x => x.ToKeyId == notice.NoticeId);

            foreach (var item in getProjects)
            {
                Model.InformationProject_ReceiveFileManager newFile = new Model.InformationProject_ReceiveFileManager
                {
                    ReceiveFileManagerId = SQLHelper.GetNewID(),
                    ProjectId            = item,
                    ReceiveFileCode      = CodeRecordsService.ReturnCodeByMenuIdProjectId(Const.ReceiveFileManagerMenuId, item, unitId),
                    ReceiveFileName      = notice.NoticeTitle,
                    Version      = "V1.0",
                    FileUnitId   = unitId,
                    FileCode     = notice.NoticeCode,
                    FilePageNum  = 1,
                    GetFileDate  = DateTime.Now,
                    SendPersonId = notice.CompileMan,
                    MainContent  = notice.MainContent,
                };
                if (!string.IsNullOrEmpty(notice.ProjectId))
                {
                    newFile.FileType = "0";
                }
                else
                {
                    newFile.FileType = "1";
                }
                var getPUnits = Funs.DB.Project_ProjectUnit.Where(x => x.ProjectId == item);
                foreach (var uItem in getPUnits)
                {
                    if (string.IsNullOrEmpty(newFile.UnitIds))
                    {
                        newFile.UnitIds = uItem.UnitId;
                    }
                    else
                    {
                        newFile.UnitIds += "," + uItem.UnitId;
                    }
                }
                newFile.States = Const.State_2;
                ReceiveFileManagerService.AddReceiveFileManager(newFile);
                if (getAtt != null && !string.IsNullOrEmpty(getAtt.AttachUrl))
                {
                    APIUpLoadFileService.SaveAttachUrl(Const.ReceiveFileManagerMenuId, newFile.ReceiveFileManagerId, getAtt.AttachUrl, "0");
                }
                CommonService.btnSaveData(item, Const.ReceiveFileManagerMenuId, newFile.ReceiveFileManagerId, newFile.SendPersonId, true, newFile.ReceiveFileName, "../InformationProject/ReceiveFileManagerView.aspx?ReceiveFileManagerId={0}");
            }
        }