コード例 #1
0
ファイル: Factory.cs プロジェクト: ilolo3/2sxc
        public static ISxcInstance SxcInstanceForModule(int modId, int tabId)
        {
            var moduleInfo = new ModuleController().GetModule(modId, tabId, false);
            var instance   = new DnnInstanceInfo(moduleInfo);

            return(SxcInstanceForModule(instance));
        }
コード例 #2
0
        public void Publish(int instanceId, int version)
        {
            Log.Add($"Publish(m:{instanceId}, v:{version})");
            try
            {
                // publish all entites of this content block
                var dnnModule    = ModuleController.Instance.GetModule(instanceId, Null.NullInteger, true);
                var instanceInfo = new DnnInstanceInfo(dnnModule);
                // must find tenant through module, as the PortalSettings.Current is null in search mode
                var tenant = new DnnTenant(new PortalSettings(dnnModule.OwnerPortalID));
                var cb     = new ModuleContentBlock(instanceInfo, Log, tenant);

                Log.Add($"found dnn mod {instanceInfo.Id}, tenant {tenant.Id}, cb exists: {cb.ContentGroupExists}");
                if (cb.ContentGroupExists)
                {
                    Log.Add("cb exists");
                    var appManager = new AppManager(cb.AppId, Log);

                    // Add content entities
                    IEnumerable <IEntity> list = new List <IEntity>();
                    list = TryToAddStream(list, cb.Data, "Default");
                    list = TryToAddStream(list, cb.Data, "ListContent");
                    list = TryToAddStream(list, cb.Data, "PartOfPage");

                    // ReSharper disable PossibleMultipleEnumeration
                    // Find related presentation entities
                    var attachedPresItems = list
                                            .Where(e => (e as EntityInContentGroup)?.Presentation != null)
                                            .Select(e => ((EntityInContentGroup)e).Presentation);
                    Log.Add($"adding presentation item⋮{attachedPresItems.Count()}");
                    list = list.Concat(attachedPresItems);
                    // ReSharper restore PossibleMultipleEnumeration

                    var ids = list.Where(e => !e.IsPublished).Select(e => e.EntityId).ToList();

                    // publish ContentGroup as well - if there already is one
                    if (cb.ContentGroup != null)
                    {
                        Log.Add($"add group id:{cb.ContentGroup.ContentGroupId}");
                        ids.Add(cb.ContentGroup.ContentGroupId);
                    }

                    Log.Add(() => $"will publish id⋮{ids.Count} ids:[{ string.Join(",", ids.Select(i => i.ToString()).ToArray()) }]");

                    if (ids.Any())
                    {
                        appManager.Entities.Publish(ids.ToArray());
                    }
                    else
                    {
                        Log.Add("no ids found, won\'t publish items");
                    }
                }

                // Set published version
                new ModuleVersions(instanceId, Log).PublishLatestVersion();
                Log.Add("publish completed");
            }
            catch (Exception ex)
            {
                Logging.LogToDnn("exception", "publishing", Log, force: true);
                DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
                throw;
            }
        }