/// <summary> /// Add a crash passed in the payload as Xml to the database. /// </summary> /// <param name="id">Unused.</param> /// <returns>The row id of the newly added crash.</returns> public ActionResult AddCrash(int id) { using (FAutoScopedLogTimer LogTimer = new FAutoScopedLogTimer(this.GetType().ToString() + "(NewCrashId=" + id + ")")) { CrashRepository Crashes = new CrashRepository(); CrashReporterResult NewCrashResult = new CrashReporterResult(); NewCrashResult.ID = -1; string PayloadString = string.Empty; for (int Index = 0; Index < 3; Index++) { try { using (StreamReader Reader = new StreamReader(Request.InputStream, Request.ContentEncoding)) { PayloadString = Reader.ReadToEnd(); CrashDescription NewCrash = XmlHandler.FromXmlString <CrashDescription>(PayloadString); NewCrashResult.ID = Crashes.AddNewCrash(NewCrash); NewCrashResult.bSuccess = true; } break; } catch (SqlException SqlExc) { if (SqlExc.Number == -2) { FLogger.Global.WriteEvent(string.Format("AddCrash:Timeout, retrying {0} of 3", Index + 1)); } else { NewCrashResult.Message = SqlExc.ToString(); NewCrashResult.bSuccess = false; break; } } catch (Exception Ex) { StringBuilder MessageBuilder = new StringBuilder(); MessageBuilder.AppendLine("Exception was:"); MessageBuilder.AppendLine(Ex.ToString()); MessageBuilder.AppendLine("Received payload was:"); MessageBuilder.AppendLine(PayloadString); NewCrashResult.Message = MessageBuilder.ToString(); NewCrashResult.bSuccess = false; break; } System.Threading.Thread.Sleep(5000 * (Index + 1)); } string ReturnResult = XmlHandler.ToXmlString <CrashReporterResult>(NewCrashResult); return(Content(ReturnResult, "text/xml")); } }
/// <summary> /// Add a crash passed in the payload as Xml to the database. /// </summary> /// <param name="id">Unused.</param> /// <returns>The row id of the newly added crash.</returns> public ActionResult AddCrash(int id) { using (FAutoScopedLogTimer LogTimer = new FAutoScopedLogTimer(this.GetType().ToString() + "(NewCrashId=" + id + ")")) { CrashRepository Crashes = new CrashRepository(); CrashReporterResult NewCrashResult = new CrashReporterResult(); NewCrashResult.ID = -1; for (int Index = 0; Index < 3; Index++) { try { UnsafeAddCrash(NewCrashResult, Crashes); break; } catch (SqlException SqlExc) { if (SqlExc.Number == -2) { FLogger.Global.WriteEvent(string.Format("AddCrash:Timeout, retrying {0} of 3", Index + 1)); } else { NewCrashResult.Message = SqlExc.ToString(); NewCrashResult.bSuccess = false; break; } } catch (Exception Ex) { NewCrashResult.Message = Ex.ToString(); NewCrashResult.bSuccess = false; break; } System.Threading.Thread.Sleep(5000 * (Index + 1)); } string ReturnResult = XmlHandler.ToXmlString <CrashReporterResult>(NewCrashResult); return(Content(ReturnResult, "text/xml")); } }