/// <summary>
        /// Gets an estimate of the number of items in the specific folder.
        /// </summary>
        /// <param name="syncKey">The latest SyncKey.</param>
        /// <param name="collectionId">The CollectionId of the folder.</param>
        /// <returns>The response of GetItemEstimate command.</returns>
        protected GetItemEstimateResponse CallGetItemEstimateCommand(string syncKey, string collectionId)
        {
            List <Request.ItemsChoiceType10> itemsElementName = new List <Request.ItemsChoiceType10>()
            {
                Request.ItemsChoiceType10.SyncKey,
                Request.ItemsChoiceType10.CollectionId,
            };

            List <object> items = new List <object>()
            {
                syncKey,
                collectionId,
            };

            if (Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site) != "12.1")
            {
                itemsElementName.Add(Request.ItemsChoiceType10.ConversationMode);
                items.Add(true);
            }
            // Create GetItemEstimate command request.
            Request.GetItemEstimateCollection collection = new Request.GetItemEstimateCollection
            {
                ItemsElementName = itemsElementName.ToArray(),
                Items            = items.ToArray()
            };

            GetItemEstimateRequest getItemEstimateRequest = Common.CreateGetItemEstimateRequest(new Request.GetItemEstimateCollection[] { collection });

            GetItemEstimateResponse getItemEstimateResponse = this.CONAdapter.GetItemEstimate(getItemEstimateRequest);

            return(getItemEstimateResponse);
        }
        /// <summary>
        /// Gets an estimated number of items in a collection or folder on the server that has to be synchronized.
        /// </summary>
        /// <param name="request">A GetItemEstimateRequest object that contains the request information.</param>
        /// <returns>GetItemEstimate command response</returns>
        public GetItemEstimateResponse GetItemEstimate(GetItemEstimateRequest request)
        {
            GetItemEstimateResponse response = this.activeSyncClient.GetItemEstimate(request);

            this.VerifyTransportRequirements();
            this.VerifyWBXMLCapture(CommandName.GetItemEstimate, response);
            this.VerifyGetItemEstimateCommand(response);
            return(response);
        }
        internal int GetCountOfItemsToSync(string folderId, EasSyncOptions options)
        {
            GetItemEstimateRequest  getItemEstimateRequest = EasRequestGenerator.CreateEstimateRequest(options.SyncKey, folderId, options.RecentOnly);
            GetItemEstimateResponse itemEstimate           = this.GetItemEstimate(getItemEstimateRequest);

            if (itemEstimate.Estimate == null)
            {
                return(0);
            }
            return(itemEstimate.Estimate.Value);
        }
Esempio n. 4
0
        /// <summary>
        /// Gets an estimate of the number of items in a collection or folder on the server that have to be synchronized.
        /// </summary>
        /// <param name="getItemEstimateRequest">A GetItemEstimateRequest object that contains the request information.</param>
        /// <returns>GetItemEstimate command response.</returns>
        public GetItemEstimateResponse GetItemEstimate(GetItemEstimateRequest getItemEstimateRequest)
        {
            GetItemEstimateResponse getItemEstimateResponse = this.activeSyncClient.GetItemEstimate(getItemEstimateRequest);

            Site.Assert.IsNotNull(getItemEstimateResponse, "The GetItemEstimate response returned from server should not be null.");

            // Verify related requirements.
            this.VerifyCommonRequirements();

            return(getItemEstimateResponse);
        }
Esempio n. 5
0
        public void MSASCON_S02_TC01_GetItemEstimate_Filter()
        {
            #region Create a conversation and sync to get the created conversation item.
            string conversationSubject = Common.GenerateResourceName(Site, "Conversation");
            this.CreateConversation(conversationSubject);
            #endregion

            #region Initial Sync on Inbox folder.
            // Call Initial Sync command to get the latest SyncKey.
            SyncStore syncStore = this.CONAdapter.Sync(Common.CreateInitialSyncRequest(User1Information.InboxCollectionId));
            #endregion

            #region Send GetItemEstimate request and get response.
            GetItemEstimateResponse getItemEstimateResponse = this.CallGetItemEstimateCommand(syncStore.SyncKey, User1Information.InboxCollectionId);

            // Verify GetItemEstimate command response.
            bool isVerifyR211 = getItemEstimateResponse.ResponseData.Response.Length == 1 && getItemEstimateResponse.ResponseData.Response[0].Status == "1";

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCON_R211");
            Site.Log.Add(LogEntryKind.Debug, "The length of the Response element from GetItemEstimate command response is {0}.", getItemEstimateResponse.ResponseData.Response.Length);
            Site.Log.Add(LogEntryKind.Debug, "The value of the Status element from GetItemEstimate command response is {0}.", getItemEstimateResponse.ResponseData.Response[0].Status);

            // Verify MS-ASCON requirement: MS-ASCON_R211
            // If the GetItemEstimate command executed successfully, this requirement can be captured.
            Site.CaptureRequirementIfIsTrue(
                isVerifyR211,
                211,
                @"[In Processing a GetItemEstimate Command] When a conversation-based filter is applied to the GetItemEstimate command request, as specified in section 3.1.4.9, the server sends a GetItemEstimate command response ([MS-ASCMD] section 2.2.1.9) that specifies an estimate of the items that meet the filter criteria and need to be synchronized.");

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCON_R332");

            // Verify MS-ASCON requirement: MS-ASCON_R332
            // If the GetItemEstimate command executed successfully, this requirement can be captured.
            Site.CaptureRequirementIfIsTrue(
                isVerifyR211,
                332,
                @"[In Applying a Conversation-based Filter] A conversation-based filter can also be applied to the GetItemEstimate command request ([MS-ASCMD] section 2.2.1.9) to get an estimate of the items that both meet the filter criteria and need to be synchronized.");
            #endregion
        }
Esempio n. 6
0
        /// <summary>
        /// Gets an estimate of the number of items in the specific folder.
        /// </summary>
        /// <param name="syncKey">The latest SyncKey.</param>
        /// <param name="collectionId">The CollectionId of the folder.</param>
        /// <returns>The response of GetItemEstimate command.</returns>
        protected GetItemEstimateResponse CallGetItemEstimateCommand(string syncKey, string collectionId)
        {
            // Create GetItemEstimate command request.
            Request.GetItemEstimateCollection collection = new Request.GetItemEstimateCollection
            {
                CollectionId = collectionId,
                SyncKey      = syncKey
            };

            if (Common.GetConfigurationPropertyValue("ActiveSyncProtocolVersion", this.Site) != "12.1")
            {
                collection.ConversationMode          = true;
                collection.ConversationModeSpecified = true;
            }

            GetItemEstimateRequest getItemEstimateRequest = Common.CreateGetItemEstimateRequest(new Request.GetItemEstimateCollection[] { collection });

            GetItemEstimateResponse getItemEstimateResponse = this.CONAdapter.GetItemEstimate(getItemEstimateRequest);

            return(getItemEstimateResponse);
        }
Esempio n. 7
0
        public void MSASCON_S02_TC02_GetItemEstimate_Status4()
        {
            #region Initial Sync on Calendar folder.
            // Call Initial Sync command to get the latest SyncKey.
            SyncStore syncStore = this.CONAdapter.Sync(Common.CreateInitialSyncRequest(User1Information.CalendarCollectionId));
            #endregion

            #region Call GetItemEstimate command on Calendar folder with setting ConversationMode element in the request.
            GetItemEstimateResponse getItemEstimateResponse = this.CallGetItemEstimateCommand(syncStore.SyncKey, User1Information.CalendarCollectionId);

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-ASCON_R336");

            // Verify MS-ASCON requirement: MS-ASCON_R336
            // If the response Status is 4, this requirement can be captured.
            Site.CaptureRequirementIfAreEqual <int>(
                4,
                int.Parse(getItemEstimateResponse.ResponseData.Status),
                336,
                @"[In Processing a GetItemEstimate Command] [The meaning of status code] 4 [is] Protocol error. The conversation-based filter cannot be applied to a folder that is not of the Email class.");
            #endregion
        }