示例#1
0
        /// <summary>
        /// Standardize the interaction for a retrying a ServiceObject.Load() call,
        /// removing bad properties until the call succeeds.
        /// </summary>
        /// <param name="obj">Object to load</param>
        /// <param name="propSet">PropertySet to load for the object</param>
        public static void PerformRetryableLoad(ServiceObject obj, PropertySet propSet)
        {
            bool retry = true;

            while (retry)
            {
                try
                {
                    obj.Service.ClientRequestId = Guid.NewGuid().ToString();  // Set a new GUID
                    obj.Load(propSet);
                    retry = false;
                }
                catch (ServiceResponseException srex)
                {
                    DebugLog.WriteVerbose("Handled exception when retrieving property", srex);

                    // Give the user the option of removing the bad properites from the request
                    // and retrying.
                    if (ErrorDialog.ShowServiceExceptionMsgBox(srex, true, MessageBoxIcon.Warning) == DialogResult.Yes)
                    {
                        // Remove the bad properties from the PropertySet and try again.
                        foreach (PropertyDefinitionBase propDef in srex.Response.ErrorProperties)
                        {
                            propSet.Remove(propDef);
                        }

                        retry = true;
                    }
                    else
                    {
                        retry = false;
                    }
                }
            }
        }
示例#2
0
        public static void ExLoad(
            this ServiceObject obj,
            AgentJobProcessorState <ExchangeSharedMailboxCrawlJobData> state,
            PropertySet propertySet)
        {
            state.Status.Ping();

            ActionExtensions.ExecuteWithRetry(
                () => obj.Load(propertySet),
                retryIntervalMilliseconds: retryInterval.Milliseconds,
                isTransient: ex => TransientExceptionHandler(state, ex));
        }