示例#1
0
        public static void WebMiniDumpHandler(Exception ex)
        {
            try
            {
                DumpData dump = new DumpData(ex);
                dump.AddFile(Path.Combine(Utils.GetStartupPath, "settings", "default.xml"));
                dump.AddFile(Path.Combine(Utils.GetStartupPath, "chummerlog.txt"));

                byte[] info = new UTF8Encoding(true).GetBytes(dump.SerializeBase64());
                File.WriteAllBytes(Path.Combine(Utils.GetStartupPath, "json.txt"), info);

                if (GlobalOptions.UseLoggingApplicationInsights)
                {
                    if (Program.TelemetryClient != null)
                    {
                        ExceptionTelemetry et = new ExceptionTelemetry(ex)
                        {
                            SeverityLevel = SeverityLevel.Critical
                        };
                        Program.TelemetryClient.TrackException(et);
                        Program.TelemetryClient.Flush();
                    }
                }

                //Process crashHandler = Process.Start("crashhandler", "crash " + Path.Combine(Utils.GetStartupPath, "json.txt") + " --debug");
                Process crashHandler = Process.Start("crashhandler", "crash " + Path.Combine(Utils.GetStartupPath, "json.txt"));

                crashHandler?.WaitForExit();
            }
            catch(Exception nex)
            {
                MessageBox.Show("Failed to create crash report." + Environment.NewLine +
                                "Here is some information to help the developers figure out why:" + Environment.NewLine + nex + Environment.NewLine + "Crash information:" + Environment.NewLine + ex);
            }
        }
示例#2
0
        public static void WebMiniDumpHandler(Exception ex)
        {
            try
            {
                DumpData dump = new DumpData(ex);
                foreach (string strSettingFile in Directory.EnumerateFiles(Utils.GetSettingsFolderPath, "*.xml"))
                {
                    dump.AddFile(strSettingFile);
                }

                dump.AddFile(Path.Combine(Utils.GetStartupPath, "chummerlog.txt"));

                byte[] info = new UTF8Encoding(true).GetBytes(dump.SerializeBase64());
                File.WriteAllBytes(Path.Combine(Utils.GetStartupPath, "json.txt"), info);

#if DEBUG
                using (Process crashHandler
                           = Process.Start("crashhandler", "crash " + Path.Combine(Utils.GetStartupPath, "json.txt")
                                           + " --debug"))
#else
                using (Process crashHandler
                           = Process.Start("crashhandler", "crash " + Path.Combine(Utils.GetStartupPath, "json.txt")))
#endif
                    crashHandler?.WaitForExit();
            }
            catch (Exception nex)
            {
                Program.ShowMessageBox(
                    "Failed to create crash report." + Environment.NewLine +
                    "Chummer crashed with version: " + Utils.CurrentChummerVersion + Environment.NewLine +
                    "Here is some information to help the developers figure out why:" + Environment.NewLine + nex +
                    Environment.NewLine + "Crash information:" + Environment.NewLine + ex, "Failed to Create Crash Report", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#3
0
        public void Test_GetSelectionForData_Returns_Correct_Start_And_End_Indexes(string text, int line, int start, int end)
        {
            var data = new DumpData("a", "b", line);

            var result = Subject.GetSelectionForData(data, text);

            result.start.Should().Be(start);
            result.end.Should().Be(end);
        }
示例#4
0
        public async Task TestMethod1()
        {
            DumpData dumpData = new DumpData();

            dumpData.DeviceId           = "abcdeviceid";
            dumpData.ApplicationName    = "service2test";
            dumpData.ApplicationVersion = "0.1";
            dumpData.Entries            = new System.Collections.Generic.List <Entry>();
            dumpData.Entries.Add(new Entry()
            {
                Id = 1, Created = DateTime.Now, Message = "my message123"
            });
            var client = new ServiceClient("http://localhost/logging2");
            await client.PostDumpData(dumpData);
        }
示例#5
0
        public static void WebMiniDumpHandler(Exception ex)
        {
            try
            {
                DumpData dump = new DumpData(ex);
                dump.AddFile(Path.Combine(Utils.GetStartupPath, "settings", "default.xml"));
                dump.AddFile(Path.Combine(Utils.GetStartupPath, "chummerlog.txt"));

                byte[] info = new UTF8Encoding(true).GetBytes(dump.SerializeBase64());
                File.WriteAllBytes(Path.Combine(Utils.GetStartupPath, "json.txt"), info);

                if (GlobalOptions.UseLoggingApplicationInsights >= UseAILogging.Crashes)
                {
                    if (Program.ChummerTelemetryClient != null)
                    {
                        ex.Data.Add("IsCrash", bool.TrueString);
                        ExceptionTelemetry et = new ExceptionTelemetry(ex)
                        {
                            SeverityLevel = SeverityLevel.Critical
                        };
                        //we have to enable the uploading of THIS message, so it isn't filtered out in the DropUserdataTelemetryProcessos
                        foreach (DictionaryEntry d in ex.Data)
                        {
                            if ((d.Key != null) && (d.Value != null))
                            {
                                et.Properties.Add(d.Key.ToString(), d.Value.ToString());
                            }
                        }
                        Program.ChummerTelemetryClient.TrackException(et);
                        Program.ChummerTelemetryClient.Flush();
                    }
                }

                //Process crashHandler = Process.Start("crashhandler", "crash " + Path.Combine(Utils.GetStartupPath, "json.txt") + " --debug");
                Process crashHandler = Process.Start("crashhandler", "crash " + Path.Combine(Utils.GetStartupPath, "json.txt"));

                crashHandler?.WaitForExit();
            }
            catch (Exception nex)
            {
                Program.MainForm.ShowMessageBox(new StringBuilder()
                                                .AppendLine("Failed to create crash report.")
                                                .AppendLine("Here is some information to help the developers figure out why:")
                                                .AppendLine(nex.ToString())
                                                .AppendLine("Crash information:")
                                                .Append(ex).ToString());
            }
        }
示例#6
0
 public void Dump(DumpData data)
 {
     try
     {
         DumpResultObject(ResultObject.Create(data.Object, data.Quotas, data.Header));
     }
     catch (Exception ex)
     {
         try
         {
             Console.WriteLine("Error during Dump: " + ex.Message);
         }
         catch
         {
             // ignore
         }
     }
 }
示例#7
0
            private void OnDumped(DumpData data)
            {
                var currentCount = _dumpCount++;

                if (currentCount >= MaxDumpsPerSession)
                {
                    if (currentCount == MaxDumpsPerSession)
                    {
                        EnqueueDump(ResultObject.Create("<max results reached>", DumpQuotas.Default));
                    }

                    return;
                }

                var resultObject = ResultObject.Create(data.Object, data.Quotas, data.Header);

                EnqueueDump(resultObject);
            }
示例#8
0
        internal static void WebMiniDumpHandler(Exception ex)
        {
            try
            {
                DumpData dump = new DumpData();

                dump.AddException(ex);
                dump.AddFile(Path.Combine(Application.StartupPath, "settings", "default.xml"));
                dump.AddFile(Path.Combine(Application.StartupPath, "chummerlog.txt"));

                Process crashHandler = Process.Start("crashhandler", "crash " + dump.SerializeBase64());

                crashHandler.WaitForExit();
            }
            catch (Exception nex)
            {
                MessageBox.Show("Failed to create crash report.\nHere is some information to help the developers figure out why\n" + nex + "\nCrash information:\n" + ex);
            }
        }
示例#9
0
        public static void WebMiniDumpHandler(Exception ex)
        {
            try
            {
                DumpData dump = new DumpData(ex);
                dump.AddFile(Path.Combine(Application.StartupPath, "settings", "default.xml"));
                dump.AddFile(Path.Combine(Application.StartupPath, "chummerlog.txt"));

                byte[] info = new UTF8Encoding(true).GetBytes(dump.SerializeBase64());
                File.WriteAllBytes(Path.Combine(Application.StartupPath, "json.txt"), info);

                //Process crashHandler = Process.Start("crashhandler", "crash " + Path.Combine(Application.StartupPath, "json.txt") + " --debug");
                Process crashHandler = Process.Start("crashhandler", "crash " + Path.Combine(Application.StartupPath, "json.txt"));

                crashHandler?.WaitForExit();
            }
            catch (Exception nex)
            {
                MessageBox.Show("Failed to create crash report." + Environment.NewLine +
                                "Here is some information to help the developers figure out why:" + Environment.NewLine + nex + Environment.NewLine + "Crash information:" + Environment.NewLine + ex);
            }
        }
示例#10
0
        internal static void WebMiniDumpHandler(Exception ex)
        {
            if (MessageBox.Show("Chummer5a crashed.\nDo you want to send a crash report to the developer?", "Crash!", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                try
                {
                    DumpData dump = new DumpData();

                    dump.AddException(ex);
                    dump.AddFile(Path.Combine(Environment.CurrentDirectory, "settings", "default.xml"));
                    dump.AddFile(Path.Combine(Environment.CurrentDirectory, "chummerlog.txt"));

                    Process crashHandler = Process.Start("crashhandler", "crash " + dump.SerializeBase64());

                    crashHandler.WaitForExit();
                }
                catch (Exception nex)
                {
                    MessageBox.Show("Failed to create crash report.\nHere is some information to help the developers figure out why\n" + nex + "\nCrash information:\n" + ex);
                }
            }
        }
示例#11
0
        public void Dump(DumpData data)
        {
            if (!CanDump())
            {
                return;
            }

            try
            {
                DumpResultObject(ResultObject.Create(data.Object, data.Quotas, data.Header));
            }
            catch (Exception ex)
            {
                try
                {
                    DumpMessage("Error during Dump: " + ex.Message);
                }
                catch
                {
                    // ignore
                }
            }
        }
示例#12
0
        internal static void WebMiniDumpHandler(Exception ex)
        {
            if (true || MessageBox.Show("Chummer5a crashed.\nDo you want to send a crash report to the developer?", "Crash!", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                try
                {
                    DumpData dump = new DumpData();

                    dump.AddException(ex);
                    dump.AddFile(Path.Combine(Environment.CurrentDirectory, "settings", "default.xml"));
                    dump.AddFile(Path.Combine(Environment.CurrentDirectory, "chummerlog.txt"));


                    Process crashHandler = Process.Start("crashhandler", "crash " + dump.SerializeBase64());

                    crashHandler.WaitForExit();
                }
                catch
                {
                    MessageBox.Show("Failed to create crash report.\nMake sure your system is connected to the internet.");
                }
            }
        }
示例#13
0
        public HttpResponseMessage PostDumpData(DumpData dumpData)
        {
            var response = Request.CreateResponse(HttpStatusCode.Created);

            //string uri = Url.Link("DefaultApi", new { id = dumpData.DeviceId });
            //response.Headers.Location = new Uri(uri);
            //return response;

            // check if, we have anything to write here.
            if (dumpData == null)
            {
                return(response);
            }

            if (dumpData.Entries.Count == 0)
            {
                return(response);
            }

            var source = string.Format("{0}_{1}.log", dumpData.ApplicationName, dumpData.UserId);

            // limit access to a file to one thread
            var semaphore = _semaphoreDictionary.GetOrAdd(source, new SemaphoreSlim(1));

            try
            {
                semaphore.Wait();
                string basePath    = WebConfigurationManager.AppSettings["Path"];
                string logFilename = Path.Combine(basePath, LogUtil.RemoveInvalidPathChars(source));

                // write log data to file
                StringBuilder sb = new StringBuilder();
                foreach (var entry in dumpData.Entries)
                {
                    //var newFormatedLine = string.Format(_format, entry.Created, entry.Level, entry.Message);
                    var formatted = EntryFormatter.Format(entry);
                    sb.AppendLine(formatted);
                }
                File.AppendAllText(logFilename, sb.ToString());

                // check if log file reaches max size, if so, move the log to .bak
                int maxSize = Convert.ToInt32(WebConfigurationManager.AppSettings["MaxLogSize"]);

                FileInfo info = new FileInfo(logFilename);
                if (info.Length > maxSize)
                {
                    var bakFilename = logFilename + ".bak";
                    if (File.Exists(bakFilename))
                    {
                        File.Delete(bakFilename);
                    }
                    File.Move(logFilename, bakFilename);
                }
            }
            finally
            {
                semaphore.Release();
            }

            return(response);
        }
示例#14
0
 private void OnDumped(DumpData data)
 {
     EnqueueResult(ResultObject.Create(data.Object, data.Quotas, data.Header));
 }
示例#15
0
        // Test the exported function is OK
        public void TestODCFunction_FindDumpPartition()
        {
            IntPtr            pAddressOfFunctionToCall = GetFunctionPointer((int)TEST_FUNC_ENUM.LOCATE_AND_COPY_RAW_DUMP);
            FindDumpPartition FindDmpPart = (FindDumpPartition)Marshal.GetDelegateForFunctionPointer(
                pAddressOfFunctionToCall,
                typeof(FindDumpPartition));
            int retVal = FindDmpPart();

            dumpWrapperError(retVal, "LocateAndCopyRawDump");

            if (retVal > 0)
            {
                switch (retVal)
                {
                case 1:
                    Verify.Fail("   ERROR: function found invalid hDisk");
                    break;

                case 2:
                    Verify.Fail("   ERROR: function found invalid diskOffset");
                    break;

                case 3:
                    Verify.Fail("   ERROR: function found invalid RawDumpPartitionLength");
                    break;

                default:
                    Verify.Fail("   ERROR: unknown return value from wrapper");
                    break;
                }
            }
            else
            {
                pAddressOfFunctionToCall = GetFunctionPointer((int)TEST_FUNC_ENUM.GET_DUMP_LOCATION);
                DumpData dmpData = (DumpData)Marshal.GetDelegateForFunctionPointer(
                    pAddressOfFunctionToCall,
                    typeof(DumpData));
                switch (dmpData())
                {
                case (int)SBL_DUMP_LOCATION.EMMC:
                    Log.Comment("Dump file location: Phone");
                    break;

                case (int)SBL_DUMP_LOCATION.SD:
                    Log.Comment("Dump file location: SD Card");
                    break;

                case (int)SBL_DUMP_LOCATION.INVALID:
                    Verify.Fail("Dump file location: INVALID");
                    break;

                default:
                    Verify.Fail("Dump file location: Unknown");
                    break;
                }

                pAddressOfFunctionToCall = GetFunctionPointer((int)TEST_FUNC_ENUM.GET_DUMP_FORMAT);
                dmpData = (DumpData)Marshal.GetDelegateForFunctionPointer(
                    pAddressOfFunctionToCall,
                    typeof(DumpData));
                switch ((int)dmpData())
                {
                case (int)SBL_DUMP_FORMAT.FILE:
                    Log.Comment("  Dump file format: File");
                    break;

                case (int)SBL_DUMP_FORMAT.RAW:
                    Log.Comment("  Dump file format: RAW");
                    break;

                case (int)SBL_DUMP_FORMAT.INVALID:
                    Verify.Fail("  Dump file format: INVALID");
                    break;

                default:
                    Verify.Fail("  Dump file format: Unknown");
                    break;
                }
            }
        }
示例#16
0
        public void DumpContext(DumpData Filter = DumpData.All)
        {
            if (context == null)
                return;

            System.Diagnostics.Debug.WriteLine("Dumping Context\n===========================\n");

            if (Filter == DumpData.Schüler || Filter == DumpData.All)
            {
                System.Diagnostics.Debug.WriteLine("Schueler\n===========================");
                foreach (var s in context.ChangeTracker.Entries<Schueler>())
                {
                    System.Diagnostics.Debug.WriteLine("[{0}] {1} ({2})", s.Entity.ID, s.Entity.DisplayName, s.State.ToString());
                }
            }

            if (Filter == DumpData.Fächer || Filter == DumpData.All)
            {
                System.Diagnostics.Debug.WriteLine("\n\nFächer\n===========================");
                foreach (var s in context.ChangeTracker.Entries<Fach>())
                {
                    System.Diagnostics.Debug.WriteLine("[{0}] {1} ({2})", s.Entity.FachId, s.Entity.Name, s.State.ToString());
                }
            }

            if (Filter == DumpData.Klassen || Filter == DumpData.All)
            {

                System.Diagnostics.Debug.WriteLine("\n\nKlassen\n===========================");
                foreach (var s in context.ChangeTracker.Entries<Klasse>())
                {
                    System.Diagnostics.Debug.WriteLine("[{0}] {1} - {2} ({3})", s.Entity.KlasseId, s.Entity.Name, s.Entity.Schuljahr.ToString(), s.State.ToString());
                }
            }

            if (Filter == DumpData.Beobachtungen || Filter == DumpData.All)
            {
                System.Diagnostics.Debug.WriteLine("\n\nBeobachtungen\n===========================");
                foreach (var s in context.ChangeTracker.Entries<Beobachtung>())
                {
                    System.Diagnostics.Debug.WriteLine("[{0}] {1} ({2})", s.Entity.BeobachtungId, s.Entity.ToString(), s.State.ToString());
                }
            }
        }
示例#17
0
        // Add Table
        public static Table AddTable(WordprocessingDocument document, DumpData[] data, int columns, int tablewidth, string tbtitle)
        {
            try
            {
                // Document handler
                Document doc = document.MainDocumentPart.Document;

                #region Table
                // Create table and set properties
                Table tb = new Table();
                TableProperties tbp = specTablePropert(4, 1, 1);
                tb.AppendChild<TableProperties>(tbp);
                #endregion

                #region tableTitle
                TableRow trtitle = AddTableTitle(columns, tablewidth, tbtitle);
                tb.Append(trtitle);
                #endregion

                doc.Body.Append(tb);
                doc.Save();
                return tb;
            }
            catch (Exception)
            {
                return null;
            }
        }
示例#18
0
        // Fill table with data
        public static bool fillTable(DumpData[] data, int tablewidth, int FIRSTCELL, Table tb, WordprocessingDocument doc)
        {
            try
            {

          
                for (int i = 0; i < data.Length; i++)
                {
                    // Row
                    var tr = new TableRow();

                    // Title cell
                    StringBuilder st = new StringBuilder();
                    st.Append("Member ");
                    st.Append(i.ToString());
                    tr.Append(getTableCell(FIRSTCELL, CreateParagraph(st.ToString())));
                                      
                    foreach (var reg in typeof(DumpData).GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public))
                    {
                        // Data cell
                        Paragraph p = CreateParagraph(reg.GetValue(data[i]).ToString());                                            
                        tr.Append(getTableCell(tablewidth - FIRSTCELL, p));  
                    }

                    tb.Append(tr);
                }

                return true;
            }

            catch (Exception)
            {

                return false;
            }
        }