/// <summary> /// 创建发文单后,发起发文流程 /// </summary> /// <param name="sid"></param> /// <param name="docKeyword"></param> /// <param name="DocList"></param> /// <returns></returns> public static JObject DocumentStartWorkFlow(string sid, string docKeyword, string DocList) { ExReJObject reJo = new ExReJObject(); try { User curUser = DBSourceController.GetCurrentUser(sid); if (curUser == null) { reJo.msg = "登录验证失败!请尝试重新登录!"; return(reJo.Value); } DBSource dbsource = curUser.dBSource; if (dbsource == null) { reJo.msg = "登录验证失败!请尝试重新登录!"; return(reJo.Value); } Doc doc = dbsource.GetDocByKeyWord(docKeyword); if (doc == null) { reJo.msg = "错误的文档操作信息!指定的文档不存在!"; return(reJo.Value); } } catch (Exception exception) { WebApi.CommonController.WebWriteLog(exception.Message + "\r\n" + exception.Source + "\r\n" + exception.StackTrace); //AssistFun.PopUpPrompt(exception.Message + "\r\n" + exception.Source + "\r\n" + exception.StackTrace); reJo.msg = "启动流程失败!" + exception.Message + "\r\n" + exception.Source + "\r\n" + exception.StackTrace; } return(reJo.Value); }
/// <summary> /// 收文流程设置通过回复并提交到下一流程 /// </summary> /// <param name="sid"></param> /// <param name="DocKeyword"></param> /// <returns></returns> public static JObject RecWorflowPassReplyState(string sid, string DocKeyword) { ExReJObject reJo = new ExReJObject(); try { User curUser = DBSourceController.GetCurrentUser(sid); if (curUser == null) { reJo.msg = "登录验证失败!请尝试重新登录!"; return(reJo.Value); } DBSource dbsource = curUser.dBSource; if (dbsource == null) { reJo.msg = "登录验证失败!请尝试重新登录!"; return(reJo.Value); } Doc m_Doc = dbsource.GetDocByKeyWord(DocKeyword); if (m_Doc == null) { reJo.msg = "参数错误!文档不存在!"; return(reJo.Value); } WorkFlow flow = m_Doc.WorkFlow; flow.O_suser3 = "pass"; flow.Modify(); WorkStateBranch wsb = null; // m_Doc.WorkFlow. wsb = flow.CuWorkState.workStateBranchList.Find(w => w.defStateBrach.O_Description == "回复"); if (wsb == null) { reJo.msg = "流程分支不存在!"; return(reJo.Value); } ExReJObject GotoNextReJo = WebWorkFlowEvent.GotoNextStateAndSelectUser(wsb);// flow.CuWorkState.workStateBranchList[0]); if (!GotoNextReJo.success) { } reJo.success = true; return(reJo.Value); } catch (Exception e) { reJo.msg = e.Message; CommonController.WebWriteLog(reJo.msg); } return(reJo.Value); }
/// <summary> /// 创建发文单后,发起发文流程 /// </summary> /// <param name="sid"></param> /// <param name="docKeyword"></param> /// <param name="DocList"></param> /// <returns></returns> public static JObject RecognitionStartWorkFlow(string sid, string docKeyword, string DocList, string UserList) { ExReJObject reJo = new ExReJObject(); try { User curUser = DBSourceController.GetCurrentUser(sid); if (curUser == null) { reJo.msg = "登录验证失败!请尝试重新登录!"; return(reJo.Value); } DBSource dbsource = curUser.dBSource; if (dbsource == null) { reJo.msg = "登录验证失败!请尝试重新登录!"; return(reJo.Value); } Doc doc = dbsource.GetDocByKeyWord(docKeyword); if (doc == null) { reJo.msg = "错误的文档操作信息!指定的文档不存在!"; return(reJo.Value); } #region 获取下一状态用户 string[] userArray = (string.IsNullOrEmpty(UserList) ? "" : UserList).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); Server.Group group = new Server.Group(); //List<User> m_UserList = new List<User>(); //启动工作流程 //反转列表 //m_UserList.Reverse(); foreach (string strObj in userArray) { object obj = dbsource.GetObjectByKeyWord(strObj); if (obj is User) { //m_UserList.Add((User)obj); group.AddUser((User)obj); } } if (group.UserList.Count <= 0) { reJo.msg = "获取下一流程状态用户错误,自动启动流程失败!请手动启动流程"; return(reJo.Value); } #endregion { #region 获取文档列表 string[] strArray = (string.IsNullOrEmpty(DocList) ? "" : DocList).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); List <Doc> m_DocList = new List <Doc>(); //启动工作流程 m_DocList.Reverse(); foreach (string strObj in strArray) { object obj = dbsource.GetObjectByKeyWord(strObj); if (obj is Doc) { m_DocList.Add((Doc)obj); } } #endregion WorkFlow flow = dbsource.NewWorkFlow(m_DocList, "RECOGNITION"); //if (flow == null || flow.CuWorkState == null || flow.CuWorkState.workStateBranchList == null || (flow.CuWorkState.workStateBranchList.Count <= 0)) if (flow == null) { reJo.msg = "自动启动流程失败!请手动启动"; return(reJo.Value); } //获取下一状态 //me.approvpathdata = [{ text: "二级-编批", value: "二级-编批" }, { text: "三级-编审批", value: "三级-编审批" }, //{ text: "四级-编审定批", value: "四级-编审定批" }, { text: "五级-编校审定批", value: "五级-编校审定批" }]; WorkState ws = new WorkState(); DefWorkState dws = flow.DefWorkFlow.DefWorkStateList.Find(s => s.KeyWord == "APPROV");// CHECK"); ws.DefWorkState = dws; //if (ApprovPath == "二级-编批") //{ // DefWorkState dws = flow.DefWorkFlow.DefWorkStateList.Find(s => s.KeyWord == "APPROV");// CHECK"); // ws.DefWorkState = dws; //} //else if (ApprovPath == "三级-编审批" || ApprovPath == "四级-编审定批") //{ // DefWorkState dws = flow.DefWorkFlow.DefWorkStateList.Find(s => s.KeyWord == "AUDIT");// CHECK"); // ws.DefWorkState = dws; //} //else if (ApprovPath == "五级-编校审定批") //{ // DefWorkState dws = flow.DefWorkFlow.DefWorkStateList.Find(s => s.KeyWord == "CHECK");// CHECK"); // ws.DefWorkState = dws; //} //else //{ // flow.Delete(); // flow.Delete(); // reJo.msg = "审批路径参数错误,自动启动流程失败!请手动启动流程"; // return reJo.Value; //} //foreach (User user in group.UserList) //{ // ws.group.AddUser(user); //} //flow.WorkStateList.Add(ws); //flow.Modify(); ////启动流程 WorkStateBranch branch = flow.CuWorkState.workStateBranchList[0]; branch.NextStateAddGroup(group); ExReJObject GotoNextReJo = WebWorkFlowEvent.GotoNextStateAndSelectUser(flow.CuWorkState.workStateBranchList[0]); if (!GotoNextReJo.success) { // doc.dBSource.ProgramRun = false; flow.Delete(); flow.Delete(); reJo.msg = "自动启动流程失败!请手动启动流程"; return(reJo.Value); } DBSourceController.RefreshDBSource(sid); return(GotoNextReJo.Value); } } catch (Exception exception) { WebApi.CommonController.WebWriteLog(exception.Message + "\r\n" + exception.Source + "\r\n" + exception.StackTrace); reJo.msg = "启动流程失败!" + exception.Message + "\r\n" + exception.Source + "\r\n" + exception.StackTrace; } return(reJo.Value); }
/// <summary> /// 获取创建收文单表单的默认配置 /// </summary> /// <param name="sid"></param> /// <param name="DocKeyword"></param> /// <returns></returns> public static JObject GetReceiveDocumentDefault(string sid, string DocKeyword) { ExReJObject reJo = new ExReJObject(); try { User curUser = DBSourceController.GetCurrentUser(sid); if (curUser == null) { reJo.msg = "登录验证失败!请尝试重新登录!"; return(reJo.Value); } DBSource dbsource = curUser.dBSource; if (dbsource == null) { reJo.msg = "登录验证失败!请尝试重新登录!"; return(reJo.Value); } Doc m_Doc = dbsource.GetDocByKeyWord(DocKeyword); if (m_Doc == null) { reJo.msg = "参数错误!文档不存在!"; return(reJo.Value); } //项目代码 string RootProjectCode = m_Doc.GetValueByKeyWord("HXNY_DOCUMENTSYSTEM_CODE"); //项目名称 string RootProjectDesc = m_Doc.GetValueByKeyWord("HXNY_DOCUMENTSYSTEM_DESC"); //来文单位 string CommUnit = ""; string CommUnitCode = ""; if (m_Doc.Project.TempDefn.KeyWord == "COM_UNIT") { CommUnit = m_Doc.Project.Description; CommUnitCode = m_Doc.Project.Code; } Project recTypeProject = CommonFunction.getParentProjectByTempDefn(m_Doc.Project, "COM_COMTYPE"); #region 获取收文编号 string recType = ""; if (recTypeProject.Code == "信函" || recTypeProject.Description == "信函") { recType = "LET"; } else if (recTypeProject.Code == "文件传递单" || recTypeProject.Description == "文件传递单") { recType = "TRA"; } Project recUnitProject = CommonFunction.getParentProjectByTempDefn(m_Doc.Project, "HXNY_DOCUMENTSYSTEM"); string recUnitCode = ""; if (recUnitProject != null) { recUnitCode = recUnitProject.GetValueByKeyWord("PRO_COMPANY"); } string ONShoreCommCode = ""; if (recUnitProject != null) { ONShoreCommCode = recUnitProject.GetValueByKeyWord("RPO_ONSHORE"); } string OFFShoreCommCode = ""; if (recUnitProject != null) { OFFShoreCommCode = recUnitProject.GetValueByKeyWord("RPO_OFFSHORE"); } //string runNum = getDocNumber(dbsource, RootProjectCode, recType, CommUnitCode, recUnitCode); //if (string.IsNullOrEmpty(runNum)) runNum = "001"; string recNumber = Document.getDocTempNumber(dbsource, RootProjectCode, "R", recType, CommUnitCode, recUnitCode); // string recNumber = RootProjectCode + "-" + CommUnitCode + "-" + recUnitCode + "-" + recType + "-" + runNum; #endregion string recCode = m_Doc.Code; //string DocNumber = getDocNumber(m_Doc.Project, RootProjectCode, strCompany); string strDesc = m_Doc.O_itemname; JObject joRecCompany = new JObject(); JObject joSendCompany = new JObject(); List <DictData> dictDataList = dbsource.GetDictDataList("Unit"); foreach (DictData data6 in dictDataList) { if (!string.IsNullOrEmpty(data6.O_sValue3) && data6.O_sValue3 == curUser.ToString) { joSendCompany.Add(new JProperty(data6.O_Code, data6.O_Desc)); } } if (!string.IsNullOrEmpty(ONShoreCommCode)) { joRecCompany.Add(new JProperty(ONShoreCommCode, ONShoreCommCode)); } if (!string.IsNullOrEmpty(OFFShoreCommCode)) { joRecCompany.Add(new JProperty(OFFShoreCommCode, OFFShoreCommCode)); } JObject joData = new JObject( new JProperty("RootProjectCode", RootProjectCode), new JProperty("RootProjectDesc", RootProjectDesc), //new JProperty("DocNumber", DocNumber), new JProperty("DraftmanCode", curUser.Code), new JProperty("DraftmanDesc", curUser.Description), new JProperty("CommUnit", CommUnit), new JProperty("RecCode", recCode), new JProperty("RecNumber", recNumber), new JProperty("RecCompanyList", joRecCompany), new JProperty("SendCompanyList", joSendCompany), new JProperty("DocType", recType) ); reJo.data = new JArray(joData); reJo.success = true; return(reJo.Value); } catch (Exception e) { reJo.msg = e.Message; CommonController.WebWriteLog(reJo.msg); } return(reJo.Value); }
/// <summary> /// 处理收文表单 /// </summary> /// <param name="sid"></param> /// <param name="DocKeyword"></param> /// <returns></returns> public static JObject ReceiveDocument(string sid, string DocKeyword, string docAttrJson) { ExReJObject reJo = new ExReJObject(); try { User curUser = DBSourceController.GetCurrentUser(sid); if (curUser == null) { reJo.msg = "登录验证失败!请尝试重新登录!"; return(reJo.Value); } DBSource dbsource = curUser.dBSource; if (dbsource == null) { reJo.msg = "登录验证失败!请尝试重新登录!"; return(reJo.Value); } Doc m_Doc = dbsource.GetDocByKeyWord(DocKeyword); if (m_Doc == null) { reJo.msg = "参数错误!文档不存在!"; return(reJo.Value); } #region 获取收文处理表单的属性 string strProjectCode = "", strProjectDesc = "", strCommUnit = "", strRecDate = "", strRecCode = "", strRecNumber = "", strPages = "", strSendCode = "", strNeedReply = "", strReplyDate = "", strUrgency = "", strRemark = "", strFileCode = "", strTitle = ""; JArray jaAttr = (JArray)JsonConvert.DeserializeObject(docAttrJson); foreach (JObject joAttr in jaAttr) { string strName = joAttr["name"].ToString(); string strValue = joAttr["value"].ToString(); //获取项目号 if (strName == "ProjectCode") { strProjectCode = strValue; } //获取项目名称 if (strName == "ProjectDesc") { strProjectDesc = strValue; } //获取来文单位 else if (strName == "CommUnit") { strCommUnit = strValue; } //获取来文单位 else if (strName == "RecDate") { strRecDate = strValue; } //获取收文编码 else if (strName == "RecCode") { strRecCode = strValue; } //获取收文编码 else if (strName == "RecNumber") { strRecNumber = strValue; } //获取文件编码 else if (strName == "FileCode") { strFileCode = strValue; } //获取文件题名 else if (strName == "Title") { strTitle = strValue; } //获取页数 else if (strName == "Pages") { strPages = strValue; } //获取我方发文编码 else if (strName == "SendCode") { strSendCode = strValue; } //获取是否要求回文 else if (strName == "NeedReply") { strNeedReply = strValue; } //获取回文期限 else if (strName == "ReplyDate") { strReplyDate = strValue; } //获取紧急程度 else if (strName == "Urgency") { strUrgency = strValue; } //获取备注 else if (strName == "Remark") { strRemark = strValue; } } #endregion #region 根据收文单模板,生成收文单文档 //获取立项单文档所在的目录 //Project m_Project = m_NewProject; List <TempDefn> docTempDefnByCode = dbsource.GetTempDefnByCode("RECEIPT"); TempDefn docTempDefn = (docTempDefnByCode != null && docTempDefnByCode.Count > 0)? docTempDefnByCode[0] : null; if (docTempDefn == null) { reJo.msg = "没有与其相关的模板管理,创建无法正常完成"; return(reJo.Value); } IEnumerable <string> source = from docx in m_Doc.Project.DocList select docx.Code; string filename = strRecCode + " 收文单"; if (source.Contains <string>(filename)) { for (int i = 1; i < 0x3e8; i++) { filename = strRecCode + " 收文单" + i.ToString(); if (!source.Contains <string>(filename)) { break; } } } //文档名称 //Doc docItem = m_Doc.Project.NewDoc(filename + ".docx", filename, "", docTempDefn); Doc docItem = m_Doc.Project.NewDoc(filename + ".docx", filename, ""); if (docItem == null) { reJo.msg = "新建信函出错!"; return(reJo.Value); } #endregion #region 设置收文文档附加属性 m_Doc.TempDefn = docTempDefn; AttrData data; //项目名称 if ((data = m_Doc.GetAttrDataByKeyWord("RE_PRONAME")) != null) { data.SetCodeDesc(strProjectDesc); } //项目代码 if ((data = m_Doc.GetAttrDataByKeyWord("RE_PROCODE")) != null) { data.SetCodeDesc(strProjectCode); } //来文单位 if ((data = m_Doc.GetAttrDataByKeyWord("RE_SENDUNIT")) != null) { data.SetCodeDesc(strCommUnit); } //收文日期 if ((data = m_Doc.GetAttrDataByKeyWord("RE_RECDATE")) != null) { data.SetCodeDesc(strRecDate); } //收文编码 if ((data = m_Doc.GetAttrDataByKeyWord("RE_RECCODE")) != null) { data.SetCodeDesc(strRecCode); } //收文编号 if ((data = m_Doc.GetAttrDataByKeyWord("RE_RECNUMBER")) != null) { data.SetCodeDesc(strRecNumber); } //文件编码 if ((data = m_Doc.GetAttrDataByKeyWord("RE_FILECODE")) != null) { data.SetCodeDesc(strFileCode); } //文件题名 if ((data = m_Doc.GetAttrDataByKeyWord("RE_FILETITLE")) != null) { data.SetCodeDesc(strTitle); } //页数 if ((data = m_Doc.GetAttrDataByKeyWord("RE_PAGE")) != null) { data.SetCodeDesc(strPages); } //发文编码 if ((data = m_Doc.GetAttrDataByKeyWord("RE_SENDCODE")) != null) { data.SetCodeDesc(strSendCode); } //是否回文 if ((data = m_Doc.GetAttrDataByKeyWord("RE_IFREPLY")) != null) { data.SetCodeDesc(strNeedReply); } //回文日期 if ((data = m_Doc.GetAttrDataByKeyWord("RE_REPLYDATE")) != null) { data.SetCodeDesc(strReplyDate); } //紧急程度 if ((data = m_Doc.GetAttrDataByKeyWord("RE_URGENTDEGREE")) != null) { data.SetCodeDesc(strUrgency); } //备注 if ((data = m_Doc.GetAttrDataByKeyWord("RE_NOTE")) != null) { data.SetCodeDesc(strRemark); } //著录人 if ((data = m_Doc.GetAttrDataByKeyWord("RE_DESIGN")) != null) { data.SetCodeDesc(curUser.ToString); } ////保存项目属性,存进数据库 m_Doc.AttrDataList.SaveData(); //m_Doc.Modify(); #endregion //修改文档编码 m_Doc.O_itemname = strRecCode; //strRecNumber; //m_Doc.O_itemdesc = strTitle; m_Doc.Modify(); #region 录入数据进入word表单 Hashtable htUserKeyWord = new Hashtable(); //格式化日期 DateTime RecDate = Convert.ToDateTime(strRecDate); DateTime ReplyDate = Convert.ToDateTime(strReplyDate); string recDate = RecDate.ToShortDateString().ToString().Replace("-", ".").Replace("/", "."); string replyDate = ReplyDate.ToShortDateString().ToString().Replace("-", ".").Replace("/", "."); htUserKeyWord.Add("PRONAME", strProjectDesc); //项目名称 htUserKeyWord.Add("PROCODE", strProjectCode); //项目代码 htUserKeyWord.Add("SENDUNIT", strCommUnit); //来文单位 htUserKeyWord.Add("RECDATE", recDate); //收文日期 htUserKeyWord.Add("RECCODE", strRecCode); //收文编码 htUserKeyWord.Add("RECNUMBER", strRecNumber); //收文编号 htUserKeyWord.Add("FILECODE", strFileCode); //文件编码 htUserKeyWord.Add("FILETITLE", strTitle); //文件题名 htUserKeyWord.Add("PAGE", strPages); //页数 htUserKeyWord.Add("SENDCODE", strSendCode); //发文编码 htUserKeyWord.Add("IFREPLY", strNeedReply); //是否回文 htUserKeyWord.Add("REPLYDATE", replyDate); //回文日期 htUserKeyWord.Add("URGENTDEGREE", strUrgency); //紧急程度 htUserKeyWord.Add("NOTE", strRemark); //备注 htUserKeyWord.Add("DESIGN", curUser.Description); //著录人 string workingPath = dbsource.LoginUser.WorkingPath; try { //上传下载文档 string exchangfilename = "收文单模板"; //获取网站路径 string sPath = System.Web.HttpContext.Current.Server.MapPath("/ISO/HXEPC/"); //获取模板文件路径 string modelFileName = sPath + exchangfilename + ".docx"; //获取即将生成的联系单文件路径 string locFileName = docItem.FullPathFile; FileInfo info = new FileInfo(locFileName); if (System.IO.File.Exists(modelFileName)) { //如果存储子目录不存在,就创建目录 if (!Directory.Exists(info.Directory.FullName)) { Directory.CreateDirectory(info.Directory.FullName); } //复制模板文件到存储目录,并覆盖同名文件 System.IO.File.Copy(modelFileName, locFileName, true); //线程锁 muxConsole.WaitOne(); try { //把参数直接写进office CDMSWebOffice office = new CDMSWebOffice { CloseApp = true, VisibleApp = false }; office.Release(true); office.WriteDataToDocument(docItem, locFileName, htUserKeyWord, htUserKeyWord); } catch { } finally { //解锁 muxConsole.ReleaseMutex(); } } int length = (int)info.Length; docItem.O_size = new int?(length); docItem.Modify(); } catch { } #endregion ////启动流程 WorkFlow flow = dbsource.NewWorkFlow(new List <Doc> { docItem, m_Doc }, "RECEIVED"); if (flow == null) { //AssistFun.PopUpPrompt("自动启动流程失败!请手动启动"); reJo.msg = "自动启动流程失败!请手动启动"; return(reJo.Value); } else { if ((flow != null) && (flow.CuWorkState != null)) { //if (((flow.CuWorkState == null) || (flow.CuWorkState.workStateBranchList == null)) || (flow.CuWorkState.workStateBranchList.Count <= 0)) //{ // //MessageBox.Show("新建流程不存在下一状态,提交失败!"); // //doc.dBSource.ProgramRun = false; // flow.Delete(); // reJo.msg = "新建流程不存在下一状态,提交失败!"; // return reJo.Value; // //return; //} //WorkStateBranch branch = flow.CuWorkState.workStateBranchList[0]; //if (branch == null) //{ // reJo.msg = "获取流程分支失败!"; // return reJo.Value; //} Project rootProj = CommonFunction.getParentProjectByTempDefn(m_Doc.Project, "HXNY_DOCUMENTSYSTEM"); if (rootProj == null) { reJo.msg = "获取项目根目录失败!"; return(reJo.Value); } string UserList = ""; AttrData secData; //rootProj.GetAttrDataByKeyWord("SECRETARILMAN"); if ((secData = rootProj.GetAttrDataByKeyWord("SECRETARILMAN")) != null) { UserList = secData.ToString; } if (string.IsNullOrEmpty(UserList)) { reJo.msg = "项目文控未设置!"; return(reJo.Value); } //ExReJObject wfReJo = WebWorkFlowEvent.GotoNextStateAndSelectUser(flow.CuWorkState.workStateBranchList[0],userlist); ////if (!WorkFlowEvent.GotoNextStateAndSelectUser(flow.CuWorkState.workStateBranchList[0])) //if (!wfReJo.success) //{ // //doc.dBSource.ProgramRun = false; // flow.Delete(); // flow.Delete(); // reJo.msg = "自动启动收文流程失败,请手动启动流程!"; // return reJo.Value; //} ////刷新数据源 //DBSourceController.RefreshDBSource(sid); #region 获取下一状态用户 string[] userArray = (string.IsNullOrEmpty(UserList) ? "" : UserList).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); Server.Group group = new Server.Group(); //List<User> m_UserList = new List<User>(); //启动工作流程 //反转列表 //m_UserList.Reverse(); foreach (string strObj in userArray) { string strUser = strObj.IndexOf("__") >= 0 ? strObj.Substring(0, strObj.IndexOf("__")) : strObj; object obj = dbsource.GetUserByName(strUser); if (obj is User) { //m_UserList.Add((User)obj); group.AddUser((User)obj); } } if (group.UserList.Count <= 0) { reJo.msg = "获取下一流程状态用户错误,自动启动流程失败!请手动启动流程"; return(reJo.Value); } #endregion //获取下一状态 WorkState ws = new WorkState(); DefWorkState dws = flow.DefWorkFlow.DefWorkStateList.Find(s => s.KeyWord == "SECRETARILMAN"); // CHECK"); ws.DefWorkState = dws; ////启动流程 WorkStateBranch branch = flow.CuWorkState.workStateBranchList[0]; branch.NextStateAddGroup(group); ExReJObject GotoNextReJo = WebWorkFlowEvent.GotoNextStateAndSelectUser(flow.CuWorkState.workStateBranchList[0]); if (!GotoNextReJo.success) { // doc.dBSource.ProgramRun = false; flow.Delete(); flow.Delete(); reJo.msg = "自动启动流程失败!请手动启动流程"; return(reJo.Value); } DBSourceController.RefreshDBSource(sid); //return GotoNextReJo.Value; reJo.data = new JArray(new JObject(new JProperty("ProjectKeyword", m_Doc.Project.KeyWord), new JProperty("DocKeyword", m_Doc.KeyWord))); reJo.success = true; return(reJo.Value); } } reJo.success = true; return(reJo.Value); } catch (Exception e) { reJo.msg = e.Message; CommonController.WebWriteLog(reJo.msg); } return(reJo.Value); }
public static JObject ResetFileCode(string sid, string DocKeyword, string DocAttrJson) { ExReJObject reJo = new ExReJObject(); try { User curUser = DBSourceController.GetCurrentUser(sid); if (curUser == null) { reJo.msg = "登录验证失败!请尝试重新登录!"; return(reJo.Value); } DBSource dbsource = curUser.dBSource; if (dbsource == null) { reJo.msg = "登录验证失败!请尝试重新登录!"; return(reJo.Value); } Doc doc = dbsource.GetDocByKeyWord(DocKeyword); if (doc == null) { reJo.msg = "错误的文档操作信息!指定的文档不存在!"; return(reJo.Value); } #region 获取信函参数内容 //获取信函参数内容 string mainFeeder = "", copyParty = "", sender = "", sendCode = "", recCode = "", totalPages = "", urgency = "", sendDate = "", seculevel = "", secrTerm = "", needreply = "", replyDate = "", title = "", content = "", approvpath = "", nextStateUserList = ""; JArray jaAttr = (JArray)JsonConvert.DeserializeObject(DocAttrJson); foreach (JObject joAttr in jaAttr) { string strName = joAttr["name"].ToString(); string strValue = joAttr["value"].ToString(); ////获取函件编号 //if (strName == "documentCode") documentCode = strValue.Trim(); //获取主送 if (strName == "mainFeeder") { mainFeeder = strValue.Trim(); } //获取抄送 else if (strName == "copyParty") { copyParty = strValue; } //获取发送方 else if (strName == "sender") { sender = strValue; } //获取发文编码 else if (strName == "sendCode") { sendCode = strValue; } //获取发送日期 else if (strName == "sendDate") { sendDate = strValue; } } if (string.IsNullOrEmpty(sendCode)) { reJo.msg = "请填写函件编号!"; return(reJo.Value); } //else if (string.IsNullOrEmpty(mainFeeder)) //{ // reJo.msg = "请填写主送!"; // return reJo.Value; //} //else if (string.IsNullOrEmpty(sender)) //{ // reJo.msg = "请选择发送方!"; // return reJo.Value; //} #endregion #region 填写发文信息进入word表单 //获取即将函件的文件路径 string locFileName = doc.FullPathFile; if (string.IsNullOrEmpty(locFileName)) { reJo.msg = "填写发文信息错误,获取函件文件失败!"; return(reJo.Value); } if (!System.IO.File.Exists(locFileName)) { reJo.msg = "填写发文信息失败,函件文件不存在!"; return(reJo.Value); } //格式化日期 DateTime senddate = Convert.ToDateTime(sendDate); string strSenddate = senddate.ToShortDateString().ToString().Replace("-", ".").Replace("/", "."); string str = doc.O_filename.ToUpper(); Hashtable htUserKeyWord = new Hashtable(); //htUserKeyWord.Add("MAINFEEDER", mainFeeder);//主送 //htUserKeyWord.Add("SENDER", sender);//发送方 htUserKeyWord.Add("SENDCODE", sendCode);//发文编码 //htUserKeyWord.Add("COPY", copyParty);//抄送 //htUserKeyWord.Add("SENDDATE", strSenddate);//发送日期 if ((str.EndsWith(".DOC") || str.EndsWith(".DOCX")) || (str.EndsWith(".XLS") || str.EndsWith(".XLSX"))) { //线程锁 muxConsole.WaitOne(); try { WebApi.CDMSWebOffice office = new WebApi.CDMSWebOffice { CloseApp = true, VisibleApp = false }; office.Release(true); if (doc.WorkFlow != null) { enWorkFlowStatus status1 = doc.WorkFlow.O_WorkFlowStatus; } office.WriteDataToDocument(doc, locFileName, htUserKeyWord, htUserKeyWord); } catch (Exception ExOffice) { WebApi.CommonController.WebWriteLog(ExOffice.Message); } finally { //解锁 muxConsole.ReleaseMutex(); } } #endregion if (doc.WorkFlow != null) { AttrData data; string orgSendCode = ""; if ((data = doc.GetAttrDataByKeyWord("CA_SENDCODE")) != null) { orgSendCode = data.ToString; //FileCode = FileCode + data.ToString + "-"; } string orgName = doc.O_itemname; foreach (Doc docItem in doc.WorkFlow.DocList) { if (docItem != doc) { docItem.O_itemname = docItem.O_itemname.Replace(orgSendCode, sendCode); docItem.Modify(); } } doc.O_itemname = doc.O_itemname.Replace(orgSendCode, sendCode); // doc.O_filename = regex.Replace(doc.O_filename, replacement); string fullPathFile = doc.FullPathFile; fullPathFile = fullPathFile.Replace('/', '\\'); string newFileName = doc.FullPathFile.Replace(orgSendCode, sendCode); try { File.Move(fullPathFile, newFileName); } catch { } doc.O_filename = doc.O_filename.Replace(orgSendCode, sendCode); #region 设置信函文档附加属性 ////主送 //if ((data = doc.GetAttrDataByKeyWord("CA_MAINFEEDER")) != null) //{ // data.SetCodeDesc(mainFeeder); //} ////发送方 //if ((data = doc.GetAttrDataByKeyWord("CA_SENDER")) != null) //{ // data.SetCodeDesc(sender); //} //发文编码 if ((data = doc.GetAttrDataByKeyWord("CA_SENDCODE")) != null) { data.SetCodeDesc(sendCode); } ////抄送 //if ((data = doc.GetAttrDataByKeyWord("CA_COPY")) != null) //{ // data.SetCodeDesc(copyParty); //} //////发送日期 //if ((data = doc.GetAttrDataByKeyWord("CA_SENDDATE")) != null) //{ // data.SetCodeDesc(sendDate); //} ////保存项目属性,存进数据库 doc.AttrDataList.SaveData(); #endregion doc.Modify(); doc.WorkFlow.O_suser3 = "pass"; doc.WorkFlow.Modify(); DBSourceController.refreshDBSource(sid); } reJo.data = new JArray(new JObject(new JProperty("WorkFlowKeyword", doc.WorkFlow.KeyWord))); reJo.success = true; return(reJo.Value); } catch (Exception exception) { //WebApi.CommonController.WebWriteLog(exception.Message + "\r\n" + exception.Source + "\r\n" + exception.StackTrace); reJo.msg = "填写发文信息失败,请手动填写发文信息!" + exception.Message; } return(reJo.Value); }
//发文流程盖章 public static JObject DocumenteSeal(string sid, string DocKeyword, string isSeal) { ExReJObject reJo = new ExReJObject(); try { User curUser = DBSourceController.GetCurrentUser(sid); if (curUser == null) { reJo.msg = "登录验证失败!请尝试重新登录!"; return(reJo.Value); } DBSource dbsource = curUser.dBSource; if (dbsource == null) { reJo.msg = "登录验证失败!请尝试重新登录!"; return(reJo.Value); } Doc doc = dbsource.GetDocByKeyWord(DocKeyword); if (doc == null) { reJo.msg = "错误的文档操作信息!指定的文档不存在!"; return(reJo.Value); } if (doc.WorkFlow == null) { reJo.msg = "错误的文档操作信息!指定的文档流程不存在!"; return(reJo.Value); } //录入数据进入表单 //格式化日期 DateTime inscribedate = Convert.ToDateTime(DateTime.Now); string strInscribedate = inscribedate.ToShortDateString().ToString().Replace("-", ".").Replace("/", "."); Hashtable htUserKeyWord = new Hashtable(); string inscribe = "", sendercode = ""; AttrData data; //获取发送方 if ((data = doc.GetAttrDataByKeyWord("CA_SENDER")) != null) { inscribe = data.ToString; } //获取发送方代码 if ((data = doc.GetAttrDataByKeyWord("CA_SENDERCODE")) != null) { sendercode = data.ToString; } if (isSeal == "true") { if (!string.IsNullOrEmpty(sendercode)) { //盖章图片名 htUserKeyWord["SEAL"] = sendercode + "SEAL"; } else { //盖章图片名 htUserKeyWord["SEAL"] = "BLANK" + "SEAL"; } } else { //盖章图片名 htUserKeyWord["SEAL"] = "BLANK" + "SEAL"; } //落款 htUserKeyWord["INSCRIBE"] = inscribe; //落款时间 htUserKeyWord["INSCRIBEDATE"] = strInscribedate; //获取即将生成的联系单文件路径 string locFileName = doc.FullPathFile; FileInfo info = new FileInfo(locFileName); if (System.IO.File.Exists(locFileName)) { //线程锁 muxConsole.WaitOne(); try { //把参数直接写进office CDMSWebOffice office = new CDMSWebOffice { CloseApp = true, VisibleApp = false }; office.Release(true); office.WriteDataToDocument(doc, locFileName, htUserKeyWord, htUserKeyWord); } catch { } finally { //解锁 muxConsole.ReleaseMutex(); } } if (doc.WorkFlow.CuWorkState.Code == "APPROV" && dbsource.LoginUser.O_userno == doc.WorkFlow.CuWorkState.CuWorkUser.O_userno) { doc.WorkFlow.O_suser3 = "approvpass"; doc.WorkFlow.Modify(); DBSourceController.refreshDBSource(sid); } reJo.data = new JArray(new JObject(new JProperty("WorkFlowKeyword", doc.WorkFlow.KeyWord))); reJo.success = true; return(reJo.Value); } catch (Exception exception) { //WebApi.CommonController.WebWriteLog(exception.Message + "\r\n" + exception.Source + "\r\n" + exception.StackTrace); reJo.msg = "盖章失败!" + exception.Message; } return(reJo.Value); }
/// <summary> /// /// </summary> /// <param name="sid"></param> /// <param name="DocKeyword"></param> /// <param name="Operator">主办人</param> /// <param name="Coordinator">协办人</param> /// <returns></returns> public static JObject SendDistriProcess(string sid, string DocKeyword, string Operator, string Coordinator) { // return RecDocument.SendDistriProcess(sid, DocKeyword, Operator, Coordinator); ExReJObject reJo = new ExReJObject(); try { User curUser = DBSourceController.GetCurrentUser(sid); if (curUser == null) { reJo.msg = "登录验证失败!请尝试重新登录!"; return(reJo.Value); } DBSource dbsource = curUser.dBSource; if (dbsource == null) { reJo.msg = "登录验证失败!请尝试重新登录!"; return(reJo.Value); } Doc doc = dbsource.GetDocByKeyWord(DocKeyword); if (doc == null) { reJo.msg = "错误的文档操作信息!指定的文档不存在!"; return(reJo.Value); } WorkFlow flow; if ((flow = doc.WorkFlow) == null) { reJo.msg = "错误的文档操作信息!指定的文档流程不存在!"; return(reJo.Value); } #region 设置本部门文控(登录用户)到部门人员状态 Server.Group group = new Server.Group(); group.AddUser(curUser); DefWorkState defWorkStateCu = flow.DefWorkFlow.DefWorkStateList.Find(dwsx => dwsx.O_Code == "DEPARTMENTCONTROL"); WorkState stateCu = flow.NewWorkState(defWorkStateCu); stateCu.SaveSelectUser(group); stateCu.IsRuning = true; stateCu.PreWorkState = flow.CuWorkState; stateCu.O_iuser5 = new int?(flow.CuWorkState.O_stateno); stateCu.Modify(); #endregion #region 设置协办部门人员状态 string[] strArry2 = Coordinator.Split(new char[] { ';' }); //每个部门一个协办分支 foreach (string op in strArry2) { string strUser = op.IndexOf("_") >= 0 ? op.Substring(0, op.IndexOf("_")) : op; Server.Group CoordinatorGroup = new Server.Group(); User CoordinatorUser = dbsource.GetUserByCode(strUser); if (CoordinatorUser != null) { CoordinatorGroup.AddUser(CoordinatorUser); DefWorkState defWorkStateCo = flow.DefWorkFlow.DefWorkStateList.Find(dwsx => dwsx.O_Code == "DEPARTMENTCONTROL"); WorkState state2 = flow.NewWorkState(defWorkStateCo); state2.SaveSelectUser(CoordinatorGroup); state2.IsRuning = true; state2.PreWorkState = flow.CuWorkState; state2.O_iuser5 = new int?(flow.CuWorkState.O_stateno); state2.Modify(); } } #endregion WorkStateBranch branch = flow.CuWorkState.workStateBranchList.Find(wsb => wsb.KeyWord == "TOCONTROL1");//[0]; branch.NextStateAddGroup(group); ExReJObject GotoNextReJo = WebWorkFlowEvent.GotoNextStateAndSelectUser(flow.CuWorkState.workStateBranchList[0]); #region 设置本部门办理人状态 string[] strArry = Operator.Split(new char[] { ';' }); Server.Group OperatorGroup = new Server.Group(); foreach (string op in strArry) { User OperatorUser = dbsource.GetUserByCode(op); if (OperatorUser != null) { OperatorGroup.AddUser(OperatorUser); } } //放置本部门办理状态人员 //WorkState state = flow.WorkStateList.Find(wsx => (wsx.Code == "MAINHANDLE") && // (wsx.CheckGroup.AllUserList.Count == 0)); //if (state == null) //{ DefWorkState defWorkState = flow.DefWorkFlow.DefWorkStateList.Find(dwsx => dwsx.O_Code == "MAINHANDLE"); WorkState state = flow.NewWorkState(defWorkState); state.SaveSelectUser(OperatorGroup); state.IsRuning = true; state.PreWorkState = stateCu; state.O_iuser5 = new int?(stateCu.O_stateno); state.Modify(); // } #endregion //reJo.data = new JArray(new JObject(new JProperty("WorkFlowKeyword", doc.WorkFlow.KeyWord))); reJo.success = true; return(reJo.Value); } catch (Exception exception) { //WebApi.CommonController.WebWriteLog(exception.Message + "\r\n" + exception.Source + "\r\n" + exception.StackTrace); reJo.msg = "分发失败!" + exception.Message; } return(reJo.Value); }