Esempio n. 1
0
        static void Main(string[] args)
        {
            try
            {
                if (args != null)
                {
                    if (args.Length < 5)
                    {
                        return;
                    }

                    string configFilePath      = "";
                    string configFileSheetName = "";
                    string rawDataFilePath     = "";
                    string outDataFilePath     = "";
                    string outCodeFilePath     = "";

                    configFilePath      = args[0];
                    configFileSheetName = args[1];
                    rawDataFilePath     = args[2];
                    outDataFilePath     = args[3];
                    outCodeFilePath     = args[4];

                    if (true)
                    {
                        Console.WriteLine("configFilePath is " + configFilePath);
                        Console.WriteLine("configFileSheetName is " + configFileSheetName);
                        Console.WriteLine("rawFilePath  is " + rawDataFilePath);
                        Console.WriteLine("outFilePath  is " + outDataFilePath);
                        Console.WriteLine("outCodeFilePath  is " + outCodeFilePath);
                    }

                    //read config file
                    SingleExcelExport.ReadXLS(configFilePath + ".xls", configFileSheetName);
                    int ColCount = SingleExcelExport.dtData.Columns.Count;
                    int RowCount = SingleExcelExport.dtData.Rows.Count;

                    string[] rawTextFileNames     = new string[RowCount];
                    string[] rawTextFileSheetName = new string[RowCount];
                    for (int i = 0; i < RowCount; i++)
                    {
                        if (SingleExcelExport.dtData.Rows[i][0].ToString() == null)
                        {
                            continue;
                        }
                        rawTextFileNames[i]     = SingleExcelExport.dtData.Rows[i][0].ToString();
                        rawTextFileSheetName[i] = SingleExcelExport.dtData.Rows[i][1].ToString();
                    }

                    ClientMultiLanguageTextExporter.ExportMLTextFiles(rawTextFileNames, rawTextFileSheetName, outDataFilePath, outCodeFilePath);
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);
            }
        }
        public static void ExportMLTextFiles(string[] textFileNames, string[] SheetName, string outPath, string outCodeFilePath)
        {
            try
            {
                Console.WriteLine("Start Export ML Text File!");

                DataTable allStringData = new DataTable();
                for (int i = 0; i < textFileNames.Length; i++)
                {
                    if (SheetName.Length <= i)
                    {
                        Console.WriteLine("Sheet input wrong!");
                    }

                    SingleExcelExport.ReadXLS(textFileNames[i] + ".xls", SheetName[i]);

                    for (int j = 0; j < SingleExcelExport.dtData.Columns.Count; j++)
                    {
                        SingleExcelExport.dtData.Columns[j].MaxLength = Int32.MaxValue;
                    }

                    if (i == 0)
                    {
                        allStringData = SingleExcelExport.dtData.Copy();
                    }
                    else
                    {
                        for (int j = 0; j < SingleExcelExport.dtData.Rows.Count; j++)
                        {
                            allStringData.Rows.Add(SingleExcelExport.dtData.Rows[j].ItemArray);
                        }
                    }
                }

                int length = allStringData.Rows.Count;
                Console.WriteLine("Multi text file Length is " + length.ToString());

                //export head
                Console.WriteLine("Exporting HEAD!" + " !");
                ExportOneLanguageData(allStringData, "TEXT_HEAD", 0, outPath, outCodeFilePath);

                //export text data, use one header, notice all header of files should be same
                string[] ColHeaders = SingleExcelExport.GetColumnHeader();//still has last table's head
                for (int i = 0; i < ColHeaders.Length; i++)
                {
                    Console.WriteLine("Exporting " + ColHeaders[i] + " !");
                    ExportOneLanguageData(allStringData, ColHeaders[i], i + 1, outPath, outCodeFilePath);
                }

                Console.WriteLine("End Export ML Text File!");
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);
            }
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            try
            {
                if (args != null)
                {
                    if (args.Length < 5)
                    {
                        Console.WriteLine("Not enough param number!");
                        return;
                    }

                    string configFilePath      = "";
                    string configFileSheetName = "";
                    string rawDataFilePath     = "";
                    string outDataFilePath     = "";
                    string outCodeFilePath     = "";

                    configFilePath      = args[0];
                    configFileSheetName = args[1];
                    rawDataFilePath     = args[2];
                    outDataFilePath     = args[3];
                    outCodeFilePath     = args[4];

                    if (true)
                    {
                        Console.WriteLine("configFilePath is " + configFilePath);
                        Console.WriteLine("configFileSheetName is " + configFileSheetName);
                        Console.WriteLine("rawFilePath  is " + rawDataFilePath);
                        Console.WriteLine("outFilePath  is " + outDataFilePath);
                        Console.WriteLine("outCodeFilePath  is " + outCodeFilePath);
                    }

                    //read config file
                    SingleExcelExport.ReadXLS(configFilePath + ".xls", configFileSheetName);
                    int ColCount = SingleExcelExport.dtData.Columns.Count;
                    int RowCount = SingleExcelExport.dtData.Rows.Count;

                    Console.WriteLine("ColCount is " + ColCount);
                    Console.WriteLine("RowCount is " + RowCount);


                    if (ColCount > 0 && RowCount > 0)
                    {
                        string[,] exportSettings = new string[RowCount, ColCount];
                        for (int i = 0; i < RowCount; i++)
                        {
                            if (SingleExcelExport.dtData.Rows[i][0].ToString() == null)
                            {
                                continue;
                            }

                            for (int j = 0; j < ColCount; j++)
                            {
                                exportSettings[i, j] = SingleExcelExport.dtData.Rows[i][j].ToString();
                            }
                        }

                        Dictionary <string, int> dicHeaders = new Dictionary <string, int>();
                        //start export
                        for (int i = 0; i < RowCount; i++)
                        {
                            //this excatly fit the settings of _tableConfig.xls
                            if (exportSettings[i, 0] == null)
                            {
                                return;
                            }
                            if (exportSettings[i, 1] == null)
                            {
                                return;
                            }
                            if (exportSettings[i, 2] == null)
                            {
                                return;
                            }

                            string fileName    = rawDataFilePath + exportSettings[i, 1];
                            string sheetName   = exportSettings[i, 2];
                            string outFileName = outDataFilePath + exportSettings[i, 3];
                            string configFlag  = exportSettings[i, 4];
                            string ColRange    = exportSettings[i, 5];
                            string RowRange    = exportSettings[i, 6];
                            // printf(ColRange);
                            // Console.WriteLine("ColRange is " + ColRange);
                            // printf(RowRange);
                            // Console.WriteLine("RowRange is " + RowRange);
                            // return;
                            string[] colRange = ColRange.Split(',');
                            string[] rowRange = RowRange.Split(',');
                            // return;
                            int startCol = int.Parse(colRange[0]);
                            int endCol   = int.Parse(colRange[1]);
                            int startRow = int.Parse(rowRange[0]);
                            int endRow   = int.Parse(rowRange[1]);

                            if (configFlag.Equals("S"))//if this table is only for server
                            {
                                continue;
                            }

                            string [] headers = SingleExcelExport.Export(fileName, sheetName, outFileName, startCol, endCol, startRow, endRow);
                            for (int j = 0; j < headers.Length; j++)
                            {
                                dicHeaders.Add(exportSettings[i, 1] + "_" + sheetName + "_" + headers[j], j);
                            }
                        }

                        string filename = outCodeFilePath + "DataDefine.cs";
                        //write to header
                        using (StreamWriter sw = new StreamWriter(filename))
                        {
                            string        content;
                            StringBuilder sb = new StringBuilder();

                            sb.Append("//This file is generated by tools!").Append("\n");
                            sb.Append("//Please do not modify this file!").Append("\n");
                            sb.Append("public class DataDefine {").Append("\n").Append("\n");


                            foreach (var item in dicHeaders)
                            {
                                string header = String.Copy(item.Key);
                                if (header.Contains(" "))
                                {
                                    header = header.Replace(' ', '_');
                                }
                                sb.Append("\tpublic const int " + header + " = " + item.Value + ";").Append("\n");
                            }

                            sb.Append("\n");
                            sb.Append("}");

                            content = sb.ToString();
                            sw.Write(content);
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);
                Console.WriteLine(exception.StackTrace);
            }
        }