protected override void Create() { var element = new AxMenuItemAction { Name = ElementName }; MetaService.CreateMenuItemAction(element, Model); }
public static void CreateMenuItem(UtilElementType type, string name, string label = "") { if (Project == null) { throw new InvalidOperationException("No project selected."); } _name = name; switch (type) { case UtilElementType.DisplayTool: var existsDisplayTool = LocalUtils.MetaService.GetMenuItemDisplayNames().Contains(name); if (!existsDisplayTool) { var displayMenu = new AxMenuItemDisplay { Name = name, Object = name, Label = label }; LocalUtils.MetaService.CreateMenuItemDisplay(displayMenu, Model); AddAotElement <AxMenuItemDisplay>("Display Menu Items"); } break; case UtilElementType.OutputTool: var existsOutputTool = LocalUtils.MetaService.GetMenuItemDisplayNames().Contains(name); if (!existsOutputTool) { var outputMenu = new AxMenuItemOutput { Name = name, Object = name }; LocalUtils.MetaService.CreateMenuItemOutput(outputMenu, Model); AddAotElement <AxMenuItemOutput>("Output Menu Items"); } break; case UtilElementType.ActionTool: var existsActionTool = LocalUtils.MetaService.GetMenuItemDisplayNames().Contains(name); if (!existsActionTool) { var actionMenu = new AxMenuItemAction { Name = name, Object = name }; LocalUtils.MetaService.CreateMenuItemAction(actionMenu, Model); AddAotElement <AxMenuItemAction>("Action Menu Items"); } break; default: throw new Exception("Element not supported"); } }
void DoMenuItemCreate() { AxMenuItem axMenuItem; switch (MenuItemType) { case UtilElementType.DisplayTool: axMenuItem = _axHelper.MetadataProvider.MenuItemDisplays.Read(MenuItemName); if (axMenuItem != null) { throw new Exception($"MenuItem: {MenuItemName} already exists"); } axMenuItem = new AxMenuItemDisplay { Name = MenuItemName, Object = ObjectName, Label = FormLabel, HelpText = FormHelp, ObjectType = ObjectTypeCaller }; _axHelper.MetaModelService.CreateMenuItemDisplay((AxMenuItemDisplay)axMenuItem, _axHelper.ModelSaveInfo); break; case UtilElementType.OutputTool: axMenuItem = _axHelper.MetadataProvider.MenuItemOutputs.Read(MenuItemName); if (axMenuItem != null) { throw new Exception($"MenuItem: {MenuItemName} already exists"); } axMenuItem = new AxMenuItemOutput { Name = MenuItemName, Object = ObjectName, Label = FormLabel, HelpText = FormHelp, ObjectType = ObjectTypeCaller }; _axHelper.MetaModelService.CreateMenuItemOutput((AxMenuItemOutput)axMenuItem, _axHelper.ModelSaveInfo); break; case UtilElementType.ActionTool: axMenuItem = _axHelper.MetadataProvider.MenuItemActions.Read(MenuItemName); if (axMenuItem != null) { throw new Exception($"MenuItem: {MenuItemName} already exists"); } axMenuItem = new AxMenuItemAction { Name = MenuItemName, Object = ObjectName, Label = FormLabel, HelpText = FormHelp, ObjectType = ObjectTypeCaller }; _axHelper.MetaModelService.CreateMenuItemAction((AxMenuItemAction)axMenuItem, _axHelper.ModelSaveInfo); break; default: throw new Exception("Element not supported"); } _axHelper.AppendToActiveProject(axMenuItem); AddLog($"MenuItem: {axMenuItem.Name}; "); }
void CreateClass() { AxHelper axHelper = new AxHelper(); NewAxClass = axHelper.MetadataProvider.Classes.Read(ClassName); //newAxClass = axHelper.MetadataProvider.Classes.Read("Tutorial_RunbaseBatch"); if (NewAxClass != null) { throw new Exception($"Class {ClassName} already exists"); } if (IsCreateMenuItem) { if (axHelper.MetadataProvider.MenuItemActions.Read(ClassName) != null) { throw new Exception($"Menu item action {ClassName} already exists"); } } NewAxClass = new AxClass { Name = ClassName }; CreateClassMethods(); axHelper.MetaModelService.CreateClass(NewAxClass, axHelper.ModelSaveInfo); axHelper.AppendToActiveProject(NewAxClass); AddLog($"Class: {NewAxClass.Name}; "); if (IsCreateMenuItem) { AxMenuItemAction axMenuItem = new AxMenuItemAction { Name = ClassName, Object = ClassName, ObjectType = MenuItemObjectType.Class }; axMenuItem.Label = ClassDescription; axMenuItem.HelpText = $"{axMenuItem.Label} operation"; axHelper.MetaModelService.CreateMenuItemAction(axMenuItem, axHelper.ModelSaveInfo); axHelper.AppendToActiveProject(axMenuItem); AddLog($"MenuItem: {axMenuItem.Name}; "); } }
public static void Create(UtilElementType type, string name) { if (Project == null) { throw new InvalidOperationException("No project selected."); } _name = name; switch (type) { case UtilElementType.DisplayTool: var existsDisplayTool = LocalUtils.MetaService.GetMenuItemDisplayNames().Contains(name); if (!existsDisplayTool) { var displayMenu = new AxMenuItemDisplay { Name = name }; LocalUtils.MetaService.CreateMenuItemDisplay(displayMenu, Model); AddAotElement <AxMenuItemDisplay>(); } break; case UtilElementType.OutputTool: var existsOutputTool = LocalUtils.MetaService.GetMenuItemDisplayNames().Contains(name); if (!existsOutputTool) { var outputMenu = new AxMenuItemOutput { Name = name }; LocalUtils.MetaService.CreateMenuItemOutput(outputMenu, Model); AddAotElement <AxMenuItemOutput>(); } break; case UtilElementType.ActionTool: var existsActionTool = LocalUtils.MetaService.GetMenuItemDisplayNames().Contains(name); if (!existsActionTool) { var actionMenu = new AxMenuItemAction { Name = name }; LocalUtils.MetaService.CreateMenuItemAction(actionMenu, Model); AddAotElement <AxMenuItemAction>(); } break; case UtilElementType.Query: var existsQuery = LocalUtils.MetaService.GetQueryNames().Contains(name); if (!existsQuery) { var query = new AxQuerySimple { Name = name }; LocalUtils.MetaService.CreateQuery(query, Model); AddAotElement <AxQuerySimple>(); } break; case UtilElementType.Enum: var Enum = LocalUtils.MetaService.GetEnumNames().Contains(name); if (!Enum) { var edtEnum = new AxEnum { Name = name }; LocalUtils.MetaService.CreateEnum(edtEnum, Model); AddAotElement <AxEnum>(); } break; case UtilElementType.ExtendedType: break; case UtilElementType.Table: var existsTable = LocalUtils.MetaService.GetTableNames().Contains(name); if (!existsTable) { var table = new AxTable { Name = name }; LocalUtils.MetaService.CreateTable(table, Model); AddAotElement <AxTable>(); } break; case UtilElementType.Class: var existsClass = LocalUtils.MetaService.GetClassNames().Contains(name); if (!existsClass) { var axClass = new AxClass { Name = name }; LocalUtils.MetaService.CreateClass(axClass, Model); AddAotElement <AxClass>(); } break; case UtilElementType.SSRSReport: var existsSsrsReport = LocalUtils.MetaService.GetReportNames().Contains(name); if (!existsSsrsReport) { var srsReport = new AxReport { Name = name }; LocalUtils.MetaService.CreateReport(srsReport, Model); AddAotElement <AxReport>(); } break; case UtilElementType.Form: var existsForm = LocalUtils.MetaService.GetFormNames().Contains(name); if (!existsForm) { var axForm = new AxForm { Name = name }; LocalUtils.MetaService.CreateForm(axForm, Model); AddAotElement <AxForm>(); } break; case UtilElementType.Menu: var existsMenu = LocalUtils.MetaService.GetMenuNames().Contains(name); if (!existsMenu) { var axMenu = new AxMenu { Name = name }; LocalUtils.MetaService.CreateMenu(axMenu, Model); AddAotElement <AxMenu>(); } break; case UtilElementType.SecDuty: var existsSecDuty = LocalUtils.MetaService.GetSecurityDutyNames().Contains(name); if (!existsSecDuty) { var axDuty = new AxSecurityDuty { Name = name }; LocalUtils.MetaService.CreateSecurityDuty(axDuty, Model); AddAotElement <AxSecurityDuty>(); } break; case UtilElementType.SecPolicy: var existsSecPolicy = LocalUtils.MetaService.GetSecurityPolicyNames().Contains(name); if (!existsSecPolicy) { var axPolicy = new AxSecurityPolicy { Name = name }; LocalUtils.MetaService.CreateSecurityPolicy(axPolicy, Model); AddAotElement <AxSecurityPolicy>(); } break; case UtilElementType.SecPrivilege: var existsSecPrivilege = LocalUtils.MetaService.GetSecurityPrivilegeNames().Contains(name); if (!existsSecPrivilege) { var privilege = new AxSecurityPrivilege { Name = name }; LocalUtils.MetaService.CreateSecurityPrivilege(privilege, Model); AddAotElement <AxSecurityPrivilege>(); } break; case UtilElementType.SecRole: var existsSecRole = LocalUtils.MetaService.GetSecurityRoleNames().Contains(name); if (!existsSecRole) { var role = new AxSecurityRole { Name = name }; LocalUtils.MetaService.CreateSecurityRole(role, Model); AddAotElement <AxSecurityRole>(); } break; default: throw new Exception("Element not supported"); } }