private void OnBuggsAdd(Bugg BuggInstance) { Buggs_Crashes.Add(new Buggs_Crash { Crash = this, Bugg = BuggInstance }); SendPropertyChanged(null); }
private void OnBuggsRemove(Bugg BuggInstance) { var BuggCrash = Buggs_Crashes.FirstOrDefault( c => c.CrashId == Id && c.BuggId == BuggInstance.Id); Buggs_Crashes.Remove(BuggCrash); SendPropertyChanged(null); }
/// <summary> /// Get a Bugg from an id /// </summary> /// <param name="Id">The id of a Bugg.</param> /// <returns>A Bugg representing a group of crashes.</returns> public Bugg GetBugg(int Id) { Bugg Result = null; try { Result = ( from BuggDetail in BuggsDataContext.Buggs where BuggDetail.Id == Id select BuggDetail ).FirstOrDefault(); } catch (Exception Ex) { Debug.WriteLine("Exception in GetBugg: " + Ex.ToString()); } return(Result); }
/// <summary> /// Associate a user with a Bugg. /// </summary> /// <param name="Bugg">The Bugg to associate the user with.</param> /// <param name="UserNameId">The id of a user to associate with the Bugg.</param> /// <returns>true if a new relationship was added, false otherwise.</returns> public bool LinkUserToBugg(Bugg Bugg, int UserNameId) { try { int BuggUserCount = Context.Buggs_Users.Where(BuggUserInstance => BuggUserInstance.BuggId == Bugg.Id && BuggUserInstance.UserNameId == UserNameId).Count(); if (BuggUserCount < 1) { Buggs_User NewBuggsUser = new Buggs_User(); NewBuggsUser.BuggId = Bugg.Id; NewBuggsUser.UserNameId = UserNameId; Context.Buggs_Users.InsertOnSubmit(NewBuggsUser); return(true); } } catch (Exception Ex) { Debug.WriteLine("Exception in LinkCrashToBugg: " + Ex.ToString()); } return(false); }
/// <summary> /// Associate a crash with a Bugg. /// </summary> /// <param name="Bugg">The Bugg to add the crash reference to.</param> /// <param name="CurrentCrash">The crash to add to the Bugg.</param> /// <returns>true if a new relationship was added, false otherwise.</returns> public bool LinkCrashToBugg(Bugg Bugg, Crash CurrentCrash) { try { // Make sure we don't already have this relationship if (Context.Buggs_Crashes.Where(BuggInstance => BuggInstance.CrashId == CurrentCrash.Id && BuggInstance.BuggId == Bugg.Id).Count() < 1) { // We don't so create the relationship Buggs_Crash NewBugg = new Buggs_Crash(); NewBugg.CrashId = CurrentCrash.Id; NewBugg.BuggId = Bugg.Id; Context.Buggs_Crashes.InsertOnSubmit(NewBugg); return(true); } } catch (Exception Ex) { Debug.WriteLine("Exception in LinkCrashToBugg: " + Ex.ToString()); } return(false); }
/// <summary> /// Get a Bugg from an id /// </summary> /// <param name="Id">The id of a Bugg.</param> /// <returns>A Bugg representing a group of crashes.</returns> public Bugg GetBugg(int Id) { using (FAutoScopedLogTimer LogTimer = new FAutoScopedLogTimer(this.GetType().ToString() + "(" + Id + ")")) { Bugg Result = null; try { Result = ( from BuggDetail in Context.Buggs where BuggDetail.Id == Id select BuggDetail ).FirstOrDefault(); } catch (Exception Ex) { Debug.WriteLine("Exception in GetBugg: " + Ex.ToString()); } return(Result); } }
partial void InsertBugg(Bugg instance);
/// <summary> /// Return a view model containing a sorted list of crashes based on the user input. /// </summary> /// <param name="FormData">The user input from the client.</param> /// <returns>A view model to use to display a list of crashes.</returns> /// <remarks>The filtering mechanism works by generating a fluent query to describe the set of crashes we wish to view. Basically, 'Select.Where().Where().Where().Where()' etc. /// The filtering is applied in the following order: /// 1. Get all crashes. /// 2. Filter between the start and end dates. /// 3. Apply the search query. /// 4. Filter by the branch. /// 5. Filter by the game name. /// 6. Filter by the type of reports to view. /// 7. Filter by the user group. /// 8. Sort the results by the sort term. /// 9. Take one page of results.</remarks> public CrashesViewModel GetResults(FormHelper FormData) { using (FAutoScopedLogTimer LogTimer = new FAutoScopedLogTimer(this.GetType().ToString())) { UsersMapping UniqueUser = null; IEnumerable <Crash> Results = null; int Skip = (FormData.Page - 1) * FormData.PageSize; int Take = FormData.PageSize; var ResultsAll = ConstructQueryForFiltering(FormData); // Filter by data and get as enumerable. Results = FilterByDate(ResultsAll, FormData.DateFrom, FormData.DateTo); // Filter by BuggId if (!string.IsNullOrEmpty(FormData.BuggId)) { int BuggId = 0; bool bValid = int.TryParse(FormData.BuggId, out BuggId); if (bValid) { BuggRepository Buggs = new BuggRepository(); Bugg NewBugg = Buggs.GetBugg(BuggId); if (NewBugg != null) { List <Crash> Crashes = NewBugg.GetCrashes(); var NewResult = Results.Intersect(Crashes, new CrashComparer()); Results = NewResult; } } } // Get UserGroup ResultCounts Dictionary <string, int> GroupCounts = GetCountsByGroupFromCrashes(Results); // Filter by user group if present int UserGroupId; if (!string.IsNullOrEmpty(FormData.UserGroup)) { UserGroupId = FRepository.Get(this).FindOrAddGroup(FormData.UserGroup); } else { UserGroupId = 1; } HashSet <int> UserIdsForGroup = FRepository.Get(this).GetUserIdsFromUserGroupId(UserGroupId); using (FScopedLogTimer LogTimer3 = new FScopedLogTimer("CrashRepository.Results.Users")) { List <Crash> NewResults = new List <Crash>(); foreach (Crash Crash in Results) { if (UserIdsForGroup.Contains(Crash.UserNameId.Value)) { NewResults.Add(Crash); } } Results = NewResults; } // Pass in the results and return them sorted properly Results = GetSortedResults(Results, FormData.SortTerm, (FormData.SortOrder == "Descending")); // Get the Count for pagination int ResultCount = 0; using (FScopedLogTimer LogTimer3 = new FScopedLogTimer("CrashRepository.Results.Users")) { ResultCount = Results.Count(); } // Grab just the results we want to display on this page Results = Results.Skip(Skip).Take(Take); using (FScopedLogTimer LogTimer3 = new FScopedLogTimer("CrashRepository.GetResults.GetCallstacks")) { // Process call stack for display foreach (Crash CrashInstance in Results) { // Put callstacks into an list so we can access them line by line in the view CrashInstance.CallStackContainer = GetCallStack(CrashInstance); } } return(new CrashesViewModel { Results = Results, PagingInfo = new PagingInfo { CurrentPage = FormData.Page, PageSize = FormData.PageSize, TotalResults = 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 - CrashesViewModel.Epoch).TotalMilliseconds, DateTo = (long)(FormData.DateTo - CrashesViewModel.Epoch).TotalMilliseconds, BranchName = FormData.BranchName, VersionName = FormData.VersionName, PlatformName = FormData.PlatformName, GameName = FormData.GameName, GroupCounts = GroupCounts, RealUserName = UniqueUser != null?UniqueUser.ToString() : null, }); } }
/// <summary> /// Associate a set of crashes and their owners with a Bugg. /// </summary> /// <param name="Bugg">The Bugg to get the data.</param> /// <param name="Crashes">The set of crashes to add to the Bugg.</param> public void UpdateBuggData( Bugg Bugg, IEnumerable<Crash> Crashes ) { using( FAutoScopedLogTimer LogTimer = new FAutoScopedLogTimer( this.GetType().ToString()+ "(" + Bugg.Id + ")" ) ) { FLogger.WriteEvent( "UpdateBuggData Bugg.Id=" + Bugg.Id ); DateTime? TimeOfFirstCrash = null; DateTime? TimeOfLastCrash = null; string BuildVersion = null; List<int> UserNameIds = new List<int>(); int CrashCount = 0; // Set or return min date max date while we're iterating through the crashes bool bHasChanges = false; try { foreach( Crash CurrentCrash in Crashes ) { CrashCount++; if( TimeOfFirstCrash == null || CurrentCrash.TimeOfCrash < TimeOfFirstCrash ) { TimeOfFirstCrash = CurrentCrash.TimeOfCrash; } if( TimeOfLastCrash == null || CurrentCrash.TimeOfCrash > TimeOfLastCrash ) { TimeOfLastCrash = CurrentCrash.TimeOfCrash; } if( BuildVersion == null || CurrentCrash.BuildVersion.CompareTo( BuildVersion ) > 0 ) { BuildVersion = CurrentCrash.BuildVersion; } // Handle user count if( Bugg.Id != 0 ) { if( !UserNameIds.Contains( CurrentCrash.User.Id ) ) { // Add username to local users variable that we will use later to set user count and associate users and user groups to the bugg. UserNameIds.Add( CurrentCrash.User.Id ); } } CurrentCrash.FixedChangeList = Bugg.FixedChangeList; CurrentCrash.TTPID = Bugg.TTPID; CurrentCrash.Status = Bugg.Status; if( Bugg.Id != 0 ) { bHasChanges |= LinkCrashToBugg( Bugg, CurrentCrash ); } } if( CrashCount > 1 ) { Bugg.TimeOfLastCrash = TimeOfLastCrash; Bugg.TimeOfFirstCrash = TimeOfFirstCrash; Bugg.NumberOfUsers = UserNameIds.Count(); Bugg.NumberOfCrashes = CrashCount; Bugg.BuildVersion = BuildVersion; foreach( int UserNameId in UserNameIds ) { // Link user to Bugg bHasChanges |= LinkUserToBugg( Bugg, UserNameId ); } } if( bHasChanges ) { BuggsDataContext.SubmitChanges(); } } catch( Exception Ex ) { Debug.WriteLine( "Exception in UpdateBuggData: " + Ex.ToString() ); } } }
/// <summary> /// Associate a user with a Bugg. /// </summary> /// <param name="Bugg">The Bugg to associate the user with.</param> /// <param name="UserNameId">The id of a user to associate with the Bugg.</param> /// <returns>true if a new relationship was added, false otherwise.</returns> public bool LinkUserToBugg( Bugg Bugg, int UserNameId ) { try { int BuggUserCount = BuggsDataContext.Buggs_Users.Where( BuggUserInstance => BuggUserInstance.BuggId == Bugg.Id && BuggUserInstance.UserNameId == UserNameId ).Count(); if( BuggUserCount < 1 ) { Buggs_User NewBuggsUser = new Buggs_User(); NewBuggsUser.BuggId = Bugg.Id; NewBuggsUser.UserNameId = UserNameId; BuggsDataContext.Buggs_Users.InsertOnSubmit( NewBuggsUser ); return true; } } catch( Exception Ex ) { Debug.WriteLine( "Exception in LinkCrashToBugg: " + Ex.ToString() ); } return false; }
/// <summary> /// Associate a crash with a Bugg. /// </summary> /// <param name="Bugg">The Bugg to add the crash reference to.</param> /// <param name="CurrentCrash">The crash to add to the Bugg.</param> /// <returns>true if a new relationship was added, false otherwise.</returns> public bool LinkCrashToBugg( Bugg Bugg, Crash CurrentCrash ) { try { // Make sure we don't already have this relationship if( BuggsDataContext.Buggs_Crashes.Where( BuggInstance => BuggInstance.CrashId == CurrentCrash.Id && BuggInstance.BuggId == Bugg.Id ).Count() < 1 ) { // We don't so create the relationship Buggs_Crash NewBugg = new Buggs_Crash(); NewBugg.CrashId = CurrentCrash.Id; NewBugg.BuggId = Bugg.Id; BuggsDataContext.Buggs_Crashes.InsertOnSubmit( NewBugg ); return true; } } catch( Exception Ex ) { Debug.WriteLine( "Exception in LinkCrashToBugg: " + Ex.ToString() ); } return false; }
private void OnBuggsRemove( Bugg BuggInstance ) { var BuggCrash = Buggs_Crashes.FirstOrDefault( c => c.CrashId == Id && c.BuggId == BuggInstance.Id ); Buggs_Crashes.Remove( BuggCrash ); SendPropertyChanged( null ); }
/// <summary> /// Retrieve all Buggs matching the search criteria. /// </summary> /// <param name="FormData">The incoming form of search criteria from the client.</param> /// <param name="BuggIDToBeAddedToJira">ID of the bugg that will be added to JIRA</param> /// <returns>A view to display the filtered Buggs.</returns> public ReportsViewModel GetResults( FormHelper FormData, int BuggIDToBeAddedToJira ) { // @TODO yrx 2015-02-17 BuggIDToBeAddedToJira replace with List<int> based on check box and Submit? // Enumerate JIRA projects if needed. // https://jira.ol.epicgames.net//rest/api/2/project var JC = JiraConnection.Get(); var JiraComponents = JC.GetNameToComponents(); var JiraVersions = JC.GetNameToVersions(); using( FAutoScopedLogTimer LogTimer = new FAutoScopedLogTimer( this.GetType().ToString() ) ) { string AnonumousGroup = "Anonymous"; List<String> Users = CrashRepository.GetUsersForGroup( AnonumousGroup ); int AnonymousGroupID = BuggRepository.GetIdFromUserGroup( AnonumousGroup ); HashSet<int> AnonumousIDs = BuggRepository.GetUserIdsFromUserGroup( AnonumousGroup ); int AnonymousID = AnonumousIDs.First(); HashSet<string> UserNamesForUserGroup = BuggRepository.GetUserNamesFromUserGroups( AnonumousGroup ); //FormData.DateFrom = DateTime.Now.AddDays( -1 ); var Crashes = CrashRepository .FilterByDate( CrashRepository.ListAll(), FormData.DateFrom, FormData.DateTo.AddDays( 1 ) ) // Only crashes and asserts .Where( Crash => Crash.CrashType == 1 || Crash.CrashType == 2 ) // Only anonymous user .Where( Crash => Crash.UserNameId.Value == AnonymousID ) .Select( Crash => new { ID = Crash.Id, TimeOfCrash = Crash.TimeOfCrash.Value, //UserID = Crash.UserNameId.Value, BuildVersion = Crash.BuildVersion, JIRA = Crash.TTPID, Platform = Crash.PlatformName, FixCL = Crash.FixedChangeList, BuiltFromCL = Crash.ChangeListVersion, Pattern = Crash.Pattern, MachineID = Crash.ComputerName, Branch = Crash.Branch, } ) .ToList(); int NumCrashes = Crashes.Count; /* // Build patterns for crashes where patters is null. var CrashesWithoutPattern = CrashRepository .FilterByDate( CrashRepository.ListAll(), FormData.DateFrom, FormData.DateTo.AddDays( 1 ) ) // Only crashes and asserts .Where( Crash => Crash.Pattern == null || Crash.Pattern == "" ) .Select( Crash => Crash ) .ToList(); foreach( var Crash in CrashesWithoutPattern ) { ////BuildPattern( Crash ); } */ // Total # of ALL (Anonymous) crashes in timeframe int TotalAnonymousCrashes = NumCrashes; // Total # of UNIQUE (Anonymous) crashes in timeframe HashSet<string> UniquePatterns = new HashSet<string>(); HashSet<string> UniqueMachines = new HashSet<string>(); Dictionary<string, int> PatternToCount = new Dictionary<string, int>(); //List<int> CrashesWithoutPattern = new List<int>(); //List<DateTime> CrashesWithoutPatternDT = new List<DateTime>(); foreach( var Crash in Crashes ) { if( string.IsNullOrEmpty( Crash.Pattern ) ) { //CrashesWithoutPattern.Add( Crash.ID ); //CrashesWithoutPatternDT.Add( Crash.TimeOfCrash ); continue; } UniquePatterns.Add( Crash.Pattern ); UniqueMachines.Add( Crash.MachineID ); bool bAdd = !PatternToCount.ContainsKey( Crash.Pattern ); if( bAdd ) { PatternToCount.Add( Crash.Pattern, 1 ); } else { PatternToCount[Crash.Pattern]++; } } var PatternToCountOrdered = PatternToCount.OrderByDescending( X => X.Value ).ToList(); // The 100 top. var PatternAndCount = PatternToCountOrdered.Take( 100 ).ToDictionary( X => X.Key, Y => Y.Value ); int TotalUniqueAnonymousCrashes = UniquePatterns.Count; // Total # of AFFECTED USERS (Anonymous) in timeframe int TotalAffectedUsers = UniqueMachines.Count; var RealBuggs = BuggRepository.GetDataContext().Buggs.Where( Bugg => PatternAndCount.Keys.Contains( Bugg.Pattern ) ).ToList(); // Build search string. List<string> FoundJiras = new List<string>(); Dictionary<string, List<Bugg>> JiraIDtoBugg = new Dictionary<string, List<Bugg>>(); List<Bugg> Buggs = new List<Bugg>( 100 ); foreach( var Top in PatternAndCount ) { Bugg NewBugg = new Bugg(); Bugg RealBugg = RealBuggs.Where( X => X.Pattern == Top.Key ).FirstOrDefault(); if( RealBugg != null ) { using( FAutoScopedLogTimer TopTimer = new FAutoScopedLogTimer( string.Format("{0}:{1}", Buggs.Count+1, RealBugg.Id ) ) ) { // Index // number NewBugg.Id = RealBugg.Id; // CrashGroup URL (a link to the Bugg) NewBugg.TTPID = RealBugg.TTPID; // JIRA NewBugg.FixedChangeList = RealBugg.FixedChangeList; // FixCL NewBugg.NumberOfCrashes = Top.Value; // # Occurrences NewBugg.Pattern = RealBugg.Pattern; // # Occurrences //NewBugg.BuildVersion = var CrashesForBugg = Crashes.Where( Crash => Crash.Pattern == Top.Key ).ToList(); NewBugg.AffectedVersions = new SortedSet<string>(); NewBugg.AffectedMajorVersions = new SortedSet<string>(); // 4.4, 4.5 and so NewBugg.BranchesFoundIn = new SortedSet<string>(); NewBugg.AffectedPlatforms = new SortedSet<string>(); HashSet<string> MachineIds = new HashSet<string>(); int FirstCLAffected = int.MaxValue; foreach( var Crash in CrashesForBugg ) { // Only add machine if the number has 32 characters if( Crash.MachineID != null && Crash.MachineID.Length == 32 ) { MachineIds.Add( Crash.MachineID ); } // Ignore bad build versions. // @TODO yrx 2015-02-17 What about launcher? if( Crash.BuildVersion.StartsWith( "4." ) ) { if( !string.IsNullOrEmpty(Crash.BuildVersion) ) { NewBugg.AffectedVersions.Add( Crash.BuildVersion ); } if( !string.IsNullOrEmpty( Crash.Branch ) && Crash.Branch.StartsWith( "UE4" ) ) { NewBugg.BranchesFoundIn.Add( Crash.Branch ); } int CrashBuiltFromCL = 0; int.TryParse( Crash.BuiltFromCL, out CrashBuiltFromCL ); if( CrashBuiltFromCL > 0 ) { FirstCLAffected = Math.Min( FirstCLAffected, CrashBuiltFromCL ); } if( !string.IsNullOrEmpty( Crash.Platform ) ) { // Platform = "Platform [Desc]"; var PlatSubs = Crash.Platform.Split( " ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries ); if( PlatSubs.Length >= 1 ) { NewBugg.AffectedPlatforms.Add( PlatSubs[0] ); } } } } // CopyToJira NewBugg.ToJiraFirstCLAffected = FirstCLAffected; if( NewBugg.AffectedVersions.Count > 0 ) { NewBugg.BuildVersion = NewBugg.AffectedVersions.Last(); // Latest Version Affected } foreach( var AffectedBuild in NewBugg.AffectedVersions ) { var Subs = AffectedBuild.Split( ".".ToCharArray(), StringSplitOptions.RemoveEmptyEntries ); if( Subs.Length >= 2 ) { string MajorVersion = Subs[0] + "." + Subs[1]; NewBugg.AffectedMajorVersions.Add( MajorVersion ); } } NewBugg.NumberOfUniqueMachines = MachineIds.Count; // # Affected Users string LatestCLAffected = CrashesForBugg. // CL of the latest build Where( Crash => Crash.BuildVersion == NewBugg.BuildVersion ). Max( Crash => Crash.BuiltFromCL ); int ILatestCLAffected = -1; int.TryParse( LatestCLAffected, out ILatestCLAffected ); NewBugg.LatestCLAffected = ILatestCLAffected; // Latest CL Affected string LatestOSAffected = CrashesForBugg.OrderByDescending( Crash => Crash.TimeOfCrash ).First().Platform; NewBugg.LatestOSAffected = LatestOSAffected; // Latest Environment Affected NewBugg.TimeOfFirstCrash = RealBugg.TimeOfFirstCrash; // First Crash Timestamp // ToJiraSummary var Callstack = RealBugg.GetFunctionCalls(); NewBugg.ToJiraSummary = Callstack.Count > 1 ? Callstack[0] : "No valid callstack found"; // ToJiraVersions NewBugg.ToJiraVersions = new List<object>(); foreach( var Version in NewBugg.AffectedMajorVersions ) { bool bValid = JC.GetNameToVersions().ContainsKey( Version ); if( bValid ) { NewBugg.ToJiraVersions.Add( JC.GetNameToVersions()[Version] ); } } // ToJiraBranches NewBugg.ToJiraBranches = new List<object>(); foreach( var Platform in NewBugg.BranchesFoundIn ) { string CleanedBranch = Platform.Contains( "UE4-Releases" ) ? "UE4-Releases" : Platform; Dictionary<string, object> JiraBranch = null; JC.GetNameToBranchFoundIn().TryGetValue( CleanedBranch, out JiraBranch ); if( JiraBranch != null && !NewBugg.ToJiraBranches.Contains( JiraBranch ) ) { NewBugg.ToJiraBranches.Add( JiraBranch ); } } // ToJiraPlatforms NewBugg.ToJiraPlatforms = new List<object>(); foreach( var Platform in NewBugg.AffectedPlatforms ) { bool bValid = JC.GetNameToPlatform().ContainsKey( Platform ); if( bValid ) { NewBugg.ToJiraPlatforms.Add( JC.GetNameToPlatform()[Platform] ); } } // Verify valid JiraID, this may be still a TTP if( !string.IsNullOrEmpty( NewBugg.TTPID ) ) { int TTPID = 0; int.TryParse( NewBugg.TTPID, out TTPID ); if( TTPID == 0 ) { AddBuggJiraMapping(NewBugg, ref FoundJiras, ref JiraIDtoBugg); } } Buggs.Add( NewBugg ); } } else { FLogger.WriteEvent( "Bugg for pattern " + Top.Key + " not found" ); } } if( BuggIDToBeAddedToJira > 0 ) { var Bugg = Buggs.Where( X => X.Id == BuggIDToBeAddedToJira ).FirstOrDefault(); if( Bugg != null ) { Bugg.CopyToJira(); AddBuggJiraMapping( Bugg, ref FoundJiras, ref JiraIDtoBugg ); } } if( JC.CanBeUsed() ) { // Grab the data form JIRA. string JiraSearchQuery = string.Join( " OR ", FoundJiras ); using( FAutoScopedLogTimer JiraResultsTimer = new FAutoScopedLogTimer( "JiraResults" ) ) { var JiraResults = JC.SearchJiraTickets( JiraSearchQuery, new string[] { "key", // string "summary", // string "components", // System.Collections.ArrayList, Dictionary<string,object>, name "resolution", // System.Collections.Generic.Dictionary`2[System.String,System.Object], name "fixVersions", // System.Collections.ArrayList, Dictionary<string,object>, name "customfield_11200" // string } ); // Jira Key, Summary, Components, Resolution, Fix version, Fix changelist foreach( var Jira in JiraResults ) { string JiraID = Jira.Key; string Summary = (string)Jira.Value["summary"]; string ComponentsText = ""; System.Collections.ArrayList Components = (System.Collections.ArrayList)Jira.Value["components"]; foreach( Dictionary<string, object> Component in Components ) { ComponentsText += (string)Component["name"]; ComponentsText += " "; } Dictionary<string, object> ResolutionFields = (Dictionary<string, object>)Jira.Value["resolution"]; string Resolution = ResolutionFields != null ? (string)ResolutionFields["name"] : ""; string FixVersionsText = ""; System.Collections.ArrayList FixVersions = (System.Collections.ArrayList)Jira.Value["fixVersions"]; foreach( Dictionary<string, object> FixVersion in FixVersions ) { FixVersionsText += (string)FixVersion["name"]; FixVersionsText += " "; } int FixCL = Jira.Value["customfield_11200"] != null ? (int)(decimal)Jira.Value["customfield_11200"] : 0; var BuggsForJira = JiraIDtoBugg[JiraID]; foreach( Bugg Bugg in BuggsForJira ) { Bugg.JiraSummary = Summary; Bugg.JiraComponentsText = ComponentsText; Bugg.JiraResolution = Resolution; Bugg.JiraFixVersionsText = FixVersionsText; if( FixCL != 0 ) { Bugg.JiraFixCL = FixCL.ToString(); } } } } } return new ReportsViewModel { Buggs = Buggs, /*Crashes = Crashes,*/ DateFrom = (long)( FormData.DateFrom - CrashesViewModel.Epoch ).TotalMilliseconds, DateTo = (long)( FormData.DateTo - CrashesViewModel.Epoch ).TotalMilliseconds, TotalAffectedUsers = TotalAffectedUsers, TotalAnonymousCrashes = TotalAnonymousCrashes, TotalUniqueAnonymousCrashes = TotalUniqueAnonymousCrashes }; } }
/// <summary> /// The Show action. /// </summary> /// <param name="BuggsForm">The form of user data passed up from the client.</param> /// <param name="id">The unique id of the Bugg.</param> /// <returns>The view to display a Bugg on the client.</returns> public ActionResult Show( FormCollection BuggsForm, int id ) { using( FAutoScopedLogTimer LogTimer = new FAutoScopedLogTimer( this.GetType().ToString() + "(BuggId=" + id + ")" ) ) { // Set the display properties based on the radio buttons bool DisplayModuleNames = false; if( BuggsForm["DisplayModuleNames"] == "true" ) { DisplayModuleNames = true; } bool DisplayFunctionNames = false; if( BuggsForm["DisplayFunctionNames"] == "true" ) { DisplayFunctionNames = true; } bool DisplayFileNames = false; if( BuggsForm["DisplayFileNames"] == "true" ) { DisplayFileNames = true; } bool DisplayFilePathNames = false; if( BuggsForm["DisplayFilePathNames"] == "true" ) { DisplayFilePathNames = true; DisplayFileNames = false; } bool DisplayUnformattedCallStack = false; if( BuggsForm["DisplayUnformattedCallStack"] == "true" ) { DisplayUnformattedCallStack = true; } // Create a new view and populate with crashes List<Crash> Crashes = null; Bugg Bugg = new Bugg(); BuggViewModel Model = new BuggViewModel(); Bugg = LocalBuggRepository.GetBugg( id ); if( Bugg == null ) { return RedirectToAction( "" ); } // @TODO yrx 2015-02-17 JIRA using( FAutoScopedLogTimer GetCrashesTimer = new FAutoScopedLogTimer( "Bugg.GetCrashes().ToList" ) ) { Crashes = Bugg.GetCrashes(); Bugg.AffectedVersions = new SortedSet<string>(); HashSet<string> MachineIds = new HashSet<string>(); foreach( Crash Crash in Crashes ) { MachineIds.Add( Crash.ComputerName ); // Ignore bad build versions. if( Crash.BuildVersion.StartsWith( "4." ) ) { Bugg.AffectedVersions.Add( Crash.BuildVersion ); } if( Crash.User == null ) { //?? } } Bugg.NumberOfUniqueMachines = MachineIds.Count; } // Apply any user settings if( BuggsForm.Count > 0 ) { if( !string.IsNullOrEmpty( BuggsForm["SetStatus"] ) ) { Bugg.Status = BuggsForm["SetStatus"]; LocalCrashRepository.SetBuggStatus( Bugg.Status, id ); } if( !string.IsNullOrEmpty( BuggsForm["SetFixedIn"] ) ) { Bugg.FixedChangeList = BuggsForm["SetFixedIn"]; LocalCrashRepository.SetBuggFixedChangeList( Bugg.FixedChangeList, id ); } if( !string.IsNullOrEmpty( BuggsForm["SetTTP"] ) ) { Bugg.TTPID = BuggsForm["SetTTP"]; BuggRepository.SetJIRAForBuggAndCrashes( Bugg.TTPID, id ); } if( !string.IsNullOrEmpty( BuggsForm["Description"] ) ) { Bugg.Description = BuggsForm["Description"]; } // <STATUS> } // Set up the view model with the crash data Model.Bugg = Bugg; Model.Crashes = Crashes; Crash NewCrash = Model.Crashes.FirstOrDefault(); if( NewCrash != null ) { using( FScopedLogTimer LogTimer2 = new FScopedLogTimer( "CallstackTrimming" ) ) { CallStackContainer CallStack = new CallStackContainer( NewCrash ); // Set callstack properties CallStack.bDisplayModuleNames = DisplayModuleNames; CallStack.bDisplayFunctionNames = DisplayFunctionNames; CallStack.bDisplayFileNames = DisplayFileNames; CallStack.bDisplayFilePathNames = DisplayFilePathNames; CallStack.bDisplayUnformattedCallStack = DisplayUnformattedCallStack; Model.CallStack = CallStack; // Shorten very long function names. foreach( CallStackEntry Entry in Model.CallStack.CallStackEntries ) { Entry.FunctionName = Entry.GetTrimmedFunctionName( 128 ); } Model.SourceContext = NewCrash.SourceContext; } } /*using( FScopedLogTimer LogTimer2 = new FScopedLogTimer( "BuggsController.Show.PopulateUserInfo" + "(id=" + id + ")" ) ) { // Add in the users for each crash in the Bugg foreach( Crash CrashInstance in Model.Crashes ) { LocalCrashRepository.PopulateUserInfo( CrashInstance ); } }*/ return View( "Show", Model ); } }
private void AddBuggJiraMapping( Bugg NewBugg, ref HashSet<string> FoundJiras, ref Dictionary<string, List<Bugg>> JiraIDtoBugg ) { string JiraID = NewBugg.Jira; FoundJiras.Add( "key = " + JiraID ); bool bAdd = !JiraIDtoBugg.ContainsKey( JiraID ); if( bAdd ) { JiraIDtoBugg.Add( JiraID, new List<Bugg>() ); } JiraIDtoBugg[JiraID].Add( NewBugg ); }
/// <summary> /// The Show action. /// </summary> /// <param name="BuggsForm">The form of user data passed up from the client.</param> /// <param name="id">The unique id of the Bugg.</param> /// <returns>The view to display a Bugg on the client.</returns> public ActionResult Show( FormCollection BuggsForm, int id ) { // Set the display properties based on the radio buttons bool DisplayModuleNames = false; if( BuggsForm["DisplayModuleNames"] == "true" ) { DisplayModuleNames = true; } bool DisplayFunctionNames = false; if( BuggsForm["DisplayFunctionNames"] == "true" ) { DisplayFunctionNames = true; } bool DisplayFileNames = false; if( BuggsForm["DisplayFileNames"] == "true" ) { DisplayFileNames = true; } bool DisplayFilePathNames = false; if( BuggsForm["DisplayFilePathNames"] == "true" ) { DisplayFilePathNames = true; DisplayFileNames = false; } bool DisplayUnformattedCallStack = false; if( BuggsForm["DisplayUnformattedCallStack"] == "true" ) { DisplayUnformattedCallStack = true; } // Create a new view and populate with crashes List<Crash> Crashes = null; Bugg Bugg = new Bugg(); BuggViewModel Model = new BuggViewModel(); Bugg = LocalBuggRepository.GetBugg( id ); if( Bugg == null ) { return RedirectToAction( "" ); } Crashes = Bugg.GetCrashes().ToList(); // Apply any user settings if( BuggsForm.Count > 0 ) { if( !string.IsNullOrEmpty( BuggsForm["SetStatus"] ) ) { Bugg.Status = BuggsForm["SetStatus"]; LocalCrashRepository.SetBuggStatus( Bugg.Status, id ); } if( !string.IsNullOrEmpty( BuggsForm["SetFixedIn"] ) ) { Bugg.FixedChangeList = BuggsForm["SetFixedIn"]; LocalCrashRepository.SetBuggFixedChangeList( Bugg.FixedChangeList, id ); } if( !string.IsNullOrEmpty( BuggsForm["SetTTP"] ) ) { Bugg.TTPID = BuggsForm["SetTTP"]; LocalCrashRepository.SetBuggTTPID( Bugg.TTPID, id ); } if( !string.IsNullOrEmpty( BuggsForm["Description"] ) ) { Bugg.Description = BuggsForm["Description"]; } } // Set up the view model with the crash data Model.Bugg = Bugg; Model.Crashes = Crashes; Crash NewCrash = Model.Crashes.FirstOrDefault(); if( NewCrash != null ) { CallStackContainer CallStack = new CallStackContainer( NewCrash ); // Set callstack properties CallStack.bDisplayModuleNames = DisplayModuleNames; CallStack.bDisplayFunctionNames = DisplayFunctionNames; CallStack.bDisplayFileNames = DisplayFileNames; CallStack.bDisplayFilePathNames = DisplayFilePathNames; CallStack.bDisplayUnformattedCallStack = DisplayUnformattedCallStack; Model.CallStack = CallStack; NewCrash.CallStackContainer = NewCrash.GetCallStack(); } // Add in the users for each crash in the Bugg foreach( Crash CrashInstance in Model.Crashes ) { LocalCrashRepository.PopulateUserInfo( CrashInstance ); } return View( "Show", Model ); }
partial void UpdateBugg(Bugg instance);
private void OnBuggsAdd( Bugg BuggInstance ) { Buggs_Crashes.Add( new Buggs_Crash { Crash = this, Bugg = BuggInstance } ); SendPropertyChanged( null ); }
partial void DeleteBugg(Bugg instance);
/// <summary> /// Associate a set of crashes and their owners with a Bugg. /// NOT USED, FIX! /// </summary> /// <param name="Bugg">The Bugg to get the data.</param> /// <param name="Crashes">The set of crashes to add to the Bugg.</param> public void UpdateBuggData(Bugg Bugg, IEnumerable <Crash> Crashes) { using (FAutoScopedLogTimer LogTimer = new FAutoScopedLogTimer(this.GetType().ToString() + "(" + Bugg.Id + ")")) { FLogger.WriteEvent("UpdateBuggData Bugg.Id=" + Bugg.Id); DateTime? TimeOfFirstCrash = null; DateTime? TimeOfLastCrash = null; string BuildVersion = null; List <int> UserNameIds = new List <int>(); int CrashCount = 0; // Set or return min date max date while we're iterating through the crashes bool bHasChanges = false; try { foreach (Crash CurrentCrash in Crashes) { CrashCount++; if (TimeOfFirstCrash == null || CurrentCrash.TimeOfCrash < TimeOfFirstCrash) { TimeOfFirstCrash = CurrentCrash.TimeOfCrash; } if (TimeOfLastCrash == null || CurrentCrash.TimeOfCrash > TimeOfLastCrash) { TimeOfLastCrash = CurrentCrash.TimeOfCrash; } if (BuildVersion == null || CurrentCrash.BuildVersion.CompareTo(BuildVersion) > 0) { BuildVersion = CurrentCrash.BuildVersion; } // Handle user count if (Bugg.Id != 0) { if (!UserNameIds.Contains(CurrentCrash.User.Id)) { // Add username to local users variable that we will use later to set user count and associate users and user groups to the bugg. UserNameIds.Add(CurrentCrash.User.Id); } } CurrentCrash.FixedChangeList = Bugg.FixedChangeList; CurrentCrash.TTPID = Bugg.TTPID; CurrentCrash.Status = Bugg.Status; if (Bugg.Id != 0) { bHasChanges |= LinkCrashToBugg(Bugg, CurrentCrash); } } if (CrashCount > 1) { Bugg.TimeOfLastCrash = TimeOfLastCrash; Bugg.TimeOfFirstCrash = TimeOfFirstCrash; Bugg.NumberOfUsers = UserNameIds.Count(); Bugg.NumberOfCrashes = CrashCount; Bugg.BuildVersion = BuildVersion; foreach (int UserNameId in UserNameIds) { // Link user to Bugg bHasChanges |= LinkUserToBugg(Bugg, UserNameId); } } if (bHasChanges) { Context.SubmitChanges(); } } catch (Exception Ex) { Debug.WriteLine("Exception in UpdateBuggData: " + Ex.ToString()); } } }