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

            try
            {
                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", "", ""));
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.LogError(this.GetType().Name, "GetView Error:" + ex.Message);
            }
            return(mprvlist);
        }
Exemple #2
0
        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;
            bool   alreadyGSorFS           = false;
            string alreadGSorFsSpliter     = string.Empty;
            List <TemplateView> GSitemList = new List <TemplateView>();

            foreach (TemplateView item in xmlList)
            {
                if (item.FieldName == "FS")
                {
                    mprvlist.Add(new ParsRowView("FS", "", ""));
                    i = 0;
                    J++;
                    alreadyGSorFS       = false;
                    alreadGSorFsSpliter = "";
                }
                else if (item.FieldName == "GS" ||
                         item.FieldName == "FS*")
                {
                    alreadyGSorFS       = true;
                    alreadGSorFsSpliter = item.FieldName.Substring(0, 2);
                }
                else
                {
                    //处理GS情况
                    if (alreadyGSorFS)
                    {
                        GSitemList.Add(item);
                        continue;
                    }

                    #region GS非结尾的情况

                    if (GSitemList.Count > 0)
                    {
                        Char     spliterGS = '\u001D';
                        string[] GSstring;
                        if (alreadGSorFsSpliter == "GS")
                        {
                            GSstring = XDCmsg.MsgASCIIStringFields[J].Split(spliterGS);
                        }
                        else
                        {
                            GSstring = OperatorHelper.GetSubArray(XDCmsg.MsgASCIIStringFields, J + 1);
                        }
                        string tempValueGS  = "";
                        string tempComment2 = "";
                        for (int k = alreadGSorFsSpliter == "GS" ? 1 : 0; k < GSstring.Length; k++)
                        {
                            if (null == (GSstring[k]))
                            {
                                break;
                            }
                            mprvlist.Add(new ParsRowView(alreadGSorFsSpliter, "", ""));
                            for (int l = 0; l < GSitemList.Count; l++)
                            {
                                if (GSitemList[l].FieldSize > 0)
                                {
                                    if (GSstring[k].Length >= GSitemList[l].FieldSize)
                                    {
                                        tempValueGS = GSstring[k].Substring(l, GSitemList[l].FieldSize);
                                    }
                                    else
                                    {
                                        tempValueGS = "";
                                    }
                                }
                                else
                                {
                                    if (l < GSstring[k].Length)
                                    {
                                        tempValueGS = GSstring[k].Substring(l, GSstring[k].Length - l);
                                    }
                                    else
                                    {
                                        tempValueGS = "";
                                    }
                                }
                                if (GSitemList[l].FieldValue != null &&
                                    GSitemList[l].FieldValue.ContainsKey(tempValueGS))
                                {
                                    tempComment2 = GSitemList[l].FieldValue[tempValueGS];
                                }
                                else if (GSitemList[l].FieldValue != null &&
                                         GSitemList[l].FieldValue.ContainsKey("*"))
                                {
                                    tempComment2 = GSitemList[l].FieldValue["*"];
                                }
                                else
                                {
                                    if (string.IsNullOrEmpty(tempValueGS))
                                    {
                                        tempComment2 = "No Value";
                                    }
                                    else
                                    {
                                        tempComment2 = "";
                                    }
                                }

                                mprvlist.Add(new ParsRowView(GSitemList[l].FieldName, tempValueGS, tempComment2));
                            }
                        }
                    }

                    GSitemList.Clear();
                    #endregion
                    string tempValue = string.Empty;
                    //域的值有指定长度的情况
                    if (item.FieldSize > 0)
                    {
                        try
                        {
                            tempValue = XDCmsg.MsgASCIIStringFields[J].Substring(i, item.FieldSize);
                            i        += item.FieldSize;
                        }
                        catch
                        {
                            tempValue = "";
                            i        += item.FieldSize;
                        }
                    }
                    else
                    {
                        try
                        {
                            tempValue = XDCmsg.MsgASCIIStringFields[J].Substring(i, XDCmsg.MsgASCIIStringFields[J].Length - i);
                            i        += XDCmsg.MsgASCIIStringFields[J].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)
            {
                Char     spliterGS = '\u001D';
                string[] GSstring;
                if (alreadGSorFsSpliter == "GS")
                {
                    GSstring = XDCmsg.MsgASCIIStringFields[J].Split(spliterGS);
                }
                else
                {
                    GSstring = OperatorHelper.GetSubArray(XDCmsg.MsgASCIIStringFields, J + 1);
                }
                string tempValueGS = "";
                string tempComment = "";
                for (int k = alreadGSorFsSpliter == "GS" ? 1 : 0; k < GSstring.Length; k++)
                {
                    if (null == (GSstring[k]))
                    {
                        break;
                    }
                    mprvlist.Add(new ParsRowView(alreadGSorFsSpliter, "", ""));
                    for (int l = 0; l < GSitemList.Count; l++)
                    {
                        if (GSitemList[l].FieldSize > 0)
                        {
                            if (GSstring[k].Length >= GSitemList[l].FieldSize)
                            {
                                tempValueGS = GSstring[k].Substring(l, GSitemList[l].FieldSize);
                            }
                            else
                            {
                                tempValueGS = "";
                            }
                        }
                        else
                        {
                            if (l < GSstring[k].Length)
                            {
                                tempValueGS = GSstring[k].Substring(l, GSstring[k].Length - l);
                            }
                            else
                            {
                                tempValueGS = "";
                            }
                        }
                        if (GSitemList[l].FieldValue != null &&
                            GSitemList[l].FieldValue.ContainsKey(tempValueGS))
                        {
                            tempComment = GSitemList[l].FieldValue[tempValueGS];
                        }
                        else if (GSitemList[l].FieldValue != null &&
                                 GSitemList[l].FieldValue.ContainsKey("*"))
                        {
                            tempComment = GSitemList[l].FieldValue["*"];
                        }
                        else
                        {
                            if (string.IsNullOrEmpty(tempValueGS))
                            {
                                tempComment = "No Value";
                            }
                            else
                            {
                                tempComment = "";
                            }
                        }

                        mprvlist.Add(new ParsRowView(GSitemList[l].FieldName, tempValueGS, tempComment));
                    }
                }
            }

            #endregion
            return(mprvlist);
        }