Exemplo n.º 1
0
        private InitiativeViewModel GetInitiativeViewModel(string id)
        {
            var developerName = _accountRepository.FindById(User.Identity.GetUserId()).Email;
            var initiatives   = _initiativeBusiness.GetInitiativesByDeveloper(developerName).ToArray();
            var initiative    = _initiativeBusiness.GetInitiative(developerName, id).ToModel(initiatives.Select(x => x.Name));

            return(initiative);
        }
Exemplo n.º 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));
        }
Exemplo n.º 3
0
        public ActionResult Details(string initiativeidentifier, string userId)
        {
            if (initiativeidentifier == null)
            {
                throw new ArgumentNullException("initiativeidentifier", "InitiativeId was not provided.");
            }

            var i            = _initiativeBusiness.GetInitiativesByDeveloper(_accountRepository.FindById(User.Identity.GetUserId()).Email).Where(x => x.Name == initiativeidentifier).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 == initiativeidentifier).Id;
            }
            else//go with id
            {
                initiativeId = _initiativeBusiness.GetInitiativesByDeveloper(_accountRepository.FindById(User.Identity.GetUserId()).Email).Single(x => x.Id == Guid.Parse(initiativeidentifier)).Id;
            }

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

            var initiative     = _initiativeBusiness.GetInitiative(initiativeId);
            var initiativeName = initiative.Name;
            var sessions       = _sessionBusiness.GetSessionsForUser(userId).ToArray();

            var applicationIds   = sessions.GroupBy(x => x.ApplicationId).Select(x => x.First().ApplicationId).ToArray();
            var applicationNames = new List <string>();

            foreach (var applicationId in applicationIds)
            {
                var singleOrDefault = initiative.ApplicationGroups.SelectMany(x => x.Applications).SingleOrDefault(x => x.Id == applicationId);
                if (singleOrDefault != null)
                {
                    applicationNames.Add(singleOrDefault.Name);
                }
            }

            var machineIds   = sessions.GroupBy(x => x.MachineFingerprint).Select(x => x.First().MachineFingerprint).ToArray();
            var machineNames = new List <string>();

            foreach (var machineId in machineIds)
            {
                machineNames.Add(_machineBusiness.GetMachine(machineId).Name);
            }

            var machines = new List <IMachine>();
            var users    = new List <IUser>();

            foreach (var session in sessions)
            {
                machines.Add(_machineBusiness.GetMachine(session.MachineFingerprint));
                users.Add(_userBusiness.GetUser(session.UserFingerprint));
            }


            var model = new UserViewModel()
            {
                Sessions                   = sessions,
                Users                      = users,
                ApplicationNames           = applicationNames,
                Machines                   = machines,
                MachineNames               = machineNames,
                InitiativeName             = initiativeName,
                InitiativeUniqueIdentifier = initiativeidentifier,
            };

            return(View(model));
        }
Exemplo n.º 4
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));
        }