コード例 #1
0
 public DomainServiceCodeBuilder(EntityCodeBuilder entityCodeBuilder,
                                 DomainServiceInterfaceCodeBuilder domainServiceInterfaceCodeBuilder,
                                 string functionName)
     : base(entityCodeBuilder, functionName)
 {
     DomainServiceInterfaceCodeBuilder = domainServiceInterfaceCodeBuilder;
 }
コード例 #2
0
 public AppServiceCodeBuilder(EntityCodeBuilder entityCodeBuilder,
                              InputDtoCodeBuilder inputDtoCodeBuilder,
                              OutputDtoCodeBuilder outputDtoCodeBuilder,
                              DomainServiceInterfaceCodeBuilder domainServiceInterfaceCodeBuilder,
                              AppServiceInterfaceCodeBuilder appServiceInterfaceCodeBuilder,
                              PermissionCodeBuilder permissionCodeBuilder,
                              string className, string functionName)
     : base(entityCodeBuilder, inputDtoCodeBuilder, outputDtoCodeBuilder,
            domainServiceInterfaceCodeBuilder, className, functionName)
 {
     AppServiceInterfaceCodeBuilder = appServiceInterfaceCodeBuilder;
     PermissionCodeBuilder          = permissionCodeBuilder;
 }
コード例 #3
0
        private void btnCodeCreate_Click(object sender, EventArgs e)
        {
            List <Field> fields_Property = new List <Field>();

            foreach (DataGridViewRow row in gvFields.Rows)
            {
                Field f = new Field();
                f.Name       = row.Cells[1].Value.ToString();
                f.Type       = row.Cells[2].Value.ToString();
                f.Length     = Convert.ToInt16(row.Cells[3].Value is null ? 0 : row.Cells[3].Value);
                f.Scale      = Convert.ToByte(row.Cells[4].Value is null ? 0 : row.Cells[4].Value);
                f.IsIdentity = Convert.ToBoolean(row.Cells[5].Value is null ? false : row.Cells[5].Value);
                f.Nullable   = Convert.ToBoolean(row.Cells[6].Value is null ? true : row.Cells[6].Value);
                f.Comments   = row.Cells[7].Value is null ? "" : row.Cells[7].Value.ToString();
                f.IsPk       = Convert.ToBoolean(row.Cells[8].Value is null ? false : row.Cells[8].Value);
                f.Property   = row.Cells[9].Value is null?CultureInfo.CurrentCulture.TextInfo.ToTitleCase(f.Name.ToLower()) : row.Cells[9].Value.ToString();

                fields_Property.Add(f);
            }

            EntityCodeBuilder entityCodeBuilder = new EntityCodeBuilder();

            entityCodeBuilder.DbType        = _DbType;
            entityCodeBuilder.Fields        = fields_Property;
            entityCodeBuilder.ModuleName    = tbModuleName.Text;
            entityCodeBuilder.SubModuleName = tbSubModuleName.Text;
            entityCodeBuilder.FileName      = tbFileName.Text;
            entityCodeBuilder.ClassName     = tbClass.Text;
            entityCodeBuilder.ClassComments = tbClassDesc.Text;
            entityCodeBuilder.BaseClass     = cbBaseClass.Text;
            entityCodeBuilder.PkType        = cbPkType.Text;

            if (rbNone.Checked)
            {
                entityCodeBuilder.TenantInterface = "";
            }
            if (rbIMayHaveTenant.Checked)
            {
                entityCodeBuilder.TenantInterface = "IMayHaveTenant";
            }
            if (rbIMustHaveTenant.Checked)
            {
                entityCodeBuilder.TenantInterface = "IMustHaveTenant";
            }

            entityCodeBuilder.CreateCode();
        }
コード例 #4
0
 public OutputDtoCodeBuilder(EntityCodeBuilder entityCodeBuilder, string className, string functionName)
     : base(entityCodeBuilder, className, functionName)
 {
 }
コード例 #5
0
        private void btnCodeCreate_Click(object sender, EventArgs e)
        {
            List <Field> fields_Property = new List <Field>();

            foreach (DataGridViewRow row in gvFields.Rows)
            {
                Field f = new Field();
                f.Name       = row.Cells["NAME"].Value.ToString();
                f.Type       = row.Cells["TYPE"].Value.ToString();
                f.Length     = Convert.ToInt16(row.Cells["LENGTH"].Value is null ? 0 : row.Cells["LENGTH"].Value);
                f.Scale      = Convert.ToByte(row.Cells["SCALE"].Value is null ? 0 : row.Cells["SCALE"].Value);
                f.IsIdentity = Convert.ToBoolean(row.Cells["IsIdentity"].Value is null ? false : row.Cells["IsIdentity"].Value);
                f.Nullable   = Convert.ToBoolean(row.Cells["Nullable"].Value is null ? true : row.Cells["Nullable"].Value);
                f.Comments   = row.Cells["comments"].Value is null ? "" : row.Cells["comments"].Value.ToString();
                f.IsPk       = Convert.ToBoolean(row.Cells["IsPk"].Value is null ? false : row.Cells["IsPk"].Value);
                f.Property   = row.Cells["Property"].Value is null?CultureInfo.CurrentCulture.TextInfo.ToTitleCase(f.Name.ToLower()) : row.Cells["Property"].Value.ToString();

                f.HasInputDto   = Convert.ToBoolean(row.Cells["HasInputDto"].Value is null ? false : row.Cells["HasInputDto"].Value);
                f.HasOutputDto  = Convert.ToBoolean(row.Cells["HasOutputDto"].Value is null ? false : row.Cells["HasOutputDto"].Value);
                f.TableColWidth = Convert.ToInt32(row.Cells["TableColWidth"].Value is null ? 0 : row.Cells["TableColWidth"].Value);
                f.IsEdit        = Convert.ToBoolean(row.Cells["IsEdit"].Value is null ? false : row.Cells["IsEdit"].Value);

                fields_Property.Add(f);
            }

            EntityCodeBuilder entityCodeBuilder = new EntityCodeBuilder();

            entityCodeBuilder.RootCodePath    = tbCodeRootPath.Text;
            entityCodeBuilder.TableName       = cbTableName.Text;
            entityCodeBuilder.DbType          = _DbType;
            entityCodeBuilder.Fields          = fields_Property;
            entityCodeBuilder.ModuleName      = tbModuleName.Text;
            entityCodeBuilder.SubModuleName   = tbSubModuleName.Text;
            entityCodeBuilder.FileName        = tbFileName.Text;
            entityCodeBuilder.ClassName       = tbClass.Text;
            entityCodeBuilder.ClassPluralName = System.Data.Entity.Design.PluralizationServices.PluralizationService.CreateService(new CultureInfo("en")).Pluralize(tbClass.Text);
            entityCodeBuilder.ClassComments   = tbClassDesc.Text;
            entityCodeBuilder.BaseClass       = cbBaseClass.Text;
            entityCodeBuilder.PkType          = cbPkType.Text;

            if (rbNone.Checked)
            {
                entityCodeBuilder.TenantInterface = "";
            }
            if (rbIMayHaveTenant.Checked)
            {
                entityCodeBuilder.TenantInterface = "IMayHaveTenant";
            }
            if (rbIMustHaveTenant.Checked)
            {
                entityCodeBuilder.TenantInterface = "IMustHaveTenant";
            }

            EntityConfigurationCodeBuilder entityConfigurationCodeBuilder = new EntityConfigurationCodeBuilder(entityCodeBuilder);

            entityConfigurationCodeBuilder.RootCodePath  = tbCodeRootPath.Text;
            entityConfigurationCodeBuilder.ClassComments = tbComment.Text + "基于数据库—" + _DbType.ToString() + "的映射";

            entityCodeBuilder.CreateCode();
            entityConfigurationCodeBuilder.CreateCode();

            //UbpDbContext
            UbpDbContextCodeBuilder ubpDbContextCodeBuilder = new UbpDbContextCodeBuilder(entityCodeBuilder, tbModuleName.Text);

            ubpDbContextCodeBuilder.RootCodePath  = tbCodeRootPath.Text;
            ubpDbContextCodeBuilder.ClassComments = tbModuleName.Text + "的DbContext";
            ubpDbContextCodeBuilder.CreateCode();

            //Domain.Service.Interface
            DomainServiceInterfaceCodeBuilder domainServiceInterfaceCodeBuilder = new DomainServiceInterfaceCodeBuilder(entityCodeBuilder, tbFunName.Text);

            domainServiceInterfaceCodeBuilder.RootCodePath            = tbCodeRootPath.Text;
            domainServiceInterfaceCodeBuilder.ClassName               = domainServiceInterfaceCodeBuilder.FileName = "I" + tbDomainServiceClassName.Text;
            domainServiceInterfaceCodeBuilder.ClassComments           = tbComment.Text + "的Domain.Service.Interface";
            domainServiceInterfaceCodeBuilder.Has_Method_GetAllAsync  = cbGetAllAsync.Checked;
            domainServiceInterfaceCodeBuilder.Has_Method_GetByIdAsync = cbGetByIdAsync.Checked;
            domainServiceInterfaceCodeBuilder.Has_Method_CreateAsync  = cbCreateAsync.Checked;
            domainServiceInterfaceCodeBuilder.Has_Method_UpdateAsync  = cbUpdateAsync.Checked;
            domainServiceInterfaceCodeBuilder.Has_Method_DeleteAsync  = cbDeleteAsync.Checked;
            domainServiceInterfaceCodeBuilder.CreateCode();

            //Domain.Service
            DomainServiceCodeBuilder domainServiceCodeBuilder = new DomainServiceCodeBuilder(entityCodeBuilder,
                                                                                             domainServiceInterfaceCodeBuilder, tbFunName.Text);

            domainServiceCodeBuilder.RootCodePath  = tbCodeRootPath.Text;
            domainServiceCodeBuilder.ClassName     = domainServiceCodeBuilder.FileName = tbDomainServiceClassName.Text;
            domainServiceCodeBuilder.ClassComments = tbComment.Text + "的Domain.Service";
            domainServiceCodeBuilder.CreateCode();

            //InputDto
            InputDtoCodeBuilder inputDtoCodeBuilder = new InputDtoCodeBuilder(entityCodeBuilder, tbInputDtoClassName.Text, tbFunName.Text);

            inputDtoCodeBuilder.RootCodePath  = tbCodeRootPath.Text;
            inputDtoCodeBuilder.ClassComments = tbComment.Text + "的InputDto";
            inputDtoCodeBuilder.CreateCode();

            //OutputDto
            OutputDtoCodeBuilder outputDtoCodeBuilder = new OutputDtoCodeBuilder(entityCodeBuilder, tbOutputDtoClassName.Text, tbFunName.Text);

            outputDtoCodeBuilder.RootCodePath  = tbCodeRootPath.Text;
            outputDtoCodeBuilder.ClassComments = tbComment.Text + "的OutputDto";
            outputDtoCodeBuilder.CreateCode();

            //Permission
            PermissionCodeBuilder permissionCodeBuilder = new PermissionCodeBuilder(tbModuleName.Text);

            permissionCodeBuilder.RootCodePath    = tbCodeRootPath.Text;
            permissionCodeBuilder.ClassComments   = tbModuleName.Text + "的Permission定义";
            permissionCodeBuilder.MenuPermValue   = tbMenuPerm.Text;
            permissionCodeBuilder.PermCreateValue = tbPermCreate.Text;
            permissionCodeBuilder.PermEditValue   = tbPermEdit.Text;
            permissionCodeBuilder.PermDeleteValue = tbPermDelete.Text;
            permissionCodeBuilder.CreateCode();


            //Application.Service.Interface
            AppServiceInterfaceCodeBuilder appServiceInterfaceCodeBuilder = new AppServiceInterfaceCodeBuilder(entityCodeBuilder,
                                                                                                               inputDtoCodeBuilder, outputDtoCodeBuilder,
                                                                                                               domainServiceInterfaceCodeBuilder, "I" + tbAppServiceClassName.Text,
                                                                                                               tbFunName.Text);

            appServiceInterfaceCodeBuilder.RootCodePath  = tbCodeRootPath.Text;
            appServiceInterfaceCodeBuilder.ClassComments = tbComment.Text + "的Application.Service.Interface";
            appServiceInterfaceCodeBuilder.CreateCode();

            //Application.Service
            AppServiceCodeBuilder appServiceCodeBuilder = new AppServiceCodeBuilder(entityCodeBuilder,
                                                                                    inputDtoCodeBuilder, outputDtoCodeBuilder, domainServiceInterfaceCodeBuilder, appServiceInterfaceCodeBuilder,
                                                                                    permissionCodeBuilder, tbAppServiceClassName.Text, tbFunName.Text);

            appServiceCodeBuilder.RootCodePath  = tbCodeRootPath.Text;
            appServiceCodeBuilder.ClassComments = tbComment.Text + "的Application.Service";
            appServiceCodeBuilder.CreateCode();

            //Controller
            ControllerCodeBuilder controllerCodeBuilder = new ControllerCodeBuilder(inputDtoCodeBuilder, outputDtoCodeBuilder,
                                                                                    appServiceInterfaceCodeBuilder, permissionCodeBuilder, tbControllerName.Text, tbModuleName.Text);

            controllerCodeBuilder.RootCodePath  = tbCodeRootPath.Text;
            controllerCodeBuilder.ClassComments = tbComment.Text + "的Controller";
            controllerCodeBuilder.CreateCode();

            //Index.cshtml
            IndexCshtmlCodeBuilder indexCshtmlCodeBuilder = new IndexCshtmlCodeBuilder(permissionCodeBuilder,
                                                                                       controllerCodeBuilder, tbModuleName.Text);

            indexCshtmlCodeBuilder.RootCodePath = tbCodeRootPath.Text;
            indexCshtmlCodeBuilder.CreateCode();

            //Index.js
            IndexJsCodeBuilder indexJsCodeBuilder = new IndexJsCodeBuilder(permissionCodeBuilder,
                                                                           controllerCodeBuilder, tbModuleName.Text);

            indexJsCodeBuilder.RootCodePath = tbCodeRootPath.Text;
            indexJsCodeBuilder.CreateCode();

            //_CreateOrEditModal.cshtml
            EditModalCshtmlCodeBuilder editModalCshtmlCodeBuilder = new EditModalCshtmlCodeBuilder(permissionCodeBuilder,
                                                                                                   controllerCodeBuilder, tbModuleName.Text);

            editModalCshtmlCodeBuilder.RootCodePath = tbCodeRootPath.Text;
            editModalCshtmlCodeBuilder.CreateCode();

            //_CreateOrEditModal.js
            EditModalJsCodeBuilder editModalJsCodeBuilder = new EditModalJsCodeBuilder(permissionCodeBuilder,
                                                                                       controllerCodeBuilder, tbModuleName.Text);

            editModalJsCodeBuilder.RootCodePath = tbCodeRootPath.Text;
            editModalJsCodeBuilder.CreateCode();

            MessageBox.Show("OK");
        }