public void Add(LogElementBO element, [Optional, DefaultParameterValue(true)] bool sendtoWeb) { element.Owner = Owner; element.CivVersion = ClientVersion; element.Assembly = new string[AppDomain.CurrentDomain.GetAssemblies().Length]; int i = 0; foreach (Assembly MyAssembly in AppDomain.CurrentDomain.GetAssemblies()) { element.Assembly[i] = MyAssembly.ToString(); i++; } WriteToFile(element); // Désactivation des services web //if (AutomaticSendReport && sendtoWeb) //{ // ThreadStart start = delegate() // { // SendToWeb(element); // }; // new Thread(start).Start(); //} }
private void btnSend_Click(object sender, RoutedEventArgs e) { LogElementBO element = new LogElementBO(); element.Error = new CivException(AppException); LogEngine.Instance.Add(element, ProgramSettings.Instance.AutomaticSendReport); }
//private void SendToWeb(LogElementBO element) //{ // try // { // CIV.CentralCenterClient.CentralCenterServiceReference.ReportBO report = new CIV.CentralCenterClient.CentralCenterServiceReference.ReportBO(); // report.Owner = element.Owner; // report.Created = element.Created; // report.CivVersion = element.CivVersion; // report.ExceptionType = element.Error.ExceptionType; // report.LogElementBOSerialized = CIV.Common.IO.GZipCompressString(XmlFactory.SaveToString(element, typeof(LogElementBO), new XmlFactorySettings()), new UTF8Encoding()); // CIV.CentralCenterClient.CentralCenterServiceReference.CentralCenterSoapClient centralCenter = new CIV.CentralCenterClient.CentralCenterServiceReference.CentralCenterSoapClient(); // if (centralCenter.IsCompatibleClient(ClientVersion) && centralCenter.IsLastVersion("CIV", report.CivVersion)) // centralCenter.SendReport(report); // } // catch (Exception sendError) // { // WriteToFile(new LogElementBO() { Error = new CivException(sendError), Created = DateTime.Now, OsVersion = Environment.OSVersion.Version.ToString() }); // } //} private void WriteToFile(LogElementBO element) { try { //Exception innerException; using (StreamWriter logFile = new StreamWriter(Path.Combine(CIV.Common.IO.GetCivDataFolder(), "civ.log"), true)) { //logFile.AutoFlush = true; logFile.WriteLine("===================================================================================================="); logFile.WriteLine(element); logFile.Flush(); } } catch { } }