/// <summary>
        /// Function: Convert ScheduleRecurrenceType to PWRecurrenceInfo
        /// Author  : Jerry Xu
        /// Date    : 2008-12-6
        /// </summary>
        /// <param name="recurrence">PWRecurrenceInfo</param>
        /// <returns>ScheduleRecurrenceType</returns>
        private ScheduleRecurrenceType ConvertRecurrence(PWRecurrenceInfo recurrence)
        {
            ScheduleRecurrenceType item = new ScheduleRecurrenceType();

            //TODO:
            if (recurrence.Type == PWRecurrenceType.Daily)
            {
                item.DailyPattern = recurrence.Periodicity;
            }
            if (recurrence.Type == PWRecurrenceType.Weekly)
            {
                item.WeeklyPattern = ConvertWeeklyPattern(recurrence);
            }
            if (recurrence.Range == PWRecurrenceRange.NoEndDate)
            {
                item.NoEndDateRange = true;
            }
            if (recurrence.Range == PWRecurrenceRange.EndByDate)
            {
                item.EndByDateRange = recurrence.End.ToString("yyyy-MM-dd");
            }
            if (recurrence.Range == PWRecurrenceRange.OccurrenceCount)
            {
                item.EndAfterByOccurenceRange = recurrence.OccurrenceCount;
            }

            //item.Pattern = null;
            //item.Range = recurrence.Range;

            return(item);
        }
        /// Function: Convert PWRecurrenceInfo... to WeeklyRecurrence
        /// Author  : Jerry Xu
        /// Date    : 2008-12-6
        /// </summary>
        /// <param name="recurrence">PWRecurrenceInfo</param>
        /// <returns>WeeklyRecurrence</returns>
        private WeeklyRecurrence ConvertWeeklyPattern(PWRecurrenceInfo recurrence)
        {
            WeeklyRecurrence item = new WeeklyRecurrence();
            //if(recurrence.w

            int target = 0;

            if ((recurrence.WeekDays & PWWeekDays.Monday) == PWWeekDays.Monday)
            {
                target = (int)WeeklyChoiceType.M;
            }
            if ((recurrence.WeekDays & PWWeekDays.Tuesday) == PWWeekDays.Tuesday)
            {
                target = target | (int)WeeklyChoiceType.T;
            }
            if ((recurrence.WeekDays & PWWeekDays.Wednesday) == PWWeekDays.Wednesday)
            {
                target = target | (int)WeeklyChoiceType.W;
            }
            if ((recurrence.WeekDays & PWWeekDays.Thursday) == PWWeekDays.Thursday)
            {
                target = target | (int)WeeklyChoiceType.TH;
            }
            if ((recurrence.WeekDays & PWWeekDays.Friday) == PWWeekDays.Friday)
            {
                target = target | (int)WeeklyChoiceType.F;
            }
            if ((recurrence.WeekDays & PWWeekDays.Saturday) == PWWeekDays.Saturday)
            {
                target = target | (int)WeeklyChoiceType.S;
            }
            if ((recurrence.WeekDays & PWWeekDays.Sunday) == PWWeekDays.Sunday)
            {
                target = target | (int)WeeklyChoiceType.SU;
            }
            if (target != 0)
            {
                item.DaysChoice = (WeeklyChoiceType)target;
            }
            //item.DaysChoice = (WeeklyChoiceType)Enum.Parse(typeof(WeeklyChoiceType), ((int)recurrence.WeekDays).ToString());
            item.RecurCycle = recurrence.Periodicity;
            return(item);
        }
Beispiel #3
0
        /// <summary>
        /// convert Appointment to AppointmentInfo
        /// </summary>
        /// <param name="appointment"></param>
        /// <returns></returns>
        public AppointmentInfo Convert(Appointment appointment)
        {
            AppointmentInfo _proxy;

            _appointment = appointment;

            if (appointment == null)
            {
                return(null);
            }

            _proxy                 = new AppointmentInfo();
            _proxy.Subject         = appointment.Subject;
            _proxy.AllDay          = appointment.AllDay;
            _proxy.AppointmentType = (PWAppointmentType)appointment.Type;
            _proxy.Description     = appointment.Description;
            _proxy.HasExceptions   = appointment.HasExceptions;
            _proxy.IsException     = appointment.IsException;
            _proxy.Duration        = appointment.Duration;
            _proxy.End             = appointment.End;
            _proxy.HasReminder     = appointment.HasReminder;
            _proxy.LabelId         = appointment.LabelId;
            _proxy.Location        = appointment.Location;
            //_proxy.ResourceId = appointment.ResourceId;
            _proxy.Start    = appointment.Start;
            _proxy.StatusId = appointment.StatusId;
            if (appointment.CustomFields["Only"] == null)
            {
                appointment.CustomFields["Only"] = appointment.Subject
                                                   + appointment.Description
                                                   + appointment.Start.ToString()
                                                   + appointment.End.ToString();
            }
            _proxy.CustomFilds = appointment.Subject
                                 + appointment.Description
                                 + appointment.Start.ToString()
                                 + appointment.End.ToString();
            if (appointment.RecurrenceInfo != null)
            {
                PWRecurrenceInfo recurrence = new PWRecurrenceInfo();
                recurrence.AllDay          = appointment.RecurrenceInfo.AllDay;
                recurrence.DayNumber       = appointment.RecurrenceInfo.DayNumber;
                recurrence.Duration        = appointment.RecurrenceInfo.Duration;
                recurrence.End             = appointment.RecurrenceInfo.End;
                recurrence.Month           = appointment.RecurrenceInfo.Month;
                recurrence.OccurrenceCount = appointment.RecurrenceInfo.OccurrenceCount;
                recurrence.Periodicity     = appointment.RecurrenceInfo.Periodicity;
                recurrence.Range           = (PWRecurrenceRange)appointment.RecurrenceInfo.Range;
                recurrence.Start           = appointment.RecurrenceInfo.Start;
                recurrence.Type            = (PWRecurrenceType)appointment.RecurrenceInfo.Type;
                recurrence.WeekDays        = (PWWeekDays)appointment.RecurrenceInfo.WeekDays;
                recurrence.WeekOfMonth     = (PWWeekOfMonth)appointment.RecurrenceInfo.WeekOfMonth;

                _proxy.RecurrenceInfo = recurrence;
            }


            _proxy.Target = GetLibrary(appointment);

            _proxy.MemeberPropertyChanged += this.OnProxyPropertyChanged;
            if (_proxy.RecurrenceInfo != null)
            {
                _proxy.RecurrenceInfo.PropertyChanged += this.OnProxyPropertyChanged;
            }

            return(_proxy);
        }