示例#1
0
        public static int Register(List <Models.WidgetManifest> manifests)
        {
            var count = 0;

            foreach (var manifest in manifests)
            {
                if (!Portal.Exists(manifest))
                {
                    Logging.Logger.InfoFormat("Registering manifest: {0}", manifest.FullName);
                    Portal.Save(manifest, Account.AuditId);
                    count++;
                }
                else
                {
                    //todo: REALLY need to reconsider how to structure this logic...
                    var m = Portal.GetWidgetManifest(manifest.FullName);
                    manifest.Id = m.Id;
                    if (manifest.ToJson() != m.ToJson())
                    {
                        Logging.Logger.InfoFormat("Registering manifest: {0}", manifest.FullName);
                        Portal.Save(manifest, Account.AuditId);
                        count++;
                    }
                }
            }
            //Repository.Current.SaveChanges();
            return(count);
        }
示例#2
0
        public static string Import(string portalId, Models.LayoutTemplate template, Dictionary <string, string> widgetContent, Dictionary <string, string> idMap, string userId = null)
        {
            userId = string.IsNullOrEmpty(userId) ? Account.AuditId : userId;
            var existing = Portal.GetLayoutTemplate(portalId, template.LayoutName);

            template.PortalId = portalId;
            template.Roles    = Security.GetNewRoleIds(template.Roles, idMap);
            template.Id       = existing != null ? existing.Id : null;
            foreach (var widget in template.Widgets)
            {
                widget.ManifestId = GetIdMap <Models.WidgetManifest>(widget.ManifestId, idMap);
                widget.Roles      = Security.GetNewRoleIds(widget.Roles, idMap);

                //todo: not creating/mapping new widget ids?
                if (widgetContent.ContainsKey(widget.Id))
                {
                    var contentProvider = widget.Manifest.GetContentProvider();
                    if (contentProvider != null)
                    {
                        widget.ContentIds = contentProvider.Import(portalId, widget.Id, widgetContent[widget.Id], idMap).Values.ToList(); //returns mapped dictionary of old id to new id... we just need to use the new ids
                    }
                }
            }
            return(Portal.Save(template));
        }
示例#3
0
        public static string Import(string portalId, Models.PageTemplate pageTemplate, Dictionary <string, string> widgetContent, Dictionary <string, string> idMap, string userId = null)
        {
            userId = string.IsNullOrEmpty(userId) ? Account.AuditId : userId;
            var existing = Portal.GetPageTemplate(pageTemplate.Urls.Count > 0 ? pageTemplate.Urls[0] : "", portalId);   //todo:  by first url ok???

            pageTemplate.PortalId = portalId;
            pageTemplate.Roles    = Security.GetNewRoleIds(pageTemplate.Roles, idMap);
            pageTemplate.Id       = existing != null ? existing.Id : null;

            foreach (var widget in pageTemplate.Widgets)
            {
                widget.ManifestId = GetIdMap <Models.WidgetManifest>(widget.ManifestId, idMap);
                widget.Roles      = Security.GetNewRoleIds(widget.Roles, idMap);

                //todo: not creating/mapping new widget ids?
                if (widgetContent.ContainsKey(widget.Id))
                {
                    var contentProvider = widget.Manifest.GetContentProvider();
                    if (contentProvider != null)
                    {
                        widget.ContentIds = contentProvider.Import(portalId, widget.Id, widgetContent[widget.Id], idMap).Values.ToList(); //returns mapped dictionary of old id to new id... we just need to use the new ids
                    }
                }
            }
            Logging.Logger.DebugFormat("Importing page template {0}", pageTemplate.ToJson());
            return(Portal.Save(pageTemplate));
        }
示例#4
0
        public static int Register(Models.Portal portal)
        {
            var count = 0;

            if (!Portal.Exists(portal))
            {
                Logging.Logger.InfoFormat("Registering portal: {0}", portal.Name);
                Portal.Save(portal, Account.AuditId);
                count++;
            }
            return(count);
        }
示例#5
0
        public static int Register(List <Models.LayoutTemplate> templates)
        {
            var count = 0;

            foreach (var template in templates)
            {
                template.PortalId = string.IsNullOrEmpty(template.PortalId) ? Services.Portal.CurrentPortalId : template.PortalId;
                if (!Portal.Exists(template))
                {
                    Logging.Logger.InfoFormat("Registering layout template: {0}", template.LayoutName);
                    Portal.Save(template, Account.AuditId);
                    count++;
                }
            }
            return(count);
        }