Exemple #1
0
        static List <SubCalendarEvent> generateRepeatSubCalendarEvent(EventID CalendarEventID, IList <Event> AllSubCalEvents)
        {
            uint j = 1;
            List <SubCalEvent>      RetValueSubCalEvents = new List <SubCalEvent>();
            List <SubCalendarEvent> RetValue             = new List <SubCalendarEvent>();

            foreach (Event eachEvent in AllSubCalEvents)
            {
                if (!GoogleIDs.Contains(eachEvent.Id))
                {
                    RetValueSubCalEvents.Add(ToRepeatInstance(eachEvent, CalendarEventID, j++));
                }
            }


            RetValue = RetValueSubCalEvents.Select(obj => GoogleSubCalendarEvent.convertFromGoogleToSubCalendarEvent(obj, new TilerElements.Location(obj.SubCalAddressDescription))).ToList();
            return(RetValue);
        }
Exemple #2
0
        public async static Task <IEnumerable <SubCalendarEvent> > getAllSubCallEvents(IList <Event> AllSubCals, CalendarService CalendarServiceData, string UserID, EventID AuthenticationID)
        {
            //ThirdPartyControl.CalendarTool calendarInUser =  ThirdPartyControl.CalendarTool.Google;

            List <Event> AllSubCalNoCancels = AllSubCals.Where(obj => obj.Status != "cancelled").ToList();

            Dictionary <string, Event> RepeatingIDs = new Dictionary <string, Event>();

            ConcurrentBag <SubCalEvent> RetValue = new ConcurrentBag <SubCalEvent>();
            DateTimeOffset now = DateTimeOffset.UtcNow.removeSecondsAndMilliseconds();
            TimeLine       CalculationTimeLine = new TimeLine(now.AddDays(Utility.defaultBeginDay), now.AddDays(Utility.defaultEndDay));

            uint i = 0;

            for (; i < AllSubCalNoCancels.Count; i++)
            {
                Event GoogleEvent = AllSubCalNoCancels[(int)i];



                if (GoogleEvent.Start.DateTime != null)
                {
                    TimeLine EventRange = new TimeLine(GoogleEvent.Start.DateTime.Value.ToUniversalTime(), GoogleEvent.End.DateTime.Value.ToUniversalTime());
                    if (EventRange.InterferringTimeLine(CalculationTimeLine) != null)
                    {
                        if (GoogleEvent.Recurrence == null)
                        {
                            GoogleIDs.Add(GoogleEvent.Id);
                            RetValue.Add(GoogleEvent.ToSubCal(AuthenticationID, i));
                        }
                        else
                        {
                            RepeatingIDs.Add(GoogleEvent.Id, GoogleEvent);
                        }
                    }
                }
            }


            KeyValuePair <string, Event> [] DictAsArray = RepeatingIDs.ToArray();


            //foreach (KeyValuePair<string, Google.Apis.Calendar.v3.Data.Event> eachKeyValuePair in RepeatingIDs)

            for (uint j = 0; j < DictAsArray.Length; j++)


            //Parallel.For(0, DictAsArray.Length, async (j) =>
            {
                uint myIndex = i + j;
                KeyValuePair <string, Event> eachKeyValuePair = DictAsArray[j];
                var RepetitionData = CalendarServiceData.Events.Instances(UserID, eachKeyValuePair.Key);
                RepetitionData.ShowDeleted = false;
                RepetitionData.TimeMax     = DateTime.Now.AddDays(Utility.defaultEndDay);
                var generatedRsults = await RepetitionData.ExecuteAsync().ConfigureAwait(false);

                List <SubCalEvent> AllRepeatSubCals = generatedRsults.Items.Select(obj => obj.ToSubCal(AuthenticationID, (myIndex))).ToList();
                AllRepeatSubCals.ForEach(obj => {
                    if (!GoogleIDs.Contains(obj.ThirdPartyEventID))
                    {
                        RetValue.Add(obj);
                    }
                });
            }
            //);
            return(RetValue.Select(obj => GoogleSubCalendarEvent.convertFromGoogleToSubCalendarEvent(obj)));
        }