示例#1
0
        public JsonResult Machines(string id, string application, bool archived)
        {
            if (id == null)
            {
                throw new ArgumentNullException("id", "No initiative id provided.");
            }

            var initiative = _initiativeBusiness.GetInitiative(_accountRepository.FindById(User.Identity.GetUserId()).Email, id);
            var app        = initiative.ApplicationGroups.SelectMany(x => x.Applications).Single(x => x.Name == application);
            var versions   = archived ? _applicationVersionBusiness.GetArchivedApplicationVersions(app.Id).ToArray() : _applicationVersionBusiness.GetApplicationVersions(app.Id).ToArray();

            var ms = new List <object>();

            foreach (var version in versions)
            {
                ms.Add(new
                {
                    Id           = version.Id,
                    MachineCount = _machineBusiness.GetMachinesByApplicationVersion(version.Id).Count(), //TODO: this method is super slow, takes ~0,5sek per version
                });
            }

            var response = Json(ms, JsonRequestBehavior.AllowGet);

            return(response);
        }
示例#2
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));
        }