コード例 #1
0
        private WhosOffDataModel ToModel(IEnumerable <IEnumerable <IEvent> > events)
        {
            var model = new WhosOffDataModel();

            model.title            = "Whos Off";
            model.updatedAtMessage = DateTime.Now.ToLongDateString();

            foreach (var cal in events)
            {
                foreach (var subItem in cal)
                {
                    var item = new WhosOffDataModel.Item()
                    {
                        StartDate = subItem.Start.Value,
                        EndDate   = subItem.End.Value,
                        DaysOff   = Math.Round((subItem.End.Value - subItem.Start.Value).TotalDays, 2),
                        Name      = subItem.Summary,
                    };

                    model.items.Add(item);
                }
            }

            return(model);
        }
コード例 #2
0
ファイル: Job.cs プロジェクト: BeeFrog/dashing.net
        public Job()
        {
            this.feelUrl = System.Configuration.ConfigurationManager.AppSettings.GetValues("whosoff-icalFeed")?.FirstOrDefault();

            var refreshStr = System.Configuration.ConfigurationManager.AppSettings.GetValues("whosoff-refreshInterval")?.FirstOrDefault();            
            if (!int.TryParse(refreshStr, out this.refreshInterval))
            {
                this.refreshInterval = 3;
            }

            var data = new WhosOffDataModel();
            data.items.Add(new WhosOffDataModel.Item { DaysOff = 0, Name = "Feed URL:" + this.feelUrl });
            Dashing.SendMessage(new { id = "whosoff", items = data.items });

            Timer = new Lazy<Timer>(() => new Timer(SendMessage, null, TimeSpan.Zero, TimeSpan.FromMinutes(this.refreshInterval)));            
        }
コード例 #3
0
ファイル: Job.cs プロジェクト: BeeFrog/dashing.net
        public WhosOffDataModel GetData()
        {
            var uri = new Uri(this.feelUrl);
            var model = new WhosOffDataModel();
            try
            {
                var cal = iCalendar.LoadFromUri(uri);
                var events = from c in cal where c.Events != null select c.Events.Where(e=>e.End.Date >= DateTime.UtcNow.Date);

                // Convert to a presentation Object
                model = this.ToModel(events);
            }
            catch (Exception ex)
            {
                model.updatedAtMessage = "Error updating calender: " + ex.ToString();
            }

            return model;
        }
コード例 #4
0
        public WhosOffDataModel GetData()
        {
            var uri   = new Uri(this.feelUrl);
            var model = new WhosOffDataModel();

            try
            {
                var cal    = iCalendar.LoadFromUri(uri);
                var events = from c in cal where c.Events != null select c.Events.Where(e => e.End.Date >= DateTime.UtcNow.Date);

                // Convert to a presentation Object
                model = this.ToModel(events);
            }
            catch (Exception ex)
            {
                model.updatedAtMessage = "Error updating calender: " + ex.ToString();
            }

            return(model);
        }
コード例 #5
0
        public Job()
        {
            this.feelUrl = System.Configuration.ConfigurationManager.AppSettings.GetValues("whosoff-icalFeed")?.FirstOrDefault();

            var refreshStr = System.Configuration.ConfigurationManager.AppSettings.GetValues("whosoff-refreshInterval")?.FirstOrDefault();

            if (!int.TryParse(refreshStr, out this.refreshInterval))
            {
                this.refreshInterval = 3;
            }

            var data = new WhosOffDataModel();

            data.items.Add(new WhosOffDataModel.Item {
                DaysOff = 0, Name = "Feed URL:" + this.feelUrl
            });
            Dashing.SendMessage(new { id = "whosoff", items = data.items });

            Timer = new Lazy <Timer>(() => new Timer(SendMessage, null, TimeSpan.Zero, TimeSpan.FromMinutes(this.refreshInterval)));
        }
コード例 #6
0
ファイル: Job.cs プロジェクト: BeeFrog/dashing.net
        private WhosOffDataModel ToModel(IEnumerable<IEnumerable<IEvent>> events)
        {
            var model = new WhosOffDataModel();
            model.title = "Whos Off";
            model.updatedAtMessage = DateTime.Now.ToLongDateString();

            foreach (var cal in events)
            {
                foreach (var subItem in cal)
                {
                    var item = new WhosOffDataModel.Item()
                    {
                        StartDate = subItem.Start.Value,
                        EndDate = subItem.End.Value,
                        DaysOff = Math.Round((subItem.End.Value - subItem.Start.Value).TotalDays, 2),
                        Name = subItem.Summary,
                    };

                    model.items.Add(item);
                }
            }

            return model;
        }