Example #1
0
        protected override void Create()
        {
            var element = new AxSecurityDuty {
                Name = ElementName
            };

            MetaService.CreateSecurityDuty(element, Model);
        }
        public static string CreateDuty_fromSecPriv(ISecurityPrivilege privilege, string postfix)
        {
            var name = privilege.Name;

            if (name.EndsWith(postfix))
            {
                // We dont need to do anything here
                postfix = String.Empty;
            }
            else if (postfix.Equals(Common.Constants.INQUIRE, StringComparison.InvariantCultureIgnoreCase) &&
                     name.EndsWith(Common.Constants.VIEW, StringComparison.InvariantCultureIgnoreCase))
            {
                name = name.Replace(Common.Constants.VIEW, String.Empty);
            }

            var duty = new AxSecurityDuty()
            {
                Name = privilege.Name + postfix
            };

            duty.Privileges.Add(new AxSecurityPrivilegeReference()
            {
                Name = privilege.Name
            });
            duty.Label       = privilege.Label;
            duty.Description = privilege.Description;

            // Find current model
            var modelSaveInfo = Common.CommonUtil.GetCurrentModelSaveInfo();

            //Create menu item in the right model
            var metaModelProviders = ServiceLocator.GetService <IMetaModelProviders>() as IMetaModelProviders;
            var metaModelService   = metaModelProviders.CurrentMetaModelService;

            metaModelService.CreateSecurityDuty(duty, modelSaveInfo);

            // Addd to project
            Common.CommonUtil.AddElementToProject(duty);

            return(duty.Name);
        }
Example #3
0
        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");
            }
        }