示例#1
0
        public List <ParsRowView> GetView(XDCMessage XDCmsg)
        {
            List <ParsRowView> mprvlist = new List <ParsRowView>();

            OperatorHelper.CurrentNode = null;
            OperatorHelper.GetXmlConfig(XDCmsg);
            int tempXMLIndex = 0;

            for (int i = 0; i < XDCmsg.MsgASCIIStringFields.Length; i++)
            {
                List <ParsRowView> ilist = OperatorHelper.GetViewList(XDCmsg, XDCmsg.MsgASCIIStringFields[i], i, ref tempXMLIndex);
                if (ilist != null)
                {
                    mprvlist.AddRange(ilist);
                }

                if (i != XDCmsg.MsgASCIIStringFields.Length - 1)
                {
                    mprvlist.Add(new ParsRowView("FS", "", ""));
                }
            }
            return(mprvlist);
        }
        public List <ParsRowView> GetView(XDCMessage XDCmsg)
        {
            List <TemplateView> xmlList = OperatorHelper.GetXmlConfig(XDCmsg);

            if (null == xmlList)
            {
                return(null);
            }
            List <ParsRowView> mprvlist = new List <ParsRowView>();
            int    i                       = 0;
            int    J                       = 0;
            int    M                       = 0;
            bool   alreadyGSorFS           = false;
            string alreadGSorFsSpliter     = string.Empty;
            List <TemplateView> GSitemList = new List <TemplateView>();

            foreach (TemplateView item in xmlList)
            {
                if (item.FieldName == "FS")
                {
                    #region 处理上一次的
                    if (GSitemList.Count > 0)
                    {
                        string[] GSstring;
                        if (alreadGSorFsSpliter == "GS")
                        {
                            GSstring = XDCmsg.MsgASCIIStringFields[J].Split(XDCSplictorChar.GS);
                        }
                        else
                        {
                            GSstring = OperatorHelper.GetSubArray(XDCmsg.MsgASCIIStringFields, J + 1);
                            J++;
                        }
                        OperatorHelper.SetFS_GS_(ref mprvlist, GSitemList, alreadGSorFsSpliter, GSstring);
                        GSitemList.Clear();
                    }
                    #endregion
                    mprvlist.Add(new ParsRowView("FS", "", ""));
                    i = 0;
                    J++;
                    M                   = 0;
                    alreadyGSorFS       = false;
                    alreadGSorFsSpliter = "";
                }
                else if (item.FieldName == "GS" ||
                         item.FieldName == "FS*")
                {
                    #region 处理上一次的
                    if (GSitemList.Count > 0)
                    {
                        string[] GSstring;
                        if (alreadGSorFsSpliter == "GS")
                        {
                            GSstring = XDCmsg.MsgASCIIStringFields[J].Split(XDCSplictorChar.GS);
                        }
                        else
                        {
                            GSstring = OperatorHelper.GetSubArray(XDCmsg.MsgASCIIStringFields, J + 1);
                            J++;
                        }
                        OperatorHelper.SetFS_GS_(ref mprvlist, GSitemList, alreadGSorFsSpliter, new string[] { GSstring[M] });
                        M++;
                        GSitemList.Clear();
                    }
                    #endregion
                    alreadyGSorFS       = true;
                    alreadGSorFsSpliter = item.FieldName.Substring(0, 2);
                }
                else
                {
                    //处理GS情况
                    if (alreadyGSorFS)
                    {
                        GSitemList.Add(item);
                        continue;
                    }

                    #region GS非结尾的情况

                    if (GSitemList.Count > 0)
                    {
                        string[] GSstring;
                        if (alreadGSorFsSpliter == "GS")
                        {
                            GSstring = XDCmsg.MsgASCIIStringFields[J].Split(XDCSplictorChar.GS);
                        }
                        else
                        {
                            GSstring = OperatorHelper.GetSubArray(XDCmsg.MsgASCIIStringFields, J + 1);
                            J++;
                        }
                        OperatorHelper.SetFS_GS_(ref mprvlist, GSitemList, alreadGSorFsSpliter, new string[] { GSstring[M] });
                        M++;
                        GSitemList.Clear();
                    }

                    GSitemList.Clear();
                    #endregion
                    string tempValue = string.Empty;
                    //域的值有指定长度的情况
                    if (item.FieldSize > 0)
                    {
                        string tempbeforeGStext = "";
                        try
                        {
                            if (XDCmsg.MsgASCIIStringFields[J].Contains(XDCSplictorChar.GS))
                            {
                                tempbeforeGStext = XDCmsg.MsgASCIIStringFields[J].Substring(0, XDCmsg.MsgASCIIStringFields[J].IndexOf(XDCSplictorChar.GS));
                            }
                            else
                            {
                                tempbeforeGStext = XDCmsg.MsgASCIIStringFields[J];
                            }
                            tempValue = tempbeforeGStext.Substring(i, item.FieldSize);
                            i        += item.FieldSize;
                        }
                        catch
                        {
                            tempValue = "";
                            i        += item.FieldSize;
                        }
                    }
                    else
                    {
                        string tempbeforeGStext = "";
                        if (XDCmsg.MsgASCIIStringFields[J].Contains(XDCSplictorChar.GS))
                        {
                            tempbeforeGStext = XDCmsg.MsgASCIIStringFields[J].Substring(0, XDCmsg.MsgASCIIStringFields[J].IndexOf(XDCSplictorChar.GS));
                        }
                        else
                        {
                            tempbeforeGStext = XDCmsg.MsgASCIIStringFields[J];
                        }
                        try
                        {
                            tempValue = tempbeforeGStext.Substring(i, tempbeforeGStext.Length - i);
                            i        += tempbeforeGStext.Length - i;
                        }
                        catch
                        {
                            tempValue = "";
                            i        += item.FieldSize;
                        }
                    }
                    string tempComment = string.Empty;

                    if (item.FieldValue != null)
                    {
                        if (string.IsNullOrEmpty(tempValue))
                        {
                            tempComment = "No Value";
                        }
                        else if (item.FieldValue.ContainsKey(tempValue))
                        {
                            tempComment = item.FieldValue[tempValue];
                        }
                        else if (item.FieldValue.ContainsKey("*"))
                        {
                            tempComment = item.FieldValue["*"];
                        }
                        else
                        {
                            bool isFind = false;
                            foreach (KeyValuePair <string, string> kvpItem in item.FieldValue)
                            {
                                //&运算
                                if (kvpItem.Key.Contains("&amp;"))
                                {
                                    isFind = true;
                                    string ampValue    = kvpItem.Key.Substring(0, kvpItem.Key.IndexOf("&amp;"));
                                    string ampOperator = kvpItem.Key.Substring(kvpItem.Key.IndexOf("&amp;") + 5, kvpItem.Key.Length - kvpItem.Key.IndexOf("&amp;") - 5);
                                    int    ampResult   = int.Parse(tempValue) & int.Parse(ampOperator);
                                    if (ampResult.ToString() == ampValue)
                                    {
                                        tempComment += kvpItem.Value + ";";
                                    }
                                }
                            }
                            if (!isFind)
                            {
                                tempComment = "UnKnow Value";
                            }
                        }
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(tempValue))
                        {
                            tempComment = "No Value";
                        }
                        else
                        {
                            tempComment = "";
                        }
                    }
                    mprvlist.Add(new ParsRowView(item.FieldName, tempValue, tempComment));
                }
            }
            #region GS结尾的情况

            if (GSitemList.Count > 0)
            {
                string[] GSstring;
                if (alreadGSorFsSpliter == "GS")
                {
                    GSstring = XDCmsg.MsgASCIIStringFields[J].Split(XDCSplictorChar.GS);
                }
                else
                {
                    GSstring = OperatorHelper.GetSubArray(XDCmsg.MsgASCIIStringFields, J + 1);
                    J++;
                }
                try
                {
                    OperatorHelper.SetFS_GS_(ref mprvlist, GSitemList, alreadGSorFsSpliter, new string[] { GSstring[M] });
                    M++;
                }
                catch
                {
                }
                finally
                {
                    GSitemList.Clear();
                }
            }

            #endregion
            return(mprvlist);
        }