Exemplo n.º 1
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;
        }
Exemplo n.º 2
0
 public IAsyncResult BeginSaveAppointment(AppointmentItem item, Identification identification, AsyncCallback callback, object state)
 {
     logger.Log(LogLevel.Trace, AppLib.GetCaller(logger));
     if (AppLib.VerifyToken(identification.Token) <= 0) {
         throw new FaultException<ServiceFault>(new ServiceFault("Invalid Authentication", "Authorization"), new FaultReason("Unauthorized"));
     }
     var task = Task<int>.Factory.StartNew(process => DoSaveAppointment(identification, item), state);
     return task.ContinueWith(res => callback(task));
 }
Exemplo n.º 3
0
 public SaveAppointmentRequest(AppointmentItem item)
 {
     this.item = item;
 }
Exemplo n.º 4
0
 public int DoSaveAppointment(Identification identification, AppointmentItem item)
 {
     logger.Log(LogLevel.Trace, AppLib.GetCaller(logger));
     using (SystemDAO dao = new SystemDAO()) {
         return dao.SaveAppointmentRecord(item, identification.Token, identification.UserId);
     }
 }