/// <summary> /// Parse the response data into response body. /// </summary> /// <param name="rawData">The raw data of response</param> /// <returns>The response body of the request</returns> public static QueryColumnsResponseBody Parse(byte[] rawData) { QueryColumnsResponseBody responseBody = new QueryColumnsResponseBody(); int index = 0; responseBody.StatusCode = BitConverter.ToUInt32(rawData, index); index += sizeof(uint); responseBody.ErrorCode = BitConverter.ToUInt32(rawData, index); index += sizeof(uint); responseBody.HasColumns = BitConverter.ToBoolean(rawData, index); index += sizeof(bool); if (responseBody.HasColumns) { responseBody.Columns = LargePropTagArray.Parse(rawData, ref index); } else { responseBody.Columns = null; } 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 response data into response body. /// </summary> /// <param name="rawData">The raw data of response</param> /// <returns>The response body of the request</returns> public static ResolveNamesResponseBody Parse(byte[] rawData) { ResolveNamesResponseBody responseBody = new ResolveNamesResponseBody(); int index = 0; responseBody.StatusCode = BitConverter.ToUInt32(rawData, index); index += sizeof(uint); responseBody.ErrorCode = BitConverter.ToUInt32(rawData, index); index += sizeof(uint); responseBody.CodePage = BitConverter.ToUInt32(rawData, index); index += sizeof(uint); responseBody.HasMinimalIds = BitConverter.ToBoolean(rawData, index); index += sizeof(bool); if (responseBody.HasMinimalIds) { responseBody.MinimalIdCount = BitConverter.ToUInt32(rawData, index); index += sizeof(uint); responseBody.MinimalIds = new uint[(uint)responseBody.MinimalIdCount]; for (int i = 0; i < responseBody.MinimalIdCount; i++) { responseBody.MinimalIds[i] = BitConverter.ToUInt32(rawData, index); index += sizeof(uint); } } else { responseBody.MinimalIdCount = null; responseBody.MinimalIds = null; } responseBody.HasRowsAndPropertyTags = BitConverter.ToBoolean(rawData, index); index += sizeof(bool); if (responseBody.HasRowsAndPropertyTags) { responseBody.PropertyTags = LargePropTagArray.Parse(rawData, ref index); responseBody.RowCount = BitConverter.ToUInt32(rawData, index); index += sizeof(uint); responseBody.RowData = new AddressBookPropertyRow[(uint)responseBody.RowCount]; for (int i = 0; i < responseBody.RowCount; i++) { responseBody.RowData[i] = AddressBookPropertyRow.Parse(rawData, (LargePropTagArray)responseBody.PropertyTags, ref index); } } 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 response data into response body. /// </summary> /// <param name="rawData">The raw data of response</param> /// <returns>The response body of the request</returns> public static SeekEntriesResponseBody Parse(byte[] rawData) { SeekEntriesResponseBody responseBody = new SeekEntriesResponseBody(); int index = 0; responseBody.StatusCode = BitConverter.ToUInt32(rawData, index); index += sizeof(uint); responseBody.ErrorCode = BitConverter.ToUInt32(rawData, index); index += sizeof(uint); responseBody.HasState = BitConverter.ToBoolean(rawData, index); index += sizeof(bool); if (responseBody.HasState) { responseBody.State = STAT.Parse(rawData, ref index); } else { responseBody.State = null; } responseBody.HasColumnsAndRows = BitConverter.ToBoolean(rawData, index); index += sizeof(bool); if (responseBody.HasColumnsAndRows) { responseBody.Columns = LargePropTagArray.Parse(rawData, ref index); responseBody.RowCount = BitConverter.ToUInt32(rawData, index); responseBody.RowData = new AddressBookPropertyRow[(uint)responseBody.RowCount]; index += sizeof(uint); for (int i = 0; i < responseBody.RowCount; i++) { responseBody.RowData[i] = AddressBookPropertyRow.Parse(rawData, (LargePropTagArray)responseBody.Columns, ref index); } } else { responseBody.Columns = null; responseBody.RowCount = null; responseBody.RowData = null; } 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 Large property tag array from the response data. /// </summary> /// <param name="rawData">The response data.</param> /// <param name="index">The start index of response data.</param> /// <returns>The result of parse the response data</returns> public static LargePropTagArray Parse(byte[] rawData, ref int index) { LargePropTagArray largePropTagArray = new LargePropTagArray(); largePropTagArray.PropertyTagCount = BitConverter.ToUInt32(rawData, index); index += sizeof(uint); largePropTagArray.PropertyTags = new PropertyTag[largePropTagArray.PropertyTagCount]; int count = 0; while (largePropTagArray.PropertyTagCount > count) { largePropTagArray.PropertyTags[count].PropertyType = BitConverter.ToUInt16(rawData, index); index += 2; largePropTagArray.PropertyTags[count].PropertyId = BitConverter.ToUInt16(rawData, index); index += 2; count++; } return largePropTagArray; }
/// <summary> /// Parse the Large property tag array from the response data. /// </summary> /// <param name="rawData">The response data.</param> /// <param name="index">The start index of response data.</param> /// <returns>The result of parse the response data</returns> public static LargePropTagArray Parse(byte[] rawData, ref int index) { LargePropTagArray largePropTagArray = new LargePropTagArray(); largePropTagArray.PropertyTagCount = BitConverter.ToUInt32(rawData, index); index += sizeof(uint); largePropTagArray.PropertyTags = new PropertyTag[largePropTagArray.PropertyTagCount]; int count = 0; while (largePropTagArray.PropertyTagCount > count) { largePropTagArray.PropertyTags[count].PropertyType = BitConverter.ToUInt16(rawData, index); index += 2; largePropTagArray.PropertyTags[count].PropertyId = BitConverter.ToUInt16(rawData, index); index += 2; count++; } return(largePropTagArray); }
/// <summary> /// Parse the AddressBookPropertyRow structure. /// </summary> /// <param name="rawBuffer">The raw data returned from server.</param> /// <param name="propTagArray">The list of property tags.</param> /// <param name="index">The start index.</param> /// <returns>Return an instance of AddressBookPropertyRow.</returns> public static AddressBookPropertyRow Parse(byte[] rawBuffer, LargePropTagArray propTagArray, ref int index) { AddressBookPropertyRow addressBookPropertyRow = new AddressBookPropertyRow(); addressBookPropertyRow.Flag = rawBuffer[index]; index++; addressBookPropertyRow.ValueArray = new List<PropertyValue>(); Context.Instance.PropertyBytes = rawBuffer; Context.Instance.CurIndex = index; Context.Instance.CurProperty = new Property(PropertyType.PtypUnspecified); // If the value of the Flags field is set to 0x00: The array contains either a PropertyValue structure, or a TypedPropertyValue structure. // If the value of the Flags field is set to 0x01: The array contains either a FlaggedPropertyValue structure, or a FlaggedPropertyValueWithType structure. if (addressBookPropertyRow.Flag == 0x00) { foreach (PropertyTag propertyTag in propTagArray.PropertyTags) { if (propertyTag.PropertyType == 0x0000) { // If the value of the Flags field is set to 0x00: The array contains a TypedPropertyValue structure, if the type of property is PtyUnspecified. TypedPropertyValue typedPropertyValue = new TypedPropertyValue(); typedPropertyValue.Parse(Context.Instance); addressBookPropertyRow.ValueArray.Add(typedPropertyValue); index = Context.Instance.CurIndex; } else { // If the value of the Flags field is set to 0x00: The array contains a PropertyValue structure, if the type of property is specified. Context.Instance.CurProperty.Type = (PropertyType)propertyTag.PropertyType; PropertyValue propertyValue = new PropertyValue(); propertyValue.Parse(Context.Instance); addressBookPropertyRow.ValueArray.Add(propertyValue); index = Context.Instance.CurIndex; } } } else if (addressBookPropertyRow.Flag == 0x01) { foreach (PropertyTag propertyTag in propTagArray.PropertyTags) { if (propertyTag.PropertyType == 0x0000) { // If the value of the Flags field is set to 0x01: The array contains a FlaggedPropertyValueWithType structure, if the type of property is PtyUnspecified. FlaggedPropertyValueWithType flaggedPropertyValue = new FlaggedPropertyValueWithType(); flaggedPropertyValue.Parse(Context.Instance); addressBookPropertyRow.ValueArray.Add(flaggedPropertyValue); index = Context.Instance.CurIndex; } else { // If the value of the Flags field is set to 0x01: The array contains a FlaggedPropertyValue structure, if the type of property is specified. Context.Instance.CurProperty.Type = (PropertyType)propertyTag.PropertyType; FlaggedPropertyValue propertyValue = new FlaggedPropertyValue(); propertyValue.Parse(Context.Instance); addressBookPropertyRow.ValueArray.Add(propertyValue); index = Context.Instance.CurIndex; } } } return addressBookPropertyRow; }
/// <summary> /// Parse the AddressBookPropertyRow structure. /// </summary> /// <param name="rawBuffer">The raw data returned from server.</param> /// <param name="propTagArray">The list of property tags.</param> /// <param name="index">The start index.</param> /// <returns>Return an instance of AddressBookPropertyRow.</returns> public static AddressBookPropertyRow Parse(byte[] rawBuffer, LargePropTagArray propTagArray, ref int index) { AddressBookPropertyRow addressBookPropertyRow = new AddressBookPropertyRow(); addressBookPropertyRow.Flag = rawBuffer[index]; index++; addressBookPropertyRow.ValueArray = new List <PropertyValue>(); Context.Instance.PropertyBytes = rawBuffer; Context.Instance.CurIndex = index; Context.Instance.CurProperty = new Property(PropertyType.PtypUnspecified); // If the value of the Flags field is set to 0x00: The array contains either a PropertyValue structure, or a TypedPropertyValue structure. // If the value of the Flags field is set to 0x01: The array contains either a FlaggedPropertyValue structure, or a FlaggedPropertyValueWithType structure. if (addressBookPropertyRow.Flag == 0x00) { foreach (PropertyTag propertyTag in propTagArray.PropertyTags) { if (propertyTag.PropertyType == 0x0000) { // If the value of the Flags field is set to 0x00: The array contains a TypedPropertyValue structure, if the type of property is PtyUnspecified. TypedPropertyValue typedPropertyValue = new TypedPropertyValue(); typedPropertyValue.Parse(Context.Instance); addressBookPropertyRow.ValueArray.Add(typedPropertyValue); index = Context.Instance.CurIndex; } else { // If the value of the Flags field is set to 0x00: The array contains a PropertyValue structure, if the type of property is specified. Context.Instance.CurProperty.Type = (PropertyType)propertyTag.PropertyType; PropertyValue propertyValue = new PropertyValue(); propertyValue.Parse(Context.Instance); addressBookPropertyRow.ValueArray.Add(propertyValue); index = Context.Instance.CurIndex; } } } else if (addressBookPropertyRow.Flag == 0x01) { foreach (PropertyTag propertyTag in propTagArray.PropertyTags) { if (propertyTag.PropertyType == 0x0000) { // If the value of the Flags field is set to 0x01: The array contains a FlaggedPropertyValueWithType structure, if the type of property is PtyUnspecified. FlaggedPropertyValueWithType flaggedPropertyValue = new FlaggedPropertyValueWithType(); flaggedPropertyValue.Parse(Context.Instance); addressBookPropertyRow.ValueArray.Add(flaggedPropertyValue); index = Context.Instance.CurIndex; } else { // If the value of the Flags field is set to 0x01: The array contains a FlaggedPropertyValue structure, if the type of property is specified. Context.Instance.CurProperty.Type = (PropertyType)propertyTag.PropertyType; FlaggedPropertyValue propertyValue = new FlaggedPropertyValue(); propertyValue.Parse(Context.Instance); addressBookPropertyRow.ValueArray.Add(propertyValue); index = Context.Instance.CurIndex; } } } return(addressBookPropertyRow); }
/// <summary> /// The NspiResolveNamesW method takes a set of string values in the Unicode character set /// and performs ANR on those strings. /// </summary> /// <param name="reserved">A DWORD value that is reserved for future use.</param> /// <param name="stat">A STAT block that describes a logical position in a specific address book container.</param> /// <param name="propTags">The value NULL or a reference to a PropertyTagArray_r containing a list of the proptags of the columns /// that the client requests to be returned for each row returned.</param> /// <param name="wstr">A WStringsArray_r value. It specifies the values on which the client is requesting the server to perform ANR.</param> /// <param name="mids">A PropertyTagArray_r value. On return, it contains a list of Minimal Entry IDs that match the array of strings.</param> /// <param name="rows">A reference to a PropertyRowSet_r structure. It contains the address book container rows that the server returns in response to the request.</param> /// <returns>Status of NSPI method.</returns> public ErrorCodeValue ResolveNames(uint reserved, STAT stat, PropertyTagArray_r? propTags, WStringsArray_r? wstr, out PropertyTagArray_r? mids, out PropertyRowSet_r? rows) { ErrorCodeValue result; byte[] auxIn = new byte[] { }; ResolveNamesRequestBody resolveNamesRequestBody = new ResolveNamesRequestBody() { Reserved = reserved, HasState = true, State = stat, AuxiliaryBuffer = auxIn, AuxiliaryBufferSize = (uint)auxIn.Length }; if (propTags != null) { LargePropTagArray propetyTags = new LargePropTagArray(); propetyTags.PropertyTagCount = propTags.Value.CValues; propetyTags.PropertyTags = new PropertyTag[propetyTags.PropertyTagCount]; for (int i = 0; i < propTags.Value.CValues; i++) { propetyTags.PropertyTags[i].PropertyId = (ushort)((propTags.Value.AulPropTag[i] & 0xFFFF0000) >> 16); propetyTags.PropertyTags[i].PropertyType = (ushort)(propTags.Value.AulPropTag[i] & 0x0000FFFF); } resolveNamesRequestBody.HasPropertyTags = true; resolveNamesRequestBody.PropertyTags = propetyTags; } else { resolveNamesRequestBody.HasPropertyTags = false; resolveNamesRequestBody.PropertyTags = new LargePropTagArray(); } if (wstr != null) { resolveNamesRequestBody.HasNames = true; resolveNamesRequestBody.Names = wstr.Value; } else { resolveNamesRequestBody.HasNames = false; } ChunkedResponse chunkedResponse = this.SendAddressBookRequest(resolveNamesRequestBody, RequestType.ResolveNames); ResolveNamesResponseBody resolveNamesResponseBody = ResolveNamesResponseBody.Parse(chunkedResponse.ResponseBodyRawData); result = (ErrorCodeValue)resolveNamesResponseBody.ErrorCode; if (resolveNamesResponseBody.RowCount != null) { PropertyRowSet_r newRows = AdapterHelper.ParsePropertyRowSet_r(resolveNamesResponseBody.PropertyTags.Value, resolveNamesResponseBody.RowCount.Value, resolveNamesResponseBody.RowData); rows = newRows; } else { rows = null; } if (resolveNamesResponseBody.HasMinimalIds) { PropertyTagArray_r propertyTagArray = new PropertyTagArray_r(); propertyTagArray.CValues = resolveNamesResponseBody.MinimalIdCount.Value; propertyTagArray.AulPropTag = resolveNamesResponseBody.MinimalIds; mids = propertyTagArray; } else { mids = null; } return result; }
/// <summary> /// The NspiModProps method is used to modify the properties of an object in the address book. /// </summary> /// <param name="stat">A STAT block that describes a logical position in a specific address book container.</param> /// <param name="propTags">The value NULL or a reference to a PropertyTagArray_r. /// It contains a list of the proptags of the columns from which the client requests all the values to be removed.</param> /// <param name="row">A PropertyRow_r value. It contains an address book row.</param> /// <returns>Status of NSPI method.</returns> public ErrorCodeValue ModProps(STAT stat, PropertyTagArray_r? propTags, PropertyRow_r row) { ErrorCodeValue result; ModPropsRequestBody modPropsRequestBody = new ModPropsRequestBody(); modPropsRequestBody.HasState = true; modPropsRequestBody.State = stat; if (propTags != null) { LargePropTagArray largePropTagArray = new LargePropTagArray(); largePropTagArray.PropertyTagCount = propTags.Value.CValues; largePropTagArray.PropertyTags = new PropertyTag[propTags.Value.CValues]; for (int i = 0; i < propTags.Value.CValues; i++) { largePropTagArray.PropertyTags[i].PropertyId = (ushort)((propTags.Value.AulPropTag[i] & 0xFFFF0000) >> 16); largePropTagArray.PropertyTags[i].PropertyType = (ushort)(propTags.Value.AulPropTag[i] & 0x0000FFFF); } modPropsRequestBody.HasPropertyTagsToRemove = true; modPropsRequestBody.PropertyTagsToRemove = largePropTagArray; } else { modPropsRequestBody.HasPropertyTagsToRemove = false; } modPropsRequestBody.HasPropertyValues = true; AddressBookPropValueList addressBookPropValueList = new AddressBookPropValueList(); addressBookPropValueList.PropertyValueCount = row.CValues; addressBookPropValueList.PropertyValues = new TaggedPropertyValue[row.CValues]; for (int i = 0; i < row.CValues; i++) { addressBookPropValueList.PropertyValues[i] = new TaggedPropertyValue(); byte[] propertyBytes = new byte[row.LpProps[i].Serialize().Length - 8]; Array.Copy(row.LpProps[i].Serialize(), 8, propertyBytes, 0, row.LpProps[i].Serialize().Length - 8); addressBookPropValueList.PropertyValues[i].Value = propertyBytes; PropertyTag propertyTagOfRow = new PropertyTag(); propertyTagOfRow.PropertyId = (ushort)((row.LpProps[i].PropTag & 0xFFFF0000) >> 16); propertyTagOfRow.PropertyType = (ushort)(row.LpProps[i].PropTag & 0x0000FFFF); addressBookPropValueList.PropertyValues[i].PropertyTag = propertyTagOfRow; } modPropsRequestBody.PropertyVaules = addressBookPropValueList; byte[] auxIn = new byte[] { }; modPropsRequestBody.AuxiliaryBuffer = auxIn; modPropsRequestBody.AuxiliaryBufferSize = (uint)auxIn.Length; ChunkedResponse chunkedResponse = this.SendAddressBookRequest(modPropsRequestBody, RequestType.ModProps); ModPropsResponseBody modPropsResponseBody = ModPropsResponseBody.Parse(chunkedResponse.ResponseBodyRawData); result = (ErrorCodeValue)modPropsResponseBody.ErrorCode; return result; }
/// <summary> /// The NspiGetMatches method returns an Explicit Table. /// </summary> /// <param name="reserved">A DWORD value reserved for future use.</param> /// <param name="stat">A STAT block that describes a logical position in a specific address book container.</param> /// <param name="proReserved">A PropertyTagArray_r reserved for future use.</param> /// <param name="reserved2">A DWORD value reserved for future use. Ignored by the server.</param> /// <param name="filter">The value NULL or a Restriction_r value. /// It holds a logical restriction to apply to the rows in the address book container specified in the stat parameter.</param> /// <param name="propName">The value NULL or a PropertyName_r value. /// It holds the property to be opened as a restricted address book container.</param> /// <param name="requested">A DWORD value. It contains the maximum number of rows to return in a restricted address book container.</param> /// <param name="outMids">A PropertyTagArray_r value. On return, it holds a list of Minimal Entry IDs that comprise a restricted address book container.</param> /// <param name="propTags">The value NULL or a reference to a PropertyTagArray_r value. /// It contains a list of the proptags of the columns that client wants to be returned for each row returned.</param> /// <param name="rows">A reference to a PropertyRowSet_r value. It contains the address book container rows the server returns in response to the request.</param> /// <returns>Status of NSPI method.</returns> public ErrorCodeValue GetMatches(uint reserved, ref STAT stat, PropertyTagArray_r? proReserved, uint reserved2, Restriction_r? filter, PropertyName_r? propName, uint requested, out PropertyTagArray_r? outMids, PropertyTagArray_r? propTags, out PropertyRowSet_r? rows) { ErrorCodeValue result; byte[] auxIn = new byte[] { }; GetMatchesRequestBody getMatchesRequestBody = new GetMatchesRequestBody() { Reserved = reserved, HasState = true, State = stat, InterfaceOptionFlags = reserved2, HasPropertyName = false, RowCount = requested, AuxiliaryBuffer = auxIn, AuxiliaryBufferSize = (uint)auxIn.Length }; if (propTags != null) { LargePropTagArray propetyTags = new LargePropTagArray(); propetyTags.PropertyTagCount = propTags.Value.CValues; propetyTags.PropertyTags = new PropertyTag[propetyTags.PropertyTagCount]; for (int i = 0; i < propTags.Value.CValues; i++) { propetyTags.PropertyTags[i].PropertyId = (ushort)((propTags.Value.AulPropTag[i] & 0xFFFF0000) >> 16); propetyTags.PropertyTags[i].PropertyType = (ushort)(propTags.Value.AulPropTag[i] & 0x0000FFFF); } getMatchesRequestBody.HasColumns = true; getMatchesRequestBody.Columns = propetyTags; } if (proReserved != null) { getMatchesRequestBody.HasMinimalIds = true; getMatchesRequestBody.MinimalIdCount = proReserved.Value.CValues; getMatchesRequestBody.MinimalIds = proReserved.Value.AulPropTag; } if (filter != null) { getMatchesRequestBody.HasFilter = true; getMatchesRequestBody.Filter = AdapterHelper.ConvertRestriction_rToRestriction(filter.Value); } ChunkedResponse chunkedResponse = this.SendAddressBookRequest(getMatchesRequestBody, RequestType.GetMatches); GetMatchesResponseBody getMatchesResponseBody = GetMatchesResponseBody.Parse(chunkedResponse.ResponseBodyRawData); result = (ErrorCodeValue)getMatchesResponseBody.ErrorCode; if (getMatchesResponseBody.HasMinimalIds) { PropertyTagArray_r propertyTagArray = new PropertyTagArray_r(); propertyTagArray.CValues = getMatchesResponseBody.MinimalIdCount.Value; propertyTagArray.AulPropTag = getMatchesResponseBody.MinimalIds; outMids = propertyTagArray; } else { outMids = null; } if (getMatchesResponseBody.RowCount != null) { PropertyRowSet_r newRows = AdapterHelper.ParsePropertyRowSet_r(getMatchesResponseBody.Columns.Value, getMatchesResponseBody.RowCount.Value, getMatchesResponseBody.RowData); rows = newRows; } else { rows = null; } if (getMatchesResponseBody.HasState) { stat = getMatchesResponseBody.State.Value; } return result; }
/// <summary> /// The NspiSeekEntries method searches for and sets the logical position in a specific table /// to the first entry greater than or equal to a specified value. /// </summary> /// <param name="reserved">A DWORD value that is reserved for future use. Ignored by the server.</param> /// <param name="stat">A STAT block that describes a logical position in a specific address book container.</param> /// <param name="target">A PropertyValue_r value holding the value that is being sought.</param> /// <param name="table">The value NULL or a PropertyTagArray_r value. /// It holds a list of Minimal Entry IDs that comprise a restricted address book container.</param> /// <param name="propTags">It contains a list of the proptags of the columns /// that client wants to be returned for each row returned.</param> /// <param name="rows">It contains the address book container rows the server returns in response to the request.</param> /// <returns>Status of NSPI method.</returns> public ErrorCodeValue SeekEntries(uint reserved, ref STAT stat, PropertyValue_r target, PropertyTagArray_r? table, PropertyTagArray_r? propTags, out PropertyRowSet_r? rows) { ErrorCodeValue result; SeekEntriesRequestBody seekEntriesRequestBody = new SeekEntriesRequestBody(); TaggedPropertyValue targetValue = new TaggedPropertyValue(); targetValue.PropertyTag = new PropertyTag((ushort)((target.PropTag & 0xFFFF0000) >> 16), (ushort)(target.PropTag & 0x0000FFFF)); targetValue.Value = new byte[target.Serialize().Length - 8]; Array.Copy(target.Serialize(), 8, targetValue.Value, 0, target.Serialize().Length - 8); // Reserved. The client MUST set this field to 0x00000000 and the server MUST ignore this field. seekEntriesRequestBody.Reserved = reserved; seekEntriesRequestBody.HasState = true; seekEntriesRequestBody.State = stat; seekEntriesRequestBody.HasTarget = true; seekEntriesRequestBody.Target = targetValue; if (table != null) { seekEntriesRequestBody.HasExplicitTable = true; seekEntriesRequestBody.ExplicitTable = table.Value.AulPropTag; } LargePropTagArray propetyTags = new LargePropTagArray(); if (propTags != null) { propetyTags.PropertyTagCount = propTags.Value.CValues; propetyTags.PropertyTags = new PropertyTag[propetyTags.PropertyTagCount]; for (int i = 0; i < propTags.Value.CValues; i++) { propetyTags.PropertyTags[i].PropertyId = (ushort)((propTags.Value.AulPropTag[i] & 0xFFFF0000) >> 16); propetyTags.PropertyTags[i].PropertyType = (ushort)(propTags.Value.AulPropTag[i] & 0x0000FFFF); } seekEntriesRequestBody.HasColumns = true; seekEntriesRequestBody.Columns = propetyTags; } seekEntriesRequestBody.AuxiliaryBufferSize = 0; seekEntriesRequestBody.AuxiliaryBuffer = new byte[] { }; ChunkedResponse chunkedResponse = this.SendAddressBookRequest(seekEntriesRequestBody, RequestType.SeekEntries); SeekEntriesResponseBody seekEntriesResponseBody = SeekEntriesResponseBody.Parse(chunkedResponse.ResponseBodyRawData); result = (ErrorCodeValue)seekEntriesResponseBody.ErrorCode; if (seekEntriesResponseBody.HasColumnsAndRows) { PropertyRowSet_r newRows = AdapterHelper.ParsePropertyRowSet_r(seekEntriesResponseBody.Columns.Value, seekEntriesResponseBody.RowCount.Value, seekEntriesResponseBody.RowData); rows = newRows; } else { rows = null; } if (seekEntriesResponseBody.HasState) { stat = seekEntriesResponseBody.State.Value; } return result; }
/// <summary> /// The NspiQueryRows method returns a number of rows from a specified table to the client. /// </summary> /// <param name="flags">A DWORD value that contains a set of bit flags.</param> /// <param name="stat">A STAT block that describes a logical position in a specific address book container.</param> /// <param name="tableCount">A DWORD value that contains the number values in the input parameter table. /// This value is limited to 100,000.</param> /// <param name="table">An array of DWORD values, representing an Explicit Table.</param> /// <param name="count">A DWORD value that contains the number of rows the client is requesting.</param> /// <param name="propTags">The value NULL or a reference to a PropertyTagArray_r value, /// containing a list of the proptags of the properties that the client requires to be returned for each row returned.</param> /// <param name="rows">A nullable PropertyRowSet_r value, it contains the address book container rows that the server returns in response to the request.</param> /// <returns>Status of NSPI method.</returns> public ErrorCodeValue QueryRows(uint flags, ref STAT stat, uint tableCount, uint[] table, uint count, PropertyTagArray_r? propTags, out PropertyRowSet_r? rows) { ErrorCodeValue result; QueryRowsRequestBody queryRowsRequestBody = new QueryRowsRequestBody(); LargePropTagArray propetyTags = new LargePropTagArray(); if (propTags != null) { propetyTags.PropertyTagCount = propTags.Value.CValues; propetyTags.PropertyTags = new PropertyTag[propetyTags.PropertyTagCount]; for (int i = 0; i < propTags.Value.CValues; i++) { propetyTags.PropertyTags[i].PropertyId = (ushort)((propTags.Value.AulPropTag[i] & 0xFFFF0000) >> 16); propetyTags.PropertyTags[i].PropertyType = (ushort)(propTags.Value.AulPropTag[i] & 0x0000FFFF); } queryRowsRequestBody.HasColumns = true; queryRowsRequestBody.Columns = propetyTags; } queryRowsRequestBody.Flags = flags; queryRowsRequestBody.HasState = true; queryRowsRequestBody.State = stat; queryRowsRequestBody.ExplicitTableCount = tableCount; queryRowsRequestBody.ExplicitTable = table; queryRowsRequestBody.RowCount = count; byte[] auxIn = new byte[] { }; queryRowsRequestBody.AuxiliaryBuffer = auxIn; queryRowsRequestBody.AuxiliaryBufferSize = (uint)auxIn.Length; ChunkedResponse chunkedResponse = this.SendAddressBookRequest(queryRowsRequestBody, RequestType.QueryRows); QueryRowsResponseBody queryRowsResponseBody = QueryRowsResponseBody.Parse(chunkedResponse.ResponseBodyRawData); result = (ErrorCodeValue)queryRowsResponseBody.ErrorCode; if (queryRowsResponseBody.RowCount != null) { PropertyRowSet_r newRows = AdapterHelper.ParsePropertyRowSet_r(queryRowsResponseBody.Columns.Value, queryRowsResponseBody.RowCount.Value, queryRowsResponseBody.RowData); rows = newRows; } else { rows = null; } if (queryRowsResponseBody.HasState) { stat = queryRowsResponseBody.State.Value; } return result; }
/// <summary> /// The NspiGetProps method returns an address book row that contains a set of the properties /// and values that exist on an object. /// </summary> /// <param name="flags">A DWORD value that contains a set of bit flags.</param> /// <param name="stat">A STAT block that describes a logical position in a specific address book container.</param> /// <param name="propTags">The value NULL or a reference to a PropertyTagArray_r value. /// It contains a list of the proptags of the properties that the client wants to be returned.</param> /// <param name="rows">A nullable PropertyRow_r value. /// It contains the address book container row the server returns in response to the request.</param> /// <returns>Status of NSPI method.</returns> public ErrorCodeValue GetProps(uint flags, STAT stat, PropertyTagArray_r? propTags, out PropertyRow_r? rows) { ErrorCodeValue result; GetPropsRequestBody getPropertyRequestBody = null; LargePropTagArray propetyTags = new LargePropTagArray(); if (propTags != null) { propetyTags.PropertyTagCount = propTags.Value.CValues; propetyTags.PropertyTags = new PropertyTag[propetyTags.PropertyTagCount]; for (int i = 0; i < propTags.Value.CValues; i++) { propetyTags.PropertyTags[i].PropertyId = (ushort)((propTags.Value.AulPropTag[i] & 0xFFFF0000) >> 16); propetyTags.PropertyTags[i].PropertyType = (ushort)(propTags.Value.AulPropTag[i] & 0x0000FFFF); } getPropertyRequestBody = this.BuildGetPropsRequestBody(flags, true, stat, true, propetyTags); } else { getPropertyRequestBody = this.BuildGetPropsRequestBody(flags, true, stat, false, propetyTags); } ChunkedResponse chunkedResponse = this.SendAddressBookRequest(getPropertyRequestBody, RequestType.GetProps); GetPropsResponseBody getPropsResponseBody = GetPropsResponseBody.Parse(chunkedResponse.ResponseBodyRawData); result = (ErrorCodeValue)getPropsResponseBody.ErrorCode; if (getPropsResponseBody.HasPropertyValues) { PropertyRow_r propertyRow = AdapterHelper.ParsePropertyRow_r(getPropsResponseBody.PropertyValues.Value); rows = propertyRow; } else { rows = null; } return result; }
/// <summary> /// Initialize the GetProps request body. /// </summary> /// <param name="flags">A set of bit flags that specify options to the server.</param> /// <param name="hasState">A Boolean value that specifies whether the State field is present.</param> /// <param name="stat">A STAT block that describes a logical position in a specific address book container.</param> /// <param name="hasPropertyTags">A Boolean value that specifies whether the PropertyTags field is present.</param> /// <param name="propetyTags">A LargePropertyTagArray structure that contains the property tags of the properties that the client is requesting.</param> /// <returns>An instance of the GetProps request body.</returns> private GetPropsRequestBody BuildGetPropsRequestBody(uint flags, bool hasState, STAT? stat, bool hasPropertyTags, LargePropTagArray propetyTags) { GetPropsRequestBody getPropertyRequestBody = new GetPropsRequestBody(); getPropertyRequestBody.Flags = flags; byte[] auxIn = new byte[] { }; getPropertyRequestBody.AuxiliaryBuffer = auxIn; getPropertyRequestBody.AuxiliaryBufferSize = (uint)auxIn.Length; if (hasState) { getPropertyRequestBody.HasState = true; if (stat != null) { getPropertyRequestBody.State = (STAT)stat; } } else { getPropertyRequestBody.HasState = false; STAT statNew = new STAT(); getPropertyRequestBody.State = statNew; } if (hasPropertyTags) { getPropertyRequestBody.HasPropertyTags = true; getPropertyRequestBody.PropertyTags = propetyTags; } else { getPropertyRequestBody.HasPropertyTags = false; LargePropTagArray propetyTagsNew = new LargePropTagArray(); getPropertyRequestBody.PropertyTags = propetyTagsNew; } return getPropertyRequestBody; }