Beispiel #1
0
        public bool Refresh(bool forse)
        {
            if (DateTime.Now.AddMilliseconds(-RefreshRate) > LastRefresh)
            {
                Logg.Debug(new { cache = "begin refresh" }.stringify());
                LastRefresh = DateTime.Now;
                lock (this) {
                    var currentEtag    = ETag;
                    var currentVersion = Version;
                    foreach (var extension in Extensions)
                    {
                        extension.Refresh(forse);
                    }
                    if (currentEtag == ETag && currentVersion == Version)
                    {
                        return(false);
                    }
                    Logg.Trace(new{ cache = "refreshed" }.stringify());
                    Clear();

                    return(true);
                }
            }
            return(false);
        }
Beispiel #2
0
 protected override void OnChangeExtensions()
 {
     base.OnChangeExtensions();
     if (Logg.IsForTrace())
     {
         Logg.Trace(new { logonproviders = Extensions.Select(_ => _.ToString()).ToArray() }.stringify());
     }
 }
Beispiel #3
0
        public void UpdateSourceList()
        {
            var sources = Container.All <ITaskSource>();

            foreach (var taskSource in sources)
            {
                if (Extensions.All(_ => _.GetType() != taskSource.GetType()))
                {
                    Logg.Trace("taskfactory add source of type: " + taskSource.GetType().FullName);
                    Extensions.Add(taskSource);
                }
            }
        }
Beispiel #4
0
        public async Task <IReportContext> Execute(IReportRequest request)
        {
            Logg.Debug(new { op = "start", r = request }.stringify());
            var context = InitializeContext(request);

            try {
                var scope = new Scope();
                await ExecutePhase(context, ReportPhase.Init, scope);
                await ExecutePhase(context, ReportPhase.Data, scope);
                await ExecutePhase(context, ReportPhase.Prepare, scope);

                if (request.DataOnly)
                {
                    if (null != context.Data)
                    {
                        context.SetHeader("Content-Type", "application/json; charset=utf-8");
                        context.Write(context.Data.stringify());
                    }
                }
                else
                {
                    await ExecutePhase(context, ReportPhase.Render, scope);
                }
                await ExecutePhase(context, ReportPhase.Finalize, scope);

                context.Finish();
            }
            catch (Exception e) {
                Logg.Error(e);
                context.Error = e;
                if (!context.Request.NoFinalizeOnError)
                {
                    context.Finish(e);
                }
            }
            finally {
                Logg.Trace(new { op = "success", r = request }.stringify());
            }
            return(context);
        }
Beispiel #5
0
 public void Clear()
 {
     Logg.Trace(new{ roles = "clear called" }.stringify());
     _cache.Clear();
 }