예제 #1
0
        public void RefreshNodeName(string tenantUid, string tenantName)
        {
            var home     = TenantHelper.GetCurrentTenantHome(contentService, tenantUid);
            var children = contentService.GetByLevel(2).Where(x => x.ParentId == home.Id);

            try
            {
                foreach (var language in localizationService.GetAllLanguages())
                {
                    if (home.GetCultureName(language.IsoCode) == null)
                    {
                        home.SetCultureName(tenantName, language.IsoCode);
                    }

                    foreach (var child in children)
                    {
                        if (child.GetCultureName(language.IsoCode) == null)
                        {
                            child.SetCultureName($"{tenantName}-{language}", language.IsoCode);
                            contentService.Save(child);
                        }
                    }
                }
                ConnectorContext.AuditService.Add(AuditType.Save, -1, home.Id, "Content Node", $"Children for {tenantName} have been refreshed");
            }
            catch (Exception ex)
            {
                logger.Error(typeof(NodeHelper), ex.Message);
                logger.Error(typeof(NodeHelper), ex.StackTrace);
                throw;
            }
        }
예제 #2
0
        public void AddLanguageVersionToNode(Tenant tenant)
        {
            var home     = TenantHelper.GetCurrentTenantHome(contentService, tenant.TenantUId.ToString());
            var children = contentService.GetByLevel(2).Where(x => x.ParentId == home.Id);

            try
            {
                foreach (var language in tenant.Languages.Alternate)
                {
                    foreach (var child in children)
                    {
                        try
                        {
                            if (child.GetCultureName(language) == null)
                            {
                                child.SetCultureName($"{child.Name}-{language}", language);
                                contentService.Save(child);
                            }
                        }
                        catch { }
                    }
                }
                ConnectorContext.AuditService.Add(AuditType.Save, -1, home.Id, "Content Node", $"Children for {home.Name} have been updated with new language");
            }
            catch (Exception ex)
            {
                logger.Error(typeof(NodeHelper), ex.Message);
                logger.Error(typeof(NodeHelper), ex.StackTrace);
                throw;
            }
        }
예제 #3
0
        public int CreateNode(Tenant tenant, int parentId, string documentTypeAlias, string nodeName, string nodeNameFa = "")
        {
            var home    = TenantHelper.GetCurrentTenantHome(contentService, tenant.TenantUId.ToString());
            var docType = contentTypeService.Get(documentTypeAlias);

            try
            {
                IContent node = contentService.Create(nodeName, parentId, documentTypeAlias);
                node.Name = nodeName;
                node.SetCultureName(nodeName, tenant.Languages.Default);
                if (tenant.Languages.Default == "fa")
                {
                    node.SetCultureName(nodeNameFa, tenant.Languages.Default);
                }

                if (!string.IsNullOrEmpty(home.GetValue <string>("languages")))
                {
                    var alternateLanguages = home.GetValue <string>("languages").Split(',');
                    foreach (var language in alternateLanguages)
                    {
                        node.SetCultureName(nodeName, language.Trim());

                        if (language.Trim() == "fa")
                        {
                            node.SetCultureName(nodeNameFa, language.Trim());
                        }
                    }
                }

                contentService.Save(node);

                ConnectorContext.AuditService.Add(AuditType.New, -1, node.Id, "Content Node", $"Node {nodeName} for {tenant.TenantUId.ToString()} has been created");
                return(node.Id);
            }
            catch (Exception ex)
            {
                logger.Error(typeof(NodeHelper), ex.Message);
                logger.Error(typeof(NodeHelper), ex.StackTrace);
                throw;
            }
        }
예제 #4
0
 public IContent GetTenantRoot(Guid tenantGuid)
 {
     return(TenantHelper.GetCurrentTenantHome(contentService, tenantGuid.ToString()));
 }