Ejemplo n.º 1
0
        protected Dictionary <string, string> ApplyAttachmentChanges(EntitySyncItem item)
        {
            Event @event = item.Item as Event;
            Dictionary <string, string> dictionary = null;

            if (@event.Attachments != null && @event.Attachments.Count > 0)
            {
                dictionary     = new Dictionary <string, string>(@event.Attachments.Count);
                @event.IsDraft = true;
                List <IAttachment> attachments = @event.Attachments;
                @event.Attachments = null;
                IAttachments attachments2 = this.Events[@event.Id].Attachments;
                foreach (IAttachment attachment in attachments)
                {
                    if (attachment is EntityDeleteAttachment)
                    {
                        attachments2.Delete(attachment.Id, null);
                    }
                    else
                    {
                        string id = attachment.Id;
                        attachment.Id = null;
                        string id2 = attachments2.Create(attachment, null).Id;
                        dictionary[id] = HttpUtility.UrlEncode(item.Item.Id + ":" + id2);
                    }
                }
                @event.IsDraft   = false;
                @event.ChangeKey = null;
            }
            return(dictionary);
        }
        // Token: 0x06001728 RID: 5928 RVA: 0x0008A6C0 File Offset: 0x000888C0
        public static IItem GetItem(Item xsoItem)
        {
            string  key    = EntitySyncItem.GetKey(xsoItem.Session.MailboxGuid, xsoItem.Id.ObjectId);
            IEvents events = EntitySyncItem.GetEvents(xsoItem.Session, xsoItem.Id.ObjectId);

            return(events.Read(key, null));
        }
Ejemplo n.º 3
0
        protected void DeleteItem(ISyncItemId syncItemId, CancelEventParameters parameters)
        {
            AirSyncDiagnostics.TraceInfo(ExTraceGlobals.RequestsTracer, this, "SyncCollection.DeleteItem");
            string key = EntitySyncItem.GetKey(base.StoreSession.MailboxGuid, (StoreId)syncItemId.NativeId);

            this.Events.Cancel(key, parameters, null);
            base.ItemIdMapping.Delete(new ISyncItemId[]
            {
                syncItemId
            });
        }
Ejemplo n.º 4
0
        public override ISyncItem CreateSyncItem(SyncCommandItem item)
        {
            string classType = item.ClassType;

            AirSyncDiagnostics.TraceInfo <string>(ExTraceGlobals.RequestsTracer, this, "EntitySyncCollection.CreateSyncItem({0})", classType);
            base.CheckFullAccess();
            string a;

            if ((a = classType) != null && a == "Calendar")
            {
                return(EntitySyncItem.Bind(new Event()));
            }
            throw new AirSyncPermanentException(HttpStatusCode.NotImplemented, StatusCode.UnexpectedItemClass, null, false)
                  {
                      ErrorStringForProtocolLogger = "BadClassType(" + classType + ")onSync"
                  };
        }
Ejemplo n.º 5
0
        private Command.ExecutionState ForwardUsingEntities(StoreObjectId smartId)
        {
            if (base.Occurrence != ExDateTime.MinValue)
            {
                base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "NoOccurrenceSupport");
                throw new AirSyncPermanentException(HttpStatusCode.BadRequest, StatusCode.ServerError, null, false);
            }
            if (this.CalendaringContainer == null)
            {
                this.CalendaringContainer = new CalendaringContainer(base.MailboxSession, null);
            }
            if (this.StoreSession == null)
            {
                this.StoreSession = base.MailboxSession;
            }
            string  key    = EntitySyncItem.GetKey(this.StoreSession.MailboxGuid, smartId);
            IEvents events = EntitySyncItem.GetEvents(this.CalendaringContainer, this.StoreSession, smartId);

            events.Forward(key, this.forwardEventParameters, null);
            return(Command.ExecutionState.Complete);
        }
Ejemplo n.º 6
0
        // Token: 0x06000CE9 RID: 3305 RVA: 0x000459B0 File Offset: 0x00043BB0
        private bool Respond(StoreObjectId itemId, string requestId, MeetingResponseCommand.RequestNodeData response, bool usingLongId)
        {
            if (base.Version <= 141)
            {
                return(this.LegacyRespond(itemId, requestId, response.UserResponse, usingLongId));
            }
            if (response.RespondToEventParameters == null)
            {
                throw new InvalidOperationException("Response.RespondToEventParameters must not be null at this point.");
            }
            StoreObjectId storeObjectId = null;
            string        calendarId    = null;

            if (this.CalendaringContainer == null)
            {
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "Set default CalendaringContainer");
                this.CalendaringContainer = new CalendaringContainer(base.MailboxSession, null);
            }
            if (this.MailboxGuid == Guid.Empty)
            {
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "Set default MailboxGuid");
                this.MailboxGuid = base.MailboxSession.MailboxGuid;
            }
            string  key = EntitySyncItem.GetKey(this.MailboxGuid, itemId);
            IEvents events;

            if (itemId.ObjectType == StoreObjectType.CalendarItem || itemId.ObjectType == StoreObjectType.CalendarItemOccurrence || itemId.ObjectType == StoreObjectType.CalendarItemSeries)
            {
                storeObjectId = itemId;
                events        = EntitySyncItem.GetEvents(this.CalendaringContainer, base.MailboxSession, itemId);
            }
            else
            {
                if (itemId.ObjectType != StoreObjectType.MeetingRequest)
                {
                    this.AppendNonSuccessXmlNode(requestId, StatusCode.Sync_ProtocolVersionMismatch, response.UserResponse, "The item is not meeting-request or calendar item.", usingLongId);
                    base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "UnsupportedObjectType" + itemId.ObjectType);
                    return(false);
                }
                using (MeetingMessage meetingMessage = MeetingMessage.Bind(base.MailboxSession, itemId))
                {
                    if (meetingMessage == null)
                    {
                        this.AppendNonSuccessXmlNode(requestId, StatusCode.Sync_ProtocolVersionMismatch, response.UserResponse, "Cannot find the meeting-request as specified in the reqest.", usingLongId);
                        base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "ItemNotFound");
                        return(false);
                    }
                    using (CalendarItemBase correlatedItem = meetingMessage.GetCorrelatedItem())
                    {
                        if (meetingMessage == null)
                        {
                            this.AppendNonSuccessXmlNode(requestId, StatusCode.Sync_ProtocolVersionMismatch, response.UserResponse, "Cannot find the correlated meeitng item.", usingLongId);
                            base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "NullCalItemInMRCmd");
                            return(false);
                        }
                        storeObjectId = correlatedItem.Id.ObjectId;
                    }
                }
                response.RespondToEventParameters.MeetingRequestIdToBeDeleted = key;
                key    = EntitySyncItem.GetKey(this.MailboxGuid, storeObjectId);
                events = this.CalendaringContainer.Calendars.Default.Events;
            }
            try
            {
                events.Respond(key, response.RespondToEventParameters, null);
            }
            catch (LocalizedException ex)
            {
                this.AppendNonSuccessXmlNode(requestId, StatusCode.Sync_ProtocolError, response.UserResponse, ex.Message, usingLongId);
                base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "EntityRespondError");
                return(false);
            }
            if (storeObjectId != null)
            {
                MailboxSyncItemId mailboxSyncItemId = MailboxSyncItemId.CreateForNewItem(storeObjectId);
                if (this.CalendarItemIdMapping.Contains(mailboxSyncItemId))
                {
                    calendarId = this.CalendarItemIdMapping[mailboxSyncItemId];
                }
                else
                {
                    calendarId = this.CalendarItemIdMapping.Add(mailboxSyncItemId);
                    this.calendarSyncStateChangedFlag = true;
                }
            }
            this.AppendXmlNode(requestId, StatusCode.Success, calendarId, response.UserResponse, usingLongId);
            return(true);
        }
Ejemplo n.º 7
0
 protected override ISyncItem GetItem(Item item)
 {
     return(EntitySyncItem.Bind(item));
 }
Ejemplo n.º 8
0
        // Token: 0x06000767 RID: 1895 RVA: 0x00029340 File Offset: 0x00027540
        protected override int InternalExecute(int count)
        {
            string[] array = HttpUtility.UrlDecode(base.FileReference).Split(new char[]
            {
                ':'
            });
            if (array.Length != 2)
            {
                throw new AirSyncPermanentException(StatusCode.Sync_TooManyFolders, false)
                      {
                          ErrorStringForProtocolLogger = "InvalidEntityAttachemtnId"
                      };
            }
            StoreObjectId itemId = StoreId.EwsIdToStoreObjectId(array[0]);
            IEvents       events = EntitySyncItem.GetEvents(this.CalendaringContainer, base.Session, itemId);

            if (events == null)
            {
                throw new AirSyncPermanentException(StatusCode.Sync_ClientServerConversion, false)
                      {
                          ErrorStringForProtocolLogger = "EventsNotFound"
                      };
            }
            IAttachments attachments = events[array[0]].Attachments;

            if (attachments == null)
            {
                throw new AirSyncPermanentException(StatusCode.Sync_ClientServerConversion, false)
                      {
                          ErrorStringForProtocolLogger = "EntityNotFound"
                      };
            }
            IAttachment attachment = attachments.Read(array[1], null);

            if (attachment == null)
            {
                throw new AirSyncPermanentException(StatusCode.Sync_ClientServerConversion, false)
                      {
                          ErrorStringForProtocolLogger = "EntityAttachementNotFound"
                      };
            }
            base.ContentType = attachment.ContentType;
            FileAttachment fileAttachment = attachment as FileAttachment;
            ItemAttachment itemAttachment = attachment as ItemAttachment;

            if (fileAttachment != null)
            {
                if (!base.MaxAttachmentSize.IsUnlimited && fileAttachment.Content.Length > (int)base.MaxAttachmentSize.Value.ToBytes())
                {
                    throw new DataTooLargeException(StatusCode.AttachmentIsTooLarge);
                }
                count = ((count == -1) ? fileAttachment.Content.Length : Math.Min(count, fileAttachment.Content.Length - base.MinRange));
                base.OutStream.Write(fileAttachment.Content, base.MinRange, count);
                return(count);
            }
            else
            {
                if (itemAttachment != null)
                {
                    int result;
                    AttachmentHelper.GetAttachment(base.Session, itemId, attachment.Id, base.OutStream, base.MinRange, count, base.MaxAttachmentSize, base.RightsManagementSupport, out result);
                    return(result);
                }
                throw new AirSyncPermanentException(StatusCode.Sync_InvalidWaitTime, new LocalizedString(string.Format("Attachment type \"{0}\" is not supported.", attachment.GetType().FullName)), false)
                      {
                          ErrorStringForProtocolLogger = "UnsupportedEntityAttachementType"
                      };
            }
        }
Ejemplo n.º 9
0
        protected ISyncItemId ApplyChanges(SyncCommandItem syncCommandItem)
        {
            AirSyncDiagnostics.TraceInfo(ExTraceGlobals.RequestsTracer, this, "SyncCollection.ApplyChanges");
            EntitySyncItem            entitySyncItem = (EntitySyncItem)syncCommandItem.Item;
            EntitySyncProviderFactory factory        = (EntitySyncProviderFactory)base.SyncProviderFactory;
            Event @event = entitySyncItem.Item as Event;

            try
            {
                if (@event == null)
                {
                    throw new NotImplementedException(string.Format("SyncCollection.ApplyChanges item type {0} is not supported", entitySyncItem.GetType().FullName));
                }
                switch (syncCommandItem.ChangeType)
                {
                case ChangeType.Add:
                {
                    List <IAttachment> list = null;
                    if (@event.Attachments != null && @event.Attachments.Count > 0)
                    {
                        list = @event.Attachments;
                        @event.Attachments = null;
                        @event.IsDraft     = true;
                    }
                    @event = this.Events.Create(@event, null);
                    entitySyncItem.UpdateId(factory, @event.Id);
                    base.ItemIdMapping.Add(entitySyncItem.Id);
                    syncCommandItem.UID = @event.Id;
                    if (list == null)
                    {
                        goto IL_16A;
                    }
                    @event = new Event
                    {
                        Id          = @event.Id,
                        Attachments = list
                    };
                    entitySyncItem = EntitySyncItem.Bind(@event);
                    break;
                }

                case ChangeType.Change:
                    break;

                case (ChangeType)3:
                    goto IL_134;

                case ChangeType.Delete:
                    throw new InvalidOperationException("SyncCollection.ApplyChanges does not support Delete, use DeleteItem.");

                default:
                    goto IL_134;
                }
                syncCommandItem.AddedAttachments = this.ApplyAttachmentChanges(entitySyncItem);
                @event.Id = this.Events.Update(@event, null).Id;
                ((EntitySyncItem)syncCommandItem.Item).Reload();
                goto IL_16A;
IL_134:
                throw new NotImplementedException(string.Format("SyncCollection.ApplyChanges ChangeType {0} is not supported", syncCommandItem.ChangeType));
                IL_16A :;
            }
            finally
            {
                if (!object.ReferenceEquals(entitySyncItem, (EntitySyncItem)syncCommandItem.Item))
                {
                    entitySyncItem.Dispose();
                }
            }
            return(syncCommandItem.Item.Id);
        }
Ejemplo n.º 10
0
 protected override ISyncItem CreateSyncItem(Item mailboxItem)
 {
     AirSyncDiagnostics.TraceInfo(ExTraceGlobals.RequestsTracer, this, "EntitySyncCollection.CreateSyncItem(mailboxItem)");
     return(EntitySyncItem.Bind(mailboxItem));
 }
Ejemplo n.º 11
0
 // Token: 0x0600172A RID: 5930 RVA: 0x0008A711 File Offset: 0x00088911
 public static IEvents GetEvents(IStoreSession storeSession, StoreObjectId itemId)
 {
     return(EntitySyncItem.GetEvents(new CalendaringContainer(storeSession, null), storeSession, itemId));
 }