Ejemplo n.º 1
0
        private static void ParseOperations(IntacctServiceResponse response, ICollection <IIntacctOperation> operations, IEnumerable <XElement> operationElements)
        {
            foreach (var operationElement in operationElements)
            {
                var authSuccess = operationElement.Element("authentication")?.Element("status")?.Value == "success";
                if (!authSuccess)
                {
                    var errorMessageElement = operationElement.Element("errormessage");
                    response.AddOperationResult(IntacctOperationAuthFailedResult.Create(ParseErrors(errorMessageElement)));
                    continue;
                }

                var opResponses = from resultElement in operationElement.Elements("result")
                                  let functionName = resultElement.Element("function")?.Value
                                                     let controlId = resultElement.Element("controlid")?.Value
                                                                     join operation in operations on new { F = functionName, C = controlId } equals new { F = operation.FunctionName, C = operation.Id }
                select new
                {
                    Operation = operation,
                    Result    = resultElement
                };
                foreach (var operationAndResponse in opResponses)
                {
                    var result = operationAndResponse.Operation.ProcessResult(operationAndResponse.Result);
                    response.AddOperationResult(result);
                }
            }
        }
Ejemplo n.º 2
0
		private static void ParseOperations(IntacctServiceResponse response, ICollection<IIntacctOperation> operations, IEnumerable<XElement> operationElements)
		{
			foreach (var operationElement in operationElements)
			{
				var authSuccess = operationElement.Element("authentication")?.Element("status")?.Value == "success";
				if (!authSuccess)
				{
					var errorMessageElement = operationElement.Element("errormessage");
					response.AddOperationResult(IntacctOperationAuthFailedResult.Create(ParseErrors(errorMessageElement)));
					continue;
				}

				var opResponses = from resultElement in operationElement.Elements("result")
				                  let functionName = resultElement.Element("function")?.Value
				                  let controlId = resultElement.Element("controlid")?.Value
				                  join operation in operations on new { F = functionName, C = controlId } equals new { F = operation.FunctionName, C = operation.Id }
				                  select new
					                         {
						                         Operation = operation,
						                         Result = resultElement
					                         };
				foreach (var operationAndResponse in opResponses)
				{
					var result = operationAndResponse.Operation.ProcessResult(operationAndResponse.Result);
					response.AddOperationResult(result);
				}
			}
		}