You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#lockdown Nick.Penwarden ========================== MAJOR FEATURES + CHANGES ========================== Change 3315219 on 2017/02/21 by Steve.Robb Fix for FObjectAndNameAsStringProxyArchive when serializing a TWeakObjectPtr. Change 3315285 on 2017/02/21 by Steve.Robb Explicitly pass string builder into code generation functions. Change 3315341 on 2017/02/21 by Ben.Marsh UAT: Clean up some formatting in StreamCopyDescription output - remove #fyi lines, exclude merge commits, and remove some blank lines. Change 3315350 on 2017/02/21 by Ben.Marsh Fix shared resource files not being rebuilt if the version header changes. Change 3315823 on 2017/02/21 by Ben.Marsh UAT: Use a class derived from AutomationException to return information specific to commandlets failing, rather than putting it in the base class. Change 3315826 on 2017/02/21 by Ben.Marsh UAT: Move Distiller class from general use in UAT; FileFilter provides a much safer and fully featured implementation of the same concepts. Change 3315857 on 2017/02/21 by Ben.Marsh UBT: Remove the StripBaseDirectory() and MakeRerootedFilePath() utility functions from UBT. These operations can now be done more safely with FileReference objects. Change 3315942 on 2017/02/21 by Ben.Marsh UBT: Convert FileFilter to use FileReference and DirectoryReference arguments everywhere. Change3316236on 2017/02/22 by Maciej.Mroz #jira UE-42045 Nativization Fixed Warning: TEnumAsByte is not intended for use with enum Change 3316253 on 2017/02/22 by Robert.Manuszewski Fixes for the async log file writer hangs and crashes. - potential fix for the logging system hang when running out of disk space while flushing log - fix for unexpected concurrency assert when flushing the log buffer to disk Change3316293on 2017/02/22 by Steve.Robb GetTypeHash and lexicographical comparison operators (operator<() etc.) for TTuple. Change 3316342 on 2017/02/22 by Maciej.Mroz Nativization: Wrappers (stubs) required only by other wrappers are properly generated. #codereview: Mike.Beach Change 3316344 on 2017/02/22 by Maciej.Mroz Fixed crash in nativized Odin Async loading properly handles nativized structs. Change 3316359 on 2017/02/22 by Steve.Robb GitHub #3287 : Ignore #pragma in USTRUCTs #jira UE-42248 Change 3316389 on 2017/02/22 by Matthew.Griffin Switched Installed Engine Filters to multiline properties to make them more readable Added Oodle to list of excluded plugins #jira UE-42030 Change 3316392 on 2017/02/22 by Ben.Marsh UBT: Split out FileReference/DirectoryReference classes into their own file. Change 3316394 on 2017/02/22 by Ben.Marsh UBT: Move FileReference/DirectoryReference extension methods into the appropriate file. Change 3316411 on 2017/02/22 by Ben.Marsh UAT: Remove file functions that take multiple arguments. There's not really a compelling use case for these to exist over looping from the calling code. Change 3316446 on 2017/02/22 by Ben.Marsh UAT: Try disabling function name prefix to log output from UAT, to see if it improves readability. Function names are still included in the log file for debugging. Change 3316575 on 2017/02/22 by Ben.Marsh UAT: Remove unused functionality for dealing with labels, and output a more human readable list of P4 settings at startup. Change 3318481 on 2017/02/22 by Steve.Robb Use of FMath::IsPowerOfTwo in check. Static assert to ensure that an inline set allocator will have a hash size of a power of two. Change 3318496 on 2017/02/22 by Steve.Robb Fix for TSet visualizers. Change 3318919 on 2017/02/23 by Steve.Robb Fix for hot reloading UScriptStruct-derived objects in a module, where the CDOs of these objects haven't had PrepareCppStructOps() called on them. #jira UE-42178 Change 3318942 on 2017/02/23 by Steve.Robb Removal of a redundant insertion which can cause problems on reallocation of the map. Change 3319010 on 2017/02/23 by Ben.Marsh UBT: Fix exception when a file that was previously part of the working set is deleted. Change 3319134 on 2017/02/23 by Robert.Manuszewski Better fix for a deadlock when flushing log while it's already being flushed due to flush timer on the async log writer thread. Change 3319249 on 2017/02/23 by Matthew.Griffin Added a function to check if running with debug game libs instead of checking command line in multiple places Added -RunConfig parameter, which has equivalent result to -debug if value of parameter starts with 'debug' Added -RunConfig=$(Configuration) as a default commandline argument for Mac so that editor can use debug game libs Removed -Shipping argument from VCProject generation as it's not used anymore Change 3319253 on 2017/02/23 by Maciej.Mroz #jira UE-41846 New mechanism to gather modules necessary for Nativized Assets. The modules are listed based on included headers. Previously the dependencies was gathered only in FBlueprintNativeCodeGenManifest::GatherModuleDependencies. Change3319591on 2017/02/23 by Ben.Marsh Don't strip prefixes beginning with WARNING: or ERROR: using the Postp filter. Change 3320357 on 2017/02/23 by Steven.Hutton Slight changes to Add Crash method - Returning select fields instead of entity objects in queries for perf reasons. Change 3320361 on 2017/02/23 by Steven.Hutton Performance improvements subsequent to the recent database changes. Change 3320446 on 2017/02/23 by Steven.Hutton adding my temporary performance tracker class - reports to a private slack channel with add crash performance data. Change 3320479 on 2017/02/23 by Ben.Marsh Fix CIS errors. Change 3320576 on 2017/02/23 by Jin.Zhang Update CrashReporter to use AWS Change 3320742 on 2017/02/23 by Jin.Zhang Merging crash caching Change 3321119 on 2017/02/24 by Robert.Manuszewski DLL injection protection support for non-monolithic builds Change 3323308 on 2017/02/27 by Matthew.Griffin Moved compilation of SwarmInterface after its dependencies so that we will see a build failure immediately if they change version in future Change 3323423 on 2017/02/27 by Chad.Garyet Adding a script to check and warn about csproj targeted .net versions being mismatched #JIRA UE-39624 Change 3323442 on 2017/02/27 by Ben.Marsh UBT: Output an error if an engine module references a game module. Change 3323743 on 2017/02/27 by Ben.Marsh PR #3303: Resolved PVS scan issues (Contributed by projectgheist) Change 3323748 on 2017/02/27 by Ben.Marsh Convert whitespace to tabs. Change 3324851 on 2017/02/28 by Chris.Wood Add Odin symbol locations to engine config for MDD on CR server. NotForLicensees Change 3324979 on 2017/02/28 by Gil.Gribb Fixed bad merge of priority change in the EDL. Change 3326889 on 2017/03/01 by Steven.Hutton Update to buggs controller to generate faster queries. Change 3326910 on 2017/03/01 by Robert.Manuszewski Removing legacy #if from PackageFileSummary. Change 3327118 on 2017/03/01 by Gil.Gribb UE4 - Fixed race that resulted in a memory leak when reading compressed paks. Change 3327633 on 2017/03/01 by Gil.Gribb UE4 - Added a cvar to control the pak precacher thottle. Change 3327674 on 2017/03/01 by Steve.Robb Unified boilerplate between all generated code files. Change 3328544 on 2017/03/01 by Chris.Wood CrashReportProcess.config update (CRP v1.2.17) Tweaks to a few values. Update website URL to explicitly point to old, non-cloud site on devweb-02. Change 3328714 on 2017/03/01 by Chris.Wood Correct CRP config regression. Point website at new cloud site. Still v1.2.17 Change3329192on 2017/03/02 by Matthew.Griffin Added Shared Build Id file to the list of Precompiled Build Dependencies in a target receipt so that it's brought into an installed build Change 3329285 on 2017/03/02 by Ben.Marsh UGS: Allow a project to specify a filters for the streams that should be displayed for fast-switching to. The QuickSelectStreamList seting in the [Options] section of the project settings references a depot path containing a list of strings used to filter the stream list. An option is shown to switch back to showing all available streams, if desired. Change 3330636 on 2017/03/02 by Ben.Marsh UBT: Bump version number of C++ include cache to force it to be rebuilt with additional include information for the default RC files. Change 3331262 on 2017/03/03 by Robert.Manuszewski Merging Dev-LoadTimes to Dev-Core (Garbage Collection performance improvements) - Improved GC multithreading - Improved BeginDestroy performance - Introduced ULevelActorCluster for StaticMeshActor and ReflectionCapture actor clustering (can be toggled through project settings or console command gc.ActorClusterEnabled) - A few improvements to AddReferencedObjects functions - Misc improvements to GC code - Garbage Collector now properly handles clusters which had their objects marked as pending kill - Blueprints can now create clusters too (can be toggled through project settings or console command gc.BlueprintClusteringEnabled, defaults to disabled) Change 3331285 on 2017/03/03 by Robert.Manuszewski A few fixes for the previous check-in. Change 3332001 on 2017/03/03 by Ben.Marsh UBT: Add support for generating a UDN file containing the valid settings for BuildConfiguration.xml. Pass -configdoc=<filename> on the command line to generate such a file. Change 3332022 on 2017/03/03 by Ben.Marsh Update documentation for where to find the BuildConfiguration settings. Change 3332031 on 2017/03/03 by Ben.Marsh Remove documentation for Windows XP support; it has been removed in the 4.16 release. Change 3332256 on 2017/03/03 by Ben.Marsh UBT: Add support for generating a UDN page containing module and target settings. Change 3332458 on 2017/03/03 by Ben.Marsh UBT: Improvements to generated documentation. Change 3332459 on 2017/03/03 by Ben.Marsh Add generated documentation for .target.cs files, .build.cs files, and BuildConfiguration.xml files. Change 3332460 on 2017/03/03 by Ben.Marsh UBT: Make LinkTypePrivate actually private, so it doesn't show up in the docs. Change 3332899 on 2017/03/06 by Robert.Manuszewski Making sure actor clustering is not used in the editor (fix for actors being deleted when GC runs in the editor) #jira UE-42548 Change 3332955 on 2017/03/06 by Maciej.Mroz Nativization distinguishes client and server platform: - Separated lists on additional assets, additional modules, excluded assets, excluded modules, excluded paths (in config) - Context (compilation options, nativization options and platform) is deliveren to BPCOmpilerCppBackend in FCompilerNativizationOptions struct. - Wrappers (for unconverted BPs) are created only when they are directly called. - Fortnite dedicated server can be nativized Change 3332990 on 2017/03/06 by Ben.Marsh UBT: Add more comprehensive wrapper methods for System.IO.File and System.IO.Directory to FileReference and DirectoryReference. Change 3333032 on 2017/03/06 by Ben.Marsh Documentation for build tools Change 3333037 on 2017/03/06 by Ben.Marsh Add a build step to extract UAT and UBT documentation from XML comments. Change 3333089 on 2017/03/06 by Ben.Marsh UAT: Re-enable logging the calling function to the console in UAT. Needs a pass for readability first. Change 3333651 on 2017/03/06 by Gil.Gribb UE4 - Fix a werid recursive situation where StaticLoadObject could return an object that has not finished loading. Also produces a fatal error if this sometimes happens. EDL only. Change 3335236 on 2017/03/07 by Ben.Marsh UGS: Set the sync changelist separately to the compatibility changelist. Change 3335261 on 2017/03/07 by Gil.Gribb UE4 - Fixed batched render fences when BeginDestroy calls FlushRenderingCommands. Change 3335740 on 2017/03/07 by Gil.Gribb maybe fix static analysis warning Change 3335945 on 2017/03/07 by Steve.Robb Move FFindInstancedReferenceSubobjectHelper code out of header. Add map/set property support to allow instanced members of these container types to be handled during CPFUO. https://udn.unrealengine.com/questions/349232/tmap-with-instanced-object-as-value-gets-cleared-o.html Change 3336693 on 2017/03/07 by Ben.Marsh UBT: Use shared PCHs for game plugins by default, to reduce time spent generating individual PCHs. Change3336694on 2017/03/07 by Steve.Robb Static assert added to TMap to prevent the use of keys which don't implement a GetTypeHash. Fixes to types which relied on implicit conversions when calling GetTypeHash. Workaround in SAssetView.h and PropertyEditorModule.h for an apparent VC bug where the compiler wrongly instantiates TPointerIsConvertibleFromTo for certain forward-declared types, causing future TSharedPtr conversions to fail. #jira UE-42441 Change 3336698 on 2017/03/07 by Steve.Robb Hardcoded endpoint handling replaced with a generic string. Obsolete .proto and .java code generation removed. Change 3336811 on 2017/03/07 by Wes.Hunt Add a game blacklist to the crash report processor. Fixed a syntax error in Config.cs, added a XML comment to shut up a warning. Change 3336973 on 2017/03/08 by Steve.Robb Fix for missing GetTypeHash in a plugin. Change 3336996 on 2017/03/08 by Steve.Robb Significant refactor of code generation, to try and make data flow more apparent. Change 3337571 on 2017/03/08 by Steve.Robb CIS fixes for missing GetTypeHash functions. Non-unity fix. Change 3337588 on 2017/03/08 by Gil.Gribb UE4 - Fixed obscure check with flushing rhi resources. Change 3337620 on 2017/03/08 by Steve.Robb WITH_HOT_RELOAD_CTORS macros removed. UseVTableConstructors config option removed. Change 3339369 on 2017/03/09 by Steve.Robb GetTypeHash overload for nn::account::Uid. Change 3339464 on 2017/03/09 by Daniel.Lamb Fixed assert in 4.15 to do with trying to gather dependency info from invalid packages. #jira UE-42583 #test Editor + Cook + Run shootergame Change 3339465 on 2017/03/09 by Maciej.Mroz Fixed serialization issue, after UserDefinedEnum was used in EnumProperty. Change 3339469 on 2017/03/09 by Maciej.Mroz Fixed Nativization problem, when default value is passed as non-const reference. Change 3340178 on 2017/03/09 by Daniel.Lamb Added support for in memory only packages. The Cooker ignores these and added core functions to recognize these packages. Other systems will need to add support where nessisary. Change 3341002 on 2017/03/10 by Maciej.Mroz Nativization: Fixed FFindHeadersToInclude. Headers necessary for owners of subobjects are properly included. Change 3341076 on 2017/03/10 by Steve.Robb Fix for FBakedTextureSourceInfo move semantics. #jira UE-42658 Change 3341160 on 2017/03/10 by Gil.Gribb UE4 - Fix hazard with SetMaterialUsage from a thread. Change 3341409 on 2017/03/10 by Steve.Robb Reduction of the generated code size for StaticRegisterNatives functions. Change 3341523 on 2017/03/10 by Steve.Robb Code generation simplified. Change 3341800 on 2017/03/10 by Ben.Marsh UnrealVS: Fix UnrealVS compatibility with RTM version of Visual Studio 2017. 2017 toolchain for extensions is no longer able to build <= 2015 extensions due to validation of the VSIX manifest, so create a separate solution for it. Change 3342034 on 2017/03/10 by Ben.Marsh Fix compiler setting not being loaded correctly into the Windows target settings dialog. #jira UE-42746 Change 3342041 on 2017/03/10 by Ben.Marsh Fix -ErrorOnEngineContentUse not being set in the cooker options correctly. Change 3342094 on 2017/03/10 by Steve.Robb Fix to deteministic name order during code generation. Change 3342251 on 2017/03/10 by Daniel.Lamb Integrate fix for resave lightmaps commandlet when upgrading from no mapbuilddatapackages to mapbuilddatapackages. #thanks Tim.Hagberg #test None Change 3342961 on 2017/03/13 by Robert.Manuszewski Fixing memory leak when playing while running -nullrhi on the commandline in cooked games caused by shader resources not being destroyed. #jira FORT-38977 Change 3343022 on 2017/03/13 by Steve.Robb GetTypeHash fixes for FUniqueNetIdLive. #jira UE-42788 Change 3343448 on 2017/03/13 by Steve.Robb Compiled-in defer object order fixed. Debuggability of the deferred registration map improved. #jira UE-42828 [CL 3345747 by Ben Marsh in Main branch]
1211 lines
51 KiB
C#
1211 lines
51 KiB
C#
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data.Entity;
|
|
using System.Data.Entity.Validation;
|
|
using System.Globalization;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Text.RegularExpressions;
|
|
using System.Web;
|
|
using System.Web.Mvc;
|
|
using Tools.CrashReporter.CrashReportWebSite.Classes;
|
|
using Tools.CrashReporter.CrashReportWebSite.DataModels;
|
|
using Tools.CrashReporter.CrashReportWebSite.DataModels.Repositories;
|
|
using Tools.CrashReporter.CrashReportWebSite.Properties;
|
|
using Tools.CrashReporter.CrashReportWebSite.ViewModels;
|
|
using Tools.DotNETCommon.XmlHandler;
|
|
using Tools.CrashReporter.CrashReportCommon;
|
|
using System.Data.SqlClient;
|
|
using System.Runtime.Caching;
|
|
|
|
namespace Tools.CrashReporter.CrashReportWebSite.Controllers
|
|
{
|
|
/// <summary>
|
|
/// The controller to handle the Crash data.
|
|
/// </summary>
|
|
[HandleError]
|
|
public class CrashesController : Controller
|
|
{
|
|
private static MemoryCache crashCache = MemoryCache.Default;
|
|
|
|
//Ugly instantiation of Crash repository will replace with dependency injection BEFORE this gets anywhere near live.
|
|
private readonly SlackWriter _slackWriter;
|
|
|
|
private static readonly PerformanceTracker PerfTracker = new PerformanceTracker(100);
|
|
|
|
/// <summary> Special user name, currently used to mark Crashes from UE4 releases. </summary>
|
|
const string UserNameAnonymous = "Anonymous";
|
|
|
|
/// <summary>
|
|
/// An empty constructor.
|
|
/// </summary>
|
|
public CrashesController()
|
|
{
|
|
_slackWriter = new SlackWriter()
|
|
{
|
|
WebhookUrl = Settings.Default.SlackWebhookUrl,
|
|
Channel = Settings.Default.SlackChannel,
|
|
Username = Settings.Default.SlackUsername,
|
|
IconEmoji = Settings.Default.SlackEmoji
|
|
};
|
|
}
|
|
|
|
class CrashCacheItem
|
|
{
|
|
public List<Crash> Crashes { get; set; }
|
|
public Dictionary<string, int> GroupCount { get; set; }
|
|
public int ResultCount { get; set; }
|
|
}
|
|
|
|
private string getCacheKeyFromFormData(FormHelper formData)
|
|
{
|
|
return string.Format("{0}-{1}-{2}-{3}-{4}-{5}-{6}-{7}-{8}-{9}-{10}-{11}-{12}-{13}-{14}-{15}-{16}-{17}-{18}-{19}-{20}-{21}-{22}",
|
|
formData.BranchName,
|
|
formData.BuggId,
|
|
formData.BuiltFromCL,
|
|
formData.CrashType,
|
|
formData.DateFrom,
|
|
formData.DateTo,
|
|
formData.EngineMode,
|
|
formData.EngineVersion,
|
|
formData.EpicIdOrMachineQuery,
|
|
formData.GameName,
|
|
formData.JiraId,
|
|
formData.JiraQuery,
|
|
formData.MessageQuery,
|
|
formData.Page,
|
|
formData.PageSize,
|
|
formData.PlatformName,
|
|
formData.PreviousOrder,
|
|
formData.SearchQuery,
|
|
formData.SortOrder,
|
|
formData.SortTerm,
|
|
formData.UserGroup,
|
|
formData.UsernameQuery,
|
|
formData.VersionName);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Display a summary list of Crashes based on the search criteria.
|
|
/// </summary>
|
|
/// <param name="CrashesForm">A form of user data passed up from the client.</param>
|
|
/// <returns>A view to display a list of Crash reports.</returns>
|
|
public ActionResult Index(FormCollection CrashesForm )
|
|
{
|
|
using( var logTimer = new FAutoScopedLogTimer( this.GetType().ToString()) )
|
|
{
|
|
// Handle any edits made in the Set form fields
|
|
//foreach( var Entry in CrashesForm )
|
|
//{
|
|
// int Id = 0;
|
|
// if( int.TryParse( Entry.ToString(), out Id ) )
|
|
// {
|
|
// Crash currentCrash = _unitOfWork.CrashRepository.GetById(Id);
|
|
// if( currentCrash != null )
|
|
// {
|
|
// if( !string.IsNullOrEmpty( CrashesForm["SetStatus"] ) )
|
|
// {
|
|
// currentCrash.Status = CrashesForm["SetStatus"];
|
|
// }
|
|
|
|
// if( !string.IsNullOrEmpty( CrashesForm["SetFixedIn"] ) )
|
|
// {
|
|
// currentCrash.FixedChangeList = CrashesForm["SetFixedIn"];
|
|
// }
|
|
|
|
// if( !string.IsNullOrEmpty( CrashesForm["SetTTP"] ) )
|
|
// {
|
|
// currentCrash.Jira = CrashesForm["SetTTP"];
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
// _unitOfWork.Save();
|
|
//}
|
|
|
|
// <STATUS>
|
|
|
|
// Parse the contents of the query string, and populate the form
|
|
var formData = new FormHelper( Request, CrashesForm, "TimeOfCrash" );
|
|
var result = GetResults( formData );
|
|
|
|
using (var unitOfWork = new UnitOfWork(new CrashReportEntities()))
|
|
{
|
|
result.BranchNames = unitOfWork.CrashRepository.GetBranchesAsListItems();
|
|
result.VersionNames = unitOfWork.CrashRepository.GetVersionsAsListItems();
|
|
result.PlatformNames = unitOfWork.CrashRepository.GetPlatformsAsListItems();
|
|
result.EngineModes = unitOfWork.CrashRepository.GetEngineModesAsListItems();
|
|
result.EngineVersions = unitOfWork.CrashRepository.GetEngineVersionsAsListItems();
|
|
}
|
|
|
|
// Add the FromCollection to the CrashesViewModel since we don't need it for the get results function but we do want to post it back to the page.
|
|
result.FormCollection = CrashesForm;
|
|
result.GenerationTime = logTimer.GetElapsedSeconds().ToString( "F2" );
|
|
return View( "Index", result );
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Show detailed information about a Crash.
|
|
/// </summary>
|
|
/// <param name="CrashesForm">A form of user data passed up from the client.</param>
|
|
/// <param name="id">The unique id of the Crash we wish to show the details of.</param>
|
|
/// <returns>A view to show Crash details.</returns>
|
|
public ActionResult Show(FormCollection CrashesForm, int id)
|
|
{
|
|
using( var logTimer = new FAutoScopedLogTimer( this.GetType().ToString() + "(CrashId=" + id + ")", bCreateNewLog: true ) )
|
|
{
|
|
CallStackContainer currentCallStack = null;
|
|
Crash currentCrash = null;
|
|
User CrashUser = null;
|
|
Bugg currentBugg = null;
|
|
UserGroup currentUserGroup = null;
|
|
|
|
// Update the selected Crash based on the form contents
|
|
using (var unitOfWork = new UnitOfWork(new CrashReportEntities()))
|
|
{
|
|
currentCrash = unitOfWork.CrashRepository.GetById(id);
|
|
CrashUser = currentCrash.User;
|
|
currentBugg = currentCrash.Bugg;
|
|
currentUserGroup = CrashUser.UserGroup;
|
|
}
|
|
|
|
if( currentCrash == null )
|
|
{
|
|
return RedirectToAction( "Index" );
|
|
}
|
|
|
|
string FormValue;
|
|
|
|
FormValue = CrashesForm["SetStatus"];
|
|
if( !string.IsNullOrEmpty( FormValue ) )
|
|
{
|
|
currentCrash.Status = FormValue;
|
|
}
|
|
|
|
FormValue = CrashesForm["SetFixedIn"];
|
|
if( !string.IsNullOrEmpty( FormValue ) )
|
|
{
|
|
currentCrash.FixedChangeList = FormValue;
|
|
}
|
|
|
|
FormValue = CrashesForm["SetTTP"];
|
|
if( !string.IsNullOrEmpty( FormValue ) )
|
|
{
|
|
currentCrash.Jira = FormValue;
|
|
if(currentCrash.Bugg != null)
|
|
currentCrash.Bugg.TTPID = FormValue;
|
|
}
|
|
|
|
// Valid to set description to an empty string
|
|
FormValue = CrashesForm["Description"];
|
|
if( FormValue != null )
|
|
{
|
|
currentCrash.Description = FormValue;
|
|
}
|
|
using (var unitOfWork = new UnitOfWork(new CrashReportEntities()))
|
|
{
|
|
unitOfWork.CrashRepository.Update(currentCrash);
|
|
unitOfWork.Save();
|
|
}
|
|
|
|
currentCallStack = new CallStackContainer( currentCrash.CrashType, currentCrash.RawCallStack, currentCrash.PlatformName );
|
|
currentCrash.Module = currentCallStack.GetModuleName();
|
|
|
|
//Set call stack properties
|
|
currentCallStack.bDisplayModuleNames = true;
|
|
currentCallStack.bDisplayFunctionNames = true;
|
|
currentCallStack.bDisplayFileNames = true;
|
|
currentCallStack.bDisplayFilePathNames = true;
|
|
currentCallStack.bDisplayUnformattedCallStack = false;
|
|
|
|
currentCrash.CallStackContainer = currentCallStack;
|
|
|
|
var Model = new CrashViewModel { Crash = currentCrash, User = CrashUser, Bugg = currentBugg, UserGroup = currentUserGroup, CallStack = currentCallStack };
|
|
Model.GenerationTime = logTimer.GetElapsedSeconds().ToString( "F2" );
|
|
return View( "Show", Model );
|
|
}
|
|
}
|
|
|
|
/// <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)
|
|
{
|
|
var newCrashResult = new CrashReporterResult();
|
|
CrashDescription newCrash;
|
|
newCrashResult.ID = -1;
|
|
string payloadString;
|
|
|
|
using (var logTimer = new FAutoScopedLogTimer(this.GetType().ToString()
|
|
+ "(CrashId=" + id + ")"))
|
|
{
|
|
//Read the request payload
|
|
try
|
|
{
|
|
using (var reader = new StreamReader(Request.InputStream, Request.ContentEncoding))
|
|
{
|
|
payloadString = reader.ReadToEnd();
|
|
if (string.IsNullOrEmpty(payloadString))
|
|
{
|
|
FLogger.Global.WriteEvent(string.Format("Add Crash Failed : Payload string empty"));
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
var messageBuilder = new StringBuilder();
|
|
messageBuilder.AppendLine("Error Reading Crash Payload");
|
|
messageBuilder.AppendLine("Exception was:");
|
|
messageBuilder.AppendLine(ex.ToString());
|
|
|
|
FLogger.Global.WriteException(messageBuilder.ToString());
|
|
|
|
newCrashResult.Message = messageBuilder.ToString();
|
|
newCrashResult.bSuccess = false;
|
|
|
|
return Content(XmlHandler.ToXmlString<CrashReporterResult>(newCrashResult), "text/xml");
|
|
}
|
|
|
|
// De-serialize the payload string
|
|
try
|
|
{
|
|
newCrash = XmlHandler.FromXmlString<CrashDescription>(payloadString);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
var messageBuilder = new StringBuilder();
|
|
messageBuilder.AppendLine("Error Reading CrashDescription XML");
|
|
messageBuilder.AppendLine("Exception was: ");
|
|
messageBuilder.AppendLine(ex.ToString());
|
|
|
|
FLogger.Global.WriteException(messageBuilder.ToString());
|
|
|
|
newCrashResult.Message = messageBuilder.ToString();
|
|
newCrashResult.bSuccess = false;
|
|
|
|
return Content(XmlHandler.ToXmlString<CrashReporterResult>(newCrashResult), "text/xml");
|
|
}
|
|
|
|
//Add Crash to database
|
|
try
|
|
{
|
|
var crash = CreateCrash(newCrash);
|
|
newCrashResult.ID = crash.Id;
|
|
newCrashResult.bSuccess = true;
|
|
}
|
|
catch (DbEntityValidationException dbentEx)
|
|
{
|
|
var messageBuilder = new StringBuilder();
|
|
messageBuilder.AppendLine("Exception was:");
|
|
messageBuilder.AppendLine(dbentEx.ToString());
|
|
|
|
var innerEx = dbentEx.InnerException;
|
|
while (innerEx != null)
|
|
{
|
|
messageBuilder.AppendLine("Inner Exception : " + innerEx.Message);
|
|
innerEx = innerEx.InnerException;
|
|
}
|
|
|
|
if (dbentEx.EntityValidationErrors != null)
|
|
{
|
|
messageBuilder.AppendLine("Validation Errors : ");
|
|
foreach (var valErr in dbentEx.EntityValidationErrors)
|
|
{
|
|
messageBuilder.AppendLine(
|
|
valErr.ValidationErrors.Select(data => data.ErrorMessage)
|
|
.Aggregate((current, next) => current + "; /n" + next));
|
|
}
|
|
}
|
|
|
|
messageBuilder.AppendLine("Received payload was:");
|
|
messageBuilder.AppendLine(payloadString);
|
|
|
|
FLogger.Global.WriteException(messageBuilder.ToString());
|
|
_slackWriter.Write(messageBuilder.ToString());
|
|
|
|
newCrashResult.Message = messageBuilder.ToString();
|
|
newCrashResult.bSuccess = false;
|
|
}
|
|
catch (SqlException sqlExc)
|
|
{
|
|
if (sqlExc.Number == -2) //If this is an sql timeout log the timeout and try again.
|
|
{
|
|
FLogger.Global.WriteEvent(string.Format("AddCrash: Timeout"));
|
|
newCrashResult.bTimeout = true;
|
|
}
|
|
else
|
|
{
|
|
var messageBuilder = new StringBuilder();
|
|
messageBuilder.AppendLine("Exception was:");
|
|
messageBuilder.AppendLine(sqlExc.ToString());
|
|
messageBuilder.AppendLine("Received payload was:");
|
|
messageBuilder.AppendLine(payloadString);
|
|
|
|
FLogger.Global.WriteException(messageBuilder.ToString());
|
|
|
|
newCrashResult.Message = messageBuilder.ToString();
|
|
newCrashResult.bSuccess = false;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
var messageBuilder = new StringBuilder();
|
|
messageBuilder.AppendLine("Exception was:");
|
|
messageBuilder.AppendLine(ex.ToString());
|
|
messageBuilder.AppendLine("Received payload was:");
|
|
messageBuilder.AppendLine(payloadString);
|
|
|
|
FLogger.Global.WriteException(messageBuilder.ToString());
|
|
|
|
newCrashResult.Message = messageBuilder.ToString();
|
|
newCrashResult.bSuccess = false;
|
|
}
|
|
|
|
var returnResult = XmlHandler.ToXmlString<CrashReporterResult>(newCrashResult);
|
|
|
|
PerfTracker.AddStat("Add Crash Complete", logTimer.GetElapsedSeconds());
|
|
PerfTracker.IncrementCount();
|
|
|
|
return Content(returnResult, "text/xml");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets a list of Crashes filtered based on our form data.
|
|
/// </summary>
|
|
/// <param name="formData"></param>
|
|
/// <returns></returns>
|
|
public CrashesViewModel GetResults(FormHelper formData)
|
|
{
|
|
List<Crash> results = null;
|
|
IQueryable<Crash> resultsQuery = null;
|
|
|
|
var cacheKey = getCacheKeyFromFormData(formData);
|
|
var cachedResults = crashCache.Get(cacheKey) as CrashCacheItem;
|
|
|
|
if (cachedResults == null)
|
|
{
|
|
var skip = (formData.Page - 1) * formData.PageSize;
|
|
var take = formData.PageSize;
|
|
|
|
Dictionary<string, int> groupCounts;
|
|
var resultCount = 0;
|
|
using (var unitOfWork = new UnitOfWork(new CrashReportEntities()))
|
|
{
|
|
resultsQuery = ConstructQueryForFiltering(unitOfWork, formData);
|
|
|
|
// Filter by data and get as enumerable.
|
|
resultsQuery = FilterByDate(resultsQuery, formData.DateFrom, formData.DateTo);
|
|
|
|
// Filter by BuggId
|
|
if (!string.IsNullOrEmpty(formData.BuggId))
|
|
{
|
|
var buggId = 0;
|
|
var bValid = int.TryParse(formData.BuggId, out buggId);
|
|
|
|
if (bValid)
|
|
{
|
|
var newBugg = unitOfWork.BuggRepository.GetById(buggId);
|
|
|
|
if (newBugg != null)
|
|
{
|
|
resultsQuery = resultsQuery.Where(data => data.PatternId == newBugg.PatternId);
|
|
}
|
|
}
|
|
}
|
|
|
|
var countsQuery =
|
|
resultsQuery.GroupBy(data => data.User.UserGroup)
|
|
.Select(data => new { Key = data.Key.Name, Count = data.Count() });
|
|
groupCounts = countsQuery.OrderBy(data => data.Key)
|
|
.ToDictionary(data => data.Key, data => data.Count);
|
|
|
|
// Filter by user group if present
|
|
var userGroupId = !string.IsNullOrEmpty(formData.UserGroup)
|
|
? unitOfWork.UserGroupRepository.First(data => data.Name == formData.UserGroup).Id
|
|
: 1;
|
|
resultsQuery = resultsQuery.Where(data => data.User.UserGroupId == userGroupId);
|
|
|
|
var orderedQuery = GetSortedQuery(resultsQuery, formData.SortTerm ?? "TimeOfCrash",
|
|
formData.SortOrder == "Descending");
|
|
|
|
// Grab just the results we want to display on this page
|
|
results = orderedQuery.Skip(skip).Take(take).ToList();
|
|
|
|
// Get the Count for pagination
|
|
resultCount = orderedQuery.Count();
|
|
|
|
// Process call stack for display
|
|
foreach (var CrashInstance in results)
|
|
{
|
|
// Put call stacks into an list so we can access them line by line in the view
|
|
CrashInstance.CallStackContainer = new CallStackContainer(CrashInstance.CrashType, CrashInstance.RawCallStack, CrashInstance.PlatformName);
|
|
}
|
|
|
|
cachedResults = new CrashCacheItem()
|
|
{
|
|
Crashes = results,
|
|
GroupCount = groupCounts,
|
|
ResultCount = resultCount
|
|
};
|
|
|
|
var itemCachePolicy = new CacheItemPolicy() { AbsoluteExpiration = DateTimeOffset.Now.AddMinutes(Settings.Default.CrashesCacheInMinutes) };
|
|
|
|
crashCache.Add(cacheKey, cachedResults, itemCachePolicy);
|
|
}
|
|
}
|
|
|
|
return new CrashesViewModel
|
|
{
|
|
Results = cachedResults.Crashes,
|
|
PagingInfo = new PagingInfo { CurrentPage = formData.Page, PageSize = formData.PageSize, TotalResults = cachedResults.ResultCount },
|
|
SortOrder = formData.SortOrder,
|
|
SortTerm = formData.SortTerm,
|
|
UserGroup = formData.UserGroup,
|
|
CrashType = formData.CrashType,
|
|
SearchQuery = formData.SearchQuery,
|
|
UsernameQuery = formData.UsernameQuery,
|
|
EpicIdOrMachineQuery = formData.EpicIdOrMachineQuery,
|
|
MessageQuery = formData.MessageQuery,
|
|
BuiltFromCL = formData.BuiltFromCL,
|
|
BuggId = formData.BuggId,
|
|
JiraQuery = formData.JiraQuery,
|
|
DateFrom = (long)(formData.DateFrom.ToUniversalTime() - CrashesViewModel.Epoch).TotalMilliseconds,
|
|
DateTo = (long)(formData.DateTo.ToUniversalTime() - CrashesViewModel.Epoch).TotalMilliseconds,
|
|
BranchName = formData.BranchName,
|
|
VersionName = formData.VersionName,
|
|
PlatformName = formData.PlatformName,
|
|
GameName = formData.GameName,
|
|
GroupCounts = cachedResults.GroupCount
|
|
};
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns a lambda expression used to sort our Crash data.
|
|
/// </summary>
|
|
/// <param name="resultsQuery">A query filter on the Crashes entity.</param>
|
|
/// <param name="sortTerm">Sort term identifying the field on which to sort.</param>
|
|
/// <param name="sortDescending">bool indicating sort order</param>
|
|
/// <returns></returns>
|
|
public IOrderedQueryable<Crash> GetSortedQuery(IQueryable<Crash> resultsQuery, string sortTerm, bool sortDescending)
|
|
{
|
|
switch (sortTerm)
|
|
{
|
|
case "Id":
|
|
return sortDescending ? resultsQuery.OrderByDescending(data => data.Id) : resultsQuery.OrderBy(data => data.Id);
|
|
break;
|
|
case "TimeOfCrash":
|
|
return sortDescending ? resultsQuery.OrderByDescending(data => data.TimeOfCrash) : resultsQuery.OrderBy(CrashInstance => CrashInstance.TimeOfCrash);
|
|
break;
|
|
case "UserName":
|
|
return sortDescending ? resultsQuery.OrderByDescending(data => data.User.UserName) : resultsQuery.OrderBy(CrashInstance => CrashInstance.User.UserName);
|
|
break;
|
|
case "RawCallStack":
|
|
return sortDescending ? resultsQuery.OrderByDescending(data => data.RawCallStack) : resultsQuery.OrderBy(CrashInstance => CrashInstance.RawCallStack);
|
|
break;
|
|
case "GameName":
|
|
return sortDescending ? resultsQuery.OrderByDescending(data => data.GameName) : resultsQuery.OrderBy(CrashInstance => CrashInstance.GameName);
|
|
break;
|
|
case "EngineMode":
|
|
return sortDescending ? resultsQuery.OrderByDescending(data => data.EngineMode) : resultsQuery.OrderBy(CrashInstance => CrashInstance.EngineMode);
|
|
break;
|
|
case "FixedChangeList":
|
|
return sortDescending ? resultsQuery.OrderByDescending(data => data.FixedChangeList) : resultsQuery.OrderBy(CrashInstance => CrashInstance.FixedChangeList);
|
|
break;
|
|
case "TTPID":
|
|
return sortDescending ? resultsQuery.OrderByDescending(data => data.Jira) : resultsQuery.OrderBy(CrashInstance => CrashInstance.Jira);
|
|
break;
|
|
case "Branch":
|
|
return sortDescending ? resultsQuery.OrderByDescending(data => data.Branch) : resultsQuery.OrderBy(CrashInstance => CrashInstance.Branch);
|
|
break;
|
|
case "ChangeListVersion":
|
|
return sortDescending ? resultsQuery.OrderByDescending(data => data.ChangelistVersion) : resultsQuery.OrderBy(CrashInstance => CrashInstance.ChangelistVersion);
|
|
break;
|
|
case "ComputerName":
|
|
return sortDescending ? resultsQuery.OrderByDescending(data => data.ComputerName) : resultsQuery.OrderBy(CrashInstance => CrashInstance.ComputerName);
|
|
break;
|
|
case "PlatformName":
|
|
return sortDescending ? resultsQuery.OrderByDescending(data => data.PlatformName) : resultsQuery.OrderBy(CrashInstance => CrashInstance.PlatformName);
|
|
break;
|
|
case "Status":
|
|
return sortDescending ? resultsQuery.OrderByDescending(data => data.Status) : resultsQuery.OrderBy(CrashInstance => CrashInstance.Status);
|
|
break;
|
|
case "Module":
|
|
return sortDescending ? resultsQuery.OrderByDescending(data => data.Module) : resultsQuery.OrderBy(CrashInstance => CrashInstance.Module);
|
|
break;
|
|
case "Summary":
|
|
return sortDescending ? resultsQuery.OrderByDescending(data => data.Summary) : resultsQuery.OrderBy(data => data.Summary);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
/// <summary>Constructs query for filtering.</summary>
|
|
private IQueryable<Crash> ConstructQueryForFiltering(IUnitOfWork unitOfWork, FormHelper formData)
|
|
{
|
|
//Instead of returning a queryable and filtering it here we should construct a filtering expression and pass that to the repository.
|
|
//I don't like that data handling is taking place in the controller.
|
|
var results = unitOfWork.CrashRepository.ListAll();
|
|
|
|
// Grab Results
|
|
var queryString = HttpUtility.HtmlDecode(formData.SearchQuery);
|
|
if (!string.IsNullOrEmpty(queryString))
|
|
{
|
|
if (!string.IsNullOrEmpty(queryString))
|
|
{
|
|
//We only use SearchQuery now for CallStack searching - if there's a SearchQuery value and a Username value, we need to get rid of the
|
|
//Username so that we can create a broader search range
|
|
formData.UsernameQuery = "";
|
|
}
|
|
results = results.Where(data => data.RawCallStack.Contains(formData.SearchQuery));
|
|
}
|
|
|
|
if (formData.IsVanilla.HasValue)
|
|
{
|
|
results = results.Where(data => data.IsVanilla == formData.IsVanilla.Value);
|
|
}
|
|
|
|
// Filter by Crash Type
|
|
if (formData.CrashType != "All")
|
|
{
|
|
switch (formData.CrashType)
|
|
{
|
|
case "Crashes":
|
|
results = results.Where(CrashInstance => CrashInstance.CrashType == 1);
|
|
break;
|
|
case "Assert":
|
|
results = results.Where(CrashInstance => CrashInstance.CrashType == 2);
|
|
break;
|
|
case "Ensure":
|
|
results = results.Where(CrashInstance => CrashInstance.CrashType == 3);
|
|
break;
|
|
case "CrashesAsserts":
|
|
results = results.Where(CrashInstance => CrashInstance.CrashType == 1 || CrashInstance.CrashType == 2);
|
|
break;
|
|
}
|
|
}
|
|
|
|
// JRX Restore EpicID/UserName searching
|
|
if (!string.IsNullOrEmpty(formData.UsernameQuery))
|
|
{
|
|
var decodedUsername = HttpUtility.HtmlDecode(formData.UsernameQuery).ToLower();
|
|
var user = unitOfWork.UserRepository.First(data => data.UserName.Contains(decodedUsername));
|
|
if (user != null)
|
|
{
|
|
var userId = user.Id;
|
|
results = (
|
|
from CrashDetail in results
|
|
where CrashDetail.UserId == userId
|
|
select CrashDetail);
|
|
}
|
|
}
|
|
|
|
// Start Filtering the results
|
|
if (!string.IsNullOrEmpty(formData.EpicIdOrMachineQuery))
|
|
{
|
|
var decodedEpicOrMachineId = HttpUtility.HtmlDecode(formData.EpicIdOrMachineQuery).ToLower();
|
|
results = (
|
|
from CrashDetail in results
|
|
where CrashDetail.EpicAccountId.Equals(decodedEpicOrMachineId) ||
|
|
CrashDetail.ComputerName.Equals(decodedEpicOrMachineId)
|
|
select CrashDetail );
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(formData.JiraQuery))
|
|
{
|
|
var decodedJira = HttpUtility.HtmlDecode(formData.JiraQuery).ToLower();
|
|
results =
|
|
(
|
|
from CrashDetail in results
|
|
where CrashDetail.Jira.Contains(decodedJira)
|
|
select CrashDetail
|
|
);
|
|
}
|
|
|
|
// Filter by BranchName
|
|
if (!string.IsNullOrEmpty(formData.BranchName))
|
|
{
|
|
results =
|
|
(
|
|
from CrashDetail in results
|
|
where CrashDetail.Branch.Equals(formData.BranchName)
|
|
select CrashDetail
|
|
);
|
|
}
|
|
|
|
// Filter by VersionName
|
|
if (!string.IsNullOrEmpty(formData.VersionName))
|
|
{
|
|
results =
|
|
(
|
|
from CrashDetail in results
|
|
where CrashDetail.BuildVersion.Equals(formData.VersionName)
|
|
select CrashDetail
|
|
);
|
|
}
|
|
|
|
//Filter by Engine Version
|
|
if (!string.IsNullOrEmpty(formData.EngineVersion))
|
|
{
|
|
results =
|
|
(
|
|
from CrashDetail in results
|
|
where CrashDetail.EngineVersion.Equals(formData.EngineVersion)
|
|
select CrashDetail
|
|
);
|
|
}
|
|
|
|
// Filter by VersionName
|
|
if (!string.IsNullOrEmpty(formData.EngineMode))
|
|
{
|
|
results =
|
|
(
|
|
from CrashDetail in results
|
|
where CrashDetail.EngineMode.Equals(formData.EngineMode)
|
|
select CrashDetail
|
|
);
|
|
}
|
|
|
|
// Filter by PlatformName
|
|
if (!string.IsNullOrEmpty(formData.PlatformName))
|
|
{
|
|
results =
|
|
(
|
|
from CrashDetail in results
|
|
where CrashDetail.PlatformName.Contains(formData.PlatformName)
|
|
select CrashDetail
|
|
);
|
|
}
|
|
|
|
// Filter by GameName
|
|
if (!string.IsNullOrEmpty(formData.GameName))
|
|
{
|
|
var DecodedGameName = HttpUtility.HtmlDecode(formData.GameName).ToLower();
|
|
|
|
if (DecodedGameName.StartsWith("-"))
|
|
{
|
|
results =
|
|
(
|
|
from CrashDetail in results
|
|
where !CrashDetail.GameName.Contains(DecodedGameName.Substring(1))
|
|
select CrashDetail
|
|
);
|
|
}
|
|
else
|
|
{
|
|
results =
|
|
(
|
|
from CrashDetail in results
|
|
where CrashDetail.GameName.Contains(DecodedGameName)
|
|
select CrashDetail
|
|
);
|
|
}
|
|
}
|
|
|
|
// Filter by MessageQuery
|
|
if (!string.IsNullOrEmpty(formData.MessageQuery))
|
|
{
|
|
results =
|
|
(
|
|
from CrashDetail in results
|
|
where CrashDetail.Summary.Contains(formData.MessageQuery) || CrashDetail.Description.Contains(formData.MessageQuery)
|
|
select CrashDetail
|
|
);
|
|
}
|
|
|
|
// Filter by BuiltFromCL
|
|
if (!string.IsNullOrEmpty(formData.BuiltFromCL))
|
|
{
|
|
var builtFromCl = 0;
|
|
var bValid = int.TryParse(formData.BuiltFromCL, out builtFromCl);
|
|
|
|
if (bValid)
|
|
{
|
|
results =
|
|
(
|
|
from CrashDetail in results
|
|
where CrashDetail.ChangelistVersion.Equals(formData.BuiltFromCL)
|
|
select CrashDetail
|
|
);
|
|
}
|
|
}
|
|
|
|
return results.Include(data => data.User);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Filter a set of Crashes to a date range.
|
|
/// </summary>
|
|
/// <param name="Results">The unfiltered set of Crashes.</param>
|
|
/// <param name="DateFrom">The earliest date to filter by.</param>
|
|
/// <param name="DateTo">The latest date to filter by.</param>
|
|
/// <returns>The set of Crashes between the earliest and latest date.</returns>
|
|
public IQueryable<Crash> FilterByDate(IQueryable<Crash> Results, DateTime DateFrom, DateTime DateTo)
|
|
{
|
|
using (FAutoScopedLogTimer LogTimer = new FAutoScopedLogTimer(this.GetType().ToString() + " SQL"))
|
|
{
|
|
DateTo = DateTo.AddDays(1);
|
|
|
|
IQueryable<Crash> CrashesInTimeFrame = Results
|
|
.Where(MyCrash => MyCrash.TimeOfCrash >= DateFrom && MyCrash.TimeOfCrash <= DateTo);
|
|
return CrashesInTimeFrame;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Create a new Crash data model object and insert it into the database
|
|
/// </summary>
|
|
/// <param name="description"></param>
|
|
/// <returns></returns>
|
|
private Crash CreateCrash(CrashDescription description)
|
|
{
|
|
var newCrash = new Crash
|
|
{
|
|
Branch = description.BranchName,
|
|
BaseDir = description.BaseDir,
|
|
BuildVersion = description.EngineVersion,
|
|
EngineVersion = description.BuildVersion,
|
|
ChangelistVersion = description.BuiltFromCL.ToString(),
|
|
CommandLine = description.CommandLine,
|
|
EngineMode = description.EngineMode,
|
|
ComputerName = description.MachineGuid,
|
|
IsVanilla = description.EngineModeEx.ToLower() == "vanilla"
|
|
};
|
|
|
|
//If there's a valid EpicAccountId assign that.
|
|
if (!string.IsNullOrEmpty(description.EpicAccountId))
|
|
{
|
|
newCrash.EpicAccountId = description.EpicAccountId;
|
|
}
|
|
|
|
newCrash.Description = "";
|
|
if (description.UserDescription != null)
|
|
{
|
|
newCrash.Description = string.Join(Environment.NewLine, description.UserDescription);
|
|
}
|
|
if (newCrash.Description.Length > 4095)
|
|
newCrash.Description = newCrash.Description.Substring(0, 4095);
|
|
|
|
newCrash.EngineMode = description.EngineMode;
|
|
newCrash.GameName = description.GameName;
|
|
newCrash.LanguageExt = description.Language; //Converted by the Crash process.
|
|
newCrash.PlatformName = description.Platform;
|
|
newCrash.HasLogFile = description.bHasLog;
|
|
newCrash.HasVideoFile = description.bHasVideo;
|
|
newCrash.HasMiniDumpFile = description.bHasMiniDump;
|
|
|
|
if (description.ErrorMessage != null)
|
|
{
|
|
newCrash.Summary = string.Join("\n", description.ErrorMessage);
|
|
}
|
|
|
|
if (description.CallStack != null)
|
|
{
|
|
newCrash.RawCallStack = string.Join("\n", description.CallStack);
|
|
}
|
|
|
|
if (description.SourceContext != null)
|
|
{
|
|
newCrash.SourceContext = string.Join("\n", description.SourceContext);
|
|
}
|
|
|
|
newCrash.TimeOfCrash = description.TimeofCrash;
|
|
|
|
newCrash.Jira = "";
|
|
newCrash.FixedChangeList = "";
|
|
newCrash.ProcessFailed = description.bProcessorFailed;
|
|
|
|
// Set the Crash type
|
|
newCrash.CrashType = 1;
|
|
|
|
//if we have a Crash type set the Crash type
|
|
if (!string.IsNullOrEmpty(description.CrashType))
|
|
{
|
|
switch (description.CrashType.ToLower())
|
|
{
|
|
case "Crash":
|
|
newCrash.CrashType = 1;
|
|
break;
|
|
case "assert":
|
|
newCrash.CrashType = 2;
|
|
break;
|
|
case "ensure":
|
|
newCrash.CrashType = 3;
|
|
break;
|
|
case "":
|
|
case null:
|
|
default:
|
|
newCrash.CrashType = 1;
|
|
break;
|
|
}
|
|
}
|
|
else //else fall back to the old behavior and try to determine type from RawCallStack
|
|
{
|
|
if (newCrash.RawCallStack != null)
|
|
{
|
|
if (newCrash.RawCallStack.Contains("FDebug::AssertFailed"))
|
|
{
|
|
newCrash.CrashType = 2;
|
|
}
|
|
else if (newCrash.RawCallStack.Contains("FDebug::Ensure"))
|
|
{
|
|
newCrash.CrashType = 3;
|
|
}
|
|
else if (newCrash.RawCallStack.Contains("FDebug::OptionallyLogFormattedEnsureMessageReturningFalse"))
|
|
{
|
|
newCrash.CrashType = 3;
|
|
}
|
|
else if (newCrash.RawCallStack.Contains("NewReportEnsure"))
|
|
{
|
|
newCrash.CrashType = 3;
|
|
}
|
|
}
|
|
}
|
|
|
|
// As we're adding it, the status is always new
|
|
newCrash.Status = "New";
|
|
newCrash.UserActivityHint = description.UserActivityHint;
|
|
newCrash.UserName = (!string.IsNullOrEmpty(description.UserName)) ? description.UserName : UserNameAnonymous;
|
|
|
|
//Match this crash to an existing user or create a new user if one does not exist.
|
|
using (var unitOfWork = new UnitOfWork(new CrashReportEntities()))
|
|
{
|
|
//if there's a valid username assign the associated UserNameId else use "anonymous".
|
|
var userName = (!string.IsNullOrEmpty(description.UserName)) ? description.UserName : UserNameAnonymous;
|
|
|
|
if (unitOfWork.UserRepository.Any(data => data.UserName.Equals(userName)))
|
|
{
|
|
newCrash.UserId = unitOfWork.UserRepository.ListAll()
|
|
.Where(data => data.UserName.Equals(userName))
|
|
.Select(data => data.Id)
|
|
.First();
|
|
}
|
|
else
|
|
{
|
|
newCrash.User = new User() { UserName = description.UserName, UserGroupId = 5 };
|
|
}
|
|
}
|
|
|
|
try
|
|
{
|
|
//Build the callstack pattern for this crash
|
|
BuildPattern(newCrash);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
FLogger.Global.WriteException("Error in Create Crash Build Pattern Method");
|
|
_slackWriter.Write("Error in Create Crash Build Pattern Method");
|
|
_slackWriter.Write(ex.Message);
|
|
if (ex.InnerException != null)
|
|
{
|
|
_slackWriter.Write(ex.InnerException.Message);
|
|
}
|
|
throw;
|
|
}
|
|
|
|
if(newCrash.CommandLine == null)
|
|
newCrash.CommandLine = "";
|
|
|
|
using (var unitOfWork = new UnitOfWork(new CrashReportEntities()))
|
|
{
|
|
var callStackRepository = unitOfWork.CallstackRepository;
|
|
|
|
try
|
|
{
|
|
var crashRepo = unitOfWork.CrashRepository;
|
|
|
|
//if we don't have any callstack data then insert the Crash and return
|
|
if (string.IsNullOrEmpty(newCrash.Pattern))
|
|
{
|
|
crashRepo.Save(newCrash);
|
|
unitOfWork.Save();
|
|
return newCrash;
|
|
}
|
|
|
|
//If this isn't a new pattern then link it to our Crash data model
|
|
if (callStackRepository.Any(data => data.Pattern == newCrash.Pattern))
|
|
{
|
|
var callstackPattern = callStackRepository.First(data => data.Pattern == newCrash.Pattern);
|
|
newCrash.PatternId = callstackPattern.id;
|
|
}
|
|
else
|
|
{
|
|
//if this is a new callstack pattern then insert into data model and create a new bugg.
|
|
var callstackPattern = new CallStackPattern {Pattern = newCrash.Pattern};
|
|
callStackRepository.Save(callstackPattern);
|
|
unitOfWork.Save();
|
|
newCrash.PatternId = callstackPattern.id;
|
|
}
|
|
|
|
//Mask out the line number and File path from our error message.
|
|
var errorMessageString = description.ErrorMessage != null
|
|
? String.Join("", description.ErrorMessage)
|
|
: "";
|
|
|
|
//Create our masking regular expressions
|
|
var fileRegex = new Regex(@"(\[File:).*?(])"); //Match the filename out the file name
|
|
var lineRegex = new Regex(@"(\[Line:).*?(])"); //Match the line no.
|
|
|
|
/**
|
|
* * Regex to match ints of two characters or longer
|
|
* * First term ((?<=\s)|(-)) : Positive look behind, match if preceeded by whitespace or if first character is '-'
|
|
* Second term (\d{3,}) match three or more decimal chracters in a row.
|
|
* Third term (?=(\s|$)) positive look ahead match if followed by whitespace or end of line/file.
|
|
*/
|
|
var intRegex = new Regex(@"-?\d{3,}");
|
|
|
|
/**
|
|
* Regular expression for masking out floats
|
|
*/
|
|
var floatRegex = new Regex(@"-?\d+\.\d+");
|
|
|
|
/**
|
|
* Regular expression for masking out hexadecimal numbers
|
|
*/
|
|
var hexRegex = new Regex(@"0x[\da-fA-F]+");
|
|
|
|
//mask out terms matches by our regex's
|
|
var trimmedError = fileRegex.Replace(errorMessageString, "");
|
|
trimmedError = lineRegex.Replace(trimmedError, "");
|
|
trimmedError = floatRegex.Replace(trimmedError, "");
|
|
trimmedError = hexRegex.Replace(trimmedError, "");
|
|
trimmedError = intRegex.Replace(trimmedError, "");
|
|
if (trimmedError.Length > 450)
|
|
trimmedError = trimmedError.Substring(0, 450);
|
|
//error message is used as an index - trim to max index length
|
|
|
|
//Check to see if the masked error message is unique
|
|
ErrorMessage errorMessage = null;
|
|
if (
|
|
unitOfWork.ErrorMessageRepository.Any(
|
|
data =>
|
|
data.ErrorMessageText.Equals(trimmedError, StringComparison.InvariantCultureIgnoreCase)))
|
|
{
|
|
errorMessage =
|
|
unitOfWork.ErrorMessageRepository.First(
|
|
data =>
|
|
data.ErrorMessageText.Equals(trimmedError,
|
|
StringComparison.InvariantCultureIgnoreCase));
|
|
}
|
|
else
|
|
{
|
|
//if it's a new message then add it to the database.
|
|
errorMessage = new ErrorMessage()
|
|
{
|
|
ErrorMessageText = trimmedError.ToLower(CultureInfo.InvariantCulture)
|
|
};
|
|
unitOfWork.ErrorMessageRepository.Save(errorMessage);
|
|
unitOfWork.Save();
|
|
}
|
|
|
|
//Check for an existing bugg with this pattern and error message / no error message
|
|
if (unitOfWork.BuggRepository.Any(data =>
|
|
(data.PatternId == newCrash.PatternId) &&
|
|
(data.ErrorMessageId == errorMessage.Id || data.ErrorMessageId == null)))
|
|
{
|
|
//if a bugg exists for this pattern update the bugg data
|
|
var bugg = unitOfWork.BuggRepository.First(data => data.PatternId == newCrash.PatternId);
|
|
bugg.PatternId = newCrash.PatternId;
|
|
|
|
bugg.CrashType = newCrash.CrashType;
|
|
bugg.ErrorMessageId = errorMessage.Id;
|
|
|
|
//also update the bugg data while we're here
|
|
bugg.TimeOfLastCrash = newCrash.TimeOfCrash;
|
|
bugg.NumberOfCrashes = bugg.NumberOfCrashes + 1;
|
|
|
|
if (String.Compare(newCrash.BuildVersion, bugg.BuildVersion,
|
|
StringComparison.Ordinal) != 1)
|
|
bugg.BuildVersion = newCrash.BuildVersion;
|
|
|
|
unitOfWork.Save();
|
|
|
|
//if a bugg exists update this Crash from the bugg
|
|
//buggs are authoritative in this case
|
|
newCrash.BuggId = bugg.Id;
|
|
newCrash.Jira = bugg.TTPID;
|
|
newCrash.FixedChangeList = bugg.FixedChangeList;
|
|
newCrash.Status = bugg.Status;
|
|
unitOfWork.CrashRepository.Save(newCrash);
|
|
unitOfWork.Save();
|
|
}
|
|
else
|
|
{
|
|
//if there's no bugg for this pattern create a new bugg and insert into the data store.
|
|
var bugg = new Bugg();
|
|
bugg.TimeOfFirstCrash = newCrash.TimeOfCrash;
|
|
bugg.TimeOfLastCrash = newCrash.TimeOfCrash;
|
|
bugg.TTPID = newCrash.Jira;
|
|
bugg.Pattern = newCrash.Pattern;
|
|
bugg.PatternId = newCrash.PatternId;
|
|
bugg.NumberOfCrashes = 1;
|
|
bugg.NumberOfUsers = 1;
|
|
bugg.NumberOfUniqueMachines = 1;
|
|
bugg.BuildVersion = newCrash.BuildVersion;
|
|
bugg.CrashType = newCrash.CrashType;
|
|
bugg.Status = newCrash.Status;
|
|
bugg.FixedChangeList = newCrash.FixedChangeList;
|
|
bugg.ErrorMessageId = errorMessage.Id;
|
|
bugg.NumberOfCrashes = 1;
|
|
newCrash.Bugg = bugg;
|
|
unitOfWork.BuggRepository.Save(bugg);
|
|
unitOfWork.CrashRepository.Save(newCrash);
|
|
unitOfWork.Save();
|
|
}
|
|
}
|
|
catch (DbEntityValidationException dbentEx)
|
|
{
|
|
var messageBuilder = new StringBuilder();
|
|
messageBuilder.AppendLine("Db Entity Validation Exception Exception was:");
|
|
messageBuilder.AppendLine(dbentEx.ToString());
|
|
|
|
var innerEx = dbentEx.InnerException;
|
|
while (innerEx != null)
|
|
{
|
|
messageBuilder.AppendLine("Inner Exception : " + innerEx.Message);
|
|
innerEx = innerEx.InnerException;
|
|
}
|
|
|
|
if (dbentEx.EntityValidationErrors != null)
|
|
{
|
|
messageBuilder.AppendLine("Validation Errors : ");
|
|
foreach (var valErr in dbentEx.EntityValidationErrors)
|
|
{
|
|
messageBuilder.AppendLine(
|
|
valErr.ValidationErrors.Select(data => data.ErrorMessage)
|
|
.Aggregate((current, next) => current + "; /n" + next));
|
|
}
|
|
}
|
|
FLogger.Global.WriteException(messageBuilder.ToString());
|
|
_slackWriter.Write("Create Crash Exception : " + messageBuilder.ToString());
|
|
throw;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
var messageBuilder = new StringBuilder();
|
|
messageBuilder.AppendLine("Create Crash Exception : ");
|
|
messageBuilder.AppendLine(ex.Message.ToString());
|
|
var innerEx = ex.InnerException;
|
|
while (innerEx != null)
|
|
{
|
|
messageBuilder.AppendLine("Inner Exception : " + innerEx.Message);
|
|
innerEx = innerEx.InnerException;
|
|
}
|
|
|
|
FLogger.Global.WriteException("Create Crash Exception : " +
|
|
messageBuilder.ToString());
|
|
_slackWriter.Write("Create Crash Exception : " + messageBuilder.ToString());
|
|
throw;
|
|
}
|
|
}
|
|
|
|
return newCrash;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Create call stack pattern and either insert into database or match to existing.
|
|
/// Update Associate Buggs.
|
|
/// </summary>
|
|
/// <param name="newCrash"></param>
|
|
private void BuildPattern(Crash newCrash)
|
|
{
|
|
|
|
var callstack = new CallStackContainer(newCrash.CrashType, newCrash.RawCallStack, newCrash.PlatformName);
|
|
newCrash.Module = callstack.GetModuleName();
|
|
newCrash.Module = newCrash.Module.Length >= 127 ? newCrash.Module.Substring(0, 127) : newCrash.Module;
|
|
|
|
if (newCrash.PatternId == null)
|
|
{
|
|
var patternList = new List<string>();
|
|
|
|
try
|
|
{
|
|
using (var unitOfWork = new UnitOfWork(new CrashReportEntities()))
|
|
{
|
|
foreach (var entry in callstack.CallStackEntries.Take(CallStackContainer.MaxLinesToParse))
|
|
{
|
|
var functionCallId = 0;
|
|
|
|
//if this function is already in the database get id
|
|
if (unitOfWork.FunctionRepository.Any(f => f.Call == entry.FunctionName))
|
|
{
|
|
functionCallId =
|
|
unitOfWork.FunctionRepository.FirstId(f => f.Call == entry.FunctionName);
|
|
}
|
|
else
|
|
{
|
|
//else add this function to the db.
|
|
var call = entry.FunctionName;
|
|
if (call.Length > 899)
|
|
call = call.Substring(0, 899);
|
|
var currentFunctionCall = new FunctionCall {Call = call};
|
|
unitOfWork.FunctionRepository.Save(currentFunctionCall);
|
|
unitOfWork.Save();
|
|
functionCallId = currentFunctionCall.Id;
|
|
}
|
|
|
|
patternList.Add(functionCallId.ToString());
|
|
}
|
|
}
|
|
|
|
newCrash.Pattern = string.Join("+", patternList);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
var messageBuilder = new StringBuilder();
|
|
FLogger.Global.WriteException("Build Pattern exception: " +
|
|
ex.Message.ToString(CultureInfo.InvariantCulture));
|
|
messageBuilder.AppendLine("Exception was:");
|
|
messageBuilder.AppendLine(ex.ToString());
|
|
while (ex.InnerException != null)
|
|
{
|
|
ex = ex.InnerException;
|
|
messageBuilder.AppendLine(ex.ToString());
|
|
}
|
|
|
|
_slackWriter.Write("Build Pattern Exception : " + ex.Message.ToString(CultureInfo.InvariantCulture));
|
|
throw;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary></summary>
|
|
/// <param name="disposing"></param>
|
|
protected override void Dispose(bool disposing)
|
|
{
|
|
base.Dispose(disposing);
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public void TestAddCrash()
|
|
{
|
|
using (
|
|
var logTimer = new FAutoScopedLogTimer(this.GetType().ToString() + "()"))
|
|
{
|
|
string CrashContext;
|
|
using (
|
|
var stream =
|
|
new FileStream(
|
|
"D:/CR/Engine/Source/Programs/CrashReporter/CrashReportWebSite/bin/Content/CrashContext.txt",
|
|
FileMode.Open))
|
|
{
|
|
CrashContext = new StreamReader(stream).ReadToEnd();
|
|
}
|
|
|
|
var Crash = XmlHandler.FromXmlString<CrashDescription>(CrashContext);
|
|
|
|
var crash = CreateCrash(Crash);
|
|
|
|
_slackWriter.Write("Test Add Crash completed. Total Time : " + logTimer.GetElapsedSeconds().ToString("F2"));
|
|
|
|
}
|
|
}
|
|
}
|
|
} |