Beispiel #1
0
        /// <summary>
        /// Calls the server and updates the history.
        /// </summary>
        private int[] UpdateHistory(
            Session session,
            List<HdaUpdateRequest> requests,
            bool checkOperationError)
        {
            int[] errors = new int[requests.Count];

            // build list of nodes to update.
            ExtensionObjectCollection nodesToUpdate = new ExtensionObjectCollection();
            List<int> indexes = new List<int>();

            for (int ii = 0; ii < requests.Count; ii++)
            {
                if (requests[ii].Error < 0)
                {
                    errors[ii] = requests[ii].Error;
                    continue;
                }

                // check if nothing to do.
                if (requests[ii].Details == null)
                {
                    continue;
                }

                nodesToUpdate.Add(requests[ii].Details);
                indexes.Add(ii);
            }

            if (nodesToUpdate.Count == 0)
            {
                return errors;
            }

            // call the server.
            HistoryUpdateResultCollection results = null;
            DiagnosticInfoCollection diagnosticInfos = null;

            session.HistoryUpdate(
                null,
                nodesToUpdate,
                out results,
                out diagnosticInfos);

            Session.ValidateResponse(results, nodesToUpdate);
            Session.ValidateDiagnosticInfos(diagnosticInfos, nodesToUpdate);

            // process results.
            for (int ii = 0; ii < nodesToUpdate.Count; ii++)
            {
                HdaUpdateRequest request = requests[indexes[ii]];

                request.Error = MapUpdateStatusToErrorCode(results[ii].StatusCode);

                if (checkOperationError)
                {
                    if (StatusCode.IsGood(results[ii].StatusCode))
                    {
                        request.Error = MapUpdateStatusToErrorCode(results[ii].OperationResults[0]);
                    }
                }

                errors[indexes[ii]] = request.Error;
            }

            return errors;
        }