예제 #1
0
 private void AddRuleCodeItem_Click(object commandBarControl, ref bool handled, ref bool cancelDefault)
 {
     try
     {
         SelectFileInfo selectFileInfo = this.GetSelectFileInfo();
         if (selectFileInfo == null)
         {
             return;
         }
         if (!selectFileInfo.IsExistsCodeConfig())
         {
             return;
         }
         if (!selectFileInfo.IsExistsWTFConfig())
         {
             return;
         }
         SqlRuleCodeForm sqlRuleCodeForm = new SqlRuleCodeForm(selectFileInfo);
         sqlRuleCodeForm.Show();
         handled = true;
     }
     catch (Exception ex)
     {
         MessageBox.Show("新建业务层抛出异常,异常信息:" + ex.ToString());
     }
     handled = true;
 }
예제 #2
0
 private void AddCodeConfigItem_Click(object commandBarControl, ref bool handled, ref bool cancelDefault)
 {
     try
     {
         SelectFileInfo selectFileInfo = this.GetSelectFileInfo();
         if (selectFileInfo == null)
         {
             return;
         }
         if (!selectFileInfo.IsExistsCodeConfig())
         {
             handled = true;
             return;
         }
         CodeConfigHelper codeConfigHelper = new CodeConfigHelper(selectFileInfo.CodeConfigPath);
         if (!codeConfigHelper.LoadCodeConfigXml())
         {
             return;
         }
         if (!Directory.Exists(selectFileInfo.ProjectPath + "\\DataAccess") || !Directory.Exists(selectFileInfo.ProjectPath + "\\Business") || !Directory.Exists(selectFileInfo.ProjectPath + "\\DataEntity"))
         {
             DialogResult dialogResult = MessageBox.Show("业务层不存在,要新增业务层吗?", "", MessageBoxButtons.OKCancel);
             if (dialogResult == DialogResult.OK)
             {
                 SqlRuleCodeForm sqlRuleCodeForm = new SqlRuleCodeForm(selectFileInfo);
                 sqlRuleCodeForm.Show();
             }
             handled = true;
             return;
         }
         string[] files  = Directory.GetFiles(selectFileInfo.ProjectPath + "\\DataAccess", "Da*.cs");
         string[] files2 = Directory.GetFiles(selectFileInfo.ProjectPath + "\\Business", "Biz*.cs");
         string[] files3 = Directory.GetFiles(selectFileInfo.ProjectPath + "\\DataEntity", "*.cs");
         if (files.Count <string>() <= 0 || files2.Count <string>() <= 0 || files3.Count <string>() <= 0)
         {
             DialogResult dialogResult = MessageBox.Show("业务层不存在,要新增业务层吗?", "", MessageBoxButtons.OKCancel);
             if (dialogResult == DialogResult.OK)
             {
                 SqlRuleCodeForm sqlRuleCodeForm = new SqlRuleCodeForm(selectFileInfo);
                 sqlRuleCodeForm.Show();
             }
             handled = true;
             return;
         }
         Dictionary <string, BusinessNodeInfo> dictionary = new Dictionary <string, BusinessNodeInfo>();
         List <BusinessNodeInfo> business = codeConfigHelper.GetBusiness();
         string[] array = files3;
         for (int i = 0; i < array.Length; i++)
         {
             string path = array[i];
             string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(path);
             string value  = Path.Combine(selectFileInfo.ProjectPath, "DataAccess", "Da" + fileNameWithoutExtension + ".cs");
             string value2 = Path.Combine(selectFileInfo.ProjectPath, "Business", "Biz" + fileNameWithoutExtension + ".cs");
             if (files.Contains(value) && files2.Contains(value2))
             {
                 BusinessNodeInfo objBusinessNodeInfo = CodeConfigHelper.GetReadFileBusinessNodeInfo(fileNameWithoutExtension, selectFileInfo.ProjectPath);
                 if (objBusinessNodeInfo != null)
                 {
                     BusinessNodeInfo businessNodeInfo = business.FirstOrDefault((BusinessNodeInfo s) => s.TableName == objBusinessNodeInfo.TableName);
                     if (businessNodeInfo == null)
                     {
                         dictionary.Add(objBusinessNodeInfo.TableName, objBusinessNodeInfo);
                     }
                     else
                     {
                         businessNodeInfo.ConnectionKeyOrConnectionString = objBusinessNodeInfo.ConnectionKeyOrConnectionString;
                         businessNodeInfo.LogModuleType = objBusinessNodeInfo.LogModuleType;
                         businessNodeInfo.IsMongoDB     = objBusinessNodeInfo.IsMongoDB;
                         dictionary.Add(businessNodeInfo.TableName, businessNodeInfo);
                     }
                 }
             }
         }
         AKeyAddCodeConfig aKeyAddCodeConfig = new AKeyAddCodeConfig(selectFileInfo, dictionary);
         aKeyAddCodeConfig.Show();
         handled = true;
     }
     catch (Exception ex)
     {
         MessageBox.Show("一键生成配置:" + ex.Message);
     }
     handled = true;
 }