Example #1
0
        public void destroyObjects(RNObject[] objects)
        {
            DestroyProcessingOptions dpo = new DestroyProcessingOptions()
            {
                SuppressExternalEvents = false,
                SuppressRules          = false
            };

            _rnowClient.Destroy(_rnowClientInfoHeader, objects, dpo);
        }
        internal GenericServiceResponse DestroyObjects(RNObject[] objects)
        {
            bool mustRetry  = false;    // used to determine if we should retry a failed job
            int  retryTimes = 0;        // we don't want to endlessly retry, so we only will retry 3 times

            do
            {
                try
                {
                    _client.Destroy(_clientInfoHeader, objects, new DestroyProcessingOptions {
                        SuppressExternalEvents = false, SuppressRules = false
                    });

                    return(new GenericServiceResponse()
                    {
                        Successful = true
                    });
                }
                catch (Exception ex)
                {
                    GlobalContext.Log(string.Format("Failed Destroy: Retry {0}: {1}", retryTimes, ex.Message), true);
                    GlobalContext.Log(string.Format("Failed Destroy: Retry {0}: {1}{2}{3}", retryTimes, ex.Message, Environment.NewLine, ex.StackTrace), false);

                    string innerExMsg = GetInnerExceptionMessage(ex);
                    if (!string.IsNullOrEmpty(innerExMsg))
                    {
                        GlobalContext.Log(string.Format("Failed Destroy: Retry {0}: InnerException Messages: {1}", retryTimes, innerExMsg), true);
                    }

                    if (retryTimes < 3)
                    {
                        // if we haven't retried 3 times then we retry the load again
                        mustRetry = true;
                        retryTimes++;
                    }
                    else
                    {
                        // don't retry for 3rd retry
                        return(new GenericServiceResponse()
                        {
                            SuccessfulSet = true,
                            Successful = false,
                            Details = ex.ToString()
                        });
                    }
                }
                GlobalContext.Log(string.Format("Destroy Must Retry {0}", mustRetry), false);
            } while (mustRetry);
            GlobalContext.Log("Destroy End: This code should never be hit.", false);
            return(null);        // this code should never be hit
        }