/// <summary>
        /// Add a new crash to the db based on a CrashDescription sent from the client.
        /// </summary>
        /// <param name="NewCrashInfo">The crash description sent from the client.</param>
        /// <returns>The id of the newly added crash.</returns>
        public int AddNewCrash(CrashDescription NewCrashInfo)
        {
            int NewID = -1;

            Crash NewCrash = new Crash();

            NewCrash.Branch       = NewCrashInfo.BranchName;
            NewCrash.BaseDir      = NewCrashInfo.BaseDir;
            NewCrash.BuildVersion = NewCrashInfo.BuildVersion;
            NewCrash.BuiltFromCL  = NewCrashInfo.BuiltFromCL.ToString();
            NewCrash.CommandLine  = NewCrashInfo.CommandLine;
            NewCrash.EngineMode   = NewCrashInfo.EngineMode;
            NewCrash.MachineId    = NewCrashInfo.MachineGuid;

            //if there's a valid username assign the associated UserNameId else use "anonymous"
            NewCrash.UserNameId = FRepository.Get(this).FindOrAddUser(!string.IsNullOrEmpty(NewCrashInfo.UserName) ? NewCrashInfo.UserName : UserNameAnonymous);

            //If there's a valid EpicAccountId assign that.
            if (!string.IsNullOrEmpty(NewCrashInfo.EpicAccountId))
            {
                NewCrash.EpicAccountId = NewCrashInfo.EpicAccountId;
            }

            NewCrash.Description = "";
            if (NewCrashInfo.UserDescription != null)
            {
                NewCrash.Description = string.Join(Environment.NewLine, NewCrashInfo.UserDescription);
            }

            NewCrash.EngineMode   = NewCrashInfo.EngineMode;
            NewCrash.GameName     = NewCrashInfo.GameName;
            NewCrash.LanguageExt  = NewCrashInfo.Language;            // Converted by the crash process.
            NewCrash.PlatformName = NewCrashInfo.Platform;

            if (NewCrashInfo.ErrorMessage != null)
            {
                NewCrash.Summary = string.Join("\n", NewCrashInfo.ErrorMessage);
            }

            if (NewCrashInfo.CallStack != null)
            {
                NewCrash.RawCallStack = string.Join("\n", NewCrashInfo.CallStack);
            }

            if (NewCrashInfo.SourceContext != null)
            {
                NewCrash.SourceContext = string.Join("\n", NewCrashInfo.SourceContext);
            }

            NewCrash.TimeOfCrash         = NewCrashInfo.TimeofCrash;
            NewCrash.bAllowToBeContacted = NewCrashInfo.bAllowToBeContacted;

            NewCrash.Jira            = "";
            NewCrash.FixedChangeList = "";

            // Set the crash type
            NewCrash.CrashType = 1;
            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";

            /*
             *      Unused Crashes' fields.
             *
             *      Title				nchar(20)
             *      Selected			bit
             *      Version				int
             *      AutoReporterID		int
             *      Processed			bit	-> renamed to AllowToBeContacted
             *      HasDiagnosticsFile	bit	always true
             *      HasNewLogFile		bit
             *      HasMetaData			bit	always true
             */
            // Set the unused fields to the default values.
            //NewCrash.Title = "";			removed from dbml
            //NewCrash.Selected = false;	removed from dbml
            //NewCrash.Version = 4;			removed from dbml
            //NewCrash.AutoReporterID = 0;	removed from dbml
            //NewCrash.HasNewLogFile = false;removed from dbml
            //
            //NewCrash.HasDiagnosticsFile = true;
            //NewCrash.HasMetaData = true;

            NewCrash.UserActivityHint = NewCrashInfo.UserActivityHint;

            // Add the crash to the database
            Context.Crashes.InsertOnSubmit(NewCrash);
            SubmitChanges();

            NewID = NewCrash.Id;

            // Build a callstack pattern for crash bucketing
            NewCrash.BuildPattern(Context);

            return(NewID);
        }
Example #2
0
        /// <summary>
        /// Add a new crash to the db based on a CrashDescription sent from the client.
        /// </summary>
        /// <param name="NewCrashInfo">The crash description sent from the client.</param>
        /// <returns>The id of the newly added crash.</returns>
        public int AddNewCrash(CrashDescription NewCrashInfo)
        {
            int NewID = -1;

            Crash NewCrash = new Crash();

            NewCrash.Branch            = NewCrashInfo.BranchName;
            NewCrash.BaseDir           = NewCrashInfo.BaseDir;
            NewCrash.BuildVersion      = NewCrashInfo.BuildVersion;
            NewCrash.ChangeListVersion = NewCrashInfo.BuiltFromCL.ToString();
            NewCrash.CommandLine       = NewCrashInfo.CommandLine;
            NewCrash.EngineMode        = NewCrashInfo.EngineMode;
            NewCrash.ComputerName      = NewCrashInfo.MachineGuid;

            // Valid MachineID and UserName, updated crash from non-UE4 release
            if (!string.IsNullOrEmpty(NewCrashInfo.UserName))
            {
                NewCrash.UserNameId = FRepository.Get(this).FindOrAddUser(NewCrashInfo.UserName);
            }
            // Valid MachineID and EpicAccountId, updated crash from UE4 release
            else if (!string.IsNullOrEmpty(NewCrashInfo.EpicAccountId))
            {
                NewCrash.EpicAccountId = NewCrashInfo.EpicAccountId;
                NewCrash.UserNameId    = FRepository.Get(this).FindOrAddUser(UserNameAnonymous);
            }
            // Crash from an older version.
            else
            {
                // MachineGuid for older crashes is obsolete, so ignore it.
                //NewCrash.ComputerName = NewCrashInfo.MachineGuid;
                NewCrash.UserNameId = FRepository.Get(this).FindOrAddUser
                                      (
                    !string.IsNullOrEmpty(NewCrashInfo.UserName) ? NewCrashInfo.UserName : UserNameAnonymous
                                      );
            }

            NewCrash.Description = "";
            if (NewCrashInfo.UserDescription != null)
            {
                NewCrash.Description = string.Join(Environment.NewLine, NewCrashInfo.UserDescription);
            }

            NewCrash.EngineMode   = NewCrashInfo.EngineMode;
            NewCrash.GameName     = NewCrashInfo.GameName;
            NewCrash.LanguageExt  = NewCrashInfo.Language;            // Converted by the crash process.
            NewCrash.PlatformName = NewCrashInfo.Platform;

            if (NewCrashInfo.ErrorMessage != null)
            {
                NewCrash.Summary = string.Join("\n", NewCrashInfo.ErrorMessage);
            }

            if (NewCrashInfo.CallStack != null)
            {
                NewCrash.RawCallStack = string.Join("\n", NewCrashInfo.CallStack);
            }

            if (NewCrashInfo.SourceContext != null)
            {
                NewCrash.SourceContext = string.Join("\n", NewCrashInfo.SourceContext);
            }

            NewCrash.TimeOfCrash = NewCrashInfo.TimeofCrash;

            NewCrash.HasLogFile         = NewCrashInfo.bHasLog;
            NewCrash.HasMiniDumpFile    = NewCrashInfo.bHasMiniDump;
            NewCrash.HasDiagnosticsFile = NewCrashInfo.bHasDiags;
            NewCrash.HasVideoFile       = NewCrashInfo.bHasVideo;
            NewCrash.HasMetaData        = NewCrashInfo.bHasWERData;

            NewCrash.bAllowToBeContacted = NewCrashInfo.bAllowToBeContacted;

            NewCrash.TTPID           = "";
            NewCrash.FixedChangeList = "";

            // Set the crash type
            NewCrash.CrashType = 1;
            if (NewCrash.RawCallStack != null)
            {
                if (NewCrash.RawCallStack.Contains("FDebug::AssertFailed()"))
                {
                    NewCrash.CrashType = 2;
                }
                else if (NewCrash.RawCallStack.Contains("FDebug::EnsureFailed()"))
                {
                    NewCrash.CrashType = 3;
                }
            }

            // As we're adding it, the status is always new
            NewCrash.Status = "New";

            /*
             *      Unused Crashes' fields.
             *
             *      Title				nchar(20)
             *      Selected			bit
             *      Version				int
             *      AutoReporterID		int
             *      Processed			bit	-> renamed to AllowToBeContacted
             *      HasDiagnosticsFile	bit	always true
             *      HasNewLogFile		bit
             *      HasMetaData			bit	always true
             */
            // Set the unused fields to the default values.
            //NewCrash.Title = "";			removed from dbml
            //NewCrash.Selected = false;	removed from dbml
            //NewCrash.Version = 4;			removed from dbml
            //NewCrash.AutoReporterID = 0;	removed from dbml
            //NewCrash.HasNewLogFile = false;removed from dbml
            //
            //NewCrash.HasDiagnosticsFile = true;
            //NewCrash.HasMetaData = true;

            // Add the crash to the database
            Context.Crashes.InsertOnSubmit(NewCrash);
            SubmitChanges();

            NewID = NewCrash.Id;

            // Build a callstack pattern for crash bucketing
            NewCrash.BuildPattern(Context);

            return(NewID);
        }