private void _xmds_SubmitStatsCompleted(object sender, SubmitStatsCompletedEventArgs e) { this._xmdsProcessing = false; if (e.Error != null) { Trace.WriteLine(new LogMessage("_xmds_SubmitStatsCompleted", string.Format("Error during Submit to XMDS {0}", e.Error.Message)), LogType.Error.ToString()); if (!string.IsNullOrEmpty(this._lastSubmit)) { try { StreamWriter writer = new StreamWriter(File.Open(App.UserAppDataPath + "//" + Settings.Default.StatsLogFile, FileMode.Append, FileAccess.Write, FileShare.Read), Encoding.UTF8); try { writer.Write(this._lastSubmit); } catch (Exception exception) { Trace.WriteLine(new LogMessage("_xmds_SubmitStatsCompleted", string.Format("Error writing stats to file with exception {0}", exception.Message)), LogType.Error.ToString()); } finally { writer.Close(); writer.Dispose(); } } catch (Exception exception2) { Trace.WriteLine(new LogMessage("_xmds_SubmitStatsCompleted", string.Format("Could not open the file with exception {0}", exception2.Message)), LogType.Error.ToString()); } } } this._lastSubmit = ""; }
//�Private�Methods�(3)� /// <summary> /// Capture the XMDS call and see if it went well /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void _xmds_SubmitStatsCompleted(object sender, SubmitStatsCompletedEventArgs e) { System.Diagnostics.Debug.WriteLine(new LogMessage("_xmds_SubmitStatsCompleted", String.Format("IN")), LogType.Audit.ToString()); _xmdsProcessing = false; // Test if we succeeded or not if (e.Error != null) { // We had an error, log it. System.Diagnostics.Trace.WriteLine(new LogMessage("_xmds_SubmitStatsCompleted", String.Format("Error during Submit to XMDS {0}", e.Error.Message)), LogType.Error.ToString()); // Dump the stats to a file instead if (!String.IsNullOrEmpty(_lastSubmit)) { try { // Open the Text Writer StreamWriter tw = new StreamWriter(File.Open(App.UserAppDataPath + "//" + Settings.Default.StatsLogFile, FileMode.Append, FileAccess.Write, FileShare.Read), Encoding.UTF8); try { tw.Write(_lastSubmit); } catch (Exception ex) { // Log this exception System.Diagnostics.Trace.WriteLine(new LogMessage("_xmds_SubmitStatsCompleted", String.Format("Error writing stats to file with exception {0}", ex.Message)), LogType.Error.ToString()); } finally { tw.Close(); tw.Dispose(); } } catch (Exception ex) { // Log this exception System.Diagnostics.Trace.WriteLine(new LogMessage("_xmds_SubmitStatsCompleted", String.Format("Could not open the file with exception {0}", ex.Message)), LogType.Error.ToString()); } } } // Clear the last sumbit _lastSubmit = ""; System.Diagnostics.Debug.WriteLine(new LogMessage("_xmds_SubmitStatsCompleted", String.Format("OUT")), LogType.Audit.ToString()); }