コード例 #1
0
ファイル: CalendarItem.cs プロジェクト: redwebs/Everlog
 public CalendarItem(CalendarItem item)
 {
     Summary            = item.Summary;
     Description        = item.Description;
     CalendarOrdinal    = item.CalendarOrdinal;
     HasTime            = item.HasTime;
     StartDateTime      = item.StartDateTime;
     EndDateTime        = item.EndDateTime;
     CreatedDateTime    = item.CreatedDateTime;
     UpatedDateTime     = item.UpatedDateTime;
     CreatorDisplayName = item.CreatorDisplayName;
     CreatorEmail       = item.CreatorEmail;
     Etag               = item.Etag;
     HtmlLink           = item.HtmlLink;
     IcalUid            = item.IcalUid;
     Id                 = item.Id;
     Location           = item.Location;
     RecurringEventId   = item.RecurringEventId;
     SourceTitle        = item.SourceTitle;
     SourceUrl          = item.SourceUrl;
     EndTimeUnspecified = item.EndTimeUnspecified;
     OriginalStartTime  = item.OriginalStartTime;
 }
コード例 #2
0
ファイル: YearList.cs プロジェクト: redwebs/Everlog
        private static List <CalendarItem> GetCalendarItems(string calendarId, CalEvents.EventsListOptionalParms parms, int calOrdinal)
        {
            var targetYear = parms.TimeMin.Year.ToString();

            Log.Debug($"******************** Starting GetCalendarItems.List for Id {calendarId}");

            var itemList = new List <CalendarItem>();

            var events = CalEvents.List(_service, calendarId, parms);

            foreach (var calEvent in events.Items)
            {
                var item = new CalendarItem
                {
                    Summary         = calEvent.Summary,
                    CalendarOrdinal = calOrdinal,
                    CreatedDateTime = calEvent.Created ?? DateTime.MinValue,
                    UpatedDateTime  = calEvent.Updated ?? DateTime.MinValue,

                    Description = calEvent.Description,

                    Etag               = calEvent.ETag,
                    HtmlLink           = calEvent.HtmlLink,
                    IcalUid            = calEvent.ICalUID,
                    Id                 = calEvent.Id,
                    Location           = calEvent.Location,
                    RecurringEventId   = calEvent.RecurringEventId,
                    EndTimeUnspecified = calEvent.EndTimeUnspecified ?? true,
                    OriginalStartTime  = DateTime.MinValue
                };

                if (calEvent.Creator != null)
                {
                    item.CreatorDisplayName = calEvent.Creator.DisplayName;
                    item.CreatorEmail       = calEvent.Creator.Email;
                }

                if (calEvent.Source != null)
                {
                    item.SourceTitle = calEvent.Source.Title;
                    item.SourceUrl   = calEvent.Source.Url;
                }

                if (calEvent.OriginalStartTime?.DateTime != null)
                {
                    item.OriginalStartTime = calEvent.OriginalStartTime.DateTime.Value;
                }

                if (calEvent.Start.DateTime != null)
                {
                    item.HasTime       = true;
                    item.StartDateTime = (DateTime)calEvent.Start.DateTime;
                }
                else
                {
                    item.HasTime       = false;
                    item.StartDateTime = DateTime.Parse(targetYear + calEvent.Start.Date.Remove(0, 4));
                }
                if (calEvent.End.DateTime != null)
                {
                    item.EndDateTime = (DateTime)calEvent.End.DateTime;
                }
                else
                {
                    item.EndDateTime = DateTime.Parse(targetYear + calEvent.End.Date.Remove(0, 4));

                    if (item.EndDateTime - item.StartDateTime > TimeSpan.FromDays(1f))
                    {
                        // This is a multiday event
                        itemList.AddRange(AddMultidays(item));
                    }
                }
                itemList.Add(item);
            }
            return(itemList);
        }