Exemple #1
0
        public static CalEvent ToDeletedCalEvent(this TilerElements.CalendarEvent CalendarEventEntry, TilerElements.TimeLine Range = null)
        {
            CalEvent retValue = new CalEvent();

            retValue.ThirdPartyUserID = CalendarEventEntry.getCreator.Id;

            retValue.ID                     = CalendarEventEntry.getId;
            retValue.ThirdPartyType         = CalendarEventEntry.ThirdpartyType.ToString();
            retValue.CalendarName           = CalendarEventEntry.getName?.NameValue;
            retValue.StartDate              = (long)(CalendarEventEntry.Start - JSStartTime).TotalMilliseconds;
            retValue.EndDate                = (long)(CalendarEventEntry.End - JSStartTime).TotalMilliseconds;
            retValue.TotalDuration          = CalendarEventEntry.getActiveDuration;
            retValue.Rigid                  = CalendarEventEntry.isRigid;
            retValue.AddressDescription     = CalendarEventEntry.Location.Description;
            retValue.Address                = CalendarEventEntry.Location.Address;
            retValue.Longitude              = CalendarEventEntry.Location.Longitude;
            retValue.Latitude               = CalendarEventEntry.Location.Latitude;
            retValue.NumberOfSubEvents      = CalendarEventEntry.AllSubEvents.Count();// CalendarEventEntry.NumberOfSplit;// AllSubEvents.Count();
            retValue.RColor                 = CalendarEventEntry.getUIParam.UIColor.R;
            retValue.GColor                 = CalendarEventEntry.getUIParam.UIColor.G;
            retValue.BColor                 = CalendarEventEntry.getUIParam.UIColor.B;
            retValue.OColor                 = CalendarEventEntry.getUIParam.UIColor.O;
            retValue.ColorSelection         = CalendarEventEntry.getUIParam.UIColor.User;
            retValue.NumberOfCompletedTasks = CalendarEventEntry.CompletionCount;
            retValue.NumberOfDeletedEvents  = CalendarEventEntry.DeletionCount;
            retValue.OtherPartyID           = CalendarEventEntry.ThirdPartyID;
            retValue.Notes                  = CalendarEventEntry.Notes.UserNote;
            retValue.isThirdParty           = CalendarEventEntry.isThirdParty;

            TimeSpan FreeTimeLeft = CalendarEventEntry.RangeSpan - CalendarEventEntry.getActiveDuration;
            long     TickTier1    = (long)(FreeTimeLeft.Ticks * (.667));
            long     TickTier2    = (long)(FreeTimeLeft.Ticks * (.865));
            long     TickTier3    = (long)(FreeTimeLeft.Ticks * (1));

            retValue.Tiers = new long[] { TickTier1, TickTier2, TickTier3 };
            if (Range != null)
            {
                retValue.AllSubCalEvents = CalendarEventEntry.AllSubEvents.Where(obj => !obj.isActive).Where(obj => obj.StartToEnd.InterferringTimeLine(Range) != null).Select(obj => obj.ToSubCalEvent(CalendarEventEntry)).ToList();
            }
            else
            {
                retValue.AllSubCalEvents = CalendarEventEntry.AllSubEvents.Where(obj => !obj.isActive).Select(obj => obj.ToSubCalEvent(CalendarEventEntry)).ToList();
            }

            return(retValue);
        }
Exemple #2
0
        public static CalEvent ToCalEvent(this TilerElements.CalendarEvent CalendarEventEntry, TilerElements.TimeLine Range = null, bool includeSubevents = true)
        {
            CalEvent retValue = new CalEvent();

            retValue.ThirdPartyUserID = CalendarEventEntry.getCreator.Id;
            retValue.ID                 = CalendarEventEntry.getId;
            retValue.ThirdPartyType     = CalendarEventEntry.ThirdpartyType.ToString();
            retValue.CalendarName       = CalendarEventEntry.getName?.NameValue;
            retValue.StartDate          = (long)(CalendarEventEntry.Start - JSStartTime).TotalMilliseconds;
            retValue.EndDate            = (long)(CalendarEventEntry.End - JSStartTime).TotalMilliseconds;
            retValue.TotalDuration      = CalendarEventEntry.getActiveDuration;
            retValue.Rigid              = CalendarEventEntry.isRigid;
            retValue.AddressDescription = CalendarEventEntry.Location.Description;
            retValue.Address            = CalendarEventEntry.Location.Address;
            retValue.Longitude          = CalendarEventEntry.Location.Longitude;
            retValue.Latitude           = CalendarEventEntry.Location.Latitude;
            retValue.NumberOfSubEvents  = CalendarEventEntry.NumberOfSplit;
            if (CalendarEventEntry.getUIParam != null && CalendarEventEntry.getUIParam.UIColor != null)
            {
                retValue.RColor         = CalendarEventEntry.getUIParam.UIColor.R;
                retValue.GColor         = CalendarEventEntry.getUIParam.UIColor.G;
                retValue.BColor         = CalendarEventEntry.getUIParam.UIColor.B;
                retValue.OColor         = CalendarEventEntry.getUIParam.UIColor.O;
                retValue.ColorSelection = CalendarEventEntry.getUIParam.UIColor.User;
            }

            retValue.NumberOfCompletedTasks = CalendarEventEntry.CompletionCount;
            retValue.NumberOfDeletedEvents  = CalendarEventEntry.DeletionCount;
            retValue.OtherPartyID           = CalendarEventEntry.ThirdPartyID;
            retValue.Notes                  = CalendarEventEntry?.Notes?.UserNote;
            retValue.isThirdParty           = CalendarEventEntry.isThirdParty;
            retValue.isReadOnly             = CalendarEventEntry.isReadOnly;
            retValue.SuggestedDeadline      = CalendarEventEntry.DeadlineSuggestion.ToUnixTimeMilliseconds();
            retValue.isProcrastinateAll     = CalendarEventEntry.isProcrastinateEvent;
            retValue.LastSuggestedDeadline  = CalendarEventEntry.LastDeadlineSuggestion.ToUnixTimeMilliseconds();
            retValue.SleepSuggestedDeadline = CalendarEventEntry.SleepDeadlineSuggestion.ToUnixTimeMilliseconds();
            TimeSpan FreeTimeLeft = CalendarEventEntry.RangeSpan - CalendarEventEntry.getActiveDuration;
            long     TickTier1    = (long)(FreeTimeLeft.Ticks * (.667));
            long     TickTier2    = (long)(FreeTimeLeft.Ticks * (.865));
            long     TickTier3    = (long)(FreeTimeLeft.Ticks * (1));

            retValue.Tiers = new long[] { TickTier1, TickTier2, TickTier3 };
            bool canDoNow = false;

            if (!CalendarEventEntry.IsFromRecurring)
            {
                canDoNow = (CalendarEventEntry.AutoDeletionCount + CalendarEventEntry.DeletionCount + CalendarEventEntry.CompletionCount) < CalendarEventEntry.NumberOfSplit;
            }
            else
            {
                canDoNow = CalendarEventEntry.End > DateTimeOffset.UtcNow;
            }

            retValue.canDoNow = canDoNow;
            if (includeSubevents)
            {
                if (Range != null)
                {
                    retValue.AllSubCalEvents = CalendarEventEntry.ActiveSubEvents.Where(obj => obj.StartToEnd.InterferringTimeLine(Range) != null).Select(obj => obj.ToSubCalEvent(CalendarEventEntry)).ToList();
                }
                else
                {
                    retValue.AllSubCalEvents = CalendarEventEntry.ActiveSubEvents.Select(obj => obj.ToSubCalEvent(CalendarEventEntry)).ToList();
                }

                if (CalendarEventEntry.PausedTimeLines.Count > 0)
                {
                    retValue.AllSubCalEvents = CalendarEventEntry.PausedTimeLines.Where(pausedImeline => pausedImeline.IsFinal && CalendarEventEntry.getSubEvent(pausedImeline.getSubEventId()) != null).Select(pausedImeline => pausedImeline.ToSubCalEvent(CalendarEventEntry)).Concat(retValue.AllSubCalEvents).ToList();
                }
            }
            retValue.IsLocked   = CalendarEventEntry.isLocked;
            retValue.UserLocked = CalendarEventEntry.userLocked;
            return(retValue);
        }