public static Dictionary <Sys_Document, JZDocument> GetDocumentDataListByModuleIDAndTestRoomCode(Guid moduleID, String testRoomCode) { Dictionary <Sys_Document, JZDocument> list = new Dictionary <Sys_Document, JZDocument>(); DataTable dt = Agent.CallService("Yqun.BO.BusinessManager.dll", "GetDocumentDataListByModuleIDAndTestRoomCode", new object[] { moduleID, testRoomCode }) as DataTable; if (dt != null && dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { Sys_Document doc = new Sys_Document() { ID = new Guid(dt.Rows[i]["ID"].ToString()), TestRoomCode = dt.Rows[i]["TestRoomCode"].ToString(), Status = short.Parse(dt.Rows[i]["Status"].ToString()), DataName = dt.Rows[i]["DataName"].ToString(), TryType = dt.Rows[i]["TryType"].ToString(), ModuleID = new Guid(dt.Rows[i]["ModuleID"].ToString()), BGBH = dt.Rows[i]["BGBH"] == DBNull.Value ? "" : dt.Rows[i]["BGBH"].ToString() }; list.Add(doc, Newtonsoft.Json.JsonConvert.DeserializeObject <JZDocument>(dt.Rows[i]["Data"].ToString())); } } return(list); }
private void Execute(object paremeter) { ThreadParameter p = paremeter as ThreadParameter; if (p.Items == null || p.Items.Count == 0) { logger.Error("未修改关键字段,document的ID为" + p.DataID + ";"); return; } //logger.Error("p.IsAdministrator:" + p.IsAdministrator + ";"); try { String json = Newtonsoft.Json.JsonConvert.SerializeObject(p.Items); DocumentHelper dh = new DocumentHelper(); Sys_Document doc = dh.GetDocumentBaseInfoByID(p.DataID); if (doc != null) { String sql = string.Empty; string JLUserName = string.Empty, JLContent = string.Empty, SGUserName = string.Empty, SGContent = string.Empty; DateTime JLOPTime = DateTime.Now, SGOPTime = DateTime.Now; DataTable dtJL = new DataTable(); #region 处理监理和施工意见 if (p.RequestID != Guid.Empty) { sql = string.Format("SELECT RequestBy,RequestTime,Reason,ApprovePerson,ApproveTime,ProcessReason FROM dbo.sys_request_change WHERE id='{0}'", p.RequestID); dtJL = GetDataTable(sql); if (dtJL != null && dtJL.Rows.Count > 0) { JLUserName = dtJL.Rows[0]["ApprovePerson"] == null ? "" : dtJL.Rows[0]["ApprovePerson"].ToString(); JLContent = dtJL.Rows[0]["ProcessReason"] == null ? "" : dtJL.Rows[0]["ProcessReason"].ToString(); SGUserName = dtJL.Rows[0]["RequestBy"] == null ? "" : dtJL.Rows[0]["RequestBy"].ToString(); SGContent = dtJL.Rows[0]["Reason"] == null ? "" : dtJL.Rows[0]["Reason"].ToString(); JLOPTime = dtJL.Rows[0]["ApproveTime"] == null ? DateTime.Now : DateTime.Parse(dtJL.Rows[0]["ApproveTime"].ToString()); SGOPTime = dtJL.Rows[0]["RequestTime"] == null ? DateTime.Now : DateTime.Parse(dtJL.Rows[0]["RequestTime"].ToString()); JLContent = JLContent.Replace("'", " "); SGContent = SGContent.Replace("'", " "); sql = "SELECT 1 FROM dbo.sys_KeyModify WHERE RequestID='" + p.RequestID + "' AND ModifyItem='" + json + "'"; DataTable dtIsExist = GetDataTable(sql); if (dtIsExist != null && dtIsExist.Rows.Count == 0) { #region INSERT sql = String.Format(@"INSERT INTO dbo.sys_KeyModify ( DataID , ModuleID , RequestID , TestRoomCode , BGBH , DataName , ModifyItem , ModifyBy , ModifyTime , Status,JLUserName ,JLOPTime ,JLContent ,SGUserName ,SGOPTime ,SGContent ) VALUES ( '{0}' , '{1}' , '{2}' , '{3}' , '{4}' , '{5}' , '{6}' , '{7}' , GETDATE(), 0,'{8}','{9}','{10}','{11}','{12}','{13}' )", doc.ID, doc.ModuleID, p.RequestID, doc.TestRoomCode, doc.BGBH, doc.DataName, json, p.UserName, JLUserName, JLOPTime, JLContent, SGUserName, SGOPTime, SGContent); ExcuteCommand(sql); #endregion #region 发送短信 if (!p.IsAdministrator && ConfigurationManager.AppSettings["ChangedSMSStart"] == "1") { String smsContent = GetSMSContent(doc.ID, p.Items, p.UserName, p.RequestID, dtJL); //logger.Error("smsContent:" + smsContent); if (String.IsNullOrEmpty(smsContent)) { logger.Error("未得到短信信息,document的ID为" + p.DataID + ";"); return; } String[] cells = GetSMSCells(); if (cells.Length == 0) { logger.Error("未设置手机收信人信息,document的ID为" + p.DataID + ";"); return; } String errorMsg = SMSAgent.CallRemoteService(cells, smsContent); SMSManager smsManager = new SMSManager(); smsManager.SendAppMessage(p.LineID, doc.ID.ToString(), p.TestRoomCode, p.SegmentName, p.CompanyName, p.TestRoomName, p.LineName, 2, smsContent); if (!string.IsNullOrEmpty(errorMsg)) { logger.Error("修改资料短信短信发送完成:" + errorMsg); } } else { logger.Error("管理员不发短信或者未打开短信发送开关ChangedSMSCells,document的ID为" + p.DataID.ToString() + ""); } #endregion } } else { logger.Error("ChangedSMSCells dtJL Is null or dtJL.Rows.Count==0!DataID:" + p.DataID.ToString() + " RequestID:" + p.RequestID); return; } } else { logger.Error("ChangedSMSCells RequestID Is null!DataID为" + p.DataID.ToString() + ""); return; } #endregion } } catch (Exception ex) { logger.Error("ChangedSMSCells error!DataID为" + p.DataID.ToString() + " ex:" + ex.ToString()); } }
public static Boolean UpdateDocumentBaseInfo(Sys_Document doc, String updatedField) { return(Convert.ToBoolean(Agent.CallService("Yqun.BO.BusinessManager.dll", "UpdateDocumentBaseInfo", new object[] { doc, updatedField }))); }
/// <summary> /// 保存资料;pxDocumentID为被平行的施工单位资料ID /// </summary> /// <param name="doc"></param> /// <param name="moduleID"></param> /// <param name="pxDocumentID"></param> /// <returns></returns> public static Guid SaveDocument(JZDocument doc, Sys_Document doc_base) { return(new Guid(Agent.CallService("Yqun.BO.BusinessManager.dll", "SaveDocument", new object[] { doc, doc_base }).ToString())); }
public void SaveEditLog(JZDocument oldDoc, JZDocument newDoc, String optType, Boolean relationRequestChange, Sys_Document docBase) { ThreadParameter p = new ThreadParameter(); p.OldDoc = oldDoc; p.NewDoc = newDoc; ApplicationContext context = ApplicationContext.Current; p.UserName = context.UserName; p.IsAdministrator = context.IsAdministrator; p.OptType = optType; p.RelationRequestChange = relationRequestChange; p.DocBase = docBase; p.LineID = ApplicationContext.Current.InProject.Index; p.TestRoomCode = ApplicationContext.Current.InTestRoom.Code; p.SegmentName = ApplicationContext.Current.InSegment.Description; p.CompanyName = ApplicationContext.Current.InCompany.Description; p.TestRoomName = ApplicationContext.Current.InTestRoom.Description; p.LineName = ApplicationContext.Current.InProject.Description; ThreadPool.QueueUserWorkItem(new WaitCallback(Execute), p); }
void worker_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; DataExportClass Params = e.Argument as DataExportClass; Font defaultFont = new Font("宋体", 9f); String Path = Params.path; if (string.IsNullOrEmpty(Path)) { return; } MyCell fpSpread = new MyCell(); fpSpread.Watermark = ModuleHelperClient.GetWatermarkByModuleID(moduleID); //初始化模板样式 List <FarPoint.CalcEngine.FunctionInfo> Infos = FunctionItemInfoUtil.getFunctionItemInfos(); List <JZFormulaData> CrossSheetFormulaInfos = ModuleHelperClient.GetFormulaByModuleIndex(moduleID); Dictionary <Sys_Document, JZDocument> list = DocumentHelperClient.GetDocumentDataListByModuleIDAndTestRoomCode(moduleID, testRoomCode); if (list.Count == 0) { return; } Dictionary <Sys_Document, JZDocument> .Enumerator em = list.GetEnumerator(); int i = 0; while (em.MoveNext()) { Sys_Document docBase = em.Current.Key; JZDocument doc = em.Current.Value; if (i == 0) { foreach (JZSheet sheet in doc.Sheets) { ProgressScreen.Current.SetStatus = string.Format("正在准备表单{0}...", sheet.Name); String sheetXML = ModuleHelperClient.GetSheetXMLByID(sheet.ID); SheetView SheetView = Serializer.LoadObjectXml(typeof(SheetView), sheetXML, "SheetView") as SheetView; SheetView.Tag = sheet.ID; SheetView.SheetName = sheet.Name; SheetView.Cells[0, 0].Value = ""; SheetView.Protect = true; fpSpread.Sheets.Add(SheetView); foreach (FarPoint.CalcEngine.FunctionInfo Info in Infos) { SheetView.AddCustomFunction(Info); } } fpSpread.LoadFormulas(true); } i = i + 1; worker.ReportProgress((int)(((float)i / (float)list.Count) * 100)); foreach (JZSheet sheet in doc.Sheets) { SheetView sheetV = null; for (int j = 0; j < fpSpread.Sheets.Count; j++) { if (new Guid(fpSpread.Sheets[j].Tag.ToString()) == sheet.ID) { sheetV = fpSpread.Sheets[j]; break; } } if (sheetV == null) { break; } foreach (JZCell dataCell in sheet.Cells) { Cell cell = sheetV.Cells[dataCell.Name]; if (cell != null) { cell.Font = defaultFont; if (cell.CellType is ImageCellType) { if (dataCell.Value != null) { cell.Value = JZCommonHelper.StringToBitmap(dataCell.Value.ToString()); } } else { cell.Value = dataCell.Value; } } } } try { //保存资料到指定目录 String reportNumber = docBase.BGBH == "" ? "无报告编号" + i.ToString() : docBase.BGBH; ExcelWarningList ewl = new ExcelWarningList(); string fileName = Path + "\\" + moduleName + "-" + reportNumber + ".xls"; fpSpread.SaveExcel(fileName, ExcelSaveFlags.NoFlagsSet, ewl); } catch { } } }