Пример #1
0
 public CalendarRendererTest()
 {
     this.cr = new CalendarRenderer(Configurator.testid);
     this.cr.cache = new MockCache();
     var est = new EventStoreTest();
     est.SerializeAndDeserializeZonelessEventStoreYieldsExpectedEvents();
     this.es = new ZonelessEventStore(calinfo);
     var uri = BlobStorage.MakeAzureBlobUri(EventStoreTest.test_container, this.es.objfile,false);
     this.es = (ZonelessEventStore)BlobStorage.DeserializeObjectFromUri(uri);
 }
Пример #2
0
        public WebRoleData(bool testing, string test_id)
        {
            GenUtils.LogMsg("info", String.Format("WebRoleData: {0}, {1}, {2}, {3}", procname, procid, domain_name, thread_id), null);

            MakeWhereAndWhatAndRegionIdLists();

            var ids = Metadata.LoadHubIdsFromAzureTable();

            Parallel.ForEach(ids, id =>
            //foreach (var id in ids)
            {
                GenUtils.LogMsg("info", "GatherWebRoleData: readying: " + id, null);

                var cr = new CalendarRenderer(id);
                this.renderers.Add(id, cr);
                this.ready_ids.Add(id);
            });
            //}

            // this pipe-delimited string defines allowed IDs in the /services/ID/... URL pattern
            this.str_ready_ids = String.Join("|", this.ready_ids.ToArray());

            GenUtils.LogMsg("info", "GatherWebRoleData: str_ready_ids: " + this.str_ready_ids, null);
        }
Пример #3
0
 private static ContentResult view_calendar_helper(string id, ContentResult r, ZonedEventStore es_zoned, ZonelessEventStore es_zoneless)
 {
     foreach (var evt in es_zoned.events)
         es_zoneless.AddEvent(evt.title, evt.url.ToString(), evt.source, "", "", evt.dtstart.LocalTime, evt.dtend.LocalTime, evt.allday, evt.categories, evt.description, evt.location);
     es_zoneless.events = EventStore.UniqueByTitleAndStart(id, es_zoneless.events, save_tag_sources: false);
     es_zoneless.ExcludePastEvents();
     es_zoneless.SortEventList();
     var cr = new CalendarRenderer(id);
     r.Content = cr.RenderHtmlEventsOnly(es_zoneless, null, 0, DateTime.MinValue, DateTime.MinValue, new Dictionary<string, object>() { { "announce_time_of_day", false }, { "add_to_cal", false }, { "inline_descriptions", true }, {"taglist",false } } );
     return r;
 }
Пример #4
0
            private void MaybeCacheView(string view_key, CalendarRenderer.ViewRenderer view_renderer, ElmcityCacheDependency dependency, Dictionary<string,object> render_args)
            {
                if (this.test)
                    return;

                if (this.cr.cache[view_key] == null)
                {
                    var view_str = this.cr.RenderDynamicViewWithoutCaching(this.controller.ControllerContext, view_renderer, this.view, this.count, this.from, this.to, render_args);
                    byte[] view_bytes = Encoding.UTF8.GetBytes(view_str);
                    var cache = new AspNetCache(this.controller.HttpContext.Cache);
                    this.controller.InsertIntoCache(cache, view_bytes, dependency, view_key);
                }
            }
Пример #5
0
            public EventsResult(ElmcityController controller, CalendarRenderer cr, string id, string type, string view, string jsonp, string count, string from, string to, string eventsonly, string mobile, string test, string raw, string raw_sentinel, string style, string theme, string taglist)
            {
                this.controller = controller;
                this.cr = cr;
                this.cr.cache = new ElmcityUtils.AspNetCache(controller.HttpContext.Cache);
                this.id = id;
                this.type = type;
                this.view = view;
                this.jsonp = jsonp;
                this.from = from == null ? DateTime.MinValue : Utils.DateTimeFromISO8601DateStr(from, DateTimeKind.Local);
                this.to = from == null ? DateTime.MinValue : Utils.DateTimeFromISO8601DateStr(to, DateTimeKind.Local);
                this.eventsonly = eventsonly;
                this.mobile = !String.IsNullOrEmpty(mobile) ? mobile.ToLower() : "";
                this.test = !String.IsNullOrEmpty(test) && test.ToLower().StartsWith("y");
                this.raw = !String.IsNullOrEmpty(raw) && raw.ToLower().StartsWith("y");
                this.raw_sentinel = raw_sentinel;
                this.style = style;
                this.theme = theme;
                this.taglist = !String.IsNullOrEmpty(taglist) ? taglist.ToLower() : "";

                int _count = 0;
                try
                {
                    if ((type == "html") && (count != "0"))
                        _count = Convert.ToInt32(settings["max_html_events_default"]);
                    if (this.raw)
                        _count = 0;
                }
                catch (Exception e)
                {
                    GenUtils.PriorityLogMsg("exception", "EventsResult", e.Message);
                }

                this.count = (count == null) ? _count : Convert.ToInt32(count);
            }
Пример #6
0
 public CalendarRendererTest()
 {
     this.cr = new CalendarRenderer(Configurator.testid);
     this.cr.cache = new MockCache();
 }
Пример #7
0
 public void UsesAlternateTemplateWhenRequested()
 {
     this.cr = new CalendarRenderer(Configurator.testid);
     var orig = this.cr.template_html;
     var args = new Dictionary<string,object>();
     args.Add("template", "a2chron.tmpl");
     this.cr.MaybeUseAlternateTemplate(args);
     Assert.AreNotEqual(this.cr.template_html, orig);
 }
Пример #8
0
 // currently unused
 // could be wired into Metadata.UpdateMetadataForId
 // meanwhile a hub metadata update happens in-memory but isn't saved until the next GeneralAdmin pass in WorkerRole (via MakeWebRoleData)
 public static void UpdateRendererForId(string id)
 {
     var wrd = GetWrd();
     var bs = BlobStorage.MakeDefaultBlobStorage();
     try
     {
         var cr = new CalendarRenderer(id);
         wrd.renderers[id] = cr;
         SaveWrd(wrd);
     }
     catch (Exception e)
     {
         GenUtils.PriorityLogMsg("exception", "UpdateRendererForId: " + id, e.Message);
     }
 }
Пример #9
0
            public EventsResult(ElmcityController controller, CalendarRenderer cr, string id, string type, string view, string jsonp, string count, string from, string to, string eventsonly, string mobile, string test, string raw, string raw_sentinel, string style, string theme, string taglist, string tags, string template, string jsurl, string days, string bare_events, string hub, string source, string first)
            {
                this.controller = controller;
                this.cr = cr;
                this.cr.cache = new ElmcityUtils.AspNetCache(controller.HttpContext.Cache);
                this.id = id;
                this.type = type;
                this.view = view;
                this.jsonp = jsonp;
                this.from = from == null ? DateTime.MinValue : Utils.DateTimeFromISO8601DateStr(from, DateTimeKind.Local);
                this.to = from == null ? DateTime.MinValue : Utils.DateTimeFromISO8601DateStr(to, DateTimeKind.Local);
                this.eventsonly = String.IsNullOrEmpty(eventsonly) ? false : eventsonly.ToLower().StartsWith("y");
                this.mobile_declared = String.IsNullOrEmpty(mobile) ? false : mobile.ToLower().StartsWith("y");
                this.mobile_refused = String.IsNullOrEmpty(mobile) ? false : mobile.ToLower().StartsWith("n");
                this.test = String.IsNullOrEmpty(test) ? false : test.ToLower().StartsWith("y");
                this.raw = String.IsNullOrEmpty(raw) ? false : raw.ToLower().StartsWith("y");
                this.raw_sentinel = raw_sentinel;
                this.style = style;
                this.theme = theme;
                this.taglist = String.IsNullOrEmpty(taglist) ? true : taglist.ToLower().StartsWith("y");
                this.tags = String.IsNullOrEmpty(tags) ? false : tags.ToLower().StartsWith("y");
                this.template = template;
                this.jsurl = jsurl;
                this.bare_events = String.IsNullOrEmpty(bare_events) ? false : bare_events.ToLower().StartsWith("y");
                this.hub = hub;
                this.source = source;

                try
                {
                    if (!String.IsNullOrEmpty(first))
                        this.first = Convert.ToInt32(first);
                    else
                        this.first = 0;
                }
                catch (Exception e)
                {
                    GenUtils.LogMsg("warning", "EventsResult: cannot convert first " + first, e.Message);
                }

                int _count = 0;
                try
                {
                    if ((type == "html") && (count != "0"))
                        _count = Convert.ToInt32(settings["max_html_events_default"]);
                    if (this.bare_events)
                        _count = 0;
                }
                catch (Exception e)
                {
                    GenUtils.PriorityLogMsg("exception", "EventsResult", e.Message);
                }

                this.count = (count == null) ? _count : Convert.ToInt32(count);

                if (!String.IsNullOrEmpty(days))
                {
                    try
                    {
                        this.days = Convert.ToInt32(days);
                        if (this.days > 0)
                        {
                            var calinfo = ElmcityApp.wrd.renderers[this.id].calinfo;
                            var from_to = Utils.ConvertDaysIntoFromTo(this.days, calinfo);
                            this.from = (DateTime)from_to["from_date"];
                            this.to = (DateTime) from_to["to_date"];
                        }
                    }
                    catch (Exception e)
                    {
                        GenUtils.LogMsg("GetEvents", "days", e.Message);
                        this.days = 0;
                    }
                }
            }