示例#1
0
        public void TransferClassServerConf()
        {
            var sb = new StringBuilder();

            sb.Append($"using System.Collections.Generic;\r\n");
            sb.Append($"using UtilLib;\r\n\r\n");
            sb.Append($"namespace ServerBase.Config\r\n{{\r\n");
            sb.Append($"\tpublic static partial class Conf\r\n\t{{\r\n");

            foreach (var nn in DictPages.Values)
            {
                if (!(nn.ValidType == EValidType.公共 || nn.ValidType == EValidType.仅服务器))
                {
                    continue;
                }
                sb.Append($"\t\t//{nn.NameCn}\t// {nn.NameFile}\r\n");
                var confname = nn.Name.Replace("Config", "Conf");
                var keytype  = nn.TypeServer[0];
                sb.Append($"\t\tpublic static Dictionary<{keytype}, {nn.Name}> {confname} = new Dictionary<{keytype}, {nn.Name}>();\r\n");
            }

            sb.Append($"\t}}\r\n");
            sb.Append($"}}\r\n");

            string path_class = PathClass + "\\" + "ClassServerConf.cs";

            XGlobal.DeleteFile(path_class);
            FileStream   fs_class = new FileStream(path_class, FileMode.OpenOrCreate);
            StreamWriter sw_class = new StreamWriter(fs_class, Encoding.Unicode);

            sw_class.Write(sb);
            sw_class.Close();
        }
示例#2
0
        public void TransferClassClientLua()
        {
            var sb = new StringBuilder();

            sb.Append($"using System.Collections.Generic;\r\n\r\n");
            sb.Append($"using XLua;\r\n\r\n");

            foreach (var nn in DictPages.Values)
            {
                if (!(nn.ValidType == EValidType.公共 || nn.ValidType == EValidType.仅客户端))
                {
                    continue;
                }
                sb.Append($"[CSharpCallLua]\r\n");
                sb.Append($"public interface {nn.Name}\r\n{{\r\n");
                for (int iii = 0; iii < nn.Head.Count; iii++)
                {
                    if (nn.Head[iii] == "")
                    {
                        continue;
                    }
                    if (nn.TypeClient[iii] == "")
                    {
                        continue;
                    }
                    sb.Append($"\t{nn.TypeClient[iii]} {nn.Head[iii]} {{ get; }}\r\n");
                }
                sb.Append($"}}\r\n");
            }

            foreach (var kvp in DictListEnums)
            {
                sb.Append($"public enum E{kvp.Key}\r\n");
                sb.Append($"{{\r\n");
                long min = 0, max = 0;
                foreach (var kvp2 in kvp.Value)
                {
                    sb.Append($"\t{kvp2.Key} = {kvp2.Value},\r\n");
                    long.TryParse(kvp2.Value, out long tempmax);
                    min = Math.Min(min, tempmax);
                    max = Math.Max(max, tempmax);
                }
                sb.Append($"}}\r\n");
            }

            string path_class = PathClass + "\\" + "ClassClientLua.cs";

            XGlobal.DeleteFile(path_class);
            FileStream   fs_class = new FileStream(path_class, FileMode.OpenOrCreate);
            StreamWriter sw_class = new StreamWriter(fs_class);

            sw_class.Write(sb);
            sw_class.Close();
        }
示例#3
0
        private void FormTool_Load(object sender, EventArgs e)
        {
            PathCurrent = Directory.GetCurrentDirectory();
            PathCurrent = XGlobal.GetParentFolder(PathCurrent);

            textBox2.Text = PathExcel = PathCurrent + @"\Config\Excel";
            textBox3.Text = PathClass = PathCurrent + @"\Config\Class";
            textBox4.Text = PathXml = PathCurrent + @"\Config\Xml";
            textBox5.Text = PathJson = PathCurrent + @"\Config\Json";
            textBox1.Text = PathLua = PathCurrent + @"\Config\Lua";

            //PathEnum = PathExcel + @"\e公共枚举.xlsx";
            PathEnum     = PathExcel + @"\A_公共枚举.xlsx";
            PathResult   = PathExcel + @"\F_返回码.xlsx";
            PathGlobalId = PathExcel + @"\Q_全局常数.xlsx";
        }
示例#4
0
        public void TransferClassServerConfRead()
        {
            var sb = new StringBuilder();

            sb.Append($"using System.Collections.Generic;\r\n");
            sb.Append($"using UtilLib;\r\n\r\n");
            sb.Append($"namespace ServerBase.Config\r\n{{\r\n");
            sb.Append($"\tpublic static partial class Conf\r\n\t{{\r\n");
            sb.Append($"\t\tpublic static bool InitConfSettings()\r\n\t\t{{\r\n");

            sb.Append($"\t\t\tbool result = true;\r\n\r\n");
            foreach (var nn in DictPages.Values)
            {
                if (!(nn.ValidType == EValidType.公共 || nn.ValidType == EValidType.仅服务器))
                {
                    continue;
                }
                sb.Append($"\t\t\t//{nn.NameCn}\r\n");
                var confname = nn.Name.Replace("Config", "Conf");
                sb.Append($"\t\t\tif (result) {{ result = ReadConfig(typeof({nn.Name}).Name, ref {confname}); }}\r\n");
            }
            sb.Append($"\r\n\t\t\tif (result) {{ result = InitConfSettingsExt(); }}\r\n\r\n");
            sb.Append($"\t\t\treturn result;\r\n");

            sb.Append($"\t\t}}\r\n");
            sb.Append($"\t}}\r\n");
            sb.Append($"}}\r\n");

            string path_class = PathClass + "\\" + "ClassServerConfRead.cs";

            XGlobal.DeleteFile(path_class);
            FileStream   fs_class = new FileStream(path_class, FileMode.OpenOrCreate);
            StreamWriter sw_class = new StreamWriter(fs_class, Encoding.Unicode);

            sw_class.Write(sb);
            sw_class.Close();
        }
示例#5
0
        public void TransferClassServer()
        {
            var sb = new StringBuilder();

            sb.Append($"using System.Collections.Generic;\r\n\r\n");
            sb.Append($"namespace ServerBase.Config\r\n{{\r\n");

            foreach (var nn in DictPages.Values)
            {
                if (!(nn.ValidType == EValidType.公共 || nn.ValidType == EValidType.仅服务器))
                {
                    continue;
                }
                sb.Append($"\tpublic class {nn.Name} : IConfigBase\t// {nn.NameFile}\r\n\t{{\r\n");
                for (int iii = 0; iii < nn.Head.Count; iii++)
                {
                    if (nn.Head[iii] == "")
                    {
                        continue;
                    }
                    if (nn.TypeServer[iii] == "")
                    {
                        continue;
                    }
                    string tp = nn.TypeServer[iii];
                    switch (tp)
                    {
                    case "List<string>":
                    case "List<int>":
                    case "List<long>":
                    case "List<float>":
                    case "Dictionary<string,string>":
                    case "Dictionary<int,int>":
                    case "Dictionary<long,long>":
                    case "Dictionary<string, string>":
                    case "Dictionary<int, int>":
                    case "Dictionary<long, long>":
                        sb.Append($"\t\tpublic {tp} {nn.Head[iii]} = new {tp}(); //{nn.HeadC[iii]}\r\n");
                        break;

                    default:
                        sb.Append($"\t\tpublic {nn.TypeServer[iii]} {nn.Head[iii]}; //{nn.HeadC[iii]}\r\n");
                        break;
                    }
                }
                string getkey = "Id";
                try { getkey = nn.Head[0]; } catch { }
                sb.Append($"\t\tpublic object GetKey() {{ return {getkey}; }}\r\n");
                sb.Append($"\t}}\r\n");
            }

            foreach (var kvp in DictListEnums)
            {
                sb.Append($"\tpublic enum E{kvp.Key}\r\n");
                sb.Append($"\t{{\r\n");
                long min = 0, max = 0;
                foreach (var kvp2 in kvp.Value)
                {
                    sb.Append($"\t\t{kvp2.Key} = {kvp2.Value},\r\n");
                    long.TryParse(kvp2.Value, out long tempmax);
                    min = Math.Min(min, tempmax);
                    max = Math.Max(max, tempmax);
                }
                sb.Append($"\t}}\r\n");
            }
            sb.Append($"}}\r\n");

            string path_class = PathClass + "\\" + "ClassServer.cs";

            XGlobal.DeleteFile(path_class);
            FileStream   fs_class = new FileStream(path_class, FileMode.OpenOrCreate);
            StreamWriter sw_class = new StreamWriter(fs_class, Encoding.Unicode);

            sw_class.Write(sb);
            sw_class.Close();
        }
示例#6
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (DateTime.Now >= new DateTime(2020, 7, 1))
            {
                return;
            }

            UpdateprogressBar1();
            var ageCoun = (from s in DictFiles.Values
                           select s.Need)
                          .Count(a => a == true);

            if (ageCoun <= 0)
            {
                MessageBox.Show($"需要导出的列表为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (!Directory.Exists(PathExcel))
            {
                MessageBox.Show($"导入文档路径< {PathExcel} >并不存在!请重新设置!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (!Directory.Exists(PathClass))
            {
                MessageBox.Show($"导入文档路径< {PathClass} >并不存在!请重新设置!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (!Directory.Exists(PathXml))
            {
                MessageBox.Show($"导入文档路径< {PathXml} >并不存在!请重新设置!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (!Directory.Exists(PathJson))
            {
                MessageBox.Show($"导入文档路径< {PathJson} >并不存在!请重新设置!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (!Directory.Exists(PathLua))
            {
                MessageBox.Show($"导入文档路径< {PathLua} >并不存在!请重新设置!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            SetEnabled(false);

            XGlobal.EmptyFolder(PathClass);
            XGlobal.EmptyFolder(PathXml);
            XGlobal.EmptyFolder(PathJson);
            XGlobal.EmptyFolder(PathLua);

            try
            {
                TransferFiles();
            }
            catch (Exception ex)
            {
                MessageBox.Show($"导出失败,请重试!错误 ({ex.Message})", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            Thread.Sleep(1000);
            MessageBox.Show($"导出完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            SetEnabled(true);
        }
示例#7
0
        public void Transfers()
        {
            foreach (var nn in DictPages.Values)
            {
                var sbXml  = new StringBuilder();
                var sbJson = new StringBuilder();
                var sbLua  = new StringBuilder();

                sbXml.Append($"<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n");
                sbXml.Append($"<{Xml_head}>\r\n");

                sbJson.Append("{\r\n");

                sbLua.Append($"{nn.Name}=\r\n{{\r\n");

                var listdataJson = new List <string>();
                var listdataLua  = new List <string>();

                foreach (var nnn in nn.ListValue)
                {
                    sbXml.Append($"\t<{Xml_node}>\r\n");

                    var listnodeJson = new List <string>();
                    var listnodeLua  = new List <string>();
                    for (int iii = 0; iii < nn.Head.Count; iii++)
                    {
                        if (nn.Head[iii] == "")
                        {
                            continue;
                        }

                        if (nn.TypeServer[iii] != "")
                        {
                            sbXml.Append($"\t\t<{nn.Head[iii]}>{nnn[iii]}</{nn.Head[iii]}>\r\n");
                        }

                        string nodeJson = "";
                        if (nn.TypeClient[iii] == "int" || nn.TypeClient[iii] == "long" || nn.TypeClient[iii] == "float" || nn.TypeClient[iii] == "double")
                        {
                            nodeJson = $"\t\t\"{nn.Head[iii]}\":{nnn[iii]}";
                        }
                        else
                        {
                            nodeJson = $"\t\t\"{nn.Head[iii]}\":\"{nnn[iii]}\"";
                        }
                        listnodeJson.Add(nodeJson);

                        string nodeLua = "";
                        if (nn.TypeClient[iii] == "int" || nn.TypeClient[iii] == "long" || nn.TypeClient[iii] == "float" || nn.TypeClient[iii] == "double")
                        {
                            nodeLua = $"{nn.Head[iii]}={nnn[iii]}";
                        }
                        else
                        {
                            nodeLua = $"{nn.Head[iii]}=\"{nnn[iii]}\"";
                        }
                        listnodeLua.Add(nodeLua);
                    }
                    string dataJson = $"\t\"{nnn[0]}\":{{\r\n{string.Join(",\r\n", listnodeJson)}\r\n\t}}";
                    listdataJson.Add(dataJson);

                    string dataLua = $"[\"{nnn[0]}\"]={{{string.Join(",", listnodeLua)},}}";
                    listdataLua.Add(dataLua);

                    sbXml.Append($"\t</{Xml_node}>\r\n");
                }

                sbXml.Append($"</{Xml_head}>\r\n");

                sbJson.Append(string.Join(",\r\n", listdataJson));
                sbJson.Append("\r\n}\r\n");

                sbLua.Append(string.Join(",\r\n", listdataLua));
                sbLua.Append("\r\n}\r\n");

                if (nn.ValidType == EValidType.公共 || nn.ValidType == EValidType.仅服务器)
                {
                    if (true)
                    {
                        string pathXml = $"{PathXml}\\{nn.Name}.xml";
                        XGlobal.DeleteFile(pathXml);
                        FileStream   fsXml = new FileStream(pathXml, FileMode.OpenOrCreate);
                        StreamWriter swXml = new StreamWriter(fsXml);
                        swXml.Write(sbXml.ToString());
                        swXml.Close();
                    }
                }
                if (nn.ValidType == EValidType.公共 || nn.ValidType == EValidType.仅客户端)
                {
                    if (true)
                    {
                        string pathJson = $"{PathJson}\\{nn.Name}.json";
                        XGlobal.DeleteFile(pathJson);
                        FileStream   fsJson = new FileStream(pathJson, FileMode.OpenOrCreate);
                        StreamWriter swJson = new StreamWriter(fsJson);
                        swJson.Write(sbJson.ToString());
                        swJson.Close();
                    }
                    if (true)
                    {
                        string pathLua = $"{PathLua}\\{nn.Name}.lua";
                        XGlobal.DeleteFile(pathLua);
                        FileStream   fsLua = new FileStream(pathLua, FileMode.OpenOrCreate);
                        StreamWriter swLua = new StreamWriter(fsLua);
                        swLua.Write(sbLua.ToString());
                        swLua.Close();
                    }
                }
            }
        }