Пример #1
0
        public IActionResult UpdateSitemapArea([FromBody] SitemapArea area, [FromQuery] Guid?appId = null)
        {
            var response = new ResponseModel();

            response.Message = "Success";
            response.Success = true;

            if (area == null)
            {
                response.Message = "Wrong object model submitted. Could not restore!";
                response.Success = false;
                return(Json(response));
            }
            if (appId == null)
            {
                response.Message = "Application Id needs to be submitted as 'appId' query string";
                response.Success = false;
                return(Json(response));
            }

            if (area.Id == null || area.Id == Guid.Empty)
            {
                response.Message = "Area Id needs to be submitted";
                response.Success = false;
                return(Json(response));
            }

            var appSrv = new AppService();

            try
            {
                appSrv.UpdateArea(area.Id, appId ?? Guid.Empty, area.Name, area.Label, area.LabelTranslations, area.Description, area.DescriptionTranslations,
                                  area.IconClass, area.Color, area.Weight, area.ShowGroupNames, area.Access);
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
                response.Success = false;
                return(Json(response));
            }

            var newSitemap = appSrv.GetApplication(appId ?? Guid.Empty).Sitemap;
            var initData   = new EntityRecord();

            initData["sitemap"]        = appSrv.OrderSitemap(newSitemap);
            initData["node_page_dict"] = PageUtils.GetNodePageDictionary(appId);
            response.Object            = initData;

            return(Json(response));
        }
Пример #2
0
        private static void Patch20181215(EntityManager entMan, EntityRelationManager relMan, RecordManager recMan)
        {
            var appSrv = new AppService();

            #region << Create SDK App >>
            var sdkApp = new App()
            {
                Id          = WEBVELLA_SDK_APP_ID,
                Name        = WEBVELLA_SDK_APP_NAME,
                Label       = "Software Development Kit",
                Description = "SDK & Development Tools",
                IconClass   = "ti-settings",
                Author      = "WebVella",
                Weight      = 1000,
                Color       = "#dc3545",
                Access      = new List <Guid>()
                {
                    SystemIds.AdministratorRoleId
                }
            };
            appSrv.CreateApplication(sdkApp.Id, sdkApp.Name, sdkApp.Label, sdkApp.Description, sdkApp.IconClass, sdkApp.Author, sdkApp.Color,
                                     sdkApp.Weight, sdkApp.Access, DbContext.Current.Transaction);

            #endregion

            #region << Create App Sitemap Areas>>
            {
                var appArea = new SitemapArea()
                {
                    Id          = WEBVELLA_SDK_APP_AREA_DESIGN_ID,
                    Name        = "objects",
                    Label       = "Objects",
                    Description = "Schema and Layout management",
                    IconClass   = "ti-ruler-pencil",
                    Weight      = 1,
                    Color       = "#2196F3"
                };
                appSrv.CreateArea(appArea.Id, WEBVELLA_SDK_APP_ID, appArea.Name, appArea.Label, appArea.LabelTranslations, appArea.Description, appArea.DescriptionTranslations,
                                  appArea.IconClass, appArea.Color, appArea.Weight, appArea.ShowGroupNames, appArea.Access, DbContext.Current.Transaction);
            }
            {
                var appArea = new SitemapArea()
                {
                    Id          = WEBVELLA_SDK_APP_AREA_ACCESS_ID,
                    Name        = "access",
                    Label       = "Access",
                    Description = "Manage users and roles",
                    IconClass   = "ti-key",
                    Weight      = 2,
                    Color       = "#673AB7"
                };
                appSrv.CreateArea(appArea.Id, WEBVELLA_SDK_APP_ID, appArea.Name, appArea.Label, appArea.LabelTranslations, appArea.Description, appArea.DescriptionTranslations,
                                  appArea.IconClass, appArea.Color, appArea.Weight, appArea.ShowGroupNames, appArea.Access, DbContext.Current.Transaction);
            }
            {
                var appArea = new SitemapArea()
                {
                    Id          = WEBVELLA_SDK_APP_AREA_SERVER_ID,
                    Name        = "server",
                    Label       = "Server",
                    Description = "Background jobs and maintenance",
                    IconClass   = "ti-server",
                    Weight      = 3,
                    Color       = "#F44336"
                };
                appSrv.CreateArea(appArea.Id, WEBVELLA_SDK_APP_ID, appArea.Name, appArea.Label, appArea.LabelTranslations, appArea.Description, appArea.DescriptionTranslations,
                                  appArea.IconClass, appArea.Color, appArea.Weight, appArea.ShowGroupNames, appArea.Access, DbContext.Current.Transaction);
            }
            #endregion

            #region Create Sitemap Nodes >>
            //Design
            {
                var appNode = new SitemapNode()
                {
                    Id        = new Guid("5b132ac0-703e-4342-a13d-c7ff93d07a4f"),
                    Name      = "page",
                    Label     = "Pages",
                    IconClass = "ti-file",
                    Url       = "/sdk/objects/page/l",
                    Weight    = 1,
                    Type      = SitemapNodeType.Url
                };
                appSrv.CreateAreaNode(appNode.Id, WEBVELLA_SDK_APP_AREA_DESIGN_ID, appNode.Name, appNode.Label, appNode.LabelTranslations, appNode.IconClass, appNode.Url,
                                      (int)appNode.Type, appNode.EntityId, appNode.Weight, appNode.Access, DbContext.Current.Transaction);
            }
            {
                var appNode = new SitemapNode()
                {
                    Id        = new Guid("9b30bf96-67d9-4d20-bf07-e6ef1c44d553"),
                    Name      = "data_source",
                    Label     = "Data sources",
                    IconClass = "ti-cloud-down",
                    Url       = "/sdk/objects/data_source/l/list",
                    Weight    = 2,
                    Type      = SitemapNodeType.Url
                };
                appSrv.CreateAreaNode(appNode.Id, WEBVELLA_SDK_APP_AREA_DESIGN_ID, appNode.Name, appNode.Label, appNode.LabelTranslations, appNode.IconClass, appNode.Url,
                                      (int)appNode.Type, appNode.EntityId, appNode.Weight, appNode.Access, DbContext.Current.Transaction);
            }
            {
                var appNode = new SitemapNode()
                {
                    Id        = new Guid("02d75ea5-8fc6-4f95-9933-0eed6b36ca49"),
                    Name      = "application",
                    Label     = "Applications",
                    IconClass = "ti-layout-grid2",
                    Url       = "/sdk/objects/application/l/list",
                    Weight    = 3,
                    Type      = SitemapNodeType.Url
                };
                appSrv.CreateAreaNode(appNode.Id, WEBVELLA_SDK_APP_AREA_DESIGN_ID, appNode.Name, appNode.Label, appNode.LabelTranslations, appNode.IconClass, appNode.Url,
                                      (int)appNode.Type, appNode.EntityId, appNode.Weight, appNode.Access, DbContext.Current.Transaction);
            }
            {
                var appNode = new SitemapNode()
                {
                    Id        = new Guid("dfa7ec55-b55b-404f-b251-889f1d81df29"),
                    Name      = "entity",
                    Label     = "Entities",
                    IconClass = "ti-server",
                    Url       = "/sdk/objects/entity/l",
                    Weight    = 4,
                    Type      = SitemapNodeType.Url
                };
                appSrv.CreateAreaNode(appNode.Id, WEBVELLA_SDK_APP_AREA_DESIGN_ID, appNode.Name, appNode.Label, appNode.LabelTranslations, appNode.IconClass, appNode.Url,
                                      (int)appNode.Type, appNode.EntityId, appNode.Weight, appNode.Access, DbContext.Current.Transaction);
            }
            {
                var appNode = new SitemapNode()
                {
                    Id        = new Guid("4571de62-a817-4a94-8b49-4b230cc0d2ad"),
                    Name      = "codegen",
                    Label     = "Code generation",
                    IconClass = "fa fa-code",
                    Url       = "/sdk/objects/codegen/a/codegen",
                    Weight    = 10,
                    Type      = SitemapNodeType.Url
                };
                appSrv.CreateAreaNode(appNode.Id, WEBVELLA_SDK_APP_AREA_DESIGN_ID, appNode.Name, appNode.Label, appNode.LabelTranslations, appNode.IconClass, appNode.Url,
                                      (int)appNode.Type, appNode.EntityId, appNode.Weight, appNode.Access, DbContext.Current.Transaction);
            }

            //Access
            {
                var appNode = new SitemapNode()
                {
                    Id        = new Guid("ff578868-817e-433d-988f-bb8d4e9baa0d"),
                    Name      = "user",
                    Label     = "Users",
                    IconClass = "ti-user",
                    Url       = "/sdk/access/user/l/list",
                    Weight    = 1,
                    Type      = SitemapNodeType.Url
                };
                appSrv.CreateAreaNode(appNode.Id, WEBVELLA_SDK_APP_AREA_ACCESS_ID, appNode.Name, appNode.Label, appNode.LabelTranslations, appNode.IconClass, appNode.Url,
                                      (int)appNode.Type, appNode.EntityId, appNode.Weight, appNode.Access, DbContext.Current.Transaction);
            }
            {
                var appNode = new SitemapNode()
                {
                    Id        = new Guid("75567fc4-70e1-41a9-9e32-2e5b62636598"),
                    Name      = "role",
                    Label     = "Roles",
                    IconClass = "fa fa-key",
                    Url       = "/sdk/access/role/l/list",
                    Weight    = 2,
                    Type      = SitemapNodeType.Url
                };
                appSrv.CreateAreaNode(appNode.Id, WEBVELLA_SDK_APP_AREA_ACCESS_ID, appNode.Name, appNode.Label, appNode.LabelTranslations, appNode.IconClass, appNode.Url,
                                      (int)appNode.Type, appNode.EntityId, appNode.Weight, appNode.Access, DbContext.Current.Transaction);
            }

            //Server
            {
                var appNode = new SitemapNode()
                {
                    Id        = new Guid("396ec481-3b2e-461c-b514-743fb3252003"),
                    Name      = "job",
                    Label     = "Background jobs",
                    IconClass = "ti-settings",
                    Url       = "/sdk/server/job/l/plan",
                    Weight    = 1,
                    Type      = SitemapNodeType.Url
                };
                appSrv.CreateAreaNode(appNode.Id, WEBVELLA_SDK_APP_AREA_SERVER_ID, appNode.Name, appNode.Label, appNode.LabelTranslations, appNode.IconClass, appNode.Url,
                                      (int)appNode.Type, appNode.EntityId, appNode.Weight, appNode.Access, DbContext.Current.Transaction);
            }
            {
                var appNode = new SitemapNode()
                {
                    Id        = new Guid("78a29ac8-d2aa-4379-b990-08f7f164a895"),
                    Name      = "log",
                    Label     = "Logs",
                    IconClass = "ti-notepad",
                    Url       = "/sdk/server/log/l/list",
                    Weight    = 2,
                    Type      = SitemapNodeType.Url
                };
                appSrv.CreateAreaNode(appNode.Id, WEBVELLA_SDK_APP_AREA_SERVER_ID, appNode.Name, appNode.Label, appNode.LabelTranslations, appNode.IconClass, appNode.Url,
                                      (int)appNode.Type, appNode.EntityId, appNode.Weight, appNode.Access, DbContext.Current.Transaction);
            }
            #endregion
        }
Пример #3
0
        private static SitemapArea JTokenToSitemapAreaConvert(JToken data)
        {
            if (data == null)
            {
                return(null);
            }

            SitemapArea model = new SitemapArea();

            model.Id             = new Guid(data["id"].ToString());
            model.AppId          = new Guid(data["app_id"].ToString());
            model.Name           = (string)data["name"];
            model.Label          = (string)data["label"];
            model.Description    = (string)data["description"];
            model.IconClass      = (string)data["icon_class"];
            model.ShowGroupNames = (bool)data["show_group_names"];
            model.Color          = (string)data["color"];
            model.Weight         = (int)data["weight"];

            if (!string.IsNullOrWhiteSpace((string)data["label_translations"]))
            {
                model.LabelTranslations = JsonConvert.DeserializeObject <List <TranslationResource> >((string)data["label_translations"]);
            }
            else
            {
                model.LabelTranslations = new List <TranslationResource>();
            }

            if (!string.IsNullOrWhiteSpace((string)data["description_translations"]))
            {
                model.DescriptionTranslations = JsonConvert.DeserializeObject <List <TranslationResource> >((string)data["description_translations"]);
            }
            else
            {
                model.DescriptionTranslations = new List <TranslationResource>();
            }

            model.Access = new List <Guid>();
            if (data["access"] != null)
            {
                foreach (var rId in data["access"].AsJEnumerable())
                {
                    model.Access.Add(new Guid(rId.ToString()));
                }
            }

            model.Groups = new List <SitemapGroup>();
            if (data["groups"] != null)
            {
                foreach (var jGroup in data["groups"].AsJEnumerable())
                {
                    model.Groups.Add(jGroup.MapToSingleObject <SitemapGroup>());
                }
            }

            model.Nodes = new List <SitemapNode>();
            if (data["nodes"] != null)
            {
                foreach (var jNode in data["nodes"].AsJEnumerable())
                {
                    model.Nodes.Add(jNode.MapToSingleObject <SitemapNode>());
                }
            }

            return(model);
        }