Beispiel #1
0
        protected override void AddExtraNodes(XmlNode responseNode, SyncCommandItem item)
        {
            if (item.Status != "1")
            {
                return;
            }
            XmlNode xmlNode = responseNode.OwnerDocument.CreateElement("ApplicationData", "AirSync:");

            if (item.ChangeType == ChangeType.Add && !string.IsNullOrEmpty(item.UID))
            {
                XmlNode xmlNode2 = responseNode.OwnerDocument.CreateElement("UID", "Calendar:");
                xmlNode2.InnerText = item.UID;
                xmlNode.AppendChild(xmlNode2);
            }
            if (item.AddedAttachments != null && item.AddedAttachments.Count > 0)
            {
                XmlNode xmlNode3 = responseNode.OwnerDocument.CreateElement("Attachments", "AirSyncBase:");
                foreach (KeyValuePair <string, string> keyValuePair in item.AddedAttachments)
                {
                    XmlNode xmlNode4 = responseNode.OwnerDocument.CreateElement("Attachment", "AirSyncBase:");
                    XmlNode xmlNode5 = responseNode.OwnerDocument.CreateElement("ClientId", "AirSyncBase:");
                    xmlNode5.InnerText = keyValuePair.Key;
                    xmlNode4.AppendChild(xmlNode5);
                    XmlNode xmlNode6 = responseNode.OwnerDocument.CreateElement("FileReference", "AirSyncBase:");
                    xmlNode6.InnerText = keyValuePair.Value;
                    xmlNode4.AppendChild(xmlNode6);
                    xmlNode3.AppendChild(xmlNode4);
                }
                xmlNode.AppendChild(xmlNode3);
            }
            if (xmlNode.HasChildNodes)
            {
                responseNode.AppendChild(xmlNode);
            }
        }
Beispiel #2
0
        public override OperationResult DeleteSyncItem(SyncCommandItem syncCommandItem, bool deletesAsMoves)
        {
            AirSyncDiagnostics.TraceInfo(ExTraceGlobals.RequestsTracer, this, "SyncCollection.DeleteSyncItem(SyncCommandItem)");
            EntitySyncProviderFactory entitySyncProviderFactory = (EntitySyncProviderFactory)base.SyncProviderFactory;
            StoreObjectId             folderId = entitySyncProviderFactory.FolderId;

            if (AirSyncUtility.GetAirSyncFolderTypeClass(folderId) == "Calendar")
            {
                CancelEventParameters parameters;
                if (syncCommandItem.XmlNode != null)
                {
                    try
                    {
                        parameters = EventParametersParser.ParseCancel(syncCommandItem.XmlNode);
                        goto IL_72;
                    }
                    catch (RequestParsingException ex)
                    {
                        throw new AirSyncPermanentException(StatusCode.Sync_ProtocolError, ex.LocalizedString, ex, false)
                              {
                                  ErrorStringForProtocolLogger = ex.LogMessage
                              };
                    }
                }
                parameters = new CancelEventParameters();
IL_72:
                this.DeleteItem(syncCommandItem.Id, parameters);
                return(OperationResult.Succeeded);
            }
            return(this.DeleteSyncItem(syncCommandItem.ServerId, deletesAsMoves));
        }
Beispiel #3
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"
                  };
        }
Beispiel #4
0
        public override ISyncItemId ConvertClientToServerObjectAndSave(SyncCommandItem syncCommandItem, ref uint maxWindowSize, ref bool mergeToClient)
        {
            AirSyncDiagnostics.TraceInfo(ExTraceGlobals.RequestsTracer, this, "SyncCollection.ConvertClientToServerObjectAndSave");
            base.CheckFullAccess();
            ItemIdMapping itemIdMapping = base.ItemIdMapping;
            IItem         item          = ((EntitySyncItem)syncCommandItem.Item).Item;

            try
            {
                this.EntityDataObject.Bind(item);
                base.AirSyncDataObject.Bind(syncCommandItem.XmlNode);
                this.EntityDataObject.CopyFrom(base.AirSyncDataObject);
            }
            finally
            {
                base.AirSyncDataObject.Unbind();
                this.EntityDataObject.Unbind();
            }
            ISyncItemId syncItemId = this.ApplyChanges(syncCommandItem);

            syncCommandItem.ChangeTrackingInformation = base.ChangeTrackFilter.UpdateChangeTrackingInformation(syncCommandItem.XmlNode, syncCommandItem.ChangeTrackingInformation);
            syncCommandItem.SyncId = base.ItemIdMapping[syncItemId];
            return(syncItemId);
        }
Beispiel #5
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);
        }