Exemple #1
0
        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);
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        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);
        }