Esempio n. 1
0
        public static List <XIMWrapper> Transform(XMLTransformer transformer, List <DataSet> dataSetList)
        {
            if (transformer == null || dataSetList == null)
            {
                return(null);
            }
            List <XIMWrapper> resultList = new List <XIMWrapper>();

            foreach (DataSet ds in dataSetList)
            {
                StringBuilder sb = new StringBuilder();
                StringWriter  sw = new StringWriter(sb);
                ds.WriteXml(sw);
                string xml = sb.ToString();

                string str = "";
                if (transformer.TransformString(xml, ref str))
                {
                    XIMWrapper w = new XIMWrapper(str);
                    w.GUIDList.Add(ConfigMain.GetGUID(ds));
                    resultList.Add(w);
                }
            }
            return(resultList);
        }
Esempio n. 2
0
        public static List <XIMWrapper> MergeProcedureStep(List <XIMWrapper> msgList, string pkPath)
        {
            if (msgList == null || pkPath == null || pkPath.Length < 1)
            {
                return(null);
            }

            int index = 0;
            Dictionary <string, XIMWrapper> mergeTable = new Dictionary <string, XIMWrapper>();

            foreach (XIMWrapper msg in msgList)
            {
                msg.Document = new XmlDocument();
                msg.Document.LoadXml(msg.XIMDocument);

                string  pkValue = null;
                XmlNode node    = msg.Document.SelectSingleNode(pkPath);
                if (node != null)
                {
                    pkValue = node.InnerText;
                }
                if (pkValue == null || pkValue.Length < 1)
                {
                    pkValue = "_" + (index++).ToString();
                }

                if (mergeTable.ContainsKey(pkValue))
                {
                    XIMWrapper oldmsg = mergeTable[pkValue];
                    foreach (string guid in msg.GUIDList)
                    {
                        oldmsg.GUIDList.Add(guid);
                    }
                    XmlNode itemNode = oldmsg.Document.SelectSingleNode(ITEM);
                    if (itemNode != null)
                    {
                        XmlNode spsNode = msg.Document.SelectSingleNode(SCHEDULED_PROCEDURE_STEP);
                        if (spsNode != null)
                        {
                            //itemNode.AppendChild(spsNode.Clone());
                            string xml = itemNode.InnerXml;
                            xml = xml + spsNode.OuterXml;
                            itemNode.InnerXml = xml;
                        }
                    }
                }
                else
                {
                    mergeTable.Add(pkValue, msg);
                }
            }

            List <XIMWrapper> resultList = new List <XIMWrapper>();

            foreach (KeyValuePair <string, XIMWrapper> pair in mergeTable)
            {
                XIMWrapper w = pair.Value;
                w.XIMDocument = w.Document.OuterXml;
                resultList.Add(w);
            }
            return(resultList);
        }