/// <summary> /// This is part of the IUpgradeable of DNN /// </summary> /// <param name="version"></param> /// <returns></returns> public string UpgradeModule(string version) { Log.Add($"upgrade module - start for v:{version}"); var res = new InstallationController().UpgradeModule(version); Log.Add($"result:{res}"); DnnLogging.LogToDnn("Upgrade", "ok", Log, force: true); // always log, this often causes hidden problems return(res); }
public void PublishVersion(int instanceId, int version) { Log.Add($"publish m#{instanceId}, v:{version}"); Publishing.Publish(instanceId, version); try { DnnLogging.LogToDnn("Publishing", "ok", Log, force: true); } catch { // ignore } }
public override void OnException(HttpActionExecutedContext context) { var exception = context.Exception; DotNetNuke.Services.Exceptions.Exceptions.LogException(exception); // try to access log created so far try { if (context.Request?.Properties.ContainsKey(DnnConstants.EavLogKey) ?? false) { // must to ContainsKey checks, otherwise we get too many errors which is a problem while debugging var log = context.Request.Properties.ContainsKey(DnnConstants.EavLogKey) ? context.Request.Properties[DnnConstants.EavLogKey] as ILog : null; var dnnContext = context.Request.Properties.ContainsKey(DnnConstants.DnnContextKey) ? context.Request.Properties[DnnConstants.DnnContextKey] as DnnContextOld : null; DnnLogging.LogToDnn("2sxc-Api", "Auto-Log Exception", log, dnnContext, force: true); } else { DnnLogging.LogToDnn("2sxc-Api", "exception, but no additional internal log to add, EavLog doesn't exist", force: true); } } catch { DnnLogging.TryToReportLoggingFailure("SxcWebApiExceptionHandling"); } // special manual exception maker, because otherwise IIS at runtime removes all messages // without this, debug-infos like what entity is causing the problem will not be shown to the client context.Response = context.Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Bad Request", context.Exception); var httpError = (HttpError)((ObjectContent <HttpError>)context.Response.Content).Value; if (!httpError.ContainsKey("ExceptionType")) { httpError.Add("ExceptionType", exception.GetType().FullName); } if (!httpError.ContainsKey("ExceptionMessage")) { httpError.Add("ExceptionMessage", exception.Message); } }
public override void OnActionExecuted(HttpActionExecutedContext actionContext) { base.OnActionExecuted(actionContext); try { var reqProps = actionContext.Request.Properties; // check if we have any logging details for this request if (!reqProps.ContainsKey(DnnConstants.EavLogKey)) { return; } if (reqProps.ContainsKey(AlreadyLogged)) { return; } var log = reqProps[DnnConstants.EavLogKey] as ILog; // check if we have additional context information (portal, module, etc.) reqProps.TryGetValue(DnnConstants.DnnContextKey, out var dnnContext); DnnLogging.LogToDnn("2sxc-Api", actionContext.Request.RequestUri.PathAndQuery, log, dnnContext as DnnContextOld); // set property, to prevent double-logging actionContext.Request.Properties.Add(AlreadyLogged, true); } catch { DnnLogging.TryToReportLoggingFailure("WebApiLogDetails"); } }
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 container = _serviceProvider.Build<DnnContainer>().Init(dnnModule, Log); // must find tenant through module, as the Portal-Settings.Current is null in search mode //var tenant = new DnnSite().Init(dnnModule.OwnerPortalID); var dnnContext = _serviceProvider.Build <IContextOfBlock>().Init(dnnModule, Log); var cb = _serviceProvider.Build <BlockFromModule>().Init(dnnContext, Log); //.Init(DnnContextOfBlock.Create(tenant, container, _serviceProvider), Log); Log.Add($"found dnn mod {dnnContext.Module.Id}, tenant {dnnContext.Site.Id}, cb exists: {cb.ContentGroupExists}"); if (cb.ContentGroupExists) { Log.Add("cb exists"); var appManager = _serviceProvider.Build <AppManager>().Init(cb, Log); // Add content entities IEnumerable <IEntity> list = new List <IEntity>(); list = TryToAddStream(list, cb.Data, Eav.Constants.DefaultStreamName); 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 EntityInBlock)?.Presentation != null) .Select(e => ((EntityInBlock)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 BlockConfiguration as well - if there already is one if (cb.Configuration != null) { Log.Add($"add group id:{cb.Configuration.Id}"); ids.Add(cb.Configuration.Id); } 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) { DnnLogging.LogToDnn("exception", "publishing", Log, force: true); DotNetNuke.Services.Exceptions.Exceptions.LogException(ex); throw; } }