Beispiel #1
0
        private static SyncTransferData CreateTransferData(EntityObject entityObject)
        {
            SyncTransferData retVal = null;
            string           transferName;

            if (_entity2transfer.TryGetValue(entityObject.MetaClassName, out transferName))
            {
                switch (transferName)
                {
                case AppointmentTransferData.DataName:
                    retVal = new AppointmentTransferData();
                    break;

                case RecurrencePatternTransferData.DataName:
                    retVal = new RecurrencePatternTransferData();
                    break;

                case RecipientTransferData.DataName:
                    retVal = new RecipientTransferData();
                    break;
                }
                if (retVal != null)
                {
                    CopyProperies(entityObject, retVal);
                }
            }

            return(retVal);
        }
Beispiel #2
0
        public void AddAppointment(AppointmentTransferData newAppointment)
        {
            appointments.Add(newAppointment);

            AppointmentChanged?.Invoke(this, new RawAppointmentChangedEventArgs(newAppointment, ChangeAction.Added));
            CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add));
        }
 public DisplayAppointmentData(AppointmentTransferData appointmentRawData, string medicalPracticeName)
 {
     Description         = appointmentRawData.Description;
     Day                 = appointmentRawData.Day;
     TimeSpan            = $"({appointmentRawData.StartTime.ToStringMinutesAndHoursOnly()} - {appointmentRawData.EndTime.ToStringMinutesAndHoursOnly()})";
     MedicalPracticeName = medicalPracticeName;
     AppointmentRawData  = appointmentRawData;
 }
Beispiel #4
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);
        }
Beispiel #5
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);
        }
Beispiel #6
0
        public void AddAppointment(Guid patientId, string description,
                                   Time startTime, Time endTime, Date day,
                                   Guid therapyPlaceId, Guid labelId,
                                   Guid appointmentId, Guid medicalPracticeId)
        {
            var newAppointment = new AppointmentTransferData(patientId,
                                                             description,
                                                             day,
                                                             startTime,
                                                             endTime,
                                                             therapyPlaceId,
                                                             appointmentId,
                                                             medicalPracticeId,
                                                             labelId);

            ObservableAppointments.AddAppointment(newAppointment);
        }
Beispiel #7
0
        public void ReplaceAppointment(AppointmentTransferData updatedAppointment)
        {
            var appointmentToRemove = GetAppointmentById(updatedAppointment.Id);

            appointments.Remove(appointmentToRemove);

            appointments.Add(updatedAppointment);

            AppointmentChanged?.Invoke(this, new RawAppointmentChangedEventArgs(updatedAppointment, ChangeAction.Modified));
            CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Replace,
                                                                                 new List <AppointmentTransferData> {
                appointmentToRemove
            },
                                                                                 new List <AppointmentTransferData> {
                updatedAppointment
            }));
        }
Beispiel #8
0
        private void AddAppointment(AppointmentTransferData newAppointmentData)
        {
            medicalPracticeRepository.RequestMedicalPractice(
                practice =>
            {
                Application.Current.Dispatcher.Invoke(() =>
                {
                    DisplayedAppointments.Add(new DisplayAppointmentData(newAppointmentData, practice.Name));
                    DisplayedAppointments.Sort(new AppointmentSorter());

                    CheckDisplayedAppointmentCount();
                });
            },
                newAppointmentData.MedicalPracticeId,
                newAppointmentData.Day,
                errorCallBack
                );
        }
Beispiel #9
0
        public void ReplaceAppointment(string newDescription, Date newDate,
                                       Time newStartTime, Time newEndTime,
                                       Guid newTherapyPlaceId, Guid newLabelId,
                                       Guid originalAppointmendId)
        {
            var appointmentToBeUpdated = ObservableAppointments.GetAppointmentById(originalAppointmendId);

            var updatedAppointment = new AppointmentTransferData(appointmentToBeUpdated.PatientId,
                                                                 newDescription,
                                                                 newDate,
                                                                 newStartTime,
                                                                 newEndTime,
                                                                 newTherapyPlaceId,
                                                                 originalAppointmendId,
                                                                 appointmentToBeUpdated.MedicalPracticeId,
                                                                 newLabelId);

            ObservableAppointments.ReplaceAppointment(updatedAppointment);
        }
 public RawAppointmentChangedEventArgs(AppointmentTransferData appointment, ChangeAction changeAction)
 {
     Appointment  = appointment;
     ChangeAction = changeAction;
 }
Beispiel #11
0
        public virtual SyncTransferData Serialize()
        {
            AppointmentTransferData appointment = new AppointmentTransferData();

            //Calculated field
            if (InnerAppointment.IsRecurring)
            {
                appointment.IsRecurring = true;
            }
            //Copy exist iCal type property to entity object
            //CATEGORIES
            if (InnerAppointment.Categories != null)
            {
                appointment.Categories = InnerAppointment.Categories;
            }
            //PRIORITY
            //TODO: check int value
            switch (InnerAppointment.Importance)
            {
            case Outlook.OlImportance.olImportanceLow:
                appointment.Importance = (int)eImportance.Low;
                break;

            case Outlook.OlImportance.olImportanceNormal:
                appointment.Importance = (int)eImportance.Normal;
                break;

            case Outlook.OlImportance.olImportanceHigh:
                appointment.Importance = (int)eImportance.High;
                break;
            }

            //CLASS
            //TDOD: check int value
            switch (InnerAppointment.Sensitivity)
            {
            case Outlook.OlSensitivity.olConfidential:
                appointment.Sensitivy = (int)eSesitivity.Confidential;
                break;

            case Outlook.OlSensitivity.olNormal:
                appointment.Sensitivy = (int)eSesitivity.Normal;
                break;

            case Outlook.OlSensitivity.olPersonal:
                appointment.Sensitivy = (int)eSesitivity.Personal;
                break;

            case Outlook.OlSensitivity.olPrivate:
                appointment.Sensitivy = (int)eSesitivity.Private;
                break;
            }
            //SUMMARY
            appointment.Subject = InnerAppointment.Subject;

            //LOCATION
            appointment.Location = InnerAppointment.Location;

            //DESCRIPTION
            appointment.Body = InnerAppointment.Body;

            //Type properties serialized always in local time
            //DTSTART
            appointment.Start = InnerAppointment.Start;
            //DTEND
            appointment.End = InnerAppointment.End;

            //URI
            appointment.Uri          = InnerAppointment.EntryID;
            appointment.LastModified = (ulong)InnerAppointment.LastModificationTime.Ticks;
            //Last modified

            return(appointment);
        }
Beispiel #12
0
        public object Deserialize(SyncTransferData data)
        {
            if (data == null)
            {
                throw new ArgumentNullException("data");
            }

            AppointmentTransferData appData = data as AppointmentTransferData;

            if (appData == null)
            {
                throw new NullReferenceException("appData");
            }

            bool isException = appData.RecurrenceId != DateTime.MinValue;

            object propVal = data.Properties[AppointmentTransferData.FieldImportance];

            if (propVal != null)
            {
                eImportance importance = (eImportance)(int)propVal;
                switch (importance)
                {
                case eImportance.Low:
                    InnerAppointment.Importance = Outlook.OlImportance.olImportanceLow;
                    break;

                case eImportance.Normal:
                    InnerAppointment.Importance = Outlook.OlImportance.olImportanceNormal;
                    break;

                case eImportance.High:
                    InnerAppointment.Importance = Outlook.OlImportance.olImportanceHigh;
                    break;
                }
            }

            InnerAppointment.Start    = (DateTime)data.Properties[AppointmentTransferData.FieldStart];
            InnerAppointment.End      = (DateTime)data.Properties[AppointmentTransferData.FieldEnd];
            InnerAppointment.Subject  = (string)data.Properties[AppointmentTransferData.FieldSubject];
            InnerAppointment.Location = (string)data.Properties[AppointmentTransferData.FieldLocation];
            InnerAppointment.Body     = (string)data.Properties[AppointmentTransferData.FieldBody];

            //case "DTSTART.TZID":
            //case "DTEND.TZID":

            //Для exception данный свойства модифицировать нельзя
            if (!isException)
            {
                InnerAppointment.Categories = (string)data.Properties[AppointmentTransferData.FieldCategories];

                propVal = data.Properties[AppointmentTransferData.FieldSensitivy];
                if (propVal != null)
                {
                    eSesitivity sensitivity = (eSesitivity)(int)data.Properties[AppointmentTransferData.FieldSensitivy];
                    switch (sensitivity)
                    {
                    case eSesitivity.Confidential:
                        InnerAppointment.Sensitivity = Outlook.OlSensitivity.olConfidential;
                        break;

                    case eSesitivity.Normal:
                        InnerAppointment.Sensitivity = Outlook.OlSensitivity.olNormal;
                        break;

                    case eSesitivity.Personal:
                        InnerAppointment.Sensitivity = Outlook.OlSensitivity.olPersonal;
                        break;

                    case eSesitivity.Private:
                        InnerAppointment.Sensitivity = Outlook.OlSensitivity.olPrivate;
                        break;
                    }
                }
            }
            return(InnerAppointment);
        }