/// <summary> /// Tries to get the <see cref="Intuit.Ipp.DataService.IntuitBatchResponse"/> with the specified id /// </summary> /// <param name="id"> unique batchitem id. </param> /// <returns>True if the item was found, otherwise false</returns> public bool TryGetValue(string id, out IntuitBatchResponse intuitBatchResponse) { BatchItemResponse batchresponse = this.batchResponses.FirstOrDefault(item => item.bId == id); if (batchresponse == null) { intuitBatchResponse = null; return(false); } intuitBatchResponse = ProcessBatchItemResponse(batchresponse); return(true); }
/// <summary> /// Gets the <see cref="Intuit.Ipp.DataService.IntuitBatchResponse"/> with the specified id. /// </summary> /// <param name="id"> unique batchitem id. </param> public IntuitBatchResponse this[string id] { get { BatchItemResponse batchresponse = this.batchResponses.Find(item => item.bId == id); // if (batchresponse == null) // { // throw new IdsException(string.Format("Could not find the batch item response with the specified id: {0}", id)); // } IntuitBatchResponse result = ProcessBatchItemResponse(batchresponse); return(result); } }
/// <summary> /// process batch item response /// </summary> /// <param name="batchitemResponse">The batchitem response.</param> /// <returns> returns IntuitBatchResponse object.</returns> private static IntuitBatchResponse ProcessBatchItemResponse(BatchItemResponse batchitemResponse) { IntuitBatchResponse result = new IntuitBatchResponse(); result.Id = batchitemResponse.bId; Fault fault = batchitemResponse.AnyIntuitObject as Fault; if (fault == null) { CDCResponse cdcResponses = batchitemResponse.AnyIntuitObject as CDCResponse; if (cdcResponses != null) { result.ResponseType = ResponseType.CdcQuery; int count = 1; IntuitCDCResponse returnValue = new IntuitCDCResponse(); object[] queryResponses = cdcResponses.AnyIntuitObjects; if (queryResponses != null) { foreach (QueryResponse queryResponse in queryResponses) { Type type = queryResponse.GetType(); List <IEntity> entities = new List <IEntity>(); PropertyInfo[] propertyInfoArray = type.GetProperties(); foreach (PropertyInfo propertyInfo in propertyInfoArray) { if (true == propertyInfo.PropertyType.IsArray) { object tempEntities = propertyInfo.GetValue(queryResponse, null); if (tempEntities != null) { object[] tempEntityArray = (object[])tempEntities; if (tempEntityArray.Length > 0) { List <IEntity> arr = new List <IEntity>(); string entityName = string.Empty; foreach (object item in tempEntityArray) { entities.Add((IEntity)item); entityName = item.GetType().Name; count++; } returnValue.entities.Add(entityName, entities); } break; } } } result.CDCResponse = returnValue; } } } else { IEntity entity = batchitemResponse.AnyIntuitObject as IEntity; if (entity == null) { QueryResponse queryResponse = batchitemResponse.AnyIntuitObject as QueryResponse; if (queryResponse != null) { result.ResponseType = ResponseType.Query; QueryResponse returnValue = new QueryResponse(); returnValue.totalCount = queryResponse.totalCount; returnValue.totalCountSpecified = queryResponse.totalCountSpecified; result.QueryResponse = returnValue; if (queryResponse.AnyIntuitObjects != null && queryResponse.AnyIntuitObjects.Count() > 0) { foreach (object obj in queryResponse.AnyIntuitObjects) { result.AddEntities(obj as IEntity); } } } else { //Not sure how we end up here } } else { result.ResponseType = ResponseType.Entity; result.Entity = entity; } } } else { result.ResponseType = ResponseType.Exception; IdsException idsException = IterateFaultAndPrepareException(fault); result.Exception = idsException; } return(result); }