Esempio n. 1
0
        public static void Finalize(Calinfo calinfo, ZonelessEventStore es_zoneless)
        {
            es_zoneless.events = EventStore.UniqueByTitleAndStart(calinfo.id, es_zoneless.events, save_tag_sources: true); // deduplicate

            es_zoneless.ExcludePastEvents();                                                                               // the EventCollector should already have done this, but in case not...

            es_zoneless.SortEventList();                                                                                   // order by dtstart

            Utils.BuildTagStructures(es_zoneless, calinfo);                                                                // build structures used to generate tag picklists

            var i = 0;

            foreach (var evt in es_zoneless.events)
            {
                var str  = evt.dtstart.ToString() + evt.title.ToString() + evt.source.ToString() + evt.url;
                var hash = HttpUtils.GetMd5Hash(Encoding.UTF8.GetBytes(str));
                evt.uid = i;
                i++;
                evt.hash = hash;
            }

            es_zoneless.PopulateDaysAndCounts();                // do this here for a) renderer efficiency, b) renderer simplification
            // (it only updates these structures for category views)

            es_zoneless.when_finalized = DateTime.UtcNow;

            es_zoneless.Serialize();
        }
Esempio n. 2
0
        private ZonelessEventStore GetEventStore(ZonelessEventStore es, string view, int count, DateTime from, DateTime to, string source, Dictionary<string,object> args)
        {
            if (args == null)
                args = new Dictionary<string, object>();
            // see RenderDynamicViewWithCaching:
            // view_data = Encoding.UTF8.GetBytes(view_renderer(eventstore:null, view:view, view:count));
            // the renderer might be, e.g., CalendarRenderer.RenderHtml, which calls this method
            if (es == null)  // if no eventstore passed in (e.g., for testing)
                es = this.es_getter(this.cache); // get the eventstore. if the getter is GetEventStoreWithCaching
            // then it will use HttpUtils.RetrieveBlobFromServerCacheOrUri
            // which gets from cache if it can, else fetches uri and loads cache

            var is_html_renderer = args.HasValue("html_renderer", true);
            var bare_events = args.HasValue("bare_events", true);
            var is_view = !String.IsNullOrEmpty(view);

            if (is_html_renderer)
            {
                MaybeBuildTagStructures(es); // transitional until new generation of objects is fully established
                if (bare_events)
                    count = 0;
            }

            if (args.HasValue("advance_to_an_hour_ago", true) && ! bare_events)
                es.AdvanceToAnHourAgo(this.calinfo);

            view = MaybeAddHubTagToView(view, args);

            var original_count = es.events.Count();
            es.events = Filter(view, count, from, to, source, es, args); // apply all filters

            if (is_view)
            {
                if (es.days_and_counts != null)  // this check needed only until new generation of objects is established
                    es.PopulateDaysAndCounts();  // mainly for html renderer but could be useful to  non-html renderers as well
            }

            return es;
        }