public SentryException ToSentryException()
        {
            var frames  = new List <SentryStackFrame>();
            var exc     = LogString.Split(new char[] { ':' }, 2);
            var excType = exc[0];
            // TODO: condition may NOT contain ':' separator
            var excValue  = exc.Length == 1 ? exc[0] : exc[1].Substring(1); // strip the space
            var stackList = LogStackTrace.Split('\n');

            // The format is as follows:
            // Module.Class.Method[.Invoke] (arguments) (at filename:lineno)
            // where :lineno is optional, will be ommitted in builds
            for (var i = 0; i < stackList.Length; i++)
            {
                string functionName;
                string filename;
                int    lineNo;

                var item = stackList[i].TrimEnd('\r');
                if (item == string.Empty)
                {
                    continue;
                }

                var closingParen = item.IndexOf(')');

                if (closingParen == -1)
                {
                    functionName = item;
                    lineNo       = -1;
                    filename     = string.Empty;
                }
                else
                {
                    try
                    {
                        functionName = item.Substring(0, closingParen + 1);
                        if (item.Substring(closingParen + 1, 5) != " (at ")
                        {
                            // we did something wrong, failed the check
                            Debug.Log("failed parsing " + item);
                            functionName = item;
                            lineNo       = -1;
                            filename     = string.Empty;
                        }
                        else
                        {
                            var colon = item.LastIndexOf(':', item.Length - 1, item.Length - closingParen);
                            if (closingParen == item.Length - 1)
                            {
                                filename = string.Empty;
                                lineNo   = -1;
                            }
                            else if (colon == -1)
                            {
                                filename = item.Substring(closingParen + 6, item.Length - closingParen - 7);
                                lineNo   = -1;
                            }
                            else
                            {
                                filename = item.Substring(closingParen + 6, colon - closingParen - 6);
                                lineNo   = Convert.ToInt32(item.Substring(colon + 1, item.Length - 2 - colon));
                            }
                        }
                    }
                    catch (Exception)
                    {
                        functionName = item;
                        lineNo       = -1;
                        filename     = string.Empty; // we have no clue
                    }
                }

                var filenameWithoutZeroes = StripZeroes(filename);
                frames.Add(new SentryStackFrame
                {
                    FileName     = TryResolveFileNameForMono(filenameWithoutZeroes),
                    AbsolutePath = filenameWithoutZeroes,
                    Function     = functionName,
                    LineNumber   = lineNo == -1 ? null : lineNo,
                    InApp        = functionName != null &&
                                   !functionName.StartsWith("UnityEngine", StringComparison.Ordinal) &&
                                   !functionName.StartsWith("System", StringComparison.Ordinal)
                });
            }

            frames.Reverse();

            var stacktrace = new SentryStackTrace();

            foreach (var frame in frames)
            {
                stacktrace.Frames.Add(frame);
            }

            return(new SentryException
            {
                Stacktrace = stacktrace,
                Type = excType,
                Value = excValue,
                Mechanism = new Mechanism
                {
                    Handled = false,
                    Type = "unity.log"
                }
            });
        }
Example #2
0
        private void CreateExcelButton_Click(object sender, EventArgs e)
        {
            List <string> FileStrings = new List <string>();
            DirectoryInfo oDir        = new DirectoryInfo(UI_UserInput_Folder.Text);

            foreach (var file in oDir.GetFiles("*.txt"))
            {
                string   HostName         = file.Name;
                string[] parsedpas        = HostName.Replace("00", "0").Split('0');
                string   magazineNumber   = parsedpas[1];
                string   commutatorNumber = parsedpas[2];
                int      firstUnusedRow   = 0;
                //string interesting = parsedpas[0];

                bool found = false;
                foreach (Excel.Worksheet sheet in xlWorkbook.Sheets)
                {
                    if (sheet.Name == magazineNumber)
                    {
                        found = true;
                        break;
                    }
                }
                if (found)
                {
                    xlWorkSheet    = xlWorkbook.Sheets["Example"];
                    firstUnusedRow = xlWorkSheet.Cells.SpecialCells(Excel.XlCellType.xlCellTypeLastCell, Type.Missing).Row + 1;
                }
                else
                {
                    xlWorkSheet               = xlWorkbook.Sheets.Add(Type.Missing, xlWorkbook.Worksheets[xlWorkbook.Worksheets.Count], Type.Missing, Type.Missing);
                    xlWorkSheet.Name          = magazineNumber.ToString();
                    xlWorkSheet.Cells[1, "A"] = "Номер магазина";       //Дублирует название листа
                    xlWorkSheet.Cells[1, "B"] = "Имя коммутатора";
                    xlWorkSheet.Cells[1, "C"] = "Номер коммутатора";
                    xlWorkSheet.Cells[1, "D"] = "Интерфейс";
                    xlWorkSheet.Cells[1, "E"] = "Описание";
                    xlWorkSheet.Cells[1, "F"] = "Статус";
                    xlWorkSheet.Cells[1, "G"] = "VLAN";
                    xlWorkSheet.Cells[1, "H"] = "duplex";
                    xlWorkSheet.Cells[1, "I"] = "speed";
                    xlWorkSheet.Cells[1, "J"] = "type";
                    firstUnusedRow            = 2;
                }
                FileStrings.Clear();
                FileStrings.AddRange(File.ReadAllLines(file.FullName));
                foreach (string LogString in FileStrings)
                {
                    string[] port = LogString.Split(',');
                    xlWorkSheet.Cells[firstUnusedRow, "A"] = magazineNumber;       //Дублирует название листа
                    xlWorkSheet.Cells[firstUnusedRow, "B"] = HostName;
                    xlWorkSheet.Cells[firstUnusedRow, "C"] = commutatorNumber;
                    xlWorkSheet.Cells[firstUnusedRow, "D"] = port[0];
                    xlWorkSheet.Cells[firstUnusedRow, "E"] = port[1];
                    xlWorkSheet.Cells[firstUnusedRow, "F"] = port[2];
                    xlWorkSheet.Cells[firstUnusedRow, "G"] = port[3];
                    xlWorkSheet.Cells[firstUnusedRow, "H"] = port[4];
                    xlWorkSheet.Cells[firstUnusedRow, "I"] = port[5];
                    xlWorkSheet.Cells[firstUnusedRow, "J"] = port[6];
                    firstUnusedRow++;
                }
            }
        }