private DataSet GetPushData4House(SlbhAndPid patchdata, ViewName viewName, PID pid, string HouseId) { string sql = string.Empty; sql = viewName.sql + string.Format(" where slbh like '{0}%' and HouseId='{0}'", patchdata.Slbh, HouseId); return(DBHelper.GetDataSet(sql, ConnectType.SXK)); }
public WriteBackWfm Xml2Model(string path) { XmlDocument doc = ReadXml2Doc(path); WriteBackWfm wfm = new WriteBackWfm(); XmlNode PidsNode = doc.DocumentElement.SelectSingleNode("PIDS"); XmlNode ViewNamesNode = doc.DocumentElement.SelectSingleNode("ViewNames"); XmlNode WebserviceAddsNode = doc.DocumentElement.SelectSingleNode("WebserviceAdds"); if (PidsNode != null) { wfm.PIDS = new List <PID>(); XmlNodeList pidnodes = PidsNode.SelectNodes("PID"); foreach (XmlNode xn in pidnodes) { PID p = new PID(); p.PId = xn.InnerText; p.name = xn.Attributes["name"].Value; p.viewId = xn.Attributes["viewId"].Value; p.WSAID = xn.Attributes["WSAID"].Value; p.stepname = xn.Attributes["StepName"].Value; wfm.PIDS.Add(p); } } if (ViewNamesNode != null) { wfm.ViewNames = new List <ViewName>(); XmlNodeList viewNamenodes = ViewNamesNode.SelectNodes("ViewName"); foreach (XmlNode xn in viewNamenodes) { ViewName v = new ViewName(); v.name = xn.InnerText; v.id = xn.Attributes["id"].Value; v.sql = xn.Attributes["sql"].Value; wfm.ViewNames.Add(v); } } if (WebserviceAddsNode != null) { wfm.WebserviceAdds = new List <WebserviceAdd>(); XmlNodeList WebserviceAddnodes = WebserviceAddsNode.SelectNodes("WebserviceAdd"); foreach (XmlNode xn in WebserviceAddnodes) { WebserviceAdd w = new WebserviceAdd(); w.name = xn.InnerText; w.id = xn.Attributes["id"].Value; wfm.WebserviceAdds.Add(w); } } return(wfm); }
private bool PushDataTo(SlbhAndPid patchdata, WriteBackWfm Wfm, PID pid, string area, string addressType) { ViewName viewName = Wfm.ViewNames.Single(v => v.id == pid.viewId); DataSet retdata = GetPushData(patchdata, viewName, pid); if (retdata.Tables[0] == null || retdata.Tables[0].Rows.Count == 0) { //errInfo.WBerrInfo = "没有取到推送数据,View[" + viewName.name + "]"; //errInfo.CGerrInfo = "没有取到推送数据,View[" + viewName.name + "]"; ResetPushResult(patchdata.Slbh, pid.name, "-1", "", pid.PId, "没有取到推送数据,View[" + viewName.name + "]", patchdata.StepName, addressType); return(false); } WebserviceAdd add = Wfm.WebserviceAdds.Single(w => w.id == pid.WSAID); if (addressType.Equals("WB")) { string pushRet = PushDataWB(retdata, add.name, area); //string pushRet = PushData(retdata, add.name, area); //if(!IsError(errInfo)) if (string.IsNullOrEmpty(pushRet)) {//推送成功 ResetPushResult(patchdata.Slbh, pid.name, "1", SerialisePushData(retdata.Tables[0], viewName.name, add.name), pid.PId, pushRet, patchdata.StepName, addressType); } else { ResetPushResult(patchdata.Slbh, pid.name, "0", SerialisePushData(retdata.Tables[0], viewName.name, add.name), pid.PId, pushRet, patchdata.StepName, addressType); } return(true); } if (addressType.Equals("CG")) { string pushRet = PushDataCG(retdata, add.name, area); //string pushRet = PushData(retdata, add.name, area); //if(!IsError(errInfo)) if (string.IsNullOrEmpty(pushRet) || pushRet.Contains("推送成功")) {//推送成功 ResetPushResult(patchdata.Slbh, pid.name, "1", SerialisePushData(retdata.Tables[0], viewName.name, add.name), pid.PId, pushRet, patchdata.StepName, addressType); } else { ResetPushResult(patchdata.Slbh, pid.name, "0", SerialisePushData(retdata.Tables[0], viewName.name, add.name), pid.PId, pushRet, patchdata.StepName, addressType); } return(true); } return(false); }
public List <dynamic> GetPushList(SlbhAndPid patchdata, WriteBackWfm Wfm, string area) { if (patchdata == null) { return(null); } IList <PID> pidList = Wfm.PIDS.Where(p => p.PId == patchdata.Pid).ToList(); if (!pidList.Any()) { return(null); } var modelList = new List <dynamic>(); foreach (PID pid in pidList) { ViewName viewName = Wfm.ViewNames.Single(v => v.id == pid.viewId); DataSet retdata = GetPushData(patchdata, viewName, pid); if (retdata.Tables[0] == null || retdata.Tables[0].Rows.Count == 0) { return(null); } WebserviceAdd add = Wfm.WebserviceAdds.Single(w => w.id == pid.WSAID); for (int i = 0; i < retdata.Tables[0].Rows.Count; i++) { dynamic model = new ExpandoObject(); var dict = (IDictionary <string, object>)model; foreach (DataColumn column in retdata.Tables[0].Columns) { dict[column.ColumnName] = retdata.Tables[0].Rows[i][column]; } model.WebServiceAdd = add.name; modelList.Add(model); } } return(modelList); }
public BusinessResult PushASLBH(string Slbh, WriteBackWfm Wfm, string area) { try { string pids = Wfm.GetPIDSString(); DataTable dt = GetPushDataInfos4SLBH(Slbh, pids); if (dt == null || dt.Rows.Count == 0) { //ILog log1 = new ErrorLog(typeof(Polling)); //log1.WriteLog(new Exception("1111111111111")); return(new BusinessResult { IsSuccess = true, Message = "对应的流程不需要推送" }); } //ILog log7= new ErrorLog(typeof(Polling)); //log7.WriteLog(new Exception(dt.Rows.Count.ToString())); SlbhAndPid patchdata = DispatchData2(dt, Wfm); if (patchdata == null) { //ILog log2 = new ErrorLog(typeof(Polling)); // log2.WriteLog(new Exception("222222222222222")); return(new BusinessResult { IsSuccess = true, Message = "对应的流程不需要推送" }); } //解析如果不存在,则抛异常 所以用single IList <PID> pidList = Wfm.PIDS.Where(p => p.PId == patchdata.Pid).ToList(); if (!pidList.Any()) { //ILog log3 = new ErrorLog(typeof(Polling)); //log3.WriteLog(new Exception("3333333333333")); return(new BusinessResult { IsSuccess = true, Message = "对应的流程不需要推送" }); } string pushRet = string.Empty; string message = string.Empty; foreach (PID pid in pidList) { string wbMessage = ""; string cgMessage = ""; ViewName viewName = Wfm.ViewNames.Single(v => v.id == pid.viewId); DataSet retdata = GetPushData(patchdata, viewName, pid); InterfaceAddress add = GetRoute(Slbh, area); if (add.WB) { wbMessage = PushDataRouter(retdata, patchdata, pid, Wfm, viewName, "WB", area); } if (add.CG) { cgMessage = PushDataRouter(retdata, patchdata, pid, Wfm, viewName, "CG", area); } if (wbMessage.Contains("成功") && cgMessage.Contains("成功")) { message = ""; } else { if (!wbMessage.Contains("成功")) { message += wbMessage; } if (!cgMessage.Contains("成功")) { message += cgMessage; } } } if (string.IsNullOrEmpty(message)) { return new BusinessResult { IsSuccess = true, Message = pushRet } } ; else { return(new BusinessResult { IsSuccess = false, Message = message }); } } catch (Exception ex) { return(new BusinessResult { IsSuccess = false, Message = ex.Message }); // return false; } }
private string PushDataRouter(DataSet retdata, SlbhAndPid patchdata, PID pid, WriteBackWfm Wfm, ViewName viewName, string addressType, string area) { string pushRet = "-1"; string message = ""; if (retdata.Tables[0] == null || retdata.Tables[0].Rows.Count == 0)//表示没有取到推送数据 { ResetPushResult(patchdata.Slbh, pid.name, pushRet, "", "", pid.PId, patchdata.StepName, addressType); message = "没有数据"; } else { WebserviceAdd add = Wfm.WebserviceAdds.Single(w => w.id == pid.WSAID); if (addressType.Equals("WB")) { message += pushRet = PushDataWB(retdata, add.name, area) + "\n"; //errInfo = PushData(retdata, add.name, area, errInfo); //if (!IsError(errInfo)) if (pushRet.Trim().Equals("推送成功")) { ResetPushResult(patchdata.Slbh, pid.name, "1", SerialisePushData(retdata.Tables[0], viewName.name, add.name), GetInLength(pushRet), pid.PId, patchdata.StepName, addressType); } else { ResetPushResult(patchdata.Slbh, pid.name, "0", SerialisePushData(retdata.Tables[0], viewName.name, add.name), GetInLength(pushRet), pid.PId, patchdata.StepName, addressType); } } if (addressType.Equals("CG")) { message += pushRet = PushDataCG(retdata, add.name, area) + "\n"; //errInfo = PushData(retdata, add.name, area, errInfo); //if (!IsError(errInfo)) if (pushRet.Trim().Equals("推送成功")) { ResetPushResult(patchdata.Slbh, pid.name, "1", SerialisePushData(retdata.Tables[0], viewName.name, add.name), GetInLength(pushRet), pid.PId, patchdata.StepName, addressType); } else { ResetPushResult(patchdata.Slbh, pid.name, "0", SerialisePushData(retdata.Tables[0], viewName.name, add.name), GetInLength(pushRet), pid.PId, patchdata.StepName, addressType); } } } return(message); }