/// <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 GetTemplateInfoResponseBody Parse(byte[] rawData) { GetTemplateInfoResponseBody responseBody = new GetTemplateInfoResponseBody(); 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.HasRow = BitConverter.ToBoolean(rawData, index); index += sizeof(bool); if (responseBody.HasRow) { responseBody.Row = AddressBookPropValueList.Parse(rawData, ref index); } else { responseBody.Row = 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 GetSpecialTableResponseBody Parse(byte[] rawData) { GetSpecialTableResponseBody responseBody = new GetSpecialTableResponseBody(); 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.HasVersion = BitConverter.ToBoolean(rawData, index); index += sizeof(bool); if (responseBody.HasVersion) { responseBody.Version = BitConverter.ToUInt32(rawData, index); index += sizeof(uint); } else { responseBody.Version = null; } responseBody.HasRows = BitConverter.ToBoolean(rawData, index); index += sizeof(bool); if (responseBody.HasRows) { responseBody.RowCount = BitConverter.ToUInt32(rawData, index); index += sizeof(uint); responseBody.Rows = new AddressBookPropValueList[(uint)responseBody.RowCount]; for (int i = 0; i < responseBody.RowCount; i++) { responseBody.Rows[i] = AddressBookPropValueList.Parse(rawData, ref index); } } else { responseBody.RowCount = null; responseBody.Rows = 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 AddressBookPropValueList structure. /// </summary> /// <param name="rawData">The raw data of response buffer.</param> /// <param name="index">The start index.</param> /// <returns>Instance of the AddressBookPropValueList.</returns> public static AddressBookPropValueList Parse(byte[] rawData, ref int index) { AddressBookPropValueList addressBookPropValueList = new AddressBookPropValueList(); addressBookPropValueList.PropertyValueCount = BitConverter.ToUInt32(rawData, index); index += sizeof(uint); Context.Instance.PropertyBytes = rawData; Context.Instance.CurIndex = index; Context.Instance.CurProperty = new Property(PropertyType.PtypUnspecified); addressBookPropValueList.PropertyValues = new TaggedPropertyValue[addressBookPropValueList.PropertyValueCount]; for (int i = 0; i < addressBookPropValueList.PropertyValueCount; i++) { // Parse the TaggedPropertyValue from the response buffer. TaggedPropertyValue taggedPropertyValue = new TaggedPropertyValue(); taggedPropertyValue.Parse(Context.Instance); addressBookPropValueList.PropertyValues[i] = taggedPropertyValue; } index = Context.Instance.CurIndex; return addressBookPropValueList; }
/// <summary> /// Parse the AddressBookPropValueList structure. /// </summary> /// <param name="rawData">The raw data of response buffer.</param> /// <param name="index">The start index.</param> /// <returns>Instance of the AddressBookPropValueList.</returns> public static AddressBookPropValueList Parse(byte[] rawData, ref int index) { AddressBookPropValueList addressBookPropValueList = new AddressBookPropValueList(); addressBookPropValueList.PropertyValueCount = BitConverter.ToUInt32(rawData, index); index += sizeof(uint); Context.Instance.PropertyBytes = rawData; Context.Instance.CurIndex = index; Context.Instance.CurProperty = new Property(PropertyType.PtypUnspecified); addressBookPropValueList.PropertyValues = new TaggedPropertyValue[addressBookPropValueList.PropertyValueCount]; for (int i = 0; i < addressBookPropValueList.PropertyValueCount; i++) { // Parse the TaggedPropertyValue from the response buffer. TaggedPropertyValue taggedPropertyValue = new TaggedPropertyValue(); taggedPropertyValue.Parse(Context.Instance); addressBookPropValueList.PropertyValues[i] = taggedPropertyValue; } index = Context.Instance.CurIndex; return(addressBookPropValueList); }
/// <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; }