/// <summary> /// Upload of an ICS state property into the synchronization context. /// </summary> /// <param name="serverId">A 32-bit signed integer represent the Identity of server.</param> /// <param name="uploadContextHandleIndex">The synchronization context handle</param> /// <param name="icsPropertyType">Property tags of the ICS state properties.</param> /// <param name="isPidTagIdsetGivenInputAsInter32"> identifies Property tags as PtypInteger32.</param> /// <param name="icsStateIndex">The index of the ICS State.</param> /// <returns>The ICS state property is upload to the server successfully or not.</returns> public RopResult SynchronizationUploadState(int serverId, int uploadContextHandleIndex, ICSStateProperties icsPropertyType, bool isPidTagIdsetGivenInputAsInter32, int icsStateIndex) { // Initialize ROP data. RopResult result = RopResult.InvalidParameter; uint synUploadContextHandle = this.handleContainer[uploadContextHandleIndex]; ICSStateData uploadICSState = new ICSStateData(); if (icsStateIndex != 0) { uploadICSState = this.icsStateContainer[icsStateIndex]; } else { uploadICSState.PidTagCnsetRead = new byte[0]; uploadICSState.PidTagCnsetSeen = new byte[0]; uploadICSState.PidTagCnsetSeenFAI = new byte[0]; uploadICSState.PidTagIdsetGiven = new byte[0]; } byte[] currentICSPropertyValue; // Construct ROP request. RopSynchronizationUploadStateStreamBeginRequest synchronizationUploadStateStreamBeginRequest; synchronizationUploadStateStreamBeginRequest.RopId = 0x75; synchronizationUploadStateStreamBeginRequest.LogonId = 0x00; synchronizationUploadStateStreamBeginRequest.InputHandleIndex = 0x00; uint stateProperty = 0; // propertyId and propertyTypId should be joined up. So propertyId should be move left 16 positions for propertyTypeID. switch (icsPropertyType) { case ICSStateProperties.PidTagCnsetRead: // PidTagCnsetRead propertyId 0x67DA, propertyTypeId 0x0102 stateProperty = (uint)((0x67D2 << 16) | 0x0102); currentICSPropertyValue = new byte[uploadICSState.PidTagCnsetRead.Length]; currentICSPropertyValue = uploadICSState.PidTagCnsetRead; break; case ICSStateProperties.PidTagCnsetSeen: // PidTagCnsetSeen propertyId 0x6796, propertyTypeId 0x0102 stateProperty = (uint)((0x6796 << 16) | 0x0102); currentICSPropertyValue = new byte[uploadICSState.PidTagCnsetSeen.Length]; currentICSPropertyValue = uploadICSState.PidTagCnsetSeen; break; case ICSStateProperties.PidTagCnsetSeenFAI: // PidTagCnsetSeenFAI propertyId 0x67DA, propertyTypeId 0x0102 stateProperty = (uint)((0x67DA << 16) | 0x0102); currentICSPropertyValue = new byte[uploadICSState.PidTagCnsetSeenFAI.Length]; currentICSPropertyValue = uploadICSState.PidTagCnsetSeenFAI; break; case ICSStateProperties.PidTagIdsetGiven: // PidTagIdsetGiven propertyId 0x4017, propertyTypeId 0x003 stateProperty = (uint)((0x4017 << 16) | 0x0102); if (isPidTagIdsetGivenInputAsInter32) { stateProperty = (uint)((0x4017 << 16) | 0x0003); } currentICSPropertyValue = new byte[uploadICSState.PidTagIdsetGiven.Length]; currentICSPropertyValue = uploadICSState.PidTagIdsetGiven; break; default: currentICSPropertyValue = new byte[0]; break; } synchronizationUploadStateStreamBeginRequest.TransferBufferSize = (uint)currentICSPropertyValue.Length; synchronizationUploadStateStreamBeginRequest.StateProperty = stateProperty; // Send the RopSynchronizationUploadStateStreamBegin request and get response from server. RopSynchronizationUploadStateStreamBeginResponse synchronizationUploadStateStreamBeginResponse = (RopSynchronizationUploadStateStreamBeginResponse)this.Process(serverId, synchronizationUploadStateStreamBeginRequest, synUploadContextHandle); result = (RopResult)synchronizationUploadStateStreamBeginResponse.ReturnValue; if (result == RopResult.Success) { // Verify ROP SynchronizationUploadStateStreamBegin this.VerifyRopSynchronizationUploadStateStreamBegin(synchronizationUploadStateStreamBeginResponse); if (isPidTagIdsetGivenInputAsInter32) { this.VerifyServerAcceptPidTagIdsetGivenPtypInteger32(result); } } else { return result; } // Construct the RopSynchronizationUploadStateStreamContinue request. RopSynchronizationUploadStateStreamContinueRequest synchronizationUploadStateStreamContinueRequest; synchronizationUploadStateStreamContinueRequest.RopId = 0x76; synchronizationUploadStateStreamContinueRequest.LogonId = 0x00; synchronizationUploadStateStreamContinueRequest.InputHandleIndex = 0x00; synchronizationUploadStateStreamContinueRequest.StreamDataSize = (uint)currentICSPropertyValue.Length; synchronizationUploadStateStreamContinueRequest.StreamData = currentICSPropertyValue; // Send the RopSynchronizationUploadStateStreamContinue request. RopSynchronizationUploadStateStreamContinueResponse synchronizationUploadStateStreamContinueResponse = (RopSynchronizationUploadStateStreamContinueResponse)this.Process(serverId, synchronizationUploadStateStreamContinueRequest, synUploadContextHandle); result = (RopResult)synchronizationUploadStateStreamContinueResponse.ReturnValue; if (result == RopResult.Success) { // Verify ROP SynchronizationUploadStateStreamContinue this.VerifyRopSynchronizationUploadStateStreamContinue(synchronizationUploadStateStreamContinueResponse); } else { return result; } // Construct the RopSynchronizationUploadStateStreamEnd request. RopSynchronizationUploadStateStreamEndRequest synchronizationUploadStateStreamEndRequest; synchronizationUploadStateStreamEndRequest.RopId = 0x77; synchronizationUploadStateStreamEndRequest.LogonId = 0x00; synchronizationUploadStateStreamEndRequest.InputHandleIndex = 0x00; RopSynchronizationUploadStateStreamEndResponse synchronizationUploadStateStreamEndResponse = (RopSynchronizationUploadStateStreamEndResponse)this.Process(serverId, synchronizationUploadStateStreamEndRequest, synUploadContextHandle); result = (RopResult)synchronizationUploadStateStreamEndResponse.ReturnValue; if (result == RopResult.Success) { // Verify ROP SynchronizationUploadStateStreamEnd this.VerifyRopSynchronizationUploadStateStreamEnd(synchronizationUploadStateStreamEndResponse); } return result; }
public static RopResult SynchronizationUploadState(int serverId, int uploadContextHandleIndex, ICSStateProperties icsPropertyType, bool isPidTagIdsetGivenInputAsInter32, int icsStateIndex) { // The contractions conditions. Condition.IsTrue(connections.Count > 0); Condition.IsTrue(connections.Keys.Contains(serverId)); Condition.IsTrue(connections[serverId].DownloadContextContainer.Count > 0 || connections[serverId].UploadContextContainer.Count > 0); // Initialize the return value. RopResult result = RopResult.InvalidParameter; AbstractUploadInfo uploadInfo = new AbstractUploadInfo(); AbstractDownloadInfo downLoadInfo = new AbstractDownloadInfo(); // Get the current ConnectionData value. ConnectionData changeConnection = connections[serverId]; // Identify whether the DownloadContext or UploadContext is existent or not and record the index. bool isCurrentUploadinfoExist = false; int currentUploadIndex = 0; bool isCurrentDownLoadinfoExist = false; int currentDownLoadIndex = 0; foreach (AbstractUploadInfo tempUploadInfo in changeConnection.UploadContextContainer) { if (tempUploadInfo.UploadHandleIndex == uploadContextHandleIndex) { // Set the value to the related variable when the current upload context is existent. isCurrentUploadinfoExist = true; uploadInfo = tempUploadInfo; currentUploadIndex = changeConnection.UploadContextContainer.IndexOf(tempUploadInfo); break; } } if (!isCurrentUploadinfoExist) { foreach (AbstractDownloadInfo tempDownLoadInfo in changeConnection.DownloadContextContainer) { if (tempDownLoadInfo.DownloadHandleIndex == uploadContextHandleIndex) { // Set the value to the related variable when the current Download context is existent. isCurrentDownLoadinfoExist = true; downLoadInfo = tempDownLoadInfo; currentDownLoadIndex = changeConnection.DownloadContextContainer.IndexOf(tempDownLoadInfo); break; } } } if (isCurrentDownLoadinfoExist || isCurrentUploadinfoExist) { if (isCurrentUploadinfoExist) { if (icsStateIndex != 0) { AbstractFolder currentFolder = new AbstractFolder(); foreach (AbstractFolder tempFolder in changeConnection.FolderContainer) { if (tempFolder.FolderHandleIndex == uploadInfo.RelatedObjectHandleIndex) { // Set the value to the related variable when the current Folder is existent. currentFolder = tempFolder; Condition.IsTrue(currentFolder.ICSStateContainer.ContainsKey(icsStateIndex)); } } // Add ICS State to ICSStateContainer of current folder. AbstractUpdatedState updatedState = currentFolder.ICSStateContainer[icsStateIndex]; switch (icsPropertyType) { case ICSStateProperties.PidTagIdsetGiven: // Set IdsetGiven value uploadInfo.UpdatedState.IdsetGiven = updatedState.IdsetGiven; break; case ICSStateProperties.PidTagCnsetRead: // Set CnsetRead value uploadInfo.UpdatedState.CnsetRead = updatedState.CnsetRead; break; case ICSStateProperties.PidTagCnsetSeen: // Set CnsetSeen value uploadInfo.UpdatedState.CnsetSeen = updatedState.CnsetSeen; break; case ICSStateProperties.PidTagCnsetSeenFAI: // Set CnsetSeenFAI value uploadInfo.UpdatedState.CnsetSeenFAI = updatedState.CnsetSeenFAI; break; default: break; } // Update the UploadContextContainer context. changeConnection.UploadContextContainer = changeConnection.UploadContextContainer.Update(currentUploadIndex, uploadInfo); } } else { if (icsStateIndex != 0) { AbstractFolder currentFolder = new AbstractFolder(); foreach (AbstractFolder tempFolder in changeConnection.FolderContainer) { if (tempFolder.FolderHandleIndex == downLoadInfo.RelatedObjectHandleIndex) { // Set the value to the related variable when the current Folder is existent. currentFolder = tempFolder; // Identify ICS State whether exist index or not in ICSStateContainer Condition.IsTrue(currentFolder.ICSStateContainer.ContainsKey(icsStateIndex)); } } // Add update state to ICSStateContainer of current folder. AbstractUpdatedState updatedState = currentFolder.ICSStateContainer[icsStateIndex]; switch (icsPropertyType) { case ICSStateProperties.PidTagIdsetGiven: // Set IdsetGiven value. downLoadInfo.UpdatedState.IdsetGiven = updatedState.IdsetGiven; break; case ICSStateProperties.PidTagCnsetRead: // Set CnsetRead value. downLoadInfo.UpdatedState.CnsetRead = updatedState.CnsetRead; break; case ICSStateProperties.PidTagCnsetSeen: // Set CnsetSeen value. downLoadInfo.UpdatedState.CnsetSeen = updatedState.CnsetSeen; break; case ICSStateProperties.PidTagCnsetSeenFAI: // Set CnsetSeenFAI value. downLoadInfo.UpdatedState.CnsetSeenFAI = updatedState.CnsetSeenFAI; break; default: break; } // Update the DownloadContextContainer. changeConnection.DownloadContextContainer = changeConnection.DownloadContextContainer.Update(currentDownLoadIndex, downLoadInfo); } } connections[serverId] = changeConnection; if (isPidTagIdsetGivenInputAsInter32) { // Identify the property tag whether PtypInteger32 is or not. if (requirementContainer.Keys.Contains(2657) && requirementContainer[2657]) { result = RopResult.Success; ModelHelper.CaptureRequirement(2657, "[In Receiving the MetaTagIdsetGiven ICS State Property] Implementation does accept this MetaTagIdsetGiven property when the property tag identifies it as PtypInteger32. (Microsoft Exchange Server 2007 and above follow this behavior.)"); } else { return result; } } result = RopResult.Success; } return result; }