public ActionResult GetIssueRow(int issueId) { var issue = IssueManager.Get(issueId); ItemsGridModel model = new ItemsGridModel(); var visibility = GetChangelogFields(issue.Entity.ProjectId); List <int> projectIds = new List <int>(); projectIds.Add(issue.Entity.ProjectId); var properties = GridManager.GetDisplayProperties(MetaManager.TypeGetAll(new List <ProjectDto>() { UserContext.Project }), visibility, projectIds); model.AllowSequencing = false; model.ShowSequencing = false; model.GroupDependencies = false; model.Issues.Add(issue); model.Columns = GridManager.DescribeGridColumns(properties); model.DisplayData = GridManager.GetDisplayData(model.Issues, model.Columns); model.Options = GridManager.DescribeGridOptions(); JsonResponse response = new JsonResponse(); response.Success = true; response.Result = new { Html = RenderPartialViewToString(this, "~/Views/Shared/DisplayTemplates/IssueDtoRow.cshtml", model), }; string data = response.ToJson().Replace("<", "\\u003c").Replace(">", "\\u003e").Replace("&", "\\u0026"); return(Content(data, Request.Files.Count == 0 ? "application/json" : "text/html")); }
private Changelog.Models.ChangelogpAppModel BuildModelData(int versionId, IEnumerable <Countersoft.Gemini.Commons.Entity.Version> iVersions, IssuesFilter OriginalFilter = null) { StringBuilder builder = new StringBuilder(); Changelog.Models.ChangelogpAppModel model = new Changelog.Models.ChangelogpAppModel(); List <VersionDto> versions = VersionManager.ConvertDesc(new List <Countersoft.Gemini.Commons.Entity.Version>(iVersions)); if (versions.Count != iVersions.Count()) { // Need to get the version again as parents is missing, probably released foreach (var ver in iVersions) { if (versions.Find(v => v.Entity.Id == ver.Id) == null) { int index = versions.FindIndex(v => v.Entity.Sequence > ver.Sequence); if (index == -1) { versions.Add(VersionManager.Convert(ver)); } else { versions.Insert(index, VersionManager.Convert(ver)); } } } } IssuesFilter filter = new IssuesFilter(); // Build up the progress data on all the cards as we go foreach (var version in versions) { Changelog.Models.ChangelogpAppModel tmp = new Changelog.Models.ChangelogpAppModel(); builder.Append(BuildAllProjectVersions(version.Entity, version.Entity.Id == versionId, version.HierarchyLevel)); if (version.Entity.Id == versionId) { List <IssueDto> issues = IssueManager.GetRoadmap(UserContext.Project.Entity.Id, null, version.Entity.Id); var visibility = GetChangelogFields(UserContext.Project.Entity.Id); var properties = GridManager.GetDisplayProperties(MetaManager.TypeGetAll(new List <ProjectDto>() { CurrentProject }), visibility, new List <int>() { version.Project.Entity.Id }); List <ColumnInfoModel> gridColumns = GridManager.DescribeGridColumns(properties); GridOptionsModel gridOptions = GridManager.DescribeGridOptions(); // get the version specific data tmp.Issues = issues; tmp.Columns = gridColumns; tmp.Options = gridOptions; tmp.Closed = tmp.Issues.Count(i => i.IsClosed); tmp.Open = tmp.Issues.Count(i => !i.IsClosed); tmp.Statuses = (from i in tmp.Issues group i by new { Id = i.Entity.StatusId, Name = i.Status } into g select new Triple <string, int, string>(g.Key.Name, g.Count(), string.Format("{0}{1}?versions={2}&statuses={3}", UserContext.Url, NavigationHelper.GetProjectPageUrl(UserContext.Project, ProjectTemplatePageType.Items), versionId, g.Key.Id))).OrderByDescending(g => g.Second).Take(3); tmp.Types = (from i in tmp.Issues group i by new { Id = i.Entity.TypeId, Name = i.Type } into g select new Triple <string, int, string>(g.Key.Name, g.Count(), string.Format("{0}{1}?versions={2}&types={3}&includeclosed=yes", UserContext.Url, NavigationHelper.GetProjectPageUrl(UserContext.Project, ProjectTemplatePageType.Items), versionId, g.Key.Id))).OrderByDescending(g => g.Second).Take(3); // store the version Id model.VersionId = version.Entity.Id; model.VersionLabel = version.Entity.Name; model.Closed = tmp.Closed; model.Columns = tmp.Columns; model.Issues = tmp.Issues; model.DisplayData = GridManager.GetDisplayData(tmp.Issues, tmp.Columns); model.Open = tmp.Open; model.Options = tmp.Options; model.Statuses = tmp.Statuses; model.Types = tmp.Types; model.Estimated = issues.Sum(i => i.Entity.EstimatedHours * 60 + i.EstimatedMinutes); model.Logged = issues.Sum(i => i.Entity.LoggedHours * 60 + i.Entity.LoggedMinutes); model.Remain = model.Estimated > model.Logged ? model.Estimated - model.Logged : 0; model.TimeLoggedOver = model.Logged > model.Estimated ? model.Logged - model.Estimated : 0; model.ReleaseStartDate = version.Entity.StartDate; model.ReleaseEndDate = version.Entity.ReleaseDate; // Now get with the extra data that we need var projectId = UserContext.Project.Entity.Id; IssuesGridFilter defaultFilter = new IssuesGridFilter(IssuesFilter.CreateProjectFilter(CurrentUser.Entity.Id, CurrentProject.Entity.Id)); filter = IssuesFilter.CreateVersionFilter(CurrentUser.Entity.Id, CurrentProject.Entity.Id, version.Entity.Id); if (OriginalFilter != null) { filter.SortField = OriginalFilter.SortField; filter.SortOrder = OriginalFilter.SortOrder; } ItemFilterManager.SetSortedColumns(gridColumns, filter); model.Filter = IssueFilterHelper.PopulateModel(model.Filter, filter, filter, PermissionsManager, ItemFilterManager, IssueFilterHelper.GetViewableFields(filter, ProjectManager, MetaManager), false); } } // attach version cards model.VersionCards = builder.ToString(); // Visibility model[ItemAttributeVisibility.Status] = CanSeeProjectItemAttribute(ItemAttributeVisibility.Status); model[ItemAttributeVisibility.EstimatedEffort] = CanSeeProjectItemAttribute(ItemAttributeVisibility.EstimatedEffort); model[ItemAttributeVisibility.CalculatedTimeLogged] = CanSeeProjectItemAttribute(ItemAttributeVisibility.CalculatedTimeLogged); model[ItemAttributeVisibility.CalculatedTimeRemaining] = model[ItemAttributeVisibility.EstimatedEffort] && model[ItemAttributeVisibility.CalculatedTimeLogged]; StringBuilder sort = new StringBuilder(); List <string> sorting = new IssuesFilter().GetSortFields(); List <int> orders = new IssuesFilter().GetSortOrders(); for (int i = 0; i < sorting.Count; i++) { sort.AppendFormat("{0}|{1}", sorting[i], orders[i] == 1 ? 0 : 1); } model.Sort = sort.ToString(); model.CurrentPageCard = CurrentCard; return(model); }
public override void AfterCreateFull(IssueDtoEventArgs args) { if (!GeminiApp.Config.EmailAlertsEnabled) { return; } var data = args.Context.GlobalConfigurationWidgetStore.Get <List <CreateItemNotifierData> >(AppConstants.AppId); if (data == null || data.Value == null || data.Value.Count == 0) { return; } var projectData = data.Value.Find(d => d.ProjectId.GetValueOrDefault() == args.Issue.Entity.ProjectId); if (projectData == null) { projectData = data.Value.Find(d => d.ProjectId.GetValueOrDefault() == 0); } if (projectData == null) { return; } var alertService = GeminiApp.Container.Resolve <IAlertTemplates>(); var alerts = alertService.GetAll(); var template = alerts.Find(t => t.Id == projectData.TemplateId); if (template == null) { return; } AlertsTemplateHelper helper = new AlertsTemplateHelper(alerts, args.GeminiUrls[0].Key); using (var cache = GeminiApp.Container.Resolve <ICacheContainer>()) { var userManager = GeminiApp.GetManager <UserManager>(cache.Users.Find(u => u.Active && u.ProjectGroups.Where(p => p.ProjectGroupId == Constants.GlobalGroupAdministrators && p.UserId == u.Id).Any())); var metaManager = new MetaManager(userManager); var types = metaManager.TypeGetAll(); var OrganizationManager = new OrganizationManager(userManager); var organizations = OrganizationManager.GetAll(); var permissions = new PermissionSetManager(userManager); var permissionSets = permissions.GetAll(); PermissionsManager permissionManager = null; foreach (var user in projectData.UserIds) { var userDto = userManager.Get(user); if (userDto != null && userDto.Entity.Active) { if (permissionManager == null) { permissionManager = new PermissionsManager(userDto, types, permissionSets, organizations, userManager.UserContext.Config.HelpDeskModeGroup, false); } else { permissionManager = permissionManager.Copy(userDto); } if (!permissionManager.CanSeeItem(args.Issue.Project, args.Issue) || !userDto.Entity.EmailMe) { continue; } var body = helper.Build(template, args.Issue, userDto); string emailLog; EmailHelper.Send(GeminiApp.Config, body.Key.HasValue() ? body.Key : string.Format("[{0}] {1}", args.Issue.IssueKey, args.Issue.Title), body.Value, userDto.Entity.Email, userDto.Entity.Fullname, true, out emailLog); } } } }