コード例 #1
0
        private void LoadAppointments(ObservableCollection<ServiceHost.Contracts.Linked.Models.AppointmentItem> appointments)
        {
            SessionInfo.Instance.Appointments.Clear();
            if (appointments.Count == 0)
                return;
            foreach (ServiceHost.Contracts.Linked.Models.AppointmentItem appointment in appointments) {
                AppAppointment appItem = new AppAppointment();
                //appItem.UniqueId = Guid.NewGuid().ToString();
                appItem.UniqueId = appointment.Id.ToString();
                appItem.RecordId = appointment.RecordId;
                appItem.RecordSource = appointment.SourceId;
                appItem.TypeId = appointment.TypeId;
                appItem.Start = appointment.Start;
                appItem.End = appointment.End;
                appItem.Importance = (Telerik.Windows.Controls.ScheduleView.Importance)appointment.Importance;
                appItem.IsAllDayEvent = appointment.IsAllDayEvent;
                appItem.Subject = appointment.Subject;
                appItem.Body = appointment.Body;
                appItem.UserId = (int)appointment.UserId;
                appItem.IsReadOnly = appointment.IsReadOnly;
                switch (appointment.TimeMarker) {
                    case "Busy":
                        appItem.TimeMarker = Telerik.Windows.Controls.TimeMarker.Busy;
                        break;
                    case "Free":
                        appItem.TimeMarker = Telerik.Windows.Controls.TimeMarker.Free;
                        break;
                    case "OutOfOffice":
                        appItem.TimeMarker = Telerik.Windows.Controls.TimeMarker.OutOfOffice;
                        break;
                    case "Tentative":
                        appItem.TimeMarker = Telerik.Windows.Controls.TimeMarker.Tentative;
                        break;
                    default:
                        break;
                }
                int? catid = appointment.CategoryId;
                if (catid.IsNotNull()) {
                    ScheduleCalendar sc = ListService.Instance.ScheduleCalendars.Select(x => x).Where(x => x.CalendarId == catid).FirstOrDefault().Clone();
                    if (sc != null) {
                        appItem.Category = new Category(sc.CalendarName, UILib.GetSolidColorBrushFromString(sc.ColorString));
                        appItem.Resources.Add(new Resource(appItem.Category.CategoryName, ResourceTypeCalendar.Name));
                    }
                }

                // Create Recurrence Rule
                if (!string.IsNullOrWhiteSpace(appointment.RecurrencePattern)) {
                    RecurrencePattern pattern;
                    RecurrencePatternHelper.TryParseRecurrencePattern(appointment.RecurrencePattern, out pattern);
                    appItem.RecurrenceRule = new RecurrenceRule(pattern);

                    foreach (AppointmentExceptionOccurrence aeo in appointment.AppointmentExceptionOccurrence) {
                        AppAppointment ai = null;
                        if (aeo.AppointmentItem != null) {
                            ai = new AppAppointment();
                            ai.UniqueId = aeo.AppointmentItem.Id.ToString();
                            ai.RecordId = aeo.AppointmentItem.RecordId;
                            ai.RecordSource = aeo.AppointmentItem.SourceId;
                            ai.TypeId = aeo.AppointmentItem.TypeId;
                            ai.Start = aeo.AppointmentItem.Start;
                            ai.End = aeo.AppointmentItem.End;
                            ai.Importance = (Telerik.Windows.Controls.ScheduleView.Importance)aeo.AppointmentItem.Importance;
                            ai.IsAllDayEvent = aeo.AppointmentItem.IsAllDayEvent;
                            ai.Subject = aeo.AppointmentItem.Subject;
                            ai.Body = aeo.AppointmentItem.Body;
                            ai.IsReadOnly = appItem.IsReadOnly;
                            ai.UserId = (int)aeo.AppointmentItem.UserId;
                            switch (aeo.AppointmentItem.TimeMarker) {
                                case "Busy":
                                    ai.TimeMarker = Telerik.Windows.Controls.TimeMarker.Busy;
                                    break;
                                case "Free":
                                    ai.TimeMarker = Telerik.Windows.Controls.TimeMarker.Free;
                                    break;
                                case "OutOfOffice":
                                    ai.TimeMarker = Telerik.Windows.Controls.TimeMarker.OutOfOffice;
                                    break;
                                case "Tentative":
                                    ai.TimeMarker = Telerik.Windows.Controls.TimeMarker.Tentative;
                                    break;
                                default:
                                    break;
                            }

                            int? catid1 = aeo.AppointmentItem.CategoryId;
                            if (catid1.IsNotNull()) {
                                ScheduleCalendar sce = ListService.Instance.ScheduleCalendars.Select(x => x).Where(x => x.CalendarId == catid1).FirstOrDefault().Clone();
                                if (sce != null) {
                                    ai.Category = new Category(sce.CalendarName, UILib.GetSolidColorBrushFromString(sce.ColorString));
                                    ai.Resources.Add(new Resource(ai.Category.CategoryName, ResourceTypeCalendar.Name));
                                }
                            }
                        }
                        appItem.RecurrenceRule.AddException(aeo.ExceptionDate, ai);
                    }
                }
                // Add Appointment to Resource (Calendar) used for grouping and filtering
                SessionInfo.Instance.Appointments.Add(appItem);
            }
        }
コード例 #2
0
 private bool FilterByCalendar(AppAppointment appointment)
 {
     return this.selectedCalendar == null || appointment.Resources.Contains(this.selectedCalendar);
 }
コード例 #3
0
        public SaveAppointmentRequest(AppAppointment item)
        {
            AppointmentItem newItem = new AppointmentItem();
            newItem.Id = Guid.Parse(item.UniqueId);
            newItem.Subject = item.Subject;
            newItem.Body = item.Body;
            newItem.IsNew = item.IsNew;
            newItem.IsDirty = item.IsDirty;
            newItem.IsAllDayEvent = item.IsAllDayEvent;
            newItem.Start = item.IsAllDayEvent ? DateEx.GetStartOfDay(item.Start) : item.Start;
            newItem.End = item.IsAllDayEvent ? DateEx.GetEndOfDay(item.End) : item.End;
            newItem.CategoryId = ListService.Instance.ScheduleCalendars.Select(x => x).Where(x => x.CalendarName == (item.Resources.Select(r => r).Where(r => r.ResourceType == "Calendar")).FirstOrDefault().ResourceName).FirstOrDefault().Clone().CalendarId;
            newItem.TypeId = item.TypeId;
            newItem.Importance = (int)item.Importance;
            if (item.TimeMarker != null)
                newItem.TimeMarker = item.TimeMarker.TimeMarkerName;
            newItem.RecordId = item.RecordId;
            newItem.SourceId = item.RecordSource;
            newItem.UserId = item.UserId;
            if (item.RecurrenceRule.IsNotNull()) {
                newItem.RecurrencePattern = RecurrencePatternHelper.RecurrencePatternToString(item.RecurrenceRule.Pattern);
            }
            newItem.RecurrencePatternExt = item.RecurrenceRuleExt;
            if (item.RecurrenceRule.IsNotNull()) {
                foreach (IExceptionOccurrence itemEx in item.RecurrenceRule.Exceptions) {
                    AppointmentExceptionOccurrence newItemExceptionOccurrence = new AppointmentExceptionOccurrence();
                    Debug.WriteLine("ExceptionDate");
                    Debug.WriteLine(itemEx.ExceptionDate);
                    newItemExceptionOccurrence.Id = Guid.NewGuid();
                    newItemExceptionOccurrence.ParentId = Guid.Parse(item.UniqueId);
                    newItemExceptionOccurrence.ExceptionDate = itemEx.ExceptionDate;
                    if ((itemEx.Appointment).IsNotNull()) {
                        AppAppointment appEx = (AppAppointment)itemEx.Appointment;
                        AppointmentItem newExApp = new AppointmentItem();
                        newItemExceptionOccurrence.AppointmentId = Guid.Parse(appEx.UniqueId);
                        newExApp.Id = Guid.Parse(appEx.UniqueId);
                        newExApp.ParentId = newItem.Id;
                        newExApp.IsNew = true;
                        newExApp.IsDirty = appEx.IsDirty;
                        newExApp.Subject = appEx.Subject;
                        newExApp.Body = appEx.Body;
                        newItem.IsAllDayEvent = appEx.IsAllDayEvent;
                        newExApp.Start = appEx.IsAllDayEvent ? DateEx.GetStartOfDay(appEx.Start) : appEx.Start;
                        newExApp.End = appEx.IsAllDayEvent ? DateEx.GetEndOfDay(appEx.End) : appEx.End;
                        newExApp.CategoryId = ListService.Instance.ScheduleCalendars.Select(x => x).Where(x => x.CalendarName == (appEx.Resources.Select(r => r).Where(r => r.ResourceType == "Calendar")).FirstOrDefault().ResourceName).FirstOrDefault().Clone().CalendarId;
                        newExApp.TypeId = appEx.TypeId;
                        newExApp.UserId = appEx.UserId;

                        newExApp.Importance = (int)appEx.Importance;
                        if (appEx.TimeMarker != null)
                            newExApp.TimeMarker = appEx.TimeMarker.TimeMarkerName;
                        newExApp.RecordId = appEx.RecordId;
                        newExApp.SourceId = appEx.RecordSource;

                        // Dont think this is set due to recurrences not having exceptions.
                        if (appEx.RecurrenceRule.IsNotNull()) {
                            newExApp.RecurrencePattern = RecurrencePatternHelper.RecurrencePatternToString(appEx.RecurrenceRule.Pattern);
                            newExApp.RecurrencePatternExt = appEx.RecurrenceRuleExt;
                        }
                        newItemExceptionOccurrence.AppointmentItem = newExApp;
                    }
                    // Add Exception Appointment to Collection of Exceptions
                    newItem.AppointmentExceptionOccurrence.Add(newItemExceptionOccurrence);
                }
            }
            this.item = newItem;
        }
コード例 #4
0
        private string ExportToString(AppAppointment exportApp)
        {
            ObservableCollection<AppAppointment> ap = new ObservableCollection<AppAppointment>();
            ap.Add(exportApp);
            StringBuilder builder = new StringBuilder();
            using (TextWriter writer = new StringWriter(builder)) {
                AppointmentCalendarExporter exporter = new AppointmentCalendarExporter();
                exporter.Export(ap.OfType<IAppointment>(), writer);
            }

            return builder.ToString();
        }
コード例 #5
0
ファイル: AppAppointment.cs プロジェクト: jserna-arl/LIMSv2
 public override IAppointment Copy()
 {
     var appAppointment = new AppAppointment();
     appAppointment.CopyFrom(this);
     return appAppointment;
 }