Beispiel #1
0
        /// <summary>
        /// Return the top lines of a callstack.
        /// </summary>
        /// <returns>A list of callstack entries.</returns>
        public List <string> GetFunctionCalls()
        {
            using (FAutoScopedLogTimer LogTimer = new FAutoScopedLogTimer(this.GetType().ToString() + "(Id=" + this.Id + ")"))
            {
                if (GenericFunctionCalls == null)
                {
                    CrashRepository CrashRepo = new CrashRepository();

                    var Crash =
                        (
                            from BuggCrash in CrashRepo.Context.Buggs_Crashes
                            where BuggCrash.BuggId == Id
                            select BuggCrash.Crash
                        ).FirstOrDefault();

                    if (Crash != null)
                    {
                        GenericFunctionCalls = Crash.GetCallStack().GetFunctionCalls();
                    }
                    else
                    {
                        GenericFunctionCalls = new List <string>();
                    }
                }
                return(GenericFunctionCalls);
            }
        }
Beispiel #2
0
 /// <summary>
 /// Accesses the instance.
 /// </summary>
 public static FRepository Get(CrashRepository Crashes)
 {
     return(new FRepository()
     {
         _Crashes = Crashes
     });
 }
Beispiel #3
0
 /// <summary>
 /// Accesses the instance.
 /// </summary>
 public static FRepository Get(CrashRepository Crashes, BuggRepository Buggs)
 {
     return(new FRepository()
     {
         _Crashes = Crashes, _Buggs = Buggs
     });
 }
Beispiel #4
0
        public CrashesViewModel()
        {
            DateTime FromDate = DateTime.Today.AddDays(-7);
            DateTime ToDate   = DateTime.Today;

            BranchNames = CrashRepository.GetBranches();
            DateTo      = (long)(ToDate - Epoch).TotalMilliseconds;
            DateFrom    = (long)(FromDate - Epoch).TotalMilliseconds;
        }
Beispiel #5
0
        /// <summary>
        /// Default constructor, used by HomeController
        /// </summary>
        public CrashesViewModel()
        {
            DateTime FromDate = DateTime.Today.AddDays(-7).ToUniversalTime();
            DateTime ToDate   = DateTime.Today.ToUniversalTime();

            BranchNames  = CrashRepository.GetBranches();
            VersionNames = CrashRepository.GetVersions();
            DateFrom     = (long)(FromDate - Epoch).TotalMilliseconds;
            DateTo       = (long)(ToDate - Epoch).TotalMilliseconds;
            CrashType    = "CrashesAsserts";
        }
Beispiel #6
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public List <Crash> GetCrashes()
        {
            CrashRepository CrashRepo = new CrashRepository();
            var             CrashList =
                (
                    from BuggCrash in CrashRepo.Context.Buggs_Crashes
                    where BuggCrash.BuggId == Id
                    select BuggCrash.Crash
                ).AsEnumerable().ToList();

            return(CrashList);
        }
Beispiel #7
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public List <Crash> GetCrashes()
 {
     using (FAutoScopedLogTimer LogTimer = new FAutoScopedLogTimer(this.GetType().ToString()))
     {
         CrashRepository CrashRepo = new CrashRepository();
         var             CrashList =
             (
                 from BuggCrash in CrashRepo.Context.Buggs_Crashes
                 where BuggCrash.BuggId == Id && BuggCrash.Crash.TimeOfCrash > DateTime.UtcNow.AddMonths(-6)
                 select BuggCrash.Crash
             ).OrderByDescending(c => c.TimeOfCrash).ToList();
         return(CrashList);
     }
 }
 /// <summary>
 /// Link the Http context cache to a crash repository.
 /// </summary>
 /// <param name="InCache">The current Http context cache.</param>
 /// <param name="InCrashRepository">The repository to associate the cache with.</param>
 public CachedDataService(Cache InCache, CrashRepository InCrashRepository)
 {
     CacheInstance        = InCache;
     LocalCrashRepository = InCrashRepository;
 }
Beispiel #9
0
        /// <summary>
        /// Gets a formatted callstack for the crash.
        /// </summary>
        /// <returns>A formatted callstack.</returns>
        public CallStackContainer GetCallStack()
        {
            CrashRepository Crashes = new CrashRepository();

            return(Crashes.GetCallStack(this));
        }
Beispiel #10
0
 /// <summary>
 /// Link the Http context cache to a Crash repository.
 /// </summary>
 /// <param name="inCache">The current Http context cache.</param>
 /// <param name="inCrashRepository">The repository to associate the cache with.</param>
 public CachedDataService(Cache inCache, CrashRepository inCrashRepository)
 {
     CacheInstance = inCache;
     Crashes       = inCrashRepository;
 }
Beispiel #11
0
 /// <summary>
 /// Default constructor
 /// </summary>
 public BuggsViewModel()
 {
     VersionNames = CrashRepository.GetVersionsAsListItems();
 }
Beispiel #12
0
        /// <summary>
        /// Gets a formatted callstack for the crash.
        /// </summary>
        /// <returns>A formatted callstack.</returns>
        public CallStackContainer GetCallStack()
        {
            CrashRepository LocalCrashRepository = new CrashRepository();

            return(LocalCrashRepository.GetCallStack(this));
        }
Beispiel #13
0
        /// <summary>
        /// Sort the container of Buggs by the requested criteria.
        /// </summary>
        /// <param name="Results">A container of unsorted Buggs.</param>
        /// <param name="SortTerm">The term to sort by.</param>
        /// <param name="bSortDescending">Whether to sort by descending or ascending.</param>
        /// <param name="DateFrom">The date of the earliest Bugg to examine.</param>
        /// <param name="DateTo">The date of the most recent Bugg to examine.</param>
        /// <param name="UserGroup">The user group name to filter by.</param>
        /// <returns>A sorted container of Buggs.</returns>
        public IEnumerable <Bugg> GetSortedResults(IEnumerable <Bugg> Results, string SortTerm, bool bSortDescending, DateTime DateFrom, DateTime DateTo, string UserGroup)
        {
            using (FAutoScopedLogTimer LogTimer = new FAutoScopedLogTimer(this.GetType().ToString()))
            {
                try
                {
                    // Get the group id and grab all buggs for the specified group.
                    int NumResults = Results.Count();
                    HashSet <string> UserNamesForUserGroup = GetUserNamesFromUserGroups(UserGroup);


                    // Simplified query.
                    var BuggIdToCountMapGroup = new Dictionary <int, int>();
                    var BuggIdToCountMapRest  = new Dictionary <int, int>();
                    var BuggIdToMachineSet    = new Dictionary <int, HashSet <string> >();
                    Dictionary <string, int> MachineIdToCountMap = new Dictionary <string, int>();
                    List <Buggs_Crash>       BuggsFromDate       = null;
                    Dictionary <int, string> CrashToUser         = null;
                    Dictionary <int, string> CrashToMachine      = null;


                    // Get all buggs from the date range.
                    using (FScopedLogTimer LogTimer1 = new FScopedLogTimer("BuggRepository.GetSortedResults.BuggsFromDate SQL"))
                    {
                        BuggsFromDate =
                            (
                                from BuggCrash in Context.Buggs_Crashes
                                where BuggCrash.Crash.TimeOfCrash >= DateFrom && BuggCrash.Crash.TimeOfCrash <= AddOneDayToDate(DateTo)
                                select BuggCrash
                            ).AsEnumerable().ToList();

                        var CrashesWithIdUserMachine =
                            (
                                from Crash in Context.Crashes
                                where Crash.TimeOfCrash >= DateFrom && Crash.TimeOfCrash <= AddOneDayToDate(DateTo)
                                select new { Id = Crash.Id, UserName = Crash.UserName, MachineId = Crash.ComputerName }
                            );

                        CrashToUser    = CrashesWithIdUserMachine.ToDictionary(x => x.Id, y => y.UserName);
                        CrashToMachine = CrashesWithIdUserMachine.ToDictionary(x => x.Id, y => y.MachineId);
                    }


                    using (FScopedLogTimer LogTimer0 = new FScopedLogTimer("BuggRepository.GetSortedResults.Filtering"))
                    {
                        // This calculates total crashes for selected group and all groups.
                        foreach (Buggs_Crash BuggCrash in BuggsFromDate)
                        {
                            string MachineId;
                            CrashToMachine.TryGetValue(BuggCrash.CrashId, out MachineId);

                            string UserName       = CrashToUser[BuggCrash.CrashId];
                            bool   bValidForGroup = UserNamesForUserGroup.Contains(UserName);
                            if (!bValidForGroup)
                            {
                                int  CountRest     = 0;
                                bool bFoundRestKey = BuggIdToCountMapRest.TryGetValue(BuggCrash.BuggId, out CountRest);
                                if (bFoundRestKey)
                                {
                                    BuggIdToCountMapRest[BuggCrash.BuggId]++;
                                }
                                else
                                {
                                    BuggIdToCountMapRest.Add(BuggCrash.BuggId, 1);
                                }

                                continue;
                            }

                            int  Count     = 0;
                            bool bFoundKey = BuggIdToCountMapGroup.TryGetValue(BuggCrash.BuggId, out Count);
                            if (bFoundKey)
                            {
                                BuggIdToCountMapGroup[BuggCrash.BuggId]++;
                            }
                            else
                            {
                                BuggIdToCountMapGroup.Add(BuggCrash.BuggId, 1);
                            }

                            if (MachineId != null && MachineId.Length > 0)
                            {
                                HashSet <string> MachineSet       = null;
                                bool             bFoundMachineKey = BuggIdToMachineSet.TryGetValue(BuggCrash.BuggId, out MachineSet);
                                if (!bFoundMachineKey)
                                {
                                    BuggIdToMachineSet.Add(BuggCrash.BuggId, new HashSet <string>());
                                }

                                BuggIdToMachineSet[BuggCrash.BuggId].Add(MachineId);
                            }
                        }
                    }

                    using (FScopedLogTimer LogTimer2 = new FScopedLogTimer("BuggRepository.GetSortedResults.CrashesInTimeFrame"))
                    {
                        foreach (var Result in Results)
                        {
                            int GroupCount = 0;
                            BuggIdToCountMapGroup.TryGetValue(Result.Id, out GroupCount);
                            Result.CrashesInTimeFrameGroup = GroupCount;

                            int GroupRest = 0;
                            BuggIdToCountMapRest.TryGetValue(Result.Id, out GroupRest);
                            Result.CrashesInTimeFrameAll = GroupCount + GroupRest;
                        }
                    }

                    using (FScopedLogTimer LogTimer2 = new FScopedLogTimer("BuggRepository.GetSortedResults.UniqueMachineCrashesInTimeFrame"))
                    {
                        foreach (var Result in Results)
                        {
                            HashSet <string> MachineSet = null;
                            bool             bFoundKey  = BuggIdToMachineSet.TryGetValue(Result.Id, out MachineSet);
                            if (bFoundKey)
                            {
                                Result.NumberOfUniqueMachines = MachineSet.Count;
                            }
                            else
                            {
                                Result.NumberOfUniqueMachines = 0;
                            }
                        }
                    }

                    var IntermediateQueryable = Results.AsQueryable();

                    switch (SortTerm)
                    {
                    case "CrashesInTimeFrameGroup":
                        Results = CrashRepository.OrderBy(IntermediateQueryable, BuggCrashInstance => BuggCrashInstance.CrashesInTimeFrameGroup, bSortDescending);
                        break;

                    case "CrashesInTimeFrameAll":
                        Results = CrashRepository.OrderBy(IntermediateQueryable, BuggCrashInstance => BuggCrashInstance.CrashesInTimeFrameAll, bSortDescending);
                        break;

                    case "Id":
                        Results = CrashRepository.OrderBy(IntermediateQueryable, BuggCrashInstance => BuggCrashInstance.Id, bSortDescending);
                        break;

                    case "BuildVersion":
                        Results = CrashRepository.OrderBy(IntermediateQueryable, BuggCrashInstance => BuggCrashInstance.BuildVersion, bSortDescending);
                        break;

                    case "LatestCrash":
                        Results = CrashRepository.OrderBy(IntermediateQueryable, BuggCrashInstance => BuggCrashInstance.TimeOfLastCrash, bSortDescending);
                        break;

                    case "FirstCrash":
                        Results = CrashRepository.OrderBy(IntermediateQueryable, BuggCrashInstance => BuggCrashInstance.TimeOfFirstCrash, bSortDescending);
                        break;

                    case "NumberOfCrashes":
                        Results = CrashRepository.OrderBy(IntermediateQueryable, BuggCrashInstance => BuggCrashInstance.NumberOfCrashes, bSortDescending);
                        break;


                    case "NumberOfUsers":
                    {
                        Results = CrashRepository.OrderBy(IntermediateQueryable, BuggCrashInstance => BuggCrashInstance.NumberOfUniqueMachines, bSortDescending);
                    }
                    break;

                    case "Pattern":
                        Results = CrashRepository.OrderBy(IntermediateQueryable, BuggCrashInstance => BuggCrashInstance.Pattern, bSortDescending);
                        break;

                    case "CrashType":
                        Results = CrashRepository.OrderBy(IntermediateQueryable, BuggCrashInstance => BuggCrashInstance.CrashType, bSortDescending);
                        break;

                    case "Status":
                        Results = CrashRepository.OrderBy(IntermediateQueryable, BuggCrashInstance => BuggCrashInstance.Status, bSortDescending);
                        break;

                    case "FixedChangeList":
                        Results = CrashRepository.OrderBy(IntermediateQueryable, BuggCrashInstance => BuggCrashInstance.FixedChangeList, bSortDescending);
                        break;

                    case "TTPID":
                        Results = CrashRepository.OrderBy(IntermediateQueryable, BuggCrashInstance => BuggCrashInstance.TTPID, bSortDescending);
                        break;
                    }
                    return(Results);
                }
                catch (Exception Ex)
                {
                    Debug.WriteLine("Exception in GetSortedResults: " + Ex.ToString());
                }
                return(Results);
            }
        }
 /// <summary>
 /// Default constructor, used by ReportsController
 /// </summary>
 public ReportsViewModel()
 {
     BranchNames = CrashRepository.GetBranchesAsListItems();
 }
Beispiel #15
0
        /// <summary>
        /// Sort the container of Buggs by the requested criteria.
        /// </summary>
        /// <param name="Results">A container of unsorted Buggs.</param>
        /// <param name="SortTerm">The term to sort by.</param>
        /// <param name="bSortDescending">Whether to sort by descending or ascending.</param>
        /// <param name="DateFrom">The date of the earliest Bugg to examine.</param>
        /// <param name="DateTo">The date of the most recent Bugg to examine.</param>
        /// <returns>A sorted container of Buggs.</returns>
        public IQueryable <Bugg> GetSortedResults(IQueryable <Bugg> Results, string SortTerm, bool bSortDescending, DateTime DateFrom, DateTime DateTo)
        {
            using (FAutoScopedLogTimer LogTimer = new FAutoScopedLogTimer(this.GetType().ToString()))
            {
                try
                {
                    var IntermediateResults =
                        (
                            from BuggCrashDetail in BuggsDataContext.Buggs_Crashes
                            where BuggCrashDetail.Crash.TimeOfCrash >= DateFrom && BuggCrashDetail.Crash.TimeOfCrash <= AddOneDayToDate(DateTo)
                            group BuggCrashDetail by BuggCrashDetail.BuggId into CrashesGrouped
                            join BuggDetail in Results on CrashesGrouped.Key equals BuggDetail.Id
                            select new { Bugg = BuggDetail, Count = CrashesGrouped.Count() }
                        );

                    using (FScopedLogTimer LogTimer2 = new FScopedLogTimer("BuggRepository.GetSortedResults.CrashesInTimeFrame"))
                    {
                        foreach (var Result in IntermediateResults)
                        {
                            Result.Bugg.CrashesInTimeFrame = Result.Count;
                        }
                    }


                    switch (SortTerm)
                    {
                    case "CrashesInTimeFrame":
                        IntermediateResults = CrashRepository.OrderBy(IntermediateResults, BuggCrashInstance => BuggCrashInstance.Count, bSortDescending);
                        break;

                    case "Id":
                        IntermediateResults = CrashRepository.OrderBy(IntermediateResults, BuggCrashInstance => BuggCrashInstance.Bugg.Id, bSortDescending);
                        break;

                    case "BuildVersion":
                        IntermediateResults = CrashRepository.OrderBy(IntermediateResults, BuggCrashInstance => BuggCrashInstance.Bugg.BuildVersion, bSortDescending);
                        break;

                    case "LatestCrash":
                        IntermediateResults = CrashRepository.OrderBy(IntermediateResults, BuggCrashInstance => BuggCrashInstance.Bugg.TimeOfLastCrash, bSortDescending);
                        break;

                    case "FirstCrash":
                        IntermediateResults = CrashRepository.OrderBy(IntermediateResults, BuggCrashInstance => BuggCrashInstance.Bugg.TimeOfFirstCrash, bSortDescending);
                        break;

                    case "NumberOfCrashes":
                        IntermediateResults = CrashRepository.OrderBy(IntermediateResults, BuggCrashInstance => BuggCrashInstance.Bugg.NumberOfCrashes, bSortDescending);
                        break;

                    case "NumberOfUsers":
                        IntermediateResults = CrashRepository.OrderBy(IntermediateResults, BuggCrashInstance => BuggCrashInstance.Bugg.NumberOfUsers, bSortDescending);
                        break;

                    case "Pattern":
                        IntermediateResults = CrashRepository.OrderBy(IntermediateResults, BuggCrashInstance => BuggCrashInstance.Bugg.Pattern, bSortDescending);
                        break;

                    case "Status":
                        IntermediateResults = CrashRepository.OrderBy(IntermediateResults, BuggCrashInstance => BuggCrashInstance.Bugg.Status, bSortDescending);
                        break;

                    case "FixedChangeList":
                        IntermediateResults = CrashRepository.OrderBy(IntermediateResults, BuggCrashInstance => BuggCrashInstance.Bugg.FixedChangeList, bSortDescending);
                        break;

                    case "TTPID":
                        IntermediateResults = CrashRepository.OrderBy(IntermediateResults, BuggCrashInstance => BuggCrashInstance.Bugg.TTPID, bSortDescending);
                        break;
                    }
                    return(IntermediateResults.Select(x => x.Bugg));
                }
                catch (Exception Ex)
                {
                    Debug.WriteLine("Exception in GetSortedResults: " + Ex.ToString());
                }
                return(Results);
            }
        }