Exemplo n.º 1
0
        void tsmiTemplate_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem tsmiTemplate = sender as ToolStripMenuItem;

            if (tsmiTemplate != null)
            {
                TemplateParas templateParas = tsmiTemplate.Tag as TemplateParas;
                if (templateParas != null)
                {
                    if (templateParas.DataTye == "DB")
                    {
                        var drTable =
                            getObject(PluginShareHelper.DBPluginKey, PluginShareHelper.DBPlugin_DBCurrentCheckTable) as
                            DataRow[];

                        ThreadPool.QueueUserWorkItem(o =>
                        {
                            var gen           = new GenTemplate();
                            gen.TemplateParas = templateParas;
                            process(drTable, gen);
                        });
                    }
                    else if (templateParas.DataTye == "Fix")
                    {
                        var os =
                            getObject(MDT.Tools.Fix.Common.Utils.PluginShareHelper.FixPluginKey, MDT.Tools.Fix.Common.Utils.PluginShareHelper.FixCurrentCheck) as
                            object[];
                        var fieldDics =
                            getObject(MDT.Tools.Fix.Common.Utils.PluginShareHelper.FixPluginKey, MDT.Tools.Fix.Common.Utils.PluginShareHelper.FixFieldDic) as
                            List <Fix.Common.Model.FieldDic>;

                        ThreadPool.QueueUserWorkItem(o =>
                        {
                            var gen           = new GenTemplate();
                            gen.TemplateParas = templateParas;
                            gen.FieldDics     = fieldDics;
                            getDBShare(gen);
                            gen.process(os);
                        });
                    }
                }
            }
        }
Exemplo n.º 2
0
        public static TemplateConfig ReadTemplateConfig()
        {
            TemplateConfig templateConfig = new TemplateConfig();

            try
            {
                StringBuilder sb = new StringBuilder(255);
                GetPrivateProfileString(Group1, TemplateNum, "", sb, sb.Capacity, FilePathHelper.SystemConfig);
                int templateNum = 0;
                if (int.TryParse(sb.ToString(), out templateNum))
                {
                    templateConfig.TemplateNum = templateNum;
                }
                for (int i = 1; i <= templateConfig.TemplateNum; i++)
                {
                    TemplateParas templateParas = new TemplateParas();
                    templateConfig.TemplateParas.Add(templateParas);
                    templateParas.MenuName = ReadIniCN(Group2, MenuName + i, FilePathHelper.SystemConfig);

                    GetPrivateProfileString(Group2, DataTye + i, "", sb, sb.Capacity, FilePathHelper.SystemConfig);
                    templateParas.DataTye = sb.ToString();

                    GetPrivateProfileString(Group2, TemplateName + i, "", sb, sb.Capacity, FilePathHelper.SystemConfig);
                    templateParas.TemplateName = sb.ToString();



                    GetPrivateProfileString(Group2, SaveFileEncoding + i, "", sb, sb.Capacity, FilePathHelper.SystemConfig);
                    templateParas.SaveFileEncoding = sb.ToString();



                    GetPrivateProfileString(Group2, Language + i, "", sb, sb.Capacity, FilePathHelper.SystemConfig);
                    templateParas.Language = sb.ToString();



                    templateParas.SaveFilePath = ReadIniCN(Group2, SaveFilePath, FilePathHelper.SystemConfig);
                    if (string.IsNullOrEmpty(templateParas.SaveFilePath))
                    {
                        templateParas.SaveFilePath = FilePathHelper.ExportTemplatePath;
                    }
                    GetPrivateProfileString(Group2, SaveFileName + i, "", sb, sb.Capacity, FilePathHelper.SystemConfig);
                    templateParas.SaveFileName = sb.ToString();


                    GetPrivateProfileString(Group2, IsAutoGenSaveFileName + i, "", sb, sb.Capacity, FilePathHelper.SystemConfig);

                    bool isAutoGenSaveFileName = true;
                    if (bool.TryParse(sb.ToString(), out isAutoGenSaveFileName))
                    {
                        templateParas.IsAutoGenSaveFileName = isAutoGenSaveFileName;
                    }



                    GetPrivateProfileString(Group2, IsShowGenCode + i, "", sb, sb.Capacity, FilePathHelper.SystemConfig);

                    bool isShowGenCode = true;
                    if (bool.TryParse(sb.ToString(), out isShowGenCode))
                    {
                        templateParas.IsShowGenCode = isShowGenCode;
                    }
                    GetPrivateProfileString(Group2, CodeLanguage + i, "", sb, sb.Capacity, FilePathHelper.SystemConfig);
                    templateParas.CodeLanguage = sb.ToString();

                    GetPrivateProfileString(Group2, MenuVisable + i, "", sb, sb.Capacity, FilePathHelper.SystemConfig);

                    bool isMenuVisable = true;
                    if (!bool.TryParse(sb.ToString(), out isMenuVisable))
                    {
                        isMenuVisable = true;
                    }
                    templateParas.IsMenuVisable = isMenuVisable;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return(templateConfig);
        }