Exemple #1
0
 private void ConnectItem_Click(object commandBarControl, ref bool handled, ref bool cancelDefault)
 {
     try
     {
         SelectFileInfo selectFileInfo = this.GetSelectFileInfo();
         if (selectFileInfo != null)
         {
             ConnectConfigFrom connectConfigFrom = new ConnectConfigFrom(selectFileInfo);
             connectConfigFrom.Show();
             handled = true;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("配置链接串" + ex.Message);
     }
 }
Exemple #2
0
        public bool IsExistsCodeConfig()
        {
            bool result;

            if (!File.Exists(this.CodeConfigPath))
            {
                DialogResult dialogResult = MessageBox.Show("CodeConfig.xml不存在,请先配置连接,是否马上配置?", "", MessageBoxButtons.OKCancel);
                if (dialogResult == DialogResult.OK)
                {
                    ConnectConfigFrom connectConfigFrom = new ConnectConfigFrom(this);
                    connectConfigFrom.Show();
                }
                result = false;
            }
            else
            {
                result = true;
            }
            return(result);
        }
Exemple #3
0
        public TableRuleSchema CreateItemTableRuleSchema(SelectFileInfo objSelectFileInfo)
        {
            TableRuleSchema result;

            if (!objSelectFileInfo.IsExistsCodeConfig())
            {
                result = null;
            }
            else
            {
                string itemPathEntityName = objSelectFileInfo.GetItemPathEntityName();
                if (string.IsNullOrWhiteSpace(itemPathEntityName))
                {
                    MessageBox.Show(objSelectFileInfo.ItemFileName + ".cs,不是基础业务层类,因此无法更新或新增");
                    result = null;
                }
                else
                {
                    CodeConfigHelper codeConfigHelper = new CodeConfigHelper(objSelectFileInfo.CodeConfigPath);
                    if (!codeConfigHelper.LoadCodeConfigXml())
                    {
                        result = null;
                    }
                    else
                    {
                        BusinessNodeInfo business = codeConfigHelper.GetBusiness(itemPathEntityName);
                        if (business == null)
                        {
                            if (MessageBox.Show(itemPathEntityName + "实体未配置业务XML?是否配置吗?", "", MessageBoxButtons.OKCancel) != DialogResult.OK)
                            {
                                result = null;
                            }
                            else
                            {
                                Dictionary <string, BusinessNodeInfo> dictionary = new Dictionary <string, BusinessNodeInfo>();
                                BusinessNodeInfo readFileBusinessNodeInfo        = CodeConfigHelper.GetReadFileBusinessNodeInfo(itemPathEntityName, objSelectFileInfo.ProjectPath);
                                if (readFileBusinessNodeInfo == null)
                                {
                                    MessageBox.Show(objSelectFileInfo.ItemFileName + ".cs,不是基础业务层类,因此无法配置XML");
                                    result = null;
                                }
                                else
                                {
                                    dictionary.Add(readFileBusinessNodeInfo.TableName, readFileBusinessNodeInfo);
                                    AKeyAddCodeConfig aKeyAddCodeConfig = new AKeyAddCodeConfig(objSelectFileInfo, dictionary);
                                    aKeyAddCodeConfig.Show();
                                    result = null;
                                }
                            }
                        }
                        else
                        {
                            string schemaName       = "";
                            string connectionString = codeConfigHelper.GetConnectionString(business.ConnectionKey, out schemaName);
                            if (string.IsNullOrWhiteSpace(connectionString))
                            {
                                if (MessageBox.Show("连接串键值(" + business.ConnectionKey + ")不存在,要配置连接吗?", "", MessageBoxButtons.OKCancel) == DialogResult.OK)
                                {
                                    ConnectConfigFrom connectConfigFrom = new ConnectConfigFrom(objSelectFileInfo);
                                    connectConfigFrom.Show();
                                }
                                result = null;
                            }
                            else
                            {
                                string tableName = business.TableName;
                                try
                                {
                                    TableRuleSchema tableRuleSchema = SqlSchemaHelper.GetAllRuleTables(schemaName, connectionString, true).FirstOrDefault((TableRuleSchema s) => s.TableName == tableName);
                                    if (tableRuleSchema == null)
                                    {
                                        MessageBox.Show("数据库找不到此:" + tableName + ",请检查配置是否正确");
                                        result = null;
                                    }
                                    else
                                    {
                                        CodeConfigHelper.BusinessNodeToTableRuleSchema(business, tableRuleSchema);
                                        tableRuleSchema.Columns = SqlSchemaHelper.GetTableRuleColumnsSchema(connectionString, schemaName, tableRuleSchema.TableName, codeConfigHelper);
                                        result = tableRuleSchema;
                                    }
                                }
                                catch (Exception ex)
                                {
                                    MessageBox.Show("更新代码出现异常,异常错误:" + ex.ToString());
                                    result = null;
                                }
                            }
                        }
                    }
                }
            }
            return(result);
        }