/// <summary> /// Retrieves a list of distinct UE4 Branches from the CrashRepository /// </summary> public static List <SelectListItem> GetBranchesAsListItems() { using (FAutoScopedLogTimer LogTimer = new FAutoScopedLogTimer("CrashRepository.GetBranches")) { CrashReportDataContext Context = new CrashReportDataContext(); DateTime Now = DateTime.UtcNow; if (Now - LastBranchesDate > TimeSpan.FromHours(1)) { var BranchList = Context.Crashes .Where(n => n.TimeOfCrash > DateTime.Now.AddDays(-14)) .Where(c => c.CrashType != 3) // Ignore ensures // Depot - //depot/UE4* || Stream //UE4, //Something etc. .Where(n => n.Branch.StartsWith("UE4") || n.Branch.StartsWith("//")) .Select(n => n.Branch) .Distinct() .ToList(); BranchesAsSelectList = BranchList .Select(listitem => new SelectListItem { Selected = false, Text = listitem, Value = listitem }) .ToList(); BranchesAsSelectList.Insert(0, new SelectListItem { Selected = true, Text = "", Value = "" }); LastBranchesDate = Now; } return(BranchesAsSelectList); } }
/// <summary> /// Retrieves a list of distinct UE4 Branches from the CrashRepository /// </summary> public static List <SelectListItem> GetBranchesAsListItems() { using (FAutoScopedLogTimer LogTimer = new FAutoScopedLogTimer("CrashRepository.GetBranches")) { CrashReportDataContext Context = new CrashReportDataContext(); DateTime Now = DateTime.UtcNow; if (Now - LastBranchesDate > TimeSpan.FromHours(1)) { var BranchList = Context.Crashes .Where(n => n.TimeOfCrash > DateTime.Now.AddMonths(-3)) .Where(n => n.Branch.StartsWith("UE4")) .Select(n => n.Branch) .Distinct() .ToList(); BranchesAsSelectList = BranchList .Select(listitem => new SelectListItem { Selected = false, Text = listitem, Value = listitem }) .ToList(); BranchesAsSelectList.Insert(0, new SelectListItem { Selected = true, Text = "", Value = "" }); LastBranchesDate = Now; } return(BranchesAsSelectList); } }
/// <summary> /// Build a callstack pattern for a crash to ease bucketing of crashes into Buggs. /// </summary> public void BuildPattern(CrashReportDataContext Context) { using (FAutoScopedLogTimer LogTimer = new FAutoScopedLogTimer(this.GetType().ToString() + "(Crash=" + Id + ")")) { List <string> PatternList = new List <string>(); var FunctionCalls = Context.FunctionCalls; // Get an array of callstack items CallStackContainer CallStack = GetCallStack(); if (Pattern == null) { // Set the module based on the modules in the callstack Module = CallStack.GetModuleName(); try { foreach (CallStackEntry Entry in CallStack.CallStackEntries.Take(64)) { FunctionCall CurrentFunctionCall = new FunctionCall(); if (FunctionCalls.Where(f => f.Call == Entry.FunctionName).Count() > 0) { CurrentFunctionCall = FunctionCalls.Where(f => f.Call == Entry.FunctionName).First(); } else { CurrentFunctionCall = new FunctionCall(); CurrentFunctionCall.Call = Entry.FunctionName; FunctionCalls.InsertOnSubmit(CurrentFunctionCall); } Context.SubmitChanges(); PatternList.Add(CurrentFunctionCall.Id.ToString()); } //CrashInstance.Pattern = "+"; Pattern = string.Join("+", PatternList); // We need something like this +1+2+3+5+ for searching for exact pattern like +5+ //CrashInstance.Pattern += "+"; Context.SubmitChanges(); } catch (Exception Ex) { FLogger.Global.WriteException("BuildPattern: " + Ex.ToString()); } } } }
/// <summary> /// Retrieves a list of distinct UE4 Branches from the CrashRepository /// </summary> /// <returns></returns> public static List <SelectListItem> GetBranches() { CrashReportDataContext Context = new CrashReportDataContext(); var lm = Context.Crashes.Where(n => n.Branch.Contains("UE4")).Select(n => n.Branch).Distinct().ToList(); var list = lm.Select(listitem => new SelectListItem { Selected = false, Text = listitem, Value = listitem }).ToList(); list.Insert(0, new SelectListItem { Selected = true, Text = "", Value = "" }); return(list); }
public bool AddCrashDescription(int rowID, string CrashDescription, string Summary) { // If CrashDescription and Summary == null then just return a successful update if(String.IsNullOrEmpty(CrashDescription) && String.IsNullOrEmpty(Summary)) { return true; } string LogFileName = ConfigurationManager.AppSettings["LogFileName"]; StreamWriter LogFile = null; try { LogFile = new StreamWriter(LogFileName, true); } catch (Exception) { // Ignore cases where the log file can't be opened (another instance may be writing to it already) } int rowsAffected = 0; try { CrashReportDataContext mCrashDataContext = new CrashReportDataContext(); Crash CrashToUpdate = mCrashDataContext.Crashes.Where(c => c.Id == rowID).First(); CrashToUpdate.Description = CrashDescription; mCrashDataContext.SubmitChanges(); } catch (Exception e) { if (LogFile != null) { LogFile.WriteLine("Exception caught!"); LogFile.WriteLine(e.Message); LogFile.Close(); } return false; } if (LogFile != null) { LogFile.WriteLine("Successfully updated Crash Description, " + rowsAffected.ToString() + " Rows updated"); LogFile.Close(); } return true; }
/// <summary> /// Build a callstack pattern for a crash to ease bucketing of crashes into Buggs. /// </summary> public void BuildPattern(CrashReportDataContext Context) { using (FAutoScopedLogTimer LogTimer = new FAutoScopedLogTimer(this.GetType().ToString() + "(Crash=" + Id + ")")) { List <string> PatternList = new List <string>(); var FunctionCalls = Context.FunctionCalls; // Get an array of call stack items CallStackContainer CallStack = GetCallStack(); if (Pattern == null) { // Set the module based on the modules in the call stack Module = CallStack.GetModuleName(); try { foreach (CallStackEntry Entry in CallStack.CallStackEntries.Take(CallStackContainer.MaxLinesToParse)) { FunctionCall currentFunctionCall; if (FunctionCalls.Any(f => f.Call == Entry.FunctionName)) { currentFunctionCall = FunctionCalls.First(f => f.Call == Entry.FunctionName); } else { currentFunctionCall = new FunctionCall(); currentFunctionCall.Call = Entry.FunctionName; FunctionCalls.InsertOnSubmit(currentFunctionCall); } Context.SubmitChanges(); PatternList.Add(currentFunctionCall.Id.ToString()); } Pattern = string.Join("+", PatternList); Context.SubmitChanges(); } catch (Exception Ex) { FLogger.Global.WriteException("BuildPattern exception: " + Ex.Message.ToString()); } } } }
/// <summary> /// Retrieves a list of distinct UE4 Versions from the CrashRepository /// </summary> public static List <SelectListItem> GetVersionsAsListItems() { using (FAutoScopedLogTimer LogTimer = new FAutoScopedLogTimer("CrashRepository.GetVersions")) { CrashReportDataContext Context = new CrashReportDataContext(); DateTime Now = DateTime.UtcNow; if (Now - LastVersionDate > TimeSpan.FromHours(1)) { var BuildVersions = Context.Crashes .Where(c => c.TimeOfCrash > DateTime.Now.AddDays(-14)) .Where(c => c.CrashType != 3) // Ignore ensures .Select(c => c.BuildVersion) .Distinct() .ToList(); DistinctBuildVersions = new HashSet <string>(); foreach (var BuildVersion in BuildVersions) { var BVParts = BuildVersion.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries); if (BVParts.Length > 2 && BVParts[0] != "0") { string CleanBV = string.Format("{0}.{1}.{2}", BVParts[0], BVParts[1], BVParts[2]); DistinctBuildVersions.Add(CleanBV); } } VersionsAsSelectList = DistinctBuildVersions .Select(listitem => new SelectListItem { Selected = false, Text = listitem, Value = listitem }) .ToList(); VersionsAsSelectList.Insert(0, new SelectListItem { Selected = true, Text = "", Value = "" }); LastVersionDate = Now; } return(VersionsAsSelectList); } }
/// <summary> /// The default constructor. /// </summary> public CrashRepository() { Context = new CrashReportDataContext(); }
/// <summary> /// The default constructor to create a data context to access the database. /// </summary> public BuggRepository() { BuggsDataContext = new CrashReportDataContext(); }
public int CreateNewCrash(int AutoReporterId, string ComputerName, string UserName, string GameName, string PlatformName, string LanguageExt, string TimeOfCrash, string BuildVer, string ChangelistVer, string CommandLine, string BaseDir, string CallStack, string EngineMode) { string LogFileName = ConfigurationManager.AppSettings["LogFileName"]; int newID = -1; StreamWriter LogFile = null; try { LogFile = new StreamWriter(LogFileName, true); } catch (Exception) { // Ignore cases where the log file can't be opened (another instance may be writing to it already) } DateTime currentDate = DateTime.Now; if (LogFile != null) { LogFile.WriteLine(""); LogFile.WriteLine("Creating new report..." + currentDate.ToString("G")); } try { //TODO Catch exception if we fail to connect to the database var NewCrash = new Crash(); if (CallStack.Contains("Assertion failed:")) { NewCrash.CrashType = 2; } else if (CallStack.Contains("Ensure condition failed:")) { NewCrash.CrashType = 3; } else { NewCrash.CrashType = 1; } NewCrash.BaseDir = BaseDir; NewCrash.BuildVersion = BuildVer; NewCrash.ChangeListVersion = ChangelistVer; NewCrash.CommandLine = CommandLine; NewCrash.ComputerName = ComputerName; NewCrash.EngineMode = EngineMode; NewCrash.GameName = GameName; NewCrash.LanguageExt = LanguageExt; NewCrash.PlatformName = PlatformName; NewCrash.RawCallStack = CallStack; NewCrash.TimeOfCrash = ConvertDumpTimeToDateTime(TimeOfCrash); NewCrash.Status = "New"; using (var DataContext = new CrashReportDataContext()) { // Crashes after this upgrade refer to users by ID NewCrash.UserNameId = DataContext.FindOrAddUser(UserName); DataContext.Crashes.InsertOnSubmit(NewCrash); DataContext.SubmitChanges(); } newID = NewCrash.Id; } catch (Exception e) { if (LogFile != null) { LogFile.WriteLine("Exception caught!"); LogFile.WriteLine(e.Message); LogFile.Close(); } return newID; } //TODO Catch any execptions from failing to open the connection to the db. /* catch (conn e) { if (LogFile != null) { LogFile.WriteLine("Failed to open connection to database!"); LogFile.WriteLine("ConnectionString"); LogFile.WriteLine(e.Message); LogFile.Close(); } return -1; }*/ if (LogFile != null) { LogFile.WriteLine("Successfully created new record with id " + newID.ToString()); LogFile.Close(); } return newID; }
public bool AddCrashFiles(int rowID, bool bHasLog, bool bHasMiniDump, bool bHasVideo) { string LogFileName = ConfigurationManager.AppSettings["LogFileName"]; StreamWriter LogFile = null; try { LogFile = new StreamWriter(LogFileName, true); } catch (Exception) { // Ignore cases where the log file can't be opened (another instance may be writing to it already) } int rowsAffected = 0; try { CrashReportDataContext mCrashDataContext = new CrashReportDataContext(); Crash CrashToUpdate = mCrashDataContext.Crashes.Where(c => c.Id == rowID).First(); CrashToUpdate.HasLogFile = bHasLog; CrashToUpdate.HasMiniDumpFile = bHasMiniDump; CrashToUpdate.HasVideoFile = bHasVideo; mCrashDataContext.SubmitChanges(); } catch (Exception e) { if (LogFile != null) { LogFile.WriteLine("Exception caught!"); LogFile.WriteLine(e.Message); LogFile.Close(); } return false; } if (LogFile != null) { LogFile.WriteLine("Successfully updated Crash Description, " + rowsAffected.ToString() + " Rows updated"); LogFile.Close(); } return true; }
/// <summary> /// Build a callstack pattern for a crash to ease bucketing of crashes into Buggs. /// </summary> public void BuildPattern( CrashReportDataContext Context ) { using( FAutoScopedLogTimer LogTimer = new FAutoScopedLogTimer( this.GetType().ToString() + "(Crash=" + Id + ")" ) ) { List<string> PatternList = new List<string>(); var FunctionCalls = Context.FunctionCalls; // Get an array of call stack items CallStackContainer CallStack = GetCallStack(); if( Pattern == null ) { // Set the module based on the modules in the call stack Module = CallStack.GetModuleName(); try { foreach (CallStackEntry Entry in CallStack.CallStackEntries.Take( CallStackContainer.MaxLinesToParse )) { FunctionCall currentFunctionCall; if( FunctionCalls.Any( f => f.Call == Entry.FunctionName ) ) { currentFunctionCall = FunctionCalls.First( f => f.Call == Entry.FunctionName ); } else { currentFunctionCall = new FunctionCall(); currentFunctionCall.Call = Entry.FunctionName; FunctionCalls.InsertOnSubmit( currentFunctionCall ); } Context.SubmitChanges(); PatternList.Add( currentFunctionCall.Id.ToString() ); } Pattern = string.Join( "+", PatternList ); Context.SubmitChanges(); } catch( Exception Ex ) { FLogger.Global.WriteException( "BuildPattern exception: " + Ex.Message.ToString() ); } } } }
/// <summary> /// The default constructor to create a data context to access the database. /// </summary> public BuggRepository() { BuggsDataContext = new CrashReportDataContext(); }
/// <summary> /// Build a callstack pattern for a crash to ease bucketing of crashes into Buggs. /// </summary> public void BuildPattern( CrashReportDataContext Context ) { using( FAutoScopedLogTimer LogTimer = new FAutoScopedLogTimer( this.GetType().ToString() + "(Crash=" + Id + ")" ) ) { List<string> PatternList = new List<string>(); var FunctionCalls = Context.FunctionCalls; // Get an array of callstack items CallStackContainer CallStack = GetCallStack(); if( Pattern == null ) { // Set the module based on the modules in the callstack Module = CallStack.GetModuleName(); try { foreach( CallStackEntry Entry in CallStack.CallStackEntries.Take( 64 ) ) { FunctionCall CurrentFunctionCall = new FunctionCall(); if( FunctionCalls.Where( f => f.Call == Entry.FunctionName ).Count() > 0 ) { CurrentFunctionCall = FunctionCalls.Where( f => f.Call == Entry.FunctionName ).First(); } else { CurrentFunctionCall = new FunctionCall(); CurrentFunctionCall.Call = Entry.FunctionName; FunctionCalls.InsertOnSubmit( CurrentFunctionCall ); } Context.SubmitChanges(); PatternList.Add( CurrentFunctionCall.Id.ToString() ); } //CrashInstance.Pattern = "+"; Pattern = string.Join( "+", PatternList ); // We need something like this +1+2+3+5+ for searching for exact pattern like +5+ //CrashInstance.Pattern += "+"; Context.SubmitChanges(); } catch( Exception Ex ) { FLogger.Global.WriteException( "BuildPattern: " + Ex.ToString() ); } } } }