Example #1
0
        private bool ShouldPreserveLocalExceptions(CalendarItem calendarItem)
        {
            InternalRecurrence recurrenceFromItem = CalendarItem.GetRecurrenceFromItem(this);
            Recurrence         recurrence         = null;

            try
            {
                recurrence = calendarItem.Recurrence;
            }
            catch (RecurrenceFormatException ex)
            {
                ExTraceGlobals.MeetingMessageTracer.Information <string, GlobalObjectId>((long)this.GetHashCode(), "Storage.MeetingRequest.ShouldPreserveLocalExceptions encountered a recurrence format exception ({0}). Local exceptions will not be preserved: GOID={1}", ex.Message, this.GlobalObjectId);
            }
            catch (CorruptDataException ex2)
            {
                ExTraceGlobals.MeetingMessageTracer.Information <string, GlobalObjectId>((long)this.GetHashCode(), "Storage.MeetingRequest.ShouldPreserveLocalExceptions encountered a corrupt data exception ({0}). Local exceptions will not be preserved: GOID={1}", ex2.Message, this.GlobalObjectId);
            }
            return(recurrence != null && recurrenceFromItem != null && recurrence.Equals(recurrenceFromItem) && MeetingRequest.ArePropsEqual(calendarItem.TryGetProperty(InternalSchema.StartTime), base.TryGetProperty(InternalSchema.StartTime)) && MeetingRequest.ArePropsEqual(calendarItem.TryGetProperty(InternalSchema.EndTime), base.TryGetProperty(InternalSchema.EndTime)));
        }
Example #2
0
        protected override ConsistencyCheckResult DetectInconsistencies()
        {
            RoleType               checkingRole           = (RoleType)(-1);
            UserObject             checkingUser           = null;
            ConsistencyCheckResult consistencyCheckResult = ConsistencyCheckResult.CreateInstance(base.Type, base.Description);

            try
            {
                Recurrence recurrence  = null;
                Recurrence recurrence2 = null;
                if (base.Context.OrganizerItem != null && base.Context.OrganizerItem is CalendarItem)
                {
                    checkingRole = RoleType.Organizer;
                    checkingUser = base.Context.Organizer;
                    recurrence   = ((CalendarItem)base.Context.OrganizerItem).Recurrence;
                }
                if (base.Context.AttendeeItem != null && base.Context.AttendeeItem is CalendarItem)
                {
                    checkingRole = RoleType.Attendee;
                    checkingUser = base.Context.Attendee;
                    recurrence2  = ((CalendarItem)base.Context.AttendeeItem).Recurrence;
                }
                consistencyCheckResult.ComparedRecurrenceBlobs  = false;
                consistencyCheckResult.RecurrenceBlobComparison = true;
                if (recurrence != null)
                {
                    checkingRole = (RoleType)(-1);
                    checkingUser = null;
                    if (recurrence2 != null)
                    {
                        consistencyCheckResult.ComparedRecurrenceBlobs  = true;
                        consistencyCheckResult.RecurrenceBlobComparison = recurrence.Equals(recurrence2);
                        checkingRole = RoleType.Attendee;
                        checkingUser = base.Context.Attendee;
                        RecurrenceInfo recurrenceInfo = recurrence2.GetRecurrenceInfo();
                        this.DetectRecurrenceInfoInconsistencies(recurrenceInfo, consistencyCheckResult);
                        base.Context.AttendeeRecurrence = recurrenceInfo;
                    }
                    else if (base.Context.AttendeeItem != null)
                    {
                        this.FailCheck(consistencyCheckResult, "Attendee's missing the recurrence in a recurring meeting.", RecurrenceInconsistencyType.MissingRecurrence, base.Context.OrganizerItem.StartTime);
                    }
                    checkingRole = RoleType.Organizer;
                    checkingUser = base.Context.Organizer;
                    RecurrenceInfo recurrenceInfo2 = recurrence.GetRecurrenceInfo();
                    this.DetectRecurrenceInfoInconsistencies(recurrenceInfo2, consistencyCheckResult);
                    base.Context.OrganizerRecurrence = recurrenceInfo2;
                }
                else if (recurrence2 != null)
                {
                    if (base.Context.OrganizerItem != null)
                    {
                        this.FailCheck(consistencyCheckResult, "A single meeting is recurring in the attendee's calendar.", RecurrenceInconsistencyType.ExtraRecurrence, base.Context.OrganizerItem.StartTime);
                    }
                    checkingRole = RoleType.Attendee;
                    checkingUser = base.Context.Attendee;
                    RecurrenceInfo recurrenceInfo3 = recurrence2.GetRecurrenceInfo();
                    this.DetectRecurrenceInfoInconsistencies(recurrenceInfo3, consistencyCheckResult);
                    base.Context.AttendeeRecurrence = recurrenceInfo3;
                }
            }
            catch (RecurrenceFormatException exception)
            {
                this.FailCheck(consistencyCheckResult, checkingRole, checkingUser, exception);
            }
            catch (StorageTransientException exception2)
            {
                this.RegisterStorageException(consistencyCheckResult, exception2);
            }
            catch (StoragePermanentException exception3)
            {
                this.RegisterStorageException(consistencyCheckResult, exception3);
            }
            return(consistencyCheckResult);
        }
        public void Save()
        {
            ExTraceGlobals.TasksCallTracer.TraceDebug((long)this.GetHashCode(), "EditTaskEventHandler.Save");
            bool       flag       = base.IsParameterSet("Id");
            bool       flag2      = false;
            bool       flag3      = false;
            ExDateTime?exDateTime = null;
            Task       task       = this.GetTask(new PropertyDefinition[0]);

            try
            {
                if (!base.IsParameterSet("Id"))
                {
                    OwaStoreObjectId owaStoreObjectId = (OwaStoreObjectId)base.GetParameter("fId");
                    if (owaStoreObjectId != null && owaStoreObjectId.IsOtherMailbox)
                    {
                        ADSessionSettings adSettings        = Utilities.CreateScopedADSessionSettings(base.UserContext.LogonIdentity.DomainName);
                        ExchangePrincipal exchangePrincipal = ExchangePrincipal.FromLegacyDN(adSettings, owaStoreObjectId.MailboxOwnerLegacyDN);
                        task[TaskSchema.TaskOwner] = exchangePrincipal.MailboxInfo.DisplayName;
                    }
                    else
                    {
                        task[TaskSchema.TaskOwner] = base.UserContext.ExchangePrincipal.MailboxInfo.DisplayName;
                    }
                }
                if (base.IsParameterSet("subj"))
                {
                    task.Subject = (string)base.GetParameter("subj");
                }
                if (base.IsParameterSet("sd"))
                {
                    task.StartDate = this.GetDateValue("sd");
                }
                if (base.IsParameterSet("dd"))
                {
                    task.DueDate = this.GetDateValue("dd");
                }
                if (base.IsParameterSet("dc"))
                {
                    exDateTime = this.GetDateValue("dc");
                    if (exDateTime != null)
                    {
                        flag2 = true;
                    }
                }
                if (base.IsParameterSet("st"))
                {
                    TaskStatus taskStatus = (TaskStatus)base.GetParameter("st");
                    if (taskStatus == TaskStatus.Completed)
                    {
                        flag2 = true;
                    }
                    else
                    {
                        TaskUtilities.SetIncomplete(task, taskStatus);
                    }
                }
                if (base.IsParameterSet("pri"))
                {
                    task[ItemSchema.Importance] = (Importance)base.GetParameter("pri");
                }
                if (base.IsParameterSet("pc"))
                {
                    double num = (double)((int)base.GetParameter("pc")) / 100.0;
                    if (!flag2 || num != 1.0)
                    {
                        if (num >= 0.0 && num < 1.0)
                        {
                            task.PercentComplete = num;
                        }
                        else if (num == 1.0)
                        {
                            flag2 = true;
                        }
                    }
                }
                if (base.IsParameterSet("rs"))
                {
                    bool flag4 = (bool)base.GetParameter("rs");
                    task[ItemSchema.ReminderIsSet] = flag4;
                    if (flag4 && base.IsParameterSet("rd"))
                    {
                        ExDateTime?dateValue = this.GetDateValue("rd");
                        if (dateValue != null)
                        {
                            task[ItemSchema.ReminderDueBy] = dateValue.Value;
                        }
                    }
                }
                if (base.IsParameterSet("ps"))
                {
                    task[ItemSchema.Sensitivity] = (((bool)base.GetParameter("ps")) ? Sensitivity.Private : Sensitivity.Normal);
                }
                if (base.IsParameterSet("tw"))
                {
                    int num2 = (int)base.GetParameter("tw");
                    if (num2 < 0 || num2 > 1525252319)
                    {
                        throw new OwaInvalidRequestException(LocalizedStrings.GetNonEncoded(-1310086288));
                    }
                    task[TaskSchema.TotalWork] = num2;
                }
                if (base.IsParameterSet("aw"))
                {
                    int num3 = (int)base.GetParameter("aw");
                    if (num3 < 0 || num3 > 1525252319)
                    {
                        throw new OwaInvalidRequestException(LocalizedStrings.GetNonEncoded(210380742));
                    }
                    task[TaskSchema.ActualWork] = num3;
                }
                if (base.IsParameterSet("mi"))
                {
                    task[TaskSchema.Mileage] = (string)base.GetParameter("mi");
                }
                if (base.IsParameterSet("bl"))
                {
                    task[TaskSchema.BillingInformation] = (string)base.GetParameter("bl");
                }
                if (base.IsParameterSet("co"))
                {
                    string   text = (string)base.GetParameter("co");
                    string[] value;
                    if (string.IsNullOrEmpty(text))
                    {
                        value = new string[0];
                    }
                    else
                    {
                        value = new string[]
                        {
                            text
                        };
                    }
                    task[TaskSchema.Companies] = value;
                }
                if (base.IsParameterSet("nt"))
                {
                    string text2 = (string)base.GetParameter("nt");
                    if (text2 != null)
                    {
                        BodyConversionUtilities.SetBody(task, text2, Markup.PlainText, base.UserContext);
                    }
                }
                if (base.IsParameterSet("RcrT"))
                {
                    Recurrence recurrence = base.CreateRecurrenceFromRequest();
                    if ((recurrence != null || task.Recurrence != null) && (recurrence == null || task.Recurrence == null || !recurrence.Equals(task.Recurrence)))
                    {
                        task.Recurrence = recurrence;
                        flag3           = true;
                    }
                }
                if (flag2 && exDateTime == null)
                {
                    if (task.CompleteDate == null)
                    {
                        exDateTime = new ExDateTime?(DateTimeUtilities.GetLocalTime());
                    }
                    else
                    {
                        exDateTime = new ExDateTime?(task.CompleteDate.Value);
                    }
                }
                if (!flag3 && flag2)
                {
                    task.SetStatusCompleted(exDateTime.Value);
                }
                Utilities.SaveItem(task, flag);
                task.Load();
                if (flag3 && flag2)
                {
                    OwaStoreObjectId owaStoreObjectId2 = OwaStoreObjectId.CreateFromStoreObject(task);
                    string           changeKey         = task.Id.ChangeKeyAsBase64String();
                    task.Dispose();
                    task = Utilities.GetItem <Task>(base.UserContext, owaStoreObjectId2, changeKey, TaskUtilities.TaskPrefetchProperties);
                    task.SetStatusCompleted(exDateTime.Value);
                    Utilities.SaveItem(task);
                    task.Load();
                }
                if (!flag)
                {
                    OwaStoreObjectId owaStoreObjectId3 = OwaStoreObjectId.CreateFromStoreObject(task);
                    if (ExTraceGlobals.TasksDataTracer.IsTraceEnabled(TraceType.DebugTrace))
                    {
                        ExTraceGlobals.TasksDataTracer.TraceDebug <string>((long)this.GetHashCode(), "New task item ID is '{0}'", owaStoreObjectId3.ToBase64String());
                    }
                    this.Writer.Write("<div id=itemId>");
                    this.Writer.Write(owaStoreObjectId3.ToBase64String());
                    this.Writer.Write("</div>");
                }
                this.Writer.Write("<div id=ck>");
                this.Writer.Write(task.Id.ChangeKeyAsBase64String());
                this.Writer.Write("</div>");
                base.MoveItemToDestinationFolderIfInScratchPad(task);
            }
            finally
            {
                task.Dispose();
            }
        }