Ejemplo n.º 1
0
        /// <summary>
        /// Retrieve all Data for a single bug given by the id
        /// </summary>
        /// <param name="buggsForm"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        private BuggViewModel GetResult(int id)
        {
            var model = new BuggViewModel();

            using (var unitOfWork = new UnitOfWork(new CrashReportEntities()))
            {
                // Create a new view and populate with Crash
                List <Crash> crashes = null;
                model.Bugg = unitOfWork.BuggRepository.GetById(id);

                crashes = model.Bugg.Crashes.OrderByDescending(data => data.TimeOfCrash).ToList();
                model.Bugg.CrashesInTimeFrameAll   = crashes.Count;
                model.Bugg.CrashesInTimeFrameGroup = crashes.Count;
                model.Bugg.NumberOfCrashes         = crashes.Count;
                model.Crashes   = crashes;
                model.CrashData = crashes.Take(50).Select(data => new CrashDataModel()
                {
                    Id = data.Id,
                    ChangelistVersion = data.ChangelistVersion,
                    GameName          = data.GameName,
                    EngineMode        = data.EngineMode,
                    PlatformName      = data.PlatformName,
                    TimeOfCrash       = data.TimeOfCrash,
                    Description       = data.Description,
                }).ToList();
            }

            return(model);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Retrieve all Data for a single bug given by the id
        /// </summary>
        /// <param name="buggsForm"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        private BuggViewModel GetResult(int id, int page, int pageSize, UnitOfWork unitOfWork)
        {
            var model = new BuggViewModel();

            model.Bugg = unitOfWork.BuggRepository.GetById(id);

            model.Bugg.CrashesInTimeFrameAll   = 0;
            model.Bugg.CrashesInTimeFrameGroup = 0;
            model.Bugg.NumberOfCrashes         = unitOfWork.CrashRepository.Count(data => data.BuggId == id);
            model.Bugg.NumberOfUniqueMachines  =
                unitOfWork.CrashRepository.ListAll()
                .Where(data => data.BuggId == id)
                .GroupBy(data => data.ComputerName)
                .Count();
            model.CrashData = unitOfWork.CrashRepository.ListAll().Where(data => data.BuggId == id)
                              .OrderByDescending(data => data.TimeOfCrash).Skip(page * pageSize).Take(pageSize).Select(data => new CrashDataModel()
            {
                Id = data.Id,
                ChangelistVersion = data.ChangelistVersion,
                GameName          = data.GameName,
                EngineMode        = data.EngineMode,
                PlatformName      = data.PlatformName,
                TimeOfCrash       = data.TimeOfCrash,
                Description       = data.Description,
                RawCallStack      = data.RawCallStack,
                CrashType         = data.CrashType,
                Summary           = data.Summary,
                SourceContext     = data.SourceContext,
                BuildVersion      = data.BuildVersion,
                ComputerName      = data.ComputerName,
                Branch            = data.Branch
            }).ToList();

            return(model);
        }
        /// <summary>
        /// Create the html required to generate a link for a line of callstack in a Bugg.
        /// </summary>
        /// <param name="Helper">The Url helper object.</param>
        /// <param name="CallStack">A line of callstack to make a link for.</param>
        /// <param name="Model">The view model for the current page.</param>
        /// <returns>A string suitable for MVC to render.</returns>
        public static MvcHtmlString CallStackSearchLink(this UrlHelper Helper, string CallStack, BuggViewModel Model)
        {
            StringBuilder Result = new StringBuilder();
            TagBuilder    Tag    = new TagBuilder("a");

            Tag.MergeAttribute("href", "/Buggs/Show/" + Model.Bugg.Id);
            Tag.InnerHtml = CallStack;
            Result.AppendLine(Tag.ToString());

            return(MvcHtmlString.Create(Result.ToString()));
        }
        /// <summary>
        /// Create the html required to create the links for table headers to control the sorting of a Bugg.
        /// </summary>
        /// <param name="Helper">The Url helper object.</param>
        /// <param name="HeaderName">The table column header name.</param>
        /// <param name="SortTerm">The sort term to use when sorting by this column.</param>
        /// <param name="Model">The view model for the current page.</param>
        /// <returns>A string suitable for MVC to render.</returns>
        public static MvcHtmlString TableHeader(this UrlHelper Helper, string HeaderName, string SortTerm, BuggViewModel Model)
        {
            StringBuilder Result = new StringBuilder();
            TagBuilder    Tag    = new TagBuilder("a");

            Tag.MergeAttribute("href", "/Buggs/Show/" + Model.Bugg.Id);
            Tag.InnerHtml = "<span>" + HeaderName + "</span>";
            Result.AppendLine(Tag.ToString());

            return(MvcHtmlString.Create(Result.ToString()));
        }
Ejemplo n.º 5
0
        /// <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 + ")", bCreateNewLog: true))
            {
                // Handle 'CopyToJira' button
                int BuggIDToBeAddedToJira = 0;
                foreach (var Entry in BuggsForm)
                {
                    if (Entry.ToString().Contains(Bugg.JiraSubmitName))
                    {
                        int.TryParse(Entry.ToString().Substring(Bugg.JiraSubmitName.Length), out BuggIDToBeAddedToJira);
                        break;
                    }
                }

                BuggRepository Buggs = new BuggRepository();

                // 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;

                BuggViewModel Model   = new BuggViewModel();
                Bugg          NewBugg = Buggs.GetBugg(id);
                if (NewBugg == null)
                {
                    return(RedirectToAction(""));
                }

                Crashes = NewBugg.GetCrashes();

                using (FAutoScopedLogTimer GetCrashesTimer = new FAutoScopedLogTimer("Bugg.PrepareBuggForJira"))
                {
                    if (Crashes.Count > 0)
                    {
                        NewBugg.PrepareBuggForJira(Crashes);

                        if (BuggIDToBeAddedToJira != 0)
                        {
                            NewBugg.CopyToJira();
                        }
                    }
                }

                using (FAutoScopedLogTimer JiraResultsTimer = new FAutoScopedLogTimer("Bugg.GrabJira"))
                {
                    var  JC         = JiraConnection.Get();
                    bool bValidJira = false;

                    // Verify valid JiraID, this may be still a TTP
                    if (!string.IsNullOrEmpty(NewBugg.Jira))
                    {
                        int TTPID = 0;
                        int.TryParse(NewBugg.Jira, out TTPID);

                        if (TTPID == 0)
                        {
                            //AddBuggJiraMapping( NewBugg, ref FoundJiras, ref JiraIDtoBugg );
                            bValidJira = true;
                        }
                    }

                    if (JC.CanBeUsed() && bValidJira)
                    {
                        // Grab the data form JIRA.
                        string JiraSearchQuery = "key = " + NewBugg.Jira;

                        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;

                            NewBugg.JiraSummary         = Summary;
                            NewBugg.JiraComponentsText  = ComponentsText;
                            NewBugg.JiraResolution      = Resolution;
                            NewBugg.JiraFixVersionsText = FixVersionsText;
                            if (FixCL != 0)
                            {
                                NewBugg.JiraFixCL = FixCL.ToString();
                            }

                            break;
                        }
                    }
                }

                // Apply any user settings
                if (BuggsForm.Count > 0)
                {
                    if (!string.IsNullOrEmpty(BuggsForm["SetStatus"]))
                    {
                        NewBugg.Status = BuggsForm["SetStatus"];
                        Buggs.SetBuggStatus(NewBugg.Status, id);
                    }

                    if (!string.IsNullOrEmpty(BuggsForm["SetFixedIn"]))
                    {
                        NewBugg.FixedChangeList = BuggsForm["SetFixedIn"];
                        Buggs.SetBuggFixedChangeList(NewBugg.FixedChangeList, id);
                    }

                    if (!string.IsNullOrEmpty(BuggsForm["SetTTP"]))
                    {
                        NewBugg.Jira = BuggsForm["SetTTP"];
                        Buggs.SetJIRAForBuggAndCrashes(NewBugg.Jira, id);
                    }

                    // <STATUS>
                }

                // Set up the view model with the crash data
                Model.Bugg    = NewBugg;
                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;
                    }

                    Model.Bugg.LatestCrashSummary = NewCrash.Summary;
                }

                Model.GenerationTime = LogTimer.GetElapsedSeconds().ToString("F2");
                return(View("Show", Model));
            }
        }
Ejemplo n.º 6
0
        /// <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"];
                }

                // <STATUS>
            }

            // 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));
        }
Ejemplo n.º 7
0
        /// <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 (var logTimer = new FAutoScopedLogTimer(this.GetType().ToString() + "(BuggId=" + id + ")", bCreateNewLog: true))
            {
                // Set the display properties based on the radio buttons
                var displayModuleNames   = buggsForm["DisplayModuleNames"] == "true";
                var displayFunctionNames = buggsForm["DisplayFunctionNames"] == "true";
                var displayFileNames     = buggsForm["DisplayFileNames"] == "true";
                var displayFilePathNames = false;
                if (buggsForm["DisplayFilePathNames"] == "true")
                {
                    displayFilePathNames = true;
                    displayFileNames     = false;
                }
                var displayUnformattedCallStack = buggsForm["DisplayUnformattedCallStack"] == "true";

                // Create a new view and populate with crashes
                List <Crash> crashes = null;
                var          model   = new BuggViewModel();
                var          newBugg = _unitOfWork.BuggRepository.GetById(id);
                if (newBugg == null)
                {
                    return(RedirectToAction("Index"));
                }
                crashes = newBugg.Crashes.OrderByDescending(data => data.TimeOfCrash).ToList();
                newBugg.CrashesInTimeFrameAll   = crashes.Count;
                newBugg.CrashesInTimeFrameGroup = crashes.Count;
                newBugg.NumberOfCrashes         = crashes.Count;

                // Handle 'CopyToJira' button
                var buggIdToBeAddedToJira = 0;
                foreach (var entry in buggsForm.Cast <object>().Where(entry => entry.ToString().Contains("CopyToJira-")))
                {
                    int.TryParse(entry.ToString().Substring("CopyToJira-".Length), out buggIdToBeAddedToJira);
                    break;
                }

                newBugg.PrepareBuggForJira(crashes);
                if (buggIdToBeAddedToJira != 0)
                {
                    newBugg.JiraProject = buggsForm["JiraProject"];
                    newBugg.CopyToJira();
                }

                var jc         = JiraConnection.Get();
                var bValidJira = false;

                // Verify valid JiraID, this may be still a TTP
                if (!string.IsNullOrEmpty(newBugg.TTPID))
                {
                    var jira = 0;
                    int.TryParse(newBugg.TTPID, out jira);

                    if (jira == 0)
                    {
                        bValidJira = true;
                    }
                }

                if (jc.CanBeUsed() && bValidJira)
                {
                    // Grab the data form JIRA.
                    var jiraSearchQuery = "key = " + newBugg.TTPID;
                    var jiraResults     = new Dictionary <string, Dictionary <string, object> >();

                    try
                    {
                        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
                        });
                    }
                    catch (System.Exception)
                    {
                        newBugg.JiraSummary         = "JIRA MISMATCH";
                        newBugg.JiraComponentsText  = "JIRA MISMATCH";
                        newBugg.JiraResolution      = "JIRA MISMATCH";
                        newBugg.JiraFixVersionsText = "JIRA MISMATCH";
                        newBugg.JiraFixCL           = "JIRA MISMATCH";
                    }

                    // Jira Key, Summary, Components, Resolution, Fix version, Fix changelist
                    if (jiraResults.Any())
                    {
                        var jira    = jiraResults.First();
                        var summary = (string)jira.Value["summary"];

                        var componentsText = "";
                        var components     = (System.Collections.ArrayList)jira.Value["components"];
                        foreach (Dictionary <string, object> component in components)
                        {
                            componentsText += (string)component["name"];
                            componentsText += " ";
                        }

                        var resolutionFields = (Dictionary <string, object>)jira.Value["resolution"];
                        var resolution       = resolutionFields != null ? (string)resolutionFields["name"] : "";

                        var fixVersionsText = "";
                        var fixVersions     = (System.Collections.ArrayList)jira.Value["fixVersions"];
                        foreach (Dictionary <string, object> fixVersion in fixVersions)
                        {
                            fixVersionsText += (string)fixVersion["name"];
                            fixVersionsText += " ";
                        }

                        var fixCl = jira.Value["customfield_11200"] != null ? (int)(decimal)jira.Value["customfield_11200"] : 0;

                        //Conversion to ado.net entity framework

                        newBugg.JiraSummary         = summary;
                        newBugg.JiraComponentsText  = componentsText;
                        newBugg.JiraResolution      = resolution;
                        newBugg.JiraFixVersionsText = fixVersionsText;
                        if (fixCl != 0)
                        {
                            newBugg.FixedChangeList = fixCl.ToString();
                        }
                    }
                }

                // Apply any user settings
                if (buggsForm.Count > 0)
                {
                    if (!string.IsNullOrEmpty(buggsForm["SetStatus"]))
                    {
                        newBugg.Status = buggsForm["SetStatus"];
                        newBugg.Crashes.ForEach(data => data.Status = buggsForm["SetStatus"]);
                    }

                    if (!string.IsNullOrEmpty(buggsForm["SetFixedIn"]))
                    {
                        newBugg.FixedChangeList = buggsForm["SetFixedIn"];
                        newBugg.Crashes.ForEach(data => data.FixedChangeList = buggsForm["SetFixedIn"]);
                    }

                    if (!string.IsNullOrEmpty(buggsForm["SetTTP"]))
                    {
                        newBugg.TTPID = buggsForm["SetTTP"];
                        newBugg.Crashes.ForEach(data => data.Jira = buggsForm["SetTTP"]);
                    }

                    _unitOfWork.BuggRepository.Update(newBugg);
                    _unitOfWork.Save();
                }

                // Set up the view model with the crash data
                model.Crashes = crashes;
                model.Bugg    = newBugg;

                var newCrash = model.Crashes.FirstOrDefault();
                if (newCrash != null)
                {
                    var 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 (var entry in model.CallStack.CallStackEntries)
                    {
                        entry.FunctionName = entry.GetTrimmedFunctionName(128);
                    }

                    model.SourceContext = newCrash.SourceContext;

                    model.LatestCrashSummary = newCrash.Summary;
                }
                model.LatestCrashSummary      = newCrash.Summary;
                model.Bugg.LatestCrashSummary = newCrash.Summary;
                model.GenerationTime          = logTimer.GetElapsedSeconds().ToString("F2");
                return(View("Show", model));
            }
        }
		/// <summary>
		/// Create the html required to generate a link for a line of callstack in a Bugg.
		/// </summary>
		/// <param name="Helper">The Url helper object.</param>
		/// <param name="CallStack">A line of callstack to make a link for.</param>
		/// <param name="Model">The view model for the current page.</param>
		/// <returns>A string suitable for MVC to render.</returns>
		public static MvcHtmlString CallStackSearchLink( this UrlHelper Helper, string CallStack, BuggViewModel Model )
		{
			StringBuilder Result = new StringBuilder();
			TagBuilder Tag = new TagBuilder( "a" );

			Tag.MergeAttribute( "href", "/Buggs/Show/" + Model.Bugg.Id );
			Tag.InnerHtml = CallStack;
			Result.AppendLine( Tag.ToString() );

			return MvcHtmlString.Create( Result.ToString() );
		}
		/// <summary>
		/// Create the html required to create the links for table headers to control the sorting of a Bugg.
		/// </summary>
		/// <param name="Helper">The Url helper object.</param>
		/// <param name="HeaderName">The table column header name.</param>
		/// <param name="SortTerm">The sort term to use when sorting by this column.</param>
		/// <param name="Model">The view model for the current page.</param>
		/// <returns>A string suitable for MVC to render.</returns>
		public static MvcHtmlString TableHeader( this UrlHelper Helper, string HeaderName, string SortTerm, BuggViewModel Model )
		{
			StringBuilder Result = new StringBuilder();
			TagBuilder Tag = new TagBuilder( "a" );

			Tag.MergeAttribute( "href", "/Buggs/Show/" + Model.Bugg.Id );
			Tag.InnerHtml = "<span>" + HeaderName + "</span>";
			Result.AppendLine( Tag.ToString() );

			return MvcHtmlString.Create( Result.ToString() );
		}
Ejemplo n.º 10
0
        /// <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));
            }
        }