Exemplo n.º 1
0
        public static void Data(string dllDir, string excelDir)
        {
            string dllFilePath = Path.Combine(dllDir, Common.dllName);

            if (!File.Exists(dllFilePath))
            {
                Console.WriteLine($"{dllFilePath}:dll文件路径不存在!!!");
                return;
            }
            assembly = Assembly.LoadFile(dllFilePath);
            if (Directory.Exists(Common.dataFileDirPath)) // 导数据前删除里面的所有文件
            {
                Directory.Delete(Common.dataFileDirPath, true);
            }
            Directory.CreateDirectory(Common.dataFileDirPath);

            if (Directory.Exists(Common.lawsDataFileDirPath))
            {
                Directory.Delete(Common.lawsDataFileDirPath, true);
            }
            Directory.CreateDirectory(Common.lawsDataFileDirPath);

            string[] excelFilePaths = ReadExcel.GetAllExcelPaths(excelDir);
            for (int i = 0; i < excelFilePaths.Length; i++)
            {
                OpenExcel(excelFilePaths[i]);
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            string exePath        = Directory.GetCurrentDirectory();
            string parentPath     = Directory.GetParent(exePath).FullName;
            string topPath        = Directory.GetParent(parentPath).FullName;
            string configFilePath = Path.Combine(topPath, "Config/PathConfig.txt");

            if (File.Exists(configFilePath))
            {
                string[] lines = File.ReadAllLines(configFilePath);
                if (lines.Length < 5) // 所需的配置条数
                {
                    Console.WriteLine($"{configFilePath}配置文件规则不正确,请按照规则进行修改");
                }
                else
                {
                    if (Directory.Exists(lines[0]) && Directory.Exists(lines[1]))
                    {
                        string[] paths = ReadExcel.GetAllExcelPaths(lines[0]);
                        ReadExcel.CreateClientFile(lines[1]);
                        for (int i = 0; i < paths.Length; i++)
                        {
                            ReadExcel.OpenExcel(paths[i]);
                        }
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("Excel表全部转换完成!!!");
                        Console.ForegroundColor = ConsoleColor.White;

                        Console.WriteLine("开始转换C#类…………");
                        bool isGenerat = GeneratClass.CallProtoc(lines[2]);
                        Console.WriteLine("转换C#类完成…………");

                        if (isGenerat)
                        {
                            Console.WriteLine("开始编译C#类…………");
                            bool isCompiler = Compiler2Dll.Compiler(lines[3], lines[3], lines[4]);
                            Console.WriteLine("编译C#类完成…………");

                            if (isCompiler)
                            {
                                Console.WriteLine("开始序列化数据……");
                                Excel2Bytes.Data(lines[3], lines[0]);
                                Console.WriteLine("序列化数据完成…………");
                            }
                        }
                    }
                    else
                    {
                        Console.WriteLine($"{configFilePath}配置文件填写的路径不正确,请填写正确的文件路径!!!");
                    }
                }
            }
            else //没有配置文件就创建配置文件并提醒填写路径: excel路径、proto输出路径
            {
                string dir = Path.GetDirectoryName(configFilePath);
                Console.WriteLine(dir);
                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                }
                File.Create(configFilePath);
                Console.WriteLine("配置文件创建完成,请按规则填写好路径配置文件!!!");
            }
            Console.ReadKey();
        }