示例#1
0
        /// <summary>
        /// Преобразует иерархию объектов SyncTranferData в Outlook Appointment
        /// </summary>
        /// <param name="transferData">The transfer data.</param>
        /// <param name="appItem">The app item.</param>
        /// <returns></returns>
        private OutlookAppointment TransferData2AppointmentItem(SyncTransferData transferData, OutlookAppointment appItem)
        {
            ITransferDataSerializable serializer = new AppointmentSerializer(appItem);

            serializer.Deserialize(transferData);
            foreach (SyncTransferData child in transferData.Childrens)
            {
                if (child.SyncDataName == RecurrencePatternTransferData.DataName)
                {
                    OutlookRecurrencePattern rPattern = appItem.GetRecurrencePattern();
                    serializer = new RecurrencePatternSerializer(rPattern);
                    if (serializer != null)
                    {
                        serializer.Deserialize(child);
                    }
                }
                else if (child.SyncDataName == RecipientTransferData.DataName)
                {
                    serializer = new RecipientSerializer();
                    string recipientName = (string)serializer.Deserialize(child);
                    if (string.IsNullOrEmpty(recipientName))
                    {
                        OutlookRecipient recipient = appItem.AddRecipient(recipientName);
                    }
                }
            }

            //Сохранем outlook appointment
            appItem.Save();
            //Переносим exception
            if (appItem.IsRecurring)
            {
                OutlookRecurrencePattern rPattern = appItem.GetRecurrencePattern();
                foreach (SyncTransferData child in transferData.Childrens)
                {
                    AppointmentTransferData exception = child as AppointmentTransferData;
                    if (exception != null)
                    {
                        OutlookAppointment appException = rPattern.GetOccurrence(exception.RecurrenceId);
                        TransferData2AppointmentItem(child, appException);
                        if (exception.DeletedException)
                        {
                            appException.Delete();
                        }
                    }
                }
            }
            return(appItem);
        }
示例#2
0
        /// <summary>
        /// Преобразует Outlook appointment  в иерархию объектов transferData
        /// </summary>
        /// <param name="appItem">The app item.</param>
        /// <returns></returns>
        private SyncTransferData Appointment2TransferData(OutlookAppointment appItem)
        {
            SyncTransferData          retVal     = null;
            ITransferDataSerializable serializer = new AppointmentSerializer(appItem);

            retVal = serializer.Serialize();
            if (appItem.IsRecurring)
            {
                OutlookRecurrencePattern rPattern = appItem.GetRecurrencePattern();
                serializer = new RecurrencePatternSerializer(rPattern);
                retVal.Childrens.Add(serializer.Serialize());
                serializer = null;
                foreach (OutlookException exception in rPattern.Exceptions)
                {
                    AppointmentTransferData transferException = new AppointmentTransferData();
                    if (!exception.Deleted)
                    {
                        OutlookAppointment appointmentException = exception.AppointmentItem;
                        serializer        = new AppointmentSerializer(appointmentException);
                        transferException = (AppointmentTransferData)serializer.Serialize();
                        //exception recipient
                        foreach (OutlookRecipient exceptionRecipient in appointmentException.Recipients)
                        {
                            serializer = new RecipientSerializer(exceptionRecipient);
                            transferException.Childrens.Add(serializer.Serialize());
                        }
                    }
                    transferException.DeletedException = exception.Deleted;
                    transferException.RecurrenceId     = exception.OriginalDate;

                    retVal.Childrens.Add(transferException);
                }
            }
            //appointment recipient
            foreach (OutlookRecipient recipient in appItem.Recipients)
            {
                serializer = new RecipientSerializer(recipient);
                retVal.Childrens.Add(serializer.Serialize());
            }

            //Инициализируем дополнительные поля (LastModified и Uri)
            retVal.LastModified = (ulong)appItem.LastModificationTime.ToUniversalTime().Ticks;
            retVal.Uri          = appItem.EntryID;

            return(retVal);
        }
示例#3
0
 public RecurrencePatternSerializer(OutlookRecurrencePattern rPattern)
 {
     _rPattern = rPattern;
 }