예제 #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
        /// <summary>
        /// Standardize the interaction for a retrying a ServiceObject.Load() call,
        /// removing bad properties until the call succeeds.
        /// </summary>
        /// <param name="service">ExchangeService to make calls with</param>
        /// <param name="id">ItemId to bind to</param>
        /// <param name="propSet">PropertySet to load for the object</param>
        /// <returns>Returns the Item that was bound</returns>
        public static Item PerformRetryableItemBind(ExchangeService service, ItemId id, PropertySet propSet)
        {
            Item item = null;

            while (true)
            {
                try
                {
                    service.ClientRequestId = Guid.NewGuid().ToString();  // Set a new GUID
                    item = Item.Bind(service, id, propSet);
                    return(item);
                }
                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);
                        }
                    }
                    else
                    {
                        return(item);
                    }
                }
                // mstehle - 11/15/2011 - This code makes little sense, commenting out for now...
                //catch (Exception ex)
                //{
                //    DebugLog.WriteVerbose(ex);

                //    if (ex.Message.Length > 0)
                //    {
                //        throw;
                //    }
                //}
            }
        }