コード例 #1
0
        public static CalendarItem CreateDraft(UserContext userContext, StoreObjectId folderId)
        {
            if (userContext == null)
            {
                throw new ArgumentNullException("userContext");
            }
            ExTraceGlobals.CalendarTracer.TraceDebug(0L, "Creating new calendar item.");
            CalendarItem calendarItem = null;

            calendarItem = CalendarItem.Create(userContext.MailboxSession, (folderId != null) ? folderId : userContext.CalendarFolderId);
            calendarItem[ItemSchema.ConversationIndexTracking] = true;
            if (calendarItem != null)
            {
                try
                {
                    calendarItem[ItemSchema.IsResponseRequested]        = true;
                    calendarItem[ItemSchema.ReminderMinutesBeforeStart] = userContext.CalendarSettings.DefaultReminderTime;
                }
                catch
                {
                    if (calendarItem != null)
                    {
                        calendarItem.Dispose();
                        calendarItem = null;
                    }
                    throw;
                }
            }
            return(calendarItem);
        }
コード例 #2
0
        public void CreateAppointment(ExchangeService exchangeService, MailboxSession session, CalendarItemType remoteItem, LocalFolder localFolder)
        {
            AppointmentTranslator.Tracer.TraceDebug <AppointmentTranslator, string>((long)this.GetHashCode(), "{0}: Creating appointment {1}", this, remoteItem.ItemId.Id);
            CalendarItem calendarItem = CalendarItem.Create(session, localFolder.Id);
            bool         flag         = false;

            try
            {
                this.UpdateAppointment(exchangeService, session, remoteItem, calendarItem);
                flag = true;
            }
            catch (LastOccurrenceDeletionException arg)
            {
                AppointmentTranslator.Tracer.TraceDebug <AppointmentTranslator, string, LastOccurrenceDeletionException>((long)this.GetHashCode(), "{0}: All occurrences in the series were deleted - {1}, Error - {2}, We will delete the local item because there are no instances.", this, remoteItem.ItemId.Id, arg);
                localFolder.SelectItemToDelete(calendarItem.Id.ObjectId);
                flag = true;
            }
            finally
            {
                if (!flag && calendarItem.Id != null)
                {
                    localFolder.SelectItemToDelete(calendarItem.Id.ObjectId);
                }
                calendarItem.Dispose();
            }
        }
コード例 #3
0
        // Token: 0x06002FD8 RID: 12248 RVA: 0x001172F8 File Offset: 0x001154F8
        public static string GenerateWhen(UserContext userContext, ExDateTime startTime, ExDateTime endTime, Recurrence recurrence)
        {
            string result;

            using (CalendarItem calendarItem = CalendarItem.Create(userContext.MailboxSession, userContext.CalendarFolderId))
            {
                calendarItem.StartTime  = startTime;
                calendarItem.EndTime    = endTime;
                calendarItem.Recurrence = recurrence;
                result = calendarItem.GenerateWhen();
            }
            return(result);
        }
コード例 #4
0
 // Token: 0x060001C9 RID: 457 RVA: 0x0001109C File Offset: 0x0000F29C
 private static bool ValidateCalendarItemData(UserContext userContext, CalendarItemData calendarItemData, out InfobarMessage infobarMessage)
 {
     infobarMessage = null;
     if (calendarItemData == null)
     {
         throw new ArgumentNullException("calendarItemData");
     }
     if (calendarItemData.FolderId == null)
     {
         throw new ArgumentNullException("calendarItemData", "calendarItemData.FolderId is null");
     }
     if (userContext == null)
     {
         throw new ArgumentNullException("userContext");
     }
     if (userContext.MailboxSession == null)
     {
         throw new ArgumentNullException("userContext", "userContext.MailboxSession is null");
     }
     using (CalendarItem calendarItem = CalendarItem.Create(userContext.MailboxSession, userContext.CalendarFolderId))
     {
         LocalizedException ex = null;
         try
         {
             calendarItemData.CopyTo(calendarItem);
             calendarItem.Validate();
         }
         catch (StoragePermanentException ex2)
         {
             ex = ex2;
         }
         catch (StorageTransientException ex3)
         {
             ex = ex3;
         }
         if (ex != null)
         {
             ErrorInformation exceptionHandlingInformation = Utilities.GetExceptionHandlingInformation(ex, userContext.MailboxIdentity);
             string           messageText = exceptionHandlingInformation.Message;
             if (ex is CorruptDataException && calendarItemData.EndTime < calendarItemData.StartTime)
             {
                 messageText = LocalizedStrings.GetNonEncoded(2047223147);
             }
             infobarMessage = InfobarMessage.CreateText(messageText, InfobarMessageType.Error);
         }
     }
     return(infobarMessage == null);
 }
コード例 #5
0
        // Token: 0x06000799 RID: 1945 RVA: 0x00039F34 File Offset: 0x00038134
        public static string GenerateWhen(UserContext userContext, ExDateTime startTime, ExDateTime endTime, Recurrence recurrence)
        {
            if (userContext == null)
            {
                throw new ArgumentNullException("userContext");
            }
            if (recurrence == null)
            {
                throw new ArgumentNullException("recurrence");
            }
            string result;

            using (CalendarItem calendarItem = CalendarItem.Create(userContext.MailboxSession, userContext.CalendarFolderId))
            {
                calendarItem.StartTime  = startTime;
                calendarItem.EndTime    = endTime;
                calendarItem.Recurrence = recurrence;
                result = calendarItem.GenerateWhen();
            }
            return(result);
        }
コード例 #6
0
 public void NewItemToPeople()
 {
     ExTraceGlobals.ContactsCallTracer.TraceDebug((long)this.GetHashCode(), "AddressBookEventHandler.NewItemToPeople");
     this.BindToData();
     if (base.UserContext.UserOptions.ViewRowCount < this.itemIds.Length)
     {
         throw new OwaInvalidOperationException(string.Format("Sending message to more than {0} item(s) in a single request is not supported", this.itemIds.Length));
     }
     AddressBookItemEventHandler.ItemTypeToPeople itemTypeToPeople = (AddressBookItemEventHandler.ItemTypeToPeople)base.GetParameter("it");
     if (!Enum.IsDefined(typeof(AddressBookItemEventHandler.ItemTypeToPeople), itemTypeToPeople))
     {
         throw new OwaInvalidOperationException(string.Format("Invalid item type '{0}' passed in.", itemTypeToPeople));
     }
     using (Item item = (itemTypeToPeople == AddressBookItemEventHandler.ItemTypeToPeople.Meeting) ? CalendarItem.Create(base.UserContext.MailboxSession, base.UserContext.CalendarFolderId) : MessageItem.Create(base.UserContext.MailboxSession, base.UserContext.DraftsFolderId))
     {
         item[ItemSchema.ConversationIndexTracking] = true;
         if (Globals.ArePerfCountersEnabled)
         {
             OwaSingleCounters.ItemsCreated.Increment();
         }
         this.LoadRecipientsToItem(item, itemTypeToPeople);
         if (itemTypeToPeople == AddressBookItemEventHandler.ItemTypeToPeople.Meeting)
         {
             CalendarItemBase calendarItemBase = (CalendarItemBase)item;
             calendarItemBase[ItemSchema.ReminderIsSet] = base.UserContext.UserOptions.EnableReminders;
             calendarItemBase[ItemSchema.ReminderMinutesBeforeStart] = base.UserContext.CalendarSettings.DefaultReminderTime;
             calendarItemBase.Save(SaveMode.ResolveConflicts);
             calendarItemBase.Load();
             this.Writer.Write("?ae=Item&a=New&t=IPM.Appointment&exdltdrft=1&id=");
             this.Writer.Write(HttpUtility.UrlEncode(calendarItemBase.Id.ObjectId.ToBase64String()));
         }
         else
         {
             MessageItem messageItem = (MessageItem)item;
             if (itemTypeToPeople == AddressBookItemEventHandler.ItemTypeToPeople.TextMessage)
             {
                 messageItem[StoreObjectSchema.ItemClass] = "IPM.Note.Mobile.SMS";
             }
             messageItem.Save(SaveMode.ResolveConflicts);
             messageItem.Load();
             this.Writer.Write((itemTypeToPeople == AddressBookItemEventHandler.ItemTypeToPeople.TextMessage) ? "?ae=Item&a=Reply&t=IPM.Note.Mobile.SMS&exdltdrft=1&id=" : "?ae=Item&a=New&t=IPM.Note&exdltdrft=1&id=");
             this.Writer.Write(HttpUtility.UrlEncode(messageItem.Id.ObjectId.ToBase64String()));
         }
     }
 }
コード例 #7
0
        private CalendarItemBase ConvertToCalendarItem(GlobalObjectId goid, Item promotedItem, object[] matchedItem)
        {
            CalendarItemBase calendarItemBase = null;
            bool             itemCreated      = true;
            bool             flag             = false;

            promotedItem[InternalSchema.BodyTag] = promotedItem.Body.CalculateBodyTag();
            try
            {
                if (matchedItem == null)
                {
                    ExTraceGlobals.SharingTracer.TraceDebug <GlobalObjectId, object, object>((long)this.GetHashCode(), "CalendarImporter::ConvertToCalendarItem. No matched existing object found, then create a new one. GOID:{0}; Subject:{1}; StartTime:{2}.", goid, promotedItem.TryGetProperty(ItemSchema.Subject), promotedItem.TryGetProperty(CalendarItemInstanceSchema.StartTime));
                    calendarItemBase = CalendarItem.Create(this.session, this.folder.Id);
                }
                else if (this.IsMeetingChanged(goid, promotedItem, matchedItem))
                {
                    StoreObjectId storeObjectId = ((VersionedId)matchedItem[this.QueryIndexId]).ObjectId;
                    if (!goid.IsCleanGlobalObjectId && true.Equals(matchedItem[this.QueryIndexRecurring]))
                    {
                        storeObjectId = new OccurrenceStoreObjectId(storeObjectId.ProviderLevelItemId, goid.Date);
                    }
                    try
                    {
                        calendarItemBase = CalendarItemBase.Bind(this.session, storeObjectId);
                        calendarItemBase.OpenAsReadWrite();
                        itemCreated = false;
                    }
                    catch (OccurrenceNotFoundException)
                    {
                        ExTraceGlobals.SharingTracer.TraceDebug <string>((long)this.GetHashCode(), "CalendarImporter::ConvertToCalendarItem. Tried to bind to an occurrence not existing", storeObjectId.ToString());
                        calendarItemBase = CalendarItem.Create(this.session, this.folder.Id);
                    }
                }
                if (calendarItemBase != null)
                {
                    try
                    {
                        this.CopyToCalendarItem(promotedItem, calendarItemBase, itemCreated);
                        flag = true;
                        goto IL_154;
                    }
                    catch (RecurrenceException arg)
                    {
                        ExTraceGlobals.SharingTracer.TraceDebug <GlobalObjectId, RecurrenceException>((long)this.GetHashCode(), "CalendarImporter::ConvertToCalendarItem. Failed to copy the iCal to a calendarItem for ID:{0}, Exception = {1}", goid, arg);
                        flag = false;
                        goto IL_154;
                    }
                    catch (AttachmentExceededException arg2)
                    {
                        ExTraceGlobals.SharingTracer.TraceDebug <GlobalObjectId, AttachmentExceededException>((long)this.GetHashCode(), "CalendarImporter::ConvertToCalendarItem. Failed to copy the iCal to a calendarItem for ID:{0}, Exception = {1}", goid, arg2);
                        flag = false;
                        goto IL_154;
                    }
                }
                flag = true;
                IL_154 :;
            }
            finally
            {
                if (!flag)
                {
                    ExTraceGlobals.SharingTracer.TraceDebug <GlobalObjectId>((long)this.GetHashCode(), "CalendarImporter::ConvertToCalendarItem. Failed to convert to XSO calendar item. GOID:{0}.", goid);
                    this.results.RawErrors.Add(ServerStrings.SyncFailedToCreateNewItemOrBindToExistingOne);
                    Util.DisposeIfPresent(calendarItemBase);
                    calendarItemBase = null;
                }
            }
            return(calendarItemBase);
        }
コード例 #8
0
ファイル: XSOFactory.cs プロジェクト: YHZX2013/exchange_diff
 public ICalendarItem CreateCalendarItem(IStoreSession session, StoreId parentFolderId)
 {
     return(CalendarItem.Create((StoreSession)session, parentFolderId));
 }
コード例 #9
0
        internal override void ValidateMeetings(ref Dictionary <GlobalObjectId, List <Attendee> > organizerRumsSent, Action <long> onItemRepaired)
        {
            bool shouldProcessMailbox = CalendarParticipant.InternalShouldProcessMailbox(this.ExchangePrincipal);

            try
            {
                List <SearchExpressionType> list = new List <SearchExpressionType>();
                foreach (CalendarInstanceContext calendarInstanceContext in base.ItemList.Values)
                {
                    calendarInstanceContext.ValidationContext.CalendarInstance = new CalendarRemoteItem(this.ExchangePrincipal, this.binding);
                    calendarInstanceContext.ValidationContext.CalendarInstance.ShouldProcessMailbox = shouldProcessMailbox;
                    GlobalObjectId       globalObjectId = calendarInstanceContext.ValidationContext.BaseItem.GlobalObjectId;
                    string               value          = Convert.ToBase64String(globalObjectId.CleanGlobalObjectIdBytes);
                    SearchExpressionType item           = new IsEqualToType
                    {
                        Item = CalendarItemFields.CleanGlobalObjectIdProp,
                        FieldURIOrConstant = new FieldURIOrConstantType
                        {
                            Item = new ConstantValueType
                            {
                                Value = value
                            }
                        }
                    };
                    list.Add(item);
                }
                ItemType[] remoteCalendarItems = this.GetRemoteCalendarItems(list);
                if (remoteCalendarItems != null)
                {
                    Dictionary <GlobalObjectId, CalendarItemType> dictionary = new Dictionary <GlobalObjectId, CalendarItemType>();
                    foreach (ItemType itemType in remoteCalendarItems)
                    {
                        CalendarItemType calendarItemType = itemType as CalendarItemType;
                        GlobalObjectId   globalObjectId2  = CalendarItemFields.GetGlobalObjectId(calendarItemType);
                        dictionary.Add(globalObjectId2, calendarItemType);
                    }
                    foreach (KeyValuePair <GlobalObjectId, CalendarInstanceContext> keyValuePair in base.ItemList)
                    {
                        if (dictionary.ContainsKey(keyValuePair.Key))
                        {
                            CalendarItemType        remoteItem = dictionary[keyValuePair.Key];
                            CalendarInstanceContext value2     = keyValuePair.Value;
                            try
                            {
                                try
                                {
                                    CalendarItemBase calendarItemBase = CalendarItem.Create(this.localSession, this.localSession.GetDefaultFolderId(DefaultFolderType.Calendar));
                                    Globals.ConsistencyChecksTracer.TraceDebug((long)this.GetHashCode(), "Converting the EWS item to XSO.");
                                    this.calendarConverter.ConvertItem(calendarItemBase, remoteItem);
                                    value2.ValidationContext.OppositeItem = calendarItemBase;
                                }
                                catch (FormatException ex)
                                {
                                    string text = string.Format("Could not convert the remote item, exception = {0}", ex.GetType());
                                    Globals.ConsistencyChecksTracer.TraceError((long)this.GetHashCode(), text);
                                    value2.ValidationContext.CalendarInstance.LoadInconsistency = Inconsistency.CreateInstance(value2.ValidationContext.OppositeRole, text, CalendarInconsistencyFlag.StorageException, value2.ValidationContext);
                                }
                                catch (CorruptDataException ex2)
                                {
                                    string text2 = string.Format("Could not convert the remote item, exception = {0}", ex2.GetType());
                                    Globals.ConsistencyChecksTracer.TraceError((long)this.GetHashCode(), text2);
                                    value2.ValidationContext.CalendarInstance.LoadInconsistency = Inconsistency.CreateInstance(value2.ValidationContext.OppositeRole, text2, CalendarInconsistencyFlag.StorageException, value2.ValidationContext);
                                }
                                catch (StorageTransientException ex3)
                                {
                                    string text3 = string.Format("Could not convert the remote item, exception = {0}", ex3.GetType());
                                    Globals.ConsistencyChecksTracer.TraceError((long)this.GetHashCode(), text3);
                                    value2.ValidationContext.CalendarInstance.LoadInconsistency = Inconsistency.CreateInstance(value2.ValidationContext.OppositeRole, text3, CalendarInconsistencyFlag.StorageException, value2.ValidationContext);
                                }
                                continue;
                            }
                            finally
                            {
                                base.ValidateInstance(value2, organizerRumsSent, onItemRepaired);
                                if (value2.ValidationContext.OppositeItem != null)
                                {
                                    value2.ValidationContext.OppositeItem.Dispose();
                                    value2.ValidationContext.OppositeItem = null;
                                }
                            }
                        }
                        Globals.ConsistencyChecksTracer.TraceDebug((long)this.GetHashCode(), "GetItem didn't return an expected GlobalObjectId.");
                    }
                }
                foreach (CalendarInstanceContext calendarInstanceContext2 in base.ItemList.Values)
                {
                    if (!calendarInstanceContext2.IsValidationDone)
                    {
                        if (calendarInstanceContext2.ValidationContext.OppositeRole == RoleType.Organizer && calendarInstanceContext2.ValidationContext.OppositeItem == null)
                        {
                            calendarInstanceContext2.ValidationContext.OppositeRoleOrganizerIsValid = true;
                        }
                        base.ValidateInstance(calendarInstanceContext2, organizerRumsSent, onItemRepaired);
                    }
                }
            }
            catch (ProtocolViolationException exception)
            {
                this.HandleRemoteException(exception);
            }
            catch (SecurityException exception2)
            {
                this.HandleRemoteException(exception2);
            }
            catch (ArgumentException exception3)
            {
                this.HandleRemoteException(exception3);
            }
            catch (InvalidOperationException exception4)
            {
                this.HandleRemoteException(exception4);
            }
            catch (NotSupportedException exception5)
            {
                this.HandleRemoteException(exception5);
            }
            catch (XmlException exception6)
            {
                this.HandleRemoteException(exception6);
            }
            catch (XPathException exception7)
            {
                this.HandleRemoteException(exception7);
            }
            catch (SoapException exception8)
            {
                this.HandleRemoteException(exception8);
            }
            catch (IOException exception9)
            {
                this.HandleRemoteException(exception9);
            }
        }