/// <summary> /// This method sends the disconnect request through MAPIHTTP transport to the server. /// </summary> /// <returns>If the method succeeds, the return value is 0. If the method fails, the return value is an implementation-specific error code.</returns> public uint Disconnect() { uint returnValue = 0; DisconnectRequestBody disconnectBody = new DisconnectRequestBody(); disconnectBody.AuxiliaryBufferSize = 0; disconnectBody.AuxiliaryBuffer = new byte[] { }; HttpWebResponse response = SendMAPIHttpRequest(this.site, this.mailStoreUrl, this.userName, this.domain, this.userPassword, disconnectBody, "Disconnect", this.cookies); string transferEncoding = response.Headers["Transfer-Encoding"]; string pendingInterval = response.Headers["X-PendingPeriod"]; string responseCode = response.Headers["X-ResponseCode"]; if (transferEncoding != null) { if (string.Compare(transferEncoding, "chunked") == 0) { byte[] rawBuffer = ReadHttpResponse(response); if (uint.Parse(responseCode) == 0) { ChunkedResponse chunkedResponse = ChunkedResponse.ParseChunkedResponse(rawBuffer); DisconnectSuccessResponseBody responseSuccess = DisconnectSuccessResponseBody.Parse(chunkedResponse.ResponseBodyRawData); returnValue = responseSuccess.ErrorCode; } } } response.GetResponseStream().Close(); this.cookies = null; return(returnValue); }
/// <summary> /// Parse the Disconnect request type success response body. /// </summary> /// <param name="rawData">The raw data which is returned by server.</param> /// <returns>An instance of DisconnectSuccessResponseBody class.</returns> public static DisconnectSuccessResponseBody Parse(byte[] rawData) { DisconnectSuccessResponseBody responseBody = new DisconnectSuccessResponseBody(); int index = 0; responseBody.StatusCode = BitConverter.ToUInt32(rawData, index); index += 4; responseBody.ErrorCode = BitConverter.ToUInt32(rawData, index); index += 4; responseBody.AuxiliaryBufferSize = BitConverter.ToUInt32(rawData, index); index += 4; responseBody.AuxiliaryBuffer = new byte[responseBody.AuxiliaryBufferSize]; Array.Copy(rawData, index, responseBody.AuxiliaryBuffer, 0, responseBody.AuxiliaryBufferSize); return responseBody; }
/// <summary> /// Parse the Disconnect request type success response body. /// </summary> /// <param name="rawData">The raw data which is returned by server.</param> /// <returns>An instance of DisconnectSuccessResponseBody class.</returns> public static DisconnectSuccessResponseBody Parse(byte[] rawData) { DisconnectSuccessResponseBody responseBody = new DisconnectSuccessResponseBody(); int index = 0; responseBody.StatusCode = BitConverter.ToUInt32(rawData, index); index += 4; responseBody.ErrorCode = BitConverter.ToUInt32(rawData, index); index += 4; responseBody.AuxiliaryBufferSize = BitConverter.ToUInt32(rawData, index); index += 4; responseBody.AuxiliaryBuffer = new byte[responseBody.AuxiliaryBufferSize]; Array.Copy(rawData, index, responseBody.AuxiliaryBuffer, 0, responseBody.AuxiliaryBufferSize); return(responseBody); }