Ejemplo n.º 1
0
        //public readonly static String ORIGIN_HOST = "?clientVersion=9.0";
        //public readonly static String IGNORE_SEQUENCE_NUMBER = "&ignoreSequenceNumber=true";

        /**
         * Check the result information returned by an Sh operation, and throw an
         * exception including result details if it does not indicate success.
         *
         * @param resultCode
         *                    The result code returned by the operation.
         * @param extendedResult
         *                    The extended result information returned by the
         *                    operation.
         * @param userData    The user data that was included in the operation.
         */
        public void CheckResultCode(int resultCode, tExtendedResult extendedResult, XmlElement userData)
        {
            //2001 is success and 5001 means doesn't exist
            //https://drive.google.com/open?id=0B7rht-P1r85vc29oRnFRQmpseFE
            if (resultCode != 2001 && resultCode != 5001)
            {
                //-----------------------------------------------------------------------
                // Request was unsuccessful, so return error information.
                //-----------------------------------------------------------------------
                StringBuilder error = new StringBuilder();

                error.Append("The Sh operation was unsuccessful.\n");
                error.Append("Result code: ");
                error.Append(resultCode);
                error.Append("\nExtended result code: ");
                error.Append(extendedResult.ExtendedResultCode);
                error.Append("\n\"" + extendedResult.ExtendedResultDetail + "\"\n");

                //-----------------------------------------------------------------------
                // Include each of the sub-results.
                //-----------------------------------------------------------------------
                foreach (tSubResult subResult in extendedResult.ExtendedSubResults)
                {
                    error.Append("\nSub-result code: ");
                    error.Append(subResult.SubResultCode);
                    error.Append("\n\"" + subResult.SubResultDetail + "\"\n");
                    error.Append("Source: " + getSourceItem(subResult, userData) + "\n");
                }

                throw new RequestFailedException(error.ToString());
            }
        }
Ejemplo n.º 2
0
        public int ShPull(string userIdentity, string serviceIndication, out tExtendedResult extendedResult, out tUserData userData)
        {
            var resultCode = _sh.ShPull(userIdentity, 0, serviceIndication, _originHost, out extendedResult, out userData);

            //Checks to make sure the request was a success and if not throws an exception and tacks on the extended result to the exception.
            _utilities.CheckResultCode(resultCode, extendedResult, null);

            return(resultCode);
        }
Ejemplo n.º 3
0
        public int ShUpdate(string dn, tUserData userData, out tExtendedResult extendedResult, bool updateExisting = false)
        {
            //The apply action tells the web service to apply the settings supplied in the field elements, creating
            //or modifying the objects as required. This is the default action, and is the behavior if the Action
            //attribute is not specified explicitly
            //this is why you may not see action specified in the script or here.


            if (string.IsNullOrEmpty(dn))
            {
                throw new Exception(MethodBase.GetCurrentMethod().Name + ": dn is required and was not supplied.");
            }

            if (userData == null)
            {
                throw new Exception(MethodBase.GetCurrentMethod().Name + ": userData is required and was not supplied.");
            }

            if (updateExisting)
            {
                var serviceIndication = userData.ShData[0].ServiceIndication;

                var sequenceNumber = RetrieveCurrentSequenceNumber(dn, serviceIndication);
                if (sequenceNumber > 0)
                {
                    userData.ShData[0].SequenceNumber = _utilities.IncrementSequenceNumber(sequenceNumber);
                }
                else
                {
                    //if the subscriber doesn't exist then forcing a sequence number of 0 and forcing not to ignore sequence number.
                    userData.ShData[0].SequenceNumber = 0;
                }
            }

            //tMeta_Subscriber_Alarms alarms;
            var resultCode = _sh.ShUpdate(dn, 0, userData, _originHost, out extendedResult);

            //Checks to make sure the request was a success and if not throws an exception and tacks on the extended result to the exception.
            _utilities.CheckResultCode(resultCode, extendedResult, null);

            return(resultCode);

            //alarms = RetrieveAlarms(dn);
        }
Ejemplo n.º 4
0
        public int ShUpdate(string dn, tUserData userData, out tExtendedResult extendedResult, bool updateExisting = false)
        {
            if (string.IsNullOrEmpty(dn))
            {
                throw new Exception(MethodBase.GetCurrentMethod().Name + ": dn is required and was not supplied.");
            }

            if (userData == null)
            {
                throw new Exception(MethodBase.GetCurrentMethod().Name + ": userData is required and was not supplied.");
            }

            if (updateExisting)
            {
                var serviceIndication = userData.ShData.RepositoryData.ServiceIndication;
                var sequenceNumber    = RetrieveCurrentSequenceNumber(dn, serviceIndication);
                if (sequenceNumber > 0)
                {
                    userData.ShData.RepositoryData.SequenceNumber = _utilities.IncrementSequenceNumber(sequenceNumber);
                    userData.ShData.RepositoryData.ServiceData.Item.IgnoreSequenceNumber = tTrueFalse.False;
                }
                else
                {
                    //if the subscriber doesn't exist then forcing a sequence number of 0 and forcing not to ignore sequence number.
                    userData.ShData.RepositoryData.SequenceNumber = 0;
                    userData.ShData.RepositoryData.ServiceData.Item.IgnoreSequenceNumber = tTrueFalse.False;
                }
            }

            //tMeta_Subscriber_Alarms alarms;
            var resultCode = _sh.ShUpdate(dn, 0, userData, _originHost, out extendedResult);

            //Checks to make sure the request was a success and if not throws an exception and tacks on the extended result to the exception.
            _utilities.CheckResultCode(resultCode, extendedResult, null);

            return(resultCode);

            //alarms = RetrieveAlarms(dn);
        }