Beispiel #1
0
        /// <summary>
        /// 解析多列式
        /// </summary>
        ///
        /// <param name="table"></param>
        /// <param name="contentArr"></param>
        private void ParseMultiColType(ETable table, String[] contentArr)
        {
            if (contentArr.Length > 1)
            {
                List <string[]> porpList = new List <string[]>();
                for (int i = 1; i < contentArr.Length; i++)
                {
                    String linestr = contentArr[i].Trim();
                    // System.out.println("linestr="+linestr);
                    if (linestr.StartsWith("#"))
                    {
                        linestr = linestr.Substring(1);
                        String[] lineArr = SplitString(linestr);
                        porpList.Add(lineArr);
                    }
                }
                String[] columnNames = new String[porpList.Count];
                for (int col = 0; col < columnNames.Length; col++)
                {
                    columnNames[col] = porpList[col][1];
                }
                table.SetColumnNames(columnNames);

                for (int row = 2; row < porpList[0].Length; row++)
                {
                    String[] data = new String[columnNames.Length];
                    for (int col_0 = 0; col_0 < data.Length; col_0++)
                    {
                        data[col_0] = porpList[col_0][row];
                    }
                    table.GetDatas().Add(data);
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// 解析横表式
        /// </summary>
        ///
        /// <param name="table"></param>
        /// <param name="contentArr"></param>
        private void ParseRowType(ETable table, String[] contentArr)
        {
            String headStr = contentArr[0].Trim();

            String[] headerArr   = SplitString(headStr.Substring("@".Length));
            String[] columnNames = new String[headerArr.Length];
            System.Array.Copy((Array)(headerArr), 0, (Array)(columnNames), 0, columnNames.Length);
            table.SetColumnNames(columnNames);
            if (contentArr.Length > 1)
            {
                for (int i = 1; i < contentArr.Length; i++)
                {
                    String linestr = contentArr[i].Trim();
                    System.Console.Out.WriteLine("datastr=" + linestr);

                    if (linestr.StartsWith("%"))
                    {
                        // 类型
                        String[] lineArr = SplitString(linestr.Substring(1));
                        String[] type    = new String[lineArr.Length];
                        System.Array.Copy((Array)(lineArr), 0, (Array)(type), 0, type.Length);
                        table.SetTypes(type);
                    }
                    else if (linestr.StartsWith("$"))
                    {
                        // 梁纲引导符 单位
                        String[] lineArr_0 = SplitString(linestr.Substring(1));
                        String[] unites    = new String[lineArr_0.Length];
                        System.Array.Copy((Array)(lineArr_0), 0, (Array)(unites), 0, unites.Length);
                        table.SetUnites(unites);
                    }
                    else if (linestr.StartsWith(":"))
                    {
                        // 限值引导符
                        String[] lineArr_1   = SplitString(linestr.Substring(1));
                        String[] limitValues = new String[lineArr_1.Length];
                        System.Array.Copy((Array)(lineArr_1), 0, (Array)(limitValues), 0, limitValues.Length);
                        table.SetLimitValues(limitValues);
                    }
                    else if (linestr.StartsWith("#"))
                    {
                        // 数据值

                        String[] lineArr_2 = SplitString(linestr.Substring(1));
                        String[] data      = new String[lineArr_2.Length];
                        System.Array.Copy((Array)(lineArr_2), 0, (Array)(data), 0, data.Length);
                        table.GetDatas().Add(data);
                    }
                    //else if (linestr.StartsWith("//"))
                    //{

                    //}
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// 解析单列式
        /// </summary>
        ///
        /// @@
        ///
        /// @param table
        /// <param name="contentArr"></param>
        private void ParseSingleColType(ETable table, String[] contentArr)
        {
            String headStr = contentArr[0].Trim();

            String[] headerArr = SplitString(headStr.Substring("@@".Length));
            if (contentArr.Length > 1)
            {
                int propNo = 0;

                /**
                 * 存储属性name--value的Map
                 */
                Dictionary <string, string> propMap = new Dictionary <string, string>();
                int loopTime = 0;

                for (int i = 1; i < contentArr.Length; i++)
                {
                    String linestr = contentArr[i].Trim();
                    // System.out.println("linestr="+linestr);

                    if (linestr.StartsWith("#"))
                    {
                        linestr = linestr.Substring(1);
                        String[] lineArr = SplitString(linestr);
                        String[] popArr  = new String[] { "", "" };
                        if (headerArr.Length == 2)
                        {
                            System.Array.Copy((Array)(lineArr), 0, (Array)(popArr), 0, lineArr.Length);
                        }
                        else if (headerArr.Length == 3)
                        {
                            System.Array.Copy((Array)(lineArr), 1, (Array)(popArr), 0, lineArr.Length - 1);
                        }
                        if (propMap.ContainsKey(popArr[0]))
                        {
                            // 把属性值 加入到table的数据列表
                            String[] data = new String[propMap.Values.Count];
                            propMap.Values.CopyTo(data, 0);
                            table.GetDatas().Add(data);
                            propMap.Clear();
                        }
                        propMap.Add(popArr[0], popArr[1]);
                    }
                }
                // 设置列名
                String[] columns = new String[propMap.Keys.Count];
                propMap.Keys.CopyTo(columns, 0);
                table.SetColumnNames(columns);
                // 把属性值 加入到table的数据列表
                String[] data_0 = new String[propMap.Values.Count];
                propMap.Values.CopyTo(data_0, 0);
                table.GetDatas().Add(data_0);
                propMap.Clear();
            }
        }
Beispiel #4
0
 public static void Main(String[] args)
 {
     try {
         DefaultEfileParse parse = new DefaultEfileParse();
         String            file  = "E:\\6.½­Î÷ÏîÄ¿\\elanguage\\data\\ºá±íʽ.txt";
         List <ETable>     list  = parse.ParseFile(file);
         elanguage.Util.Debug.Debugwrite(list);
         ETable et = new ETable();
         et.SetColumnNames(new string[] { "˳Ðò", "×Ö¶Î1", "×Ö¶Î2", "×Ö¶Î3" });
         object[]        o1    = new object[] { "1", "111", "333", "222" };
         object[]        o2    = new object[] { "2", "411", "343", "222" };
         object[]        o3    = new object[] { "3", "141", "333", "242" };
         List <object[]> listo = new List <object[]>();
         listo.Add(o1);
         listo.Add(o2);
         listo.Add(o3);
         et.SetDatas(listo);
         et.SetTableName("Õï¶Ï½á¹û");
         et.SetDate(DateTime.Now.ToString());
         parse.CreateEFile(et, "@", "D:\\test.txt");
     } catch (Exception e) {
         Console.Error.WriteLine(e.StackTrace);
     }
 }