Exemple #1
0
        public ActionResult EditEnvironmentColors()
        {
            //TODO: If provided is not the userName, but the userId, find the userId by the userName.
            var environmentColors = _initiativeBusiness.GetEnvironmentColors(User.Identity.GetUserId(), _accountRepository.FindById(User.Identity.GetUserId()).UserName);

            return(View(environmentColors));
        }
Exemple #2
0
        // GET: IssueType/Details/5
        public ActionResult Details(string id, string application, string version, string issueType)
        {
            if (id == null)
            {
                throw new ArgumentNullException("id", "InitiativeId was not provided.");
            }

            var i            = _initiativeBusiness.GetInitiativesByDeveloper(_accountRepository.FindById(User.Identity.GetUserId()).Email).Where(x => x.Name == id).ToArray();
            var initiativeId = Guid.Empty;

            if (i.Count() == 1)//Name is unique
            {
                initiativeId = _initiativeBusiness.GetInitiativesByDeveloper(_accountRepository.FindById(User.Identity.GetUserId()).Email).Single(x => x.Name == id).Id;
            }
            else//go with id
            {
                initiativeId = _initiativeBusiness.GetInitiativesByDeveloper(_accountRepository.FindById(User.Identity.GetUserId()).Email).Single(x => x.Id == Guid.Parse(id)).Id;
            }

            if (initiativeId == Guid.Empty)
            {
                throw new NullReferenceException("No initiative found for the specified uid.");
            }

            var initiative = _initiativeBusiness.GetInitiative(_accountRepository.FindById(User.Identity.GetUserId()).Email, initiativeId.ToString());
            var app        = initiative.ApplicationGroups.SelectMany(x => x.Applications).SingleOrDefault(x => x.Name == application);

            if (app == null)
            {
                throw new NullReferenceException("Cannot find application").AddData("Application", application);
            }
            var applicationVersions = _applicationVersionBusiness.GetApplicationVersions(app.Id).ToArray();

            var v   = applicationVersions.Where(x => x.Version == version);
            var ver = v.Count() == 1 ? applicationVersions.Single(x => x.Version == version) : applicationVersions.Single(x => x.Id.Replace(":", "") == version);

            var model = new IssueTypeModel
            {
                IssueType                  = ver.IssueTypes.Single(x => x.Ticket.ToString() == issueType),
                Sessions                   = _sessionBusiness.GetSessionsForApplicationVersion(ver.Id),
                Application                = application,
                Version                    = ver.Version,
                InitiativeName             = initiative.Name,
                InitiativeUniqueIdentifier = id,
                ApplicationName            = app.Name,
                VersionUniqueIdentifier    = ver.GetUniqueIdentifier(applicationVersions.Select(x => x.Version))
            };
            var environments = _initiativeBusiness.GetEnvironmentColors(User.Identity.GetUserId(), _accountRepository.FindById(User.Identity.GetUserId()).UserName);

            model.Environments = environments.Select(x => new EnvironmentViewModel()
            {
                Name = x.Key, Color = x.Value
            }).ToList();

            model.Users = model.Sessions.Select(user => _userBusiness.GetUser(user.UserFingerprint)).ToList();

            return(View(model));
        }
Exemple #3
0
        public ApplicationViewModel GetApplicationModel(IInitiative initiative, string application, IEnumerable <IApplicationVersion> versions)
        {
            var developerName   = _accountRepository.FindById(User.Identity.GetUserId()).Email;
            var initiativeHeads = _initiativeBusiness.GetInitiativesByDeveloperOwner(developerName).ToArray();

            var initiativeUniqueIdentifier = initiative.GetUniqueIdentifier(initiativeHeads.Select(xx => xx.Name));

            var applicationVersions = versions as IApplicationVersion[] ?? versions.ToArray();

            var model = new ApplicationViewModel
            {
                InitiativeId               = initiative.Id,
                InitiativeName             = initiative.Name,
                InitiativeUniqueIdentifier = initiativeUniqueIdentifier,
                Application = application,

                Versions = applicationVersions.Select(x => new VersionViewModel
                {
                    Checked               = false,
                    Build                 = x.BuildTime == null ? string.Empty : x.BuildTime.Value.ToLocalTime().ToDateTimeString(),
                    VersionId             = x.Id,
                    Version               = x.Version,
                    VersionIdentifier     = x.GetUniqueIdentifier(applicationVersions.Select(y => y.Version)),
                    ApplicationIdentifier = application,
                    InitiativeIdentifier  = initiativeUniqueIdentifier,
                    IssueTypeCount        = x.IssueTypes.Count(),
                    IssueCount            = x.IssueTypes.SelectMany(y => y.Issues).Count(),
                    Environments          = x.Environments
                }).OrderByDescending(y => y.Version).ToList(),
            };

            var envs = applicationVersions.SelectMany(x => x.Environments).Distinct().ToArray();
            var environmentColors = _initiativeBusiness.GetEnvironmentColors(User.Identity.GetUserId(), _accountRepository.FindById(User.Identity.GetUserId()).UserName).ToArray();

            model.EnvironmentColors = (from environmentColor in environmentColors where envs.Any(x => x == environmentColor.Key) select new EnvironmentViewModel()
            {
                Name = environmentColor.Key, Color = environmentColor.Value
            }).ToList();

            return(model);
        }
Exemple #4
0
        // GET: Version/Details/5
        public ActionResult Details(string id, string application, string version)
        {
            var initiative    = _initiativeBusiness.GetInitiative(_accountRepository.FindById(User.Identity.GetUserId()).Email, id);
            var applicationId = initiative.ApplicationGroups.SelectMany(x => x.Applications).Single(x => x.Name == application).Id;
            var versions      = _applicationVersionBusiness.GetApplicationVersions(applicationId).ToArray();
            var versionName   = _applicationVersionBusiness.GetApplicationVersion(initiative.Id.ToString(), applicationId.ToString(), version).Version;

            //var versionIds = versions.Select(v => v.Id).ToArray();

            //change to EnvironmentViewModel when fixed
            //var environments = new List<string>();
            //foreach (var versionId in versionIds)
            //{
            //    environments.Add(_sessionBusiness.GetSessionsForApplicationVersion(versionId).Select(x => x.Environment));
            //}

            var ver = versions.Single(x => x.Id.Replace(":", "") == version || x.Version == version);

            //var sessions = _sessionBusiness.GetSessionsForApplicationVersion();

            var issue = new IssueViewModel
            {
                InitiativeId               = initiative.Id.ToString(),
                InitiativeName             = initiative.Name,
                ApplicationName            = application,
                Version                    = version,
                VersionName                = versionName,
                IssueTypes                 = ver.IssueTypes,
                Sessions                   = _sessionBusiness.GetSessionsForApplicationVersion(ver.Id),
                ApplicationVersionId       = applicationId.ToString(),
                InitiativeUniqueIdentifier = id,
            };
            var allEnvironments = _initiativeBusiness.GetEnvironmentColors(User.Identity.GetUserId(), _accountRepository.FindById(User.Identity.GetUserId()).UserName);
            var envs            = issue.Sessions.Select(x => x.Environment).Distinct();

            var environments = new List <EnvironmentViewModel>();

            foreach (var environment in envs)
            {
                if (allEnvironments.ContainsKey(environment))
                {
                    string color;
                    allEnvironments.TryGetValue(environment, out color);
                    environments.Add(new EnvironmentViewModel()
                    {
                        Name  = environment,
                        Color = color,
                    });
                }
            }

            //issue.Environments = environments.Select(x => new EnvironmentViewModel { Name = x.Key, Color = x.Value}).ToList();
            issue.Environments     = environments;
            issue.UniqueIdentifier = issue.GetUniqueIdentifier(versionName);

            //issue.ExceptionTypeName = ver.IssueTypes.Select(x => x.ExceptionTypeName);
            //issue.Message = ver.IssueTypes.Select(x => x.Message);
            //issue.Level = ver.IssueTypes.Select(x => x.IssueLevel.ToString());
            //issue.Count = ver.IssueTypes.Select(x => x.Count.ToString());
            //issue.Ticket = ver.IssueTypes.Select(x => x.Ticket.ToString());


            var users = issue.Sessions.Select(user => _userBusiness.GetUser(user.UserFingerprint)).ToList().GroupBy(x => x.Id).Select(x => x.First());

            issue.Users = users;

            issue.Machines = _machineBusiness.GetMachinesByApplicationVersion(ver.Id);

            return(View(issue));
        }
Exemple #5
0
        public ActionResult SearchResults(string searchText)
        {
            var model = new SearchModel()
            {
                IsConfirmed = _accountRepository.GetUser(_accountRepository.FindById(User.Identity.GetUserId()).Email).EMailConfirmed,
                SearchText  = searchText,
            };

            if (!model.IsConfirmed)
            {
                return(View("SearchResults", model));
            }

            var searchResultRows = new List <SearchResultRowModel>();

            var initiativeHeads = _initiativeBusiness.GetInitiativesByDeveloper(_accountRepository.FindById(User.Identity.GetUserId()).Email);
            var initiatives     = _initiativeBusiness.GetInitiatives().ToArray();
            var userInitiatives = initiativeHeads.Select(initiativeHead => initiatives.Single(x => x.Id == initiativeHead.Id)).ToArray();

            foreach (var initiative in userInitiatives)
            {
                var applications = initiative.ApplicationGroups.SelectMany(x => x.Applications).ToArray();
                var initiativeUniqueIdentifier = initiative.GetUniqueIdentifier(initiatives.Select(x => x.Name));

                var versions = new List <IApplicationVersion>();
                foreach (var application in applications)
                {
                    versions.AddRange(_applicationVersionBusiness.GetApplicationVersions(application.Id));
                }

                foreach (var version in versions)
                {
                    foreach (var issueType in version.IssueTypes)
                    {
                        if (issueType.Ticket.ToString().Equals(searchText))
                        {
                            foreach (var issue in issueType.Issues)
                            {
                                searchResultRows.Add(new SearchResultRowModel()
                                {
                                    InitiativeName             = initiative.Name,
                                    InitiativeUniqueIdentifier = initiativeUniqueIdentifier,
                                    ApplicationName            = applications.Single(x => x.Id == version.ApplicationId).Name,
                                    Version = version.Version,
                                    VersionUniqueIdentifier = version.GetUniqueIdentifier(versions.Select(x => x.Version)),
                                    IssueType   = issueType,
                                    Issue       = issue,
                                    Environment = GetSession(issue.SessionId).Environment,
                                });
                            }
                        }
                        else
                        {
                            foreach (var issue in issueType.Issues)
                            {
                                if (issue.Ticket.ToString().Equals(searchText))
                                {
                                    searchResultRows.Add(new SearchResultRowModel()
                                    {
                                        InitiativeName             = initiative.Name,
                                        InitiativeUniqueIdentifier = initiativeUniqueIdentifier,
                                        ApplicationName            = applications.Single(x => x.Id == version.ApplicationId).Name,
                                        Version = version.Version,
                                        VersionUniqueIdentifier = version.GetUniqueIdentifier(versions.Select(x => x.Version)),
                                        IssueType   = issueType,
                                        Issue       = issue,
                                        Environment = GetSession(issue.SessionId).Environment,
                                    });
                                }
                                else
                                {
                                    if (!string.IsNullOrEmpty(issueType.ExceptionTypeName))
                                    {
                                        if (issueType.ExceptionTypeName.Contains(searchText))
                                        {
                                            searchResultRows.Add(new SearchResultRowModel()
                                            {
                                                InitiativeName             = initiative.Name,
                                                InitiativeUniqueIdentifier = initiativeUniqueIdentifier,
                                                ApplicationName            = applications.Single(x => x.Id == version.ApplicationId).Name,
                                                Version = version.Version,
                                                VersionUniqueIdentifier = version.GetUniqueIdentifier(versions.Select(x => x.Version)),
                                                IssueType   = issueType,
                                                Issue       = issue,
                                                Environment = GetSession(issue.SessionId).Environment,
                                            });
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            var allEnvironments      = _initiativeBusiness.GetEnvironmentColors(User.Identity.GetUserId(), _accountRepository.FindById(User.Identity.GetUserId()).UserName);
            var environmentsInResult = searchResultRows.Select(x => x.Environment).Distinct();

            var environments = new List <EnvironmentViewModel>();

            foreach (var env in environmentsInResult)
            {
                if (allEnvironments.ContainsKey(env))
                {
                    string color;
                    allEnvironments.TryGetValue(env, out color);
                    environments.Add(new EnvironmentViewModel()
                    {
                        Name  = env,
                        Color = color,
                    });
                }
            }

            model.SearchResultRows = searchResultRows;
            model.Environments     = environments;

            return(View("SearchResults", model));
        }