Пример #1
0
        private void CacheController_RefreshCompleted(object sender, Microsoft.Synchronization.ClientServices.RefreshCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                if (e.Error is System.Net.WebException)
                {
                    System.Net.WebException we = (System.Net.WebException)e.Error;
                    if (we.Response != null)
                    {
                        System.IO.Stream       stream = we.Response.GetResponseStream();
                        System.IO.StreamReader reader = new System.IO.StreamReader(stream);
                        String errorMessage           = reader.ReadToEnd();

                        try
                        {
                            if (errorMessage.StartsWith("<ServiceError") || errorMessage.StartsWith("<?xml"))
                            {
                                System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
                                doc.LoadXml(errorMessage);
                                errorMessage = doc.DocumentElement.InnerText;
                            }
                        }
                        catch
                        {
                        }

                        CustomException exc = HandleStatusCode(((System.Net.HttpWebResponse)we.Response).StatusCode, we.Message, errorMessage, e.Error);
                        RefreshComplete(exc);
                    }
                    else
                    {
                        RefreshComplete(new ConnectionException("WebException has been thrown during the refresh operation", e.Error));
                    }
                }
                else if (e.Error is CacheControllerWebException)
                {
                    CacheControllerWebException we  = (CacheControllerWebException)e.Error;
                    CustomException             exc = HandleStatusCode(we.StatusCode, we.Message);
                    RefreshComplete(exc);
                }
                else
                {
                    RefreshComplete(new NonFatalException(D.CONNECTION_EXCEPTION, e.Error.Message, e.Error));
                }
            }
            else
            {
                RefreshComplete();
            }
        }
 void CacheController_RefreshCompleted(object sender, Microsoft.Synchronization.ClientServices.RefreshCompletedEventArgs e)
 {
     SyncContextInstance.Context.CacheController.RefreshCompleted -= new EventHandler <Microsoft.Synchronization.ClientServices.RefreshCompletedEventArgs>(CacheController_RefreshCompleted);
     SyncContextInstance.AddStats(e.Statistics, e.Error);
 }
Пример #3
0
        /// <summary>
        /// Handles the cache controller refresh completed event.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CacheController_RefreshCompleted(object sender, RefreshCompletedEventArgs e)
        {
            SyncInactive = true;

            if (e.Error == null)
            {
                LastSyncStatus = "Synchronization with service completed successfully";
            }
            else
            {
                LastSyncStatus = "Synchronization failed: " + e.Error.ToString();
            }
        }