示例#1
0
        public Event ConvertMyEventToGoogle(SynchronEvent synchronEvent)
        {
            var eventDateTime = new EventDateTime
            {
                DateTime = synchronEvent.GetStart(),
                TimeZone = "Europe/Moscow"
            };
            var eventDateTimeEnd = new EventDateTime
            {
                DateTime = synchronEvent.GetFinish(),
                TimeZone = "Europe/Moscow"
            };
            var googleEvent = new Event
            {
                Location    = synchronEvent.GetLocation(),
                Summary     = synchronEvent.GetSubject(),
                Start       = eventDateTime,
                End         = eventDateTimeEnd,
                Description = synchronEvent.GetDescription(),
                ColorId     = "11",
            };

            if (synchronEvent.GetAllDay())
            {
                googleEvent.Start.DateTime    = null;
                googleEvent.Start.DateTimeRaw = null;
                googleEvent.Start.Date        = synchronEvent.GetStart().Year.ToString() + "-" + "0" + synchronEvent.GetStart().Month.ToString() + "-" + synchronEvent.GetStart().Day.ToString();
                googleEvent.End.DateTime      = null;
                googleEvent.End.DateTimeRaw   = null;
                googleEvent.End.Date          = synchronEvent.GetStart().Year.ToString() + "-" + "0" + synchronEvent.GetStart().Month.ToString() + "-" + synchronEvent.GetStart().AddDays(1).Day.ToString();
            }
            if (synchronEvent.GetSource() == _outlook)
            {
                googleEvent.ExtendedProperties = new Event.ExtendedPropertiesData
                {
                    Shared = new BiDictionary <string, string> {
                        { _outlook, synchronEvent.GetId() }
                    }
                };
            }

            EventAttendee[] attendees       = new EventAttendee[synchronEvent.GetParticipants().Count];
            List <string>   AllParticipants = synchronEvent.GetParticipants();

            for (int i = 0; i < AllParticipants.Count; ++i)
            {
                var evAt = new EventAttendee
                {
                    Email          = AllParticipants[i],
                    ResponseStatus = "needsAction"
                };
                attendees[i] = evAt;
            }
            googleEvent.Attendees = attendees;
            //googleEvent.Attendees.Add(evAt);
            return(googleEvent);
        }
示例#2
0
        public bool CompareOnEqual(SynchronEvent compareEvent)
        {
            bool result = true;

            result = this.GetId() == compareEvent.GetId() && this.GetLocation() == compareEvent.GetLocation() && this.GetSubject() == compareEvent.GetSubject() &&
                     this.GetStart() == compareEvent.GetStart() && this.GetFinish() == compareEvent.GetFinish() && this.GetDescription() == compareEvent.GetDescription();
            result &= this.GetParticipants().Count == compareEvent.GetParticipants().Count;
            for (int i = 0; i < companions.Count && result; ++i)
            {
                result &= companions[i] == compareEvent.companions[i];
            }
            return(result);
        }
示例#3
0
        public Microsoft.Office.Interop.Outlook.AppointmentItem ConvertSynchronToOutlook(SynchronEvent synchronEvent)
        {
            var outlookApp = new outlook2.Application();

            var result = (outlook2.AppointmentItem)outlookApp.CreateItem(outlook2.OlItemType.olAppointmentItem);

            result.Start       = synchronEvent.GetStart();
            result.End         = synchronEvent.GetFinish();
            result.Subject     = synchronEvent.GetSubject();
            result.Location    = synchronEvent.GetLocation();
            result.Body        = synchronEvent.GetDescription();
            result.AllDayEvent = synchronEvent.GetAllDay();

            string        buf             = "";
            List <string> AllParticipants = synchronEvent.GetParticipants();

            for (int i = 0; i < AllParticipants.Count; ++i)
            {
                if (i + 1 < AllParticipants.Count)
                {
                    buf = buf + AllParticipants[i] + "; ";
                }
                else
                {
                    buf = buf + AllParticipants[i];
                }
            }
            result.RequiredAttendees = buf;
            result.ResponseRequested = true;
            if (synchronEvent.GetSource() == _google)
            {
                result.Mileage    = synchronEvent.GetId();
                result.Categories = "Orange Category";
            }
            return(result);
        }