Exemple #1
0
        public void CreateJavaResContainer(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\mapsql\" + name + "Container.java";
            string        templatePath = @".\Templates\Java\temp_java_res_container.vm";
            List <string> needReplace  = new List <string>();
            ArrayList     replace      = new ArrayList();

            needReplace.Add("PackageString");
            needReplace.Add("Name");
            needReplace.Add("TimeNow");
            replace.Add(javaDataConfig.package);
            replace.Add(name);
            replace.Add(DateTime.Now.ToString("yy-MM-dd HH:mm:ss"));
            for (int i = 0; i < data.GetLength(1); i++)
            {
                if (!string.IsNullOrEmpty(data[0, i]) && data[0, i] == "1")
                {
                    needReplace.Add("ID");
                    replace.Add(Global.FirstCharToUpper(data[1, i]));
                    break;
                }
            }

            CNVelociryHelp.CreateFileByTemplate(filePath, templatePath, needReplace, replace);
            Debug.Log(name + "Container.java文件生成完毕");
        }
Exemple #2
0
        public void InitSetting(CheckedListBox listbox, List <ExcelData> sheets)
        {
            dataList   = listbox;
            dataExcels = sheets;
            XmlDocument doc  = ConfigControl.GetXmlDocument(@".\Config\JavaDataConfig.xml");
            XmlElement  root = ConfigControl.GetXmlRootAsElement(doc, "JavaDataGenerateConfig");

            XmlElement config = root.SelectSingleNode("configs") as XmlElement;

            if (config != null)
            {
                XmlNodeList configList = config.SelectNodes("JavaDataGenerateInfo");
                if (configList.Count > 0)
                {
                    for (int i = 0; i < configList.Count; i++)
                    {
                        CJavaDataConfig dataConfig = new CJavaDataConfig();
                        dataConfig.LoadConfig((XmlElement)configList[i]);
                        dataConfigs.Add(dataConfig);
                    }
                }
            }
            int index = Convert.ToInt32(ConfigControl.GetXmlElementInnerText(root, "lastIndex"));

            currentConfig = index;
            //comboBoxConfigList.Items.Clear();
            //for (int i = 0; i < dataConfigs.Count; i++)
            //{
            //    comboBoxConfigList.Items.Add(dataConfigs[i].caption);
            //}
            comBonRefreshFlag = true;
            RefreshData();
            comboBoxConfigList.SelectedIndex = index;
        }
Exemple #3
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文件生成完毕");
        }
Exemple #4
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文件生成完毕");
        }
Exemple #5
0
        private void AddNewCapter(string name)
        {
            SetCurrentData();
            CJavaDataConfig newConfig = new CJavaDataConfig();

            newConfig.caption = name;
            dataConfigs.Add(newConfig);
            currentConfig++;
            comBonRefreshFlag = true;
            RefreshData();
            //comboBoxConfigList.SelectedIndex = currentConfig;
        }
Exemple #6
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文件生成完毕");
            }
        }
Exemple #7
0
        public void CreateJavaResDao(ExcelData excelSheetData, CJavaDataConfig javaDataConfig)
        {
            string        name         = Global.FirstCharToUpper(excelSheetData.SheetName.Replace("'", "").Replace("$", ""));
            string        filePath     = javaDataConfig.folder + @"\src\com\game\data\dao\" + name + "Dao.java";
            string        templatePath = @".\Templates\Java\temp_java_res_dao.vm";
            List <string> needReplace  = new List <string>();
            ArrayList     replace      = new ArrayList();

            needReplace.Add("PackageString");
            needReplace.Add("Name");
            needReplace.Add("TimeNow");
            needReplace.Add("BaseDao");
            replace.Add(javaDataConfig.package);
            replace.Add(name);
            replace.Add(DateTime.Now.ToString("yy-MM-dd HH:mm:ss"));
            replace.Add(javaDataConfig.baseDao);
            CNVelociryHelp.CreateFileByTemplate(filePath, templatePath, needReplace, replace);
            Debug.Log(name + "Dao.java文件生成完毕");
        }
Exemple #8
0
        public void CreateJavaResDataConfig(ExcelData excelSheetData, CJavaDataConfig javaDataConfig)
        {
            string dataConfigPath = javaDataConfig.folder + @"\src\data-config.xml";

            if (File.Exists(dataConfigPath))
            {
                XmlDocument doc            = ConfigControl.GetXmlDocument(dataConfigPath);
                XmlElement  rootElement    = ConfigControl.GetXmlRootAsElement(doc, "configuration");
                XmlElement  mappersElement = rootElement.SelectSingleNode("mappers") as XmlElement;

                if (mappersElement.ChildNodes.Count > 0)
                {
                    XmlNodeList  list  = mappersElement.ChildNodes;
                    MapperNode[] nodes = new MapperNode[list.Count / 2];
                    for (int i = 0; i < nodes.Length; i++)
                    {
                        nodes[i] = new MapperNode();
                        //nodes[i].nodeValue = list[i*2].Value;
                        XmlElement element    = (XmlElement)list[i * 2 + 1];
                        string     fullNmae   = element.GetAttribute("resource");
                        int        beginIndex = fullNmae.LastIndexOf(@"/");
                        int        endIndex   = fullNmae.LastIndexOf(".");
                        nodes[i].name = fullNmae.Substring(beginIndex + 1, endIndex - beginIndex - 1).Trim();
                        string nodeValue  = list[i * 2].Value;
                        int    startIndex = nodeValue.IndexOf(":");
                        nodes[i].time = nodeValue.Substring(startIndex + 1).Trim();
                    }
                    WriteToDataConfig(excelSheetData, dataConfigPath, javaDataConfig, nodes);
                }
                else
                {
                    WriteToDataConfig(excelSheetData, dataConfigPath, javaDataConfig, null);
                }
                Debug.Log(" data-config" + ".xml文件更新完毕");
            }
            else
            {
                WriteToDataConfig(excelSheetData, dataConfigPath, javaDataConfig, null);
                Debug.Log(" data-config" + ".xml文件生成完毕");
            }
        }
Exemple #9
0
        private void WriteToDataConfig(ExcelData excelSheetData, string dataConfigPath, CJavaDataConfig javaDataConfig, MapperNode[] mapperNodes)
        {
            string        name         = excelSheetData.SheetName.Replace("'", "").Replace("$", "");
            string        filePath     = dataConfigPath;
            string        templatePath = @".\Templates\Java\temp_java_res_dataconfig.vm";
            List <string> needReplace  = new List <string>();
            ArrayList     replace      = new ArrayList();

            needReplace.Add("SqlType");
            replace.Add(javaDataConfig.dbType);
            needReplace.Add("SqlIP");
            replace.Add(javaDataConfig.dbIp);
            needReplace.Add("SqlPort");
            replace.Add(javaDataConfig.dbport);
            needReplace.Add("DBName");
            replace.Add(javaDataConfig.dbName);
            needReplace.Add("UserName");
            replace.Add(javaDataConfig.dbUser);
            needReplace.Add("Psw");
            replace.Add(javaDataConfig.dbPsw);
            needReplace.Add("sheetList");
            List <MapperSheet> sheetList = new List <MapperSheet>();
            MapperSheet        sheet     = new MapperSheet(name, DateTime.Now.ToString("yyyy-M-d HH:mm:ss"));

            if (mapperNodes != null)
            {
                foreach (var mn in mapperNodes)
                {
                    MapperSheet ms = new MapperSheet(mn.name, mn.time);
                    sheetList.Add(ms);
                }
                bool sampFlag = false;
                for (int i = 0; i < sheetList.Count; i++)
                {
                    if (sheet.sheetName == sheetList[i].sheetName)
                    {
                        sampFlag             = true;
                        sheetList[i].nowTime = sheet.nowTime;
                        break;
                    }
                }
                if (!sampFlag)
                {
                    sheetList.Add(sheet);
                }
            }
            else
            {
                sheetList.Add(sheet);
            }

            replace.Add(sheetList);
            CNVelociryHelp.CreateFileByTemplate(filePath, templatePath, needReplace, replace);
        }