예제 #1
0
파일: Burn.cs 프로젝트: xiexiaojun/HPMS
        /// <summary>
        /// 读取data里的关键字段
        /// </summary>
        /// <param name="dKey"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        private string[] GetKeyValue(Dictionary <string, KeyInformation> dKey, byte[] data)
        {
            if (data == null || data.Length == 0)
            {
                return(new [] { "NA", "NA", "NA", "NA", "NA", "NA" });
            }
            List <string> ret = new List <string>();

            foreach (var keyField in dKey)
            {
                KeyInformation temp = keyField.Value;
                temp.Data = SliceArray(data, temp.Start, temp.End - temp.Start + 1);
                if (temp.Convert)
                {
                    temp.Value = System.Text.Encoding.Default.GetString(temp.Data);
                }
                else
                {
                    temp.Value = string.Join("", temp.Data.Select(t => t.ToString().PadLeft(2, '0')).ToArray());
                }

                ret.Add(temp.Value);
            }

            return(ret.ToArray());
        }
예제 #2
0
파일: Burn.cs 프로젝트: xiexiaojun/HPMS
        /// <summary>
        /// 解析xml里的关键字段
        /// </summary>
        /// <param name="fields"></param>
        /// <returns></returns>
        private Dictionary <string, KeyInformation> GetKeyField(List <Field> fields)
        {
            Dictionary <string, KeyInformation> ret = new Dictionary <string, KeyInformation>();

            foreach (var keyField in fields)
            {
                KeyInformation temp = new KeyInformation();
                temp.Name    = keyField.Name;
                temp.Convert = Convert.ToBoolean(keyField.Convert);
                temp.Start   = ParseStr2Int(keyField.Start);
                temp.End     = ParseStr2Int(keyField.End);
                ret.Add(keyField.Name, temp);
            }

            return(ret);
        }