コード例 #1
0
        public void CreateJavaResMapSql(ExcelData excelSheetData, CJavaDataConfig javaDataConfig)
        {
            string[,] data = Global.GetSheetFromExcel(excelSheetData.ExcelName, excelSheetData.SheetName);
            string        name         = excelSheetData.SheetName.Replace("'", "").Replace("$", "");
            string        filePath     = javaDataConfig.folder + @"\src\com\game\data\sqlmap\" + name + ".xml";
            string        templatePath = @".\Templates\Java\temp_java_res_sqlmap.vm";
            List <string> needReplace  = new List <string>();
            ArrayList     replace      = new ArrayList();

            needReplace.Add("Name");
            replace.Add(name);
            if (data.GetLength(1) > 0)
            {
                needReplace.Add("fieldList");
                List <BeanVar> beanVars = new List <BeanVar>();
                for (int i = 0; i < data.GetLength(1); i++)
                {
                    BeanVar bean = new BeanVar();
                    bean.name      = data[1, i];
                    bean.className = data[2, i];
                    beanVars.Add(bean);
                }
                replace.Add(beanVars);
            }

            CNVelociryHelp.CreateFileByTemplate(filePath, templatePath, needReplace, replace);
            Debug.Log(name + ".xml文件生成完毕");
        }
コード例 #2
0
        public void CreateJavaResBean(ExcelData excelSheetData, CJavaDataConfig javaDataConfig)
        {
            string[,] data = Global.GetSheetFromExcel(excelSheetData.ExcelName, excelSheetData.SheetName);
            string        name         = Global.FirstCharToUpper(excelSheetData.SheetName.Replace("'", "").Replace("$", ""));
            string        filePath     = javaDataConfig.folder + @"\src\com\game\data\bean\" + name + "Bean.java";
            string        templatePath = @".\Templates\Java\temp_java_res_bean.vm";
            List <string> needReplace  = new List <string>();
            ArrayList     replace      = new ArrayList();

            needReplace.Add("PackageString");
            needReplace.Add("BeanName");

            replace.Add(javaDataConfig.package);
            replace.Add(name);
            if (data.GetLength(1) > 0)
            {
                needReplace.Add("fieldList");
                List <BeanVar> beanList = new List <BeanVar>();
                for (int i = 0; i < data.GetLength(1); i++)
                {
                    BeanVar beanVar = new BeanVar();
                    beanVar.name      = data[1, i];
                    beanVar.className = data[2, i];
                    beanVar.explain   = data[4, i];
                    beanList.Add(beanVar);
                }
                replace.Add(beanList);
            }
            CNVelociryHelp.CreateFileByTemplate(filePath, templatePath, needReplace, replace);
            Debug.Log(name + "Bean.java文件生成完毕");
        }
コード例 #3
0
        /// <summary>
        /// 生成CS表格资源
        /// </summary>
        /// <param name="checkedListBox1"></param>
        /// <param name="excelDatas"></param>
        /// <param name="label1"></param>
        public void CreateCsResBean(ExcelData sheet, CAsDataConfig dataConfig, bool isSet = true)
        {
            string[,] data = Global.GetSheetFromExcel(sheet.ExcelName, sheet.SheetName);
            string        name         = Global.FirstCharToUpper(sheet.SheetName.Replace("'", "").Replace("$", ""));
            string        filePath     = dataConfig.folder + @"\" + name + ".cs";
            string        templatePath = @".\Templates\CS\temp_cs_res_bean.vm";
            List <string> needReplace  = new List <string>();
            ArrayList     replace      = new ArrayList();

            needReplace.Add("DateTime");
            replace.Add(DateTime.Now.ToString("yyyy-M-d HH:mm:ss"));
            needReplace.Add("PackageString");
            replace.Add(dataConfig.package);
            needReplace.Add("BeanName");
            replace.Add(name);
            List <string> import = new List <string>();

            if (dataConfig.beanImport != null && dataConfig.beanImport.Length > 0)
            {
                needReplace.Add("importList");
                foreach (var bean in dataConfig.beanImport)
                {
                    import.Add(bean);
                }
                replace.Add(import);
            }
            needReplace.Add("fieldList");
            List <BeanVar> fieldList = new List <BeanVar>();

            for (int i = 0; i < data.GetLength(1); i++)
            {
                if (!string.IsNullOrWhiteSpace(data[1, i]) && !data[0, i].Contains("备注") && !data[1, i].Contains("备注") && !data[2, i].Contains("备注") && !data[3, i].Contains("备注") && !data[4, i].Contains("备注"))
                {
                    BeanVar field = new BeanVar();
                    field.name      = data[1, i];
                    field.className = data[2, i];
                    field.explain   = data[4, i].Replace("\n", "").Replace("\r", "");
                    fieldList.Add(field);
                }
            }
            replace.Add(fieldList);
            if (isSet)
            {
                needReplace.Add("getFieldList");
                replace.Add(fieldList);
            }
            if (File.Exists(templatePath))
            {
                CNVelociryHelp.CreateFileByTemplate(filePath, templatePath, needReplace, replace);
                Debug.Log(name + ".cs文件生成完毕");
            }
            else
            {
                Debug.Log("模板文件不存在请检查." + templatePath);
            }
        }
コード例 #4
0
 private void CreateJavaMsMessage(CMessages messages, string path)
 {
     foreach (var cMes in messages.messages)
     {
         string        msgMane      = cMes.name + "Message";
         string        filePath     = path + @"\message\" + msgMane + ".java";
         string        templatePath = @".\Templates\Java\temp_java_message_message.vm";
         List <string> needReplace  = new List <string>();
         ArrayList     replace      = new ArrayList();
         needReplace.Add("PackageString");
         replace.Add(messages.import);
         needReplace.Add("BeanSuper");
         replace.Add(messages.beanSuper);
         needReplace.Add("MessageName");
         replace.Add(msgMane);
         needReplace.Add("Explain");
         replace.Add(cMes.explain);
         if (cMes.fields != null && cMes.fields.Length > 0)
         {
             needReplace.Add("fieldList");
             List <BeanVar> beanList = new List <BeanVar>();
             foreach (var cField in cMes.fields)
             {
                 BeanVar bean = new BeanVar();
                 bean.name      = cField.name;
                 bean.className = cField.fieldType;
                 bean.explain   = cField.explain;
                 beanList.Add(bean);
             }
             replace.Add(beanList);
         }
         if (cMes.lists != null && cMes.lists.Length > 0)
         {
             needReplace.Add("beanList");
             List <BeanVar> beanList = new List <BeanVar>();
             foreach (var cList in cMes.lists)
             {
                 BeanVar bean = new BeanVar();
                 bean.name      = cList.name;
                 bean.className = cList.listType;
                 bean.explain   = cList.explain;
                 beanList.Add(bean);
             }
             replace.Add(beanList);
         }
         CNVelociryHelp.CreateFileByTemplate(filePath, templatePath, needReplace, replace);
         Debug.Log(msgMane + ".java文件生成完毕");
     }
 }
コード例 #5
0
ファイル: CAsHandleFuns.cs プロジェクト: wxyusk/GameTool
        public void CreateAsResBean(ExcelData sheet, CAsDataConfig dataConfig, bool isSet = true)
        {
            string[,] data = Global.GetSheetFromExcel(sheet.ExcelName, sheet.SheetName);
            string        name         = Global.FirstCharToUpper(sheet.SheetName.Replace("'", "").Replace("$", ""));
            string        filePath     = dataConfig.folder + @"\com\game\data\bean\" + name + ".as";
            string        templatePath = @".\Templates\AS\temp_as_res_bean.vm";
            List <string> needReplace  = new List <string>();
            ArrayList     replace      = new ArrayList();

            needReplace.Add("PackageString");
            needReplace.Add("importList");
            needReplace.Add("BeanName");
            needReplace.Add("fieldList");
            replace.Add(dataConfig.package);
            List <string> import = new List <string>();

            if (dataConfig.beanImport.Length > 0)
            {
                foreach (var bean in dataConfig.beanImport)
                {
                    import.Add(bean);
                }
            }
            replace.Add(import);
            replace.Add(name);
            List <BeanVar> fieldList = new List <BeanVar>();

            for (int i = 0; i < data.GetLength(1); i++)
            {
                if (!string.IsNullOrWhiteSpace(data[1, i]))
                {
                    BeanVar field = new BeanVar();
                    field.name      = data[1, i];
                    field.className = data[2, i];
                    field.explain   = data[4, i];
                    fieldList.Add(field);
                }
            }
            replace.Add(fieldList);
            if (isSet)
            {
                needReplace.Add("getFieldList");
                replace.Add(fieldList);
            }
            CNVelociryHelp.CreateFileByTemplate(filePath, templatePath, needReplace, replace);
            Debug.Log(name + ".as文件生成完毕");
        }
コード例 #6
0
ファイル: CAsHandleFuns.cs プロジェクト: wxyusk/GameTool
        private static void CreateAsMessages(CMessages msg, string path)
        {
            foreach (var message in msg.messages)
            {
                FileStream fs = new FileStream(path + @"\" + message.name + "Message.as",
                                               FileMode.Create, FileAccess.Write);
                StreamWriter    sw     = new StreamWriter(fs);
                Template        temp   = CNVelociryHelp.GetTemplate(@".\Templates\AS\" + Global.AsMessageTemplatePath.Substring(Global.AsMessageTemplatePath.LastIndexOf(@"\")));
                VelocityContext vltCtx = new VelocityContext();
                vltCtx.Put("PackageString", msg.import);
                vltCtx.Put("Explain", message.explain);
                vltCtx.Put("MessageName", message.name + "Message");
                vltCtx.Put("MessageID", msg.ID + message.ID);
                if (message.fields != null && message.fields.Length > 0)
                {
                    List <BeanVar> beanVarList = new List <BeanVar>();
                    //List<CField> beanWriteList = new List<CField>();
                    foreach (var field in message.fields)
                    {
                        BeanVar var = new BeanVar(field);
                        beanVarList.Add(var);
                    }
                    vltCtx.Put("fildList", beanVarList);
                }
                if (message.lists != null && message.lists.Length > 0)
                {
                    List <BeanVar> beanVarList = new List <BeanVar>();
                    foreach (var list in message.lists)
                    {
                        BeanVar var = new BeanVar(list);
                        beanVarList.Add(var);
                    }
                    vltCtx.Put("vectorList", beanVarList);
                }

                System.IO.StringWriter vltWriter = new System.IO.StringWriter();
                temp.Merge(vltCtx, vltWriter);

                Console.WriteLine(vltWriter.ToString());

                sw.Write(vltWriter.ToString());
                sw.Close();
                fs.Close();
                Debug.Log(message.name + "Message.as生成成功");
            }
        }
コード例 #7
0
        private void WriteToDataManager(string sheetDataName, string dataManagerPath, string packageString, List <BeanVar> sheetNameList)
        {
            string        name         = sheetDataName.Replace("'", "").Replace("$", "");
            string        filePath     = dataManagerPath;
            string        templatePath = @".\Templates\Java\temp_java_res_datamanager.vm";
            List <string> needReplace  = new List <string>();
            ArrayList     replace      = new ArrayList();

            needReplace.Add("PackageString");
            replace.Add(packageString);
            needReplace.Add("TimeNow");
            replace.Add(DateTime.Now.ToString("yyyy-M-d HH:mm:ss"));
            needReplace.Add("containerList");
            BeanVar beanVar = new BeanVar();

            beanVar.name = name;
            List <BeanVar> beanVarLiseList = new List <BeanVar>();

            if (sheetNameList != null)
            {
                foreach (var sheetName in sheetNameList)
                {
                    beanVarLiseList.Add(sheetName);
                }
                bool sampFlag = false;
                for (int i = 0; i < sheetNameList.Count; i++)
                {
                    if (beanVar.UpperName == sheetNameList[i].UpperName)
                    {
                        sampFlag = true;
                        break;
                    }
                }
                if (!sampFlag)
                {
                    beanVarLiseList.Add(beanVar);
                }
            }
            else
            {
                beanVarLiseList.Add(beanVar);
            }
            replace.Add(beanVarLiseList);
            CNVelociryHelp.CreateFileByTemplate(filePath, templatePath, needReplace, replace);
        }
コード例 #8
0
        public void CreateJavaResDataManager(ExcelData excelSheetData, CJavaDataConfig javaDataConfig)
        {
            string datamMnagerPath = javaDataConfig.folder + @"\src\com\game\data\manager\DataManager.java";

            if (File.Exists(datamMnagerPath))
            {
                FileStream   stream  = new FileStream(datamMnagerPath, FileMode.Open, FileAccess.Read);
                StreamReader reader  = new StreamReader(stream);
                string       content = reader.ReadToEnd();
                reader.Close();
                stream.Close();
                string[]       contectArray = content.Split('\n');
                List <string>  contentList  = new List <string>();
                List <BeanVar> beaneList    = new List <BeanVar>();
                foreach (var con in contectArray)
                {
                    if (con.Contains("import"))
                    {
                        string  temp       = con.Replace("\r", "").Trim();
                        int     beginIndex = temp.LastIndexOf(".");
                        int     endIndex   = temp.IndexOf("Container");
                        string  subStr     = temp.Substring(beginIndex + 1, endIndex - beginIndex - 1);
                        BeanVar bean       = new BeanVar();
                        bean.UpperName = subStr;
                        bean.name      = Global.FirstCharToLower(subStr);
                        beaneList.Add(bean);
                    }
                }
                if (beaneList.Count > 0)
                {
                    WriteToDataManager(excelSheetData.SheetName, datamMnagerPath, javaDataConfig.package, beaneList);
                }
                else
                {
                    WriteToDataManager(excelSheetData.SheetName, datamMnagerPath, javaDataConfig.package, null);
                }
                Debug.Log("DataManager.java文件更新完毕");
            }
            else
            {
                WriteToDataManager(excelSheetData.SheetName, datamMnagerPath, javaDataConfig.package, null);
                Debug.Log("DataManager.java文件生成完毕");
            }
        }