/// <summary> /// Get all Workspaces and it filters by "Url = items" and "BadgeCount > 0" /// If there are Items in the workspace, it updates the BadgeCount. /// If there are no Items in the workspace, it resets the BadgeCount. /// </summary> /// <param name="issueManager"></param> public void GetWorkspaceItems(IssueManager issueManager) { try { NavigationCardsManager navigationCardsManager = new NavigationCardsManager(issueManager); List <NavigationCard> workspaces = navigationCardsManager.GetAll(); foreach (NavigationCard workspace in workspaces.ToList()) { if (workspace.Url == "items" && workspace.BadgeCount > 0) { IssuesFilter filter = ChangeSystemFilterTypesMe(workspace.Filter, (int)workspace.UserId, false); List <IssueDto> workspaceItems = issueManager.GetFiltered(filter, true); if (workspaceItems.Count() > 0) { UpdateBadgeCount(workspace, workspaceItems, navigationCardsManager, false); } else { UpdateBadgeCount(workspace, workspaceItems, navigationCardsManager, true); } } } } catch (Exception exception) { GeminiApp.LogException(exception, false, string.Concat("Run Method GetWorkspaceItems: ", exception.Message)); } }
public void TestInitialize() { issueMatcher = new Mock <ISuppressedIssueMatcher>(); issueMatcher.Setup(x => x.SuppressionExists(It.IsAny <IFilterableIssue>())) .Returns((IFilterableIssue i) => matchedIssues.Contains(i)); testSubject = new IssuesFilter(issueMatcher.Object); }
public ActionResult GetColumns(int projectId) { ColumnsModel model = new ColumnsModel(); List <ScreenField> fields = GetRoadmapFields(projectId); IssuesFilter filter = ItemFilterManager.TransformFilter(IssuesFilter.CreateProjectFilter(CurrentUser.Entity.Id, projectId)); SetCurrentProjectFromFilter(filter); model.Columns = GridManager.GetAvailableColumns(filter.GetProjects(), IssueFilterHelper.AggregateTypes(filter, ProjectManager, MetaManager), fields); return(JsonSuccess(RenderPartialViewToString(this, "~/Views/Items/ColumnSelector.cshtml", model))); }
/// <summary> /// Fonction permettant de retourner le ticket /// en fonction des paramètres /// </summary> /// <param name="pCritere">Critère de sélection</param> /// <returns>Ticket correspondant</returns> /// <remarks>Guillaume Bécard - 2015-02-20 - Création</remarks> private IssueDto GetTicket(ServiceManager pService, CritereTicketDTO pCritere) { //gb - Déclaration des variables IssuesFilter lFiltre = new IssuesFilter(); List <IssueDto> lResultat = new List <IssueDto>(); //gb - Si on a une restriction sur l'id if (pCritere.IdTicket != null) { lFiltre.Issues = pCritere.IdTicket; } //gb - Récupération des tickets lResultat = pService.Item.GetFilteredItems(lFiltre); //gb - Retourne le premier item s'il y en a un return(lResultat.FirstOrDefault()); }
private void ProcessWatcherAlerts() { IConfiguration configuration = GeminiApp.Container.Resolve <IConfiguration>(); var inputConfig = configuration.Get(); SchedulerSettings settings = inputConfig.SchedulerSettings.HasValue() ? inputConfig.SchedulerSettings.FromJson <SchedulerSettings>() : new SchedulerSettings(); DateTime lastChecked = settings.LastCheckedWatchers.HasValue ? settings.LastCheckedWatchers.Value : DateTime.UtcNow; IssuesFilter filter = new IssuesFilter(); filter.RevisedAfter = lastChecked.ToString(); filter.IncludeClosed = true; LogDebugMessage("Last checked for watched item alerts: " + lastChecked); settings.LastCheckedWatchers = DateTime.UtcNow; List <IssueDto> issues = _issueManager.GetFiltered(filter); LogDebugMessage("Item that have changed: " + issues.Count); if (issues.Count > 0) { ProcessWatchers(issues, lastChecked); } GeminiConfiguration config = configuration.Get(); config.SchedulerSettings = settings.ToJson(); ConfigurationItem item = new ConfigurationItem(); item.SettingId = GeminiConfigurationOption.SchedulerSettings.ToString(); item.SettingValue = config.SchedulerSettings; configuration.Update(item); GeminiApp.RefreshConfig(config); }
public async Task <IActionResult> Get([FromQuery] IssuesFilter filter) { if (string.IsNullOrEmpty(filter.ProjectId + filter.VersionId)) { return(ErrorResult("ProjectId or versionId not found")); } if (!string.IsNullOrEmpty(filter.VersionId) && !string.IsNullOrEmpty(filter.ProjectId)) { return(ErrorResult("You only need to specify the projectId or versionId")); } ServiceResult <PagedList <IssueModel> > result; if (!string.IsNullOrEmpty(filter.VersionId)) { result = await _issuesService.GetByVersionId(filter.VersionId, CurrentUserId, filter.PageSize, filter.PageNumber); } else { result = await _issuesService.GetByProjectId(filter.ProjectId, CurrentUserId, filter.PageSize, filter.PageNumber); } return(ModelResult(result)); }
public override WidgetResult Show(IssueDto args) { _projectManager = new ProjectManager(Cache, UserContext, GeminiContext); _projectDocumentManager = new ProjectDocumentManager(Cache, UserContext, GeminiContext); IssuesGridFilter tmp = new IssuesGridFilter(); HttpSessionManager HttpSessionManager = new HttpSessionManager(); var projects = new List <int>(); int selectedFolderKey = 0; // Safety check required because of http://gemini.countersoft.com/project/DEV/21/item/5088 try { if (CurrentCard.IsNew) { tmp = new IssuesGridFilter(HttpSessionManager.GetFilter(CurrentCard.Id, CurrentCard.Filter)); if (tmp == null) { tmp = CurrentCard.Options[AppGuid].FromJson <IssuesGridFilter>(); } projects = tmp.GetProjects(); } else { var cardOptions = CurrentCard.Options[AppGuid].FromJson <DocumentAppNavCard>(); projects.Add(cardOptions.projectId); selectedFolderKey = cardOptions.folderKey; } } catch (Exception ex) { tmp = new IssuesGridFilter(HttpSessionManager.GetFilter(CurrentCard.Id, IssuesFilter.CreateProjectFilter(UserContext.User.Entity.Id, UserContext.Project.Entity.Id))); projects = tmp.GetProjects(); } var activeProjects = _projectManager.GetActive(); var viewableProjects = new List <ProjectDto>(); int?currentProjectId = projects.Count > 0 ? projects.First() : 0; if (activeProjects == null || activeProjects.Count == 0) { activeProjects = new List <ProjectDto>(); } else { viewableProjects = ProjectManager.GetAppViewableProjects(this); } if (!viewableProjects.Any(s => s.Entity.Id == currentProjectId.Value)) { currentProjectId = viewableProjects.Count > 0 ? viewableProjects.First().Entity.Id : 0; } var model = new DocumentsModel { Projects = viewableProjects, FolderList = _projectDocumentManager.GetFolders(currentProjectId), MaxFileUpload = GeminiApp.Config.MaxFileUploadSizeBytes }; model.ProjectList = new SelectList(model.Projects, "Entity.Id", "Entity.Name", currentProjectId); model.Projects = viewableProjects; model.SelectedFolder = selectedFolderKey; model.HeaderText.Add(new HeaderTextItem(ResourceKeys.Documents)); if (!model.FolderList.Any() && currentProjectId > 0) { var entity = new ProjectDocument { Name = ResourceKeys.Documents, IsFolder = true, ProjectId = currentProjectId }; model.FolderList.Add(_projectDocumentManager.Create(entity)); } if (ProjectManager.GetAppEditableProjects(this).Count > 0) { ViewBag.EditPermission = true; } else { ViewBag.EditPermission = false; } WidgetResult result = new WidgetResult(); result.Markup = new WidgetMarkup("views\\Documents.cshtml", model); result.Success = true; return(result); }
protected HttpResponseMessage GetIssuesList(IssuesFilter issuesFilter, IssuesState issuesState, IssuesLabels issuesLabels, IssuesSort issuesSort, IssuesDirection issuesDirection, IssuesSince issuesSince) { ; }
/// <summary> /// This Method change SystemFilterType" > "ME". When filters in Worksapce to be executed with Systemuser(-2). /// You need to change SystemFilterTypes to Workspace user. Returnvalue "IssuesFilter". /// param returnOriginal set back to Original /// </summary> /// <param name="filter"></param> /// <param name="userId"></param> /// <param name="returnOriginal"></param> /// <returns></returns> public IssuesFilter ChangeSystemFilterTypesMe(IssuesFilter filter, int userId, bool returnOriginal) { if (!returnOriginal) { switch (filter.SystemFilter) { case IssuesFilter.SystemFilterTypes.AssignedToMeIssues: filter.Resources = userId.ToString(); break; case IssuesFilter.SystemFilterTypes.DueNext14DaysIssues: break; case IssuesFilter.SystemFilterTypes.DueNext30DaysIssues: break; case IssuesFilter.SystemFilterTypes.DueNext7DaysIssues: break; case IssuesFilter.SystemFilterTypes.DueNext7DaysIssuesAfterTomorrow: break; case IssuesFilter.SystemFilterTypes.DueTodayIssues: break; case IssuesFilter.SystemFilterTypes.DueTomorrowIssues: break; case IssuesFilter.SystemFilterTypes.DueYesterdayIssues: break; case IssuesFilter.SystemFilterTypes.FollowedByMeIssues: List <int> users = filter.Watchers; users = new List <int> { userId }; filter.Watchers = users; break; case IssuesFilter.SystemFilterTypes.LateIssues: break; case IssuesFilter.SystemFilterTypes.NoType: break; case IssuesFilter.SystemFilterTypes.RecentlyClosedIssues: break; case IssuesFilter.SystemFilterTypes.RecentlyCreatedIssues: break; case IssuesFilter.SystemFilterTypes.RecentlyUpdatedIssues: break; case IssuesFilter.SystemFilterTypes.SubmittedByMeIssues: filter.ReportedByUserId = userId; break; case IssuesFilter.SystemFilterTypes.TimeLoggedByMeIssues: filter.TimeLoggedBy = userId.ToString(); break; case IssuesFilter.SystemFilterTypes.ToSynch: break; default: break; } } else { switch (filter.SystemFilter) { case IssuesFilter.SystemFilterTypes.AssignedToMeIssues: filter.Resources.Replace(userId.ToString(), ""); break; case IssuesFilter.SystemFilterTypes.DueNext14DaysIssues: break; case IssuesFilter.SystemFilterTypes.DueNext30DaysIssues: break; case IssuesFilter.SystemFilterTypes.DueNext7DaysIssues: break; case IssuesFilter.SystemFilterTypes.DueNext7DaysIssuesAfterTomorrow: break; case IssuesFilter.SystemFilterTypes.DueTodayIssues: break; case IssuesFilter.SystemFilterTypes.DueTomorrowIssues: break; case IssuesFilter.SystemFilterTypes.DueYesterdayIssues: break; case IssuesFilter.SystemFilterTypes.FollowedByMeIssues: filter.Watchers.Remove(userId); break; case IssuesFilter.SystemFilterTypes.LateIssues: break; case IssuesFilter.SystemFilterTypes.NoType: break; case IssuesFilter.SystemFilterTypes.RecentlyClosedIssues: break; case IssuesFilter.SystemFilterTypes.RecentlyCreatedIssues: break; case IssuesFilter.SystemFilterTypes.RecentlyUpdatedIssues: break; case IssuesFilter.SystemFilterTypes.SubmittedByMeIssues: filter.ReportedByUserId = 0; break; case IssuesFilter.SystemFilterTypes.TimeLoggedByMeIssues: filter.TimeLoggedBy.Replace(userId.ToString(), ""); break; case IssuesFilter.SystemFilterTypes.ToSynch: break; default: break; } } return(filter); }
public ActionResult GetChangelog(int versionId, int projectId) { UserContext.Project = ProjectManager.Get(projectId); IssuesFilter filter = null; if (Request.Form.Keys.Count > 0) { filter = new IssuesFilter(); string[] sort = Request.Form[0].Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); StringBuilder sortField = new StringBuilder(); StringBuilder sortDirection = new StringBuilder(); for (int i = 0; i < sort.Length; i += 2) { sortField.Append(sort[i]); sortField.Append('|'); sortDirection.Append(sort[i + 1] == "0" ? (int)SortDirection.Ascending : (int)SortDirection.Descending); sortDirection.Append('|'); } filter.SortField = sortField.ToString(); filter.SortOrder = sortDirection.ToString(); filter.ShowSequenced = false; } if (filter == null) { filter = HttpSessionManager.GetFilter(CurrentCard.Id, new IssuesFilter()); filter.ShowSequenced = false; } IEnumerable <Countersoft.Gemini.Commons.Entity.Version> versions = Cache.Versions.GetAll().Where(v => v.ProjectId == projectId && v.Released == true && v.Archived == false).OrderBy(o => o.Sequence); // get all versions that are released or not according to settings passed (BUT - NEVER show archived projects) if (!versions.Any(s => s.Id == versionId)) { VersionDto newVersion = VersionManager.GetFirstChangeLogVersion(UserContext.Project.Entity.Id); if (newVersion != null) { versionId = newVersion.Entity.Id; } else { versionId = versions.Count() > 0 ? versions.First().Id : 0; } } var version = VersionManager.Get(versionId); List <IssueDto> issues = new List <IssueDto>(); if (version != null && version.Entity.Released) { issues = IssueManager.GetRoadmap(UserContext.Project.Entity.Id, filter, versionId); } Changelog.Models.ChangelogpAppModel model = BuildModelData(versionId, versions, filter); model.Issues = issues; return(JsonSuccess(new { success = true, grid = RenderPartialViewToString(this, "~/Views/Shared/DisplayTemplates/IssueDto.cshtml", model), statusBar = RenderPartialViewToString(this, AppManager.Instance.GetAppUrl("20A79C86-9FB4-4160-A4FD-29E37E185673", "views/StatusBar.cshtml"), model), versions = RenderPartialViewToString(this, AppManager.Instance.GetAppUrl("20A79C86-9FB4-4160-A4FD-29E37E185673", "views/VersionProgress.cshtml"), model) })); }
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 WidgetResult Show(IssueDto issue = null) { WidgetResult result = new WidgetResult(); List <int> selectedProjects = new List <int>(); ReportOptions options = new ReportOptions(); SummaryModel model = new SummaryModel(); IssuesGridFilter tmp = new IssuesGridFilter(); try { if (CurrentCard.IsNew || !CurrentCard.Options.ContainsKey(AppGuid)) { tmp = new IssuesGridFilter(HttpSessionManager.GetFilter(CurrentCard.Id, CurrentCard.Filter)); if (tmp == null) { tmp = CurrentCard.Options[AppGuid].FromJson <IssuesGridFilter>(); } if (tmp.Projects == Constants.AllProjectsId.ToString()) { selectedProjects.Add(Constants.AllProjectsId); } else { selectedProjects = tmp.GetProjects(); } } else { options = CurrentCard.Options[AppGuid].FromJson <ReportOptions>(); if (options.AllProjectsSelected) { selectedProjects.Add(Constants.AllProjectsId); } else if (options.ProjectIds.Count > 0) { selectedProjects.AddRange(options.ProjectIds); } } } catch (Exception ex) { tmp = new IssuesGridFilter(HttpSessionManager.GetFilter(CurrentCard.Id, IssuesFilter.CreateProjectFilter(UserContext.User.Entity.Id, UserContext.Project.Entity.Id))); selectedProjects = tmp.GetProjects(); } model.ProjectList = GetProjectFilter(selectedProjects); model.Options = options; result.Markup = new WidgetMarkup("views\\Summary.cshtml", model); result.Success = true; return(result); }
public override WidgetResult Show(IssueDto issue = null) { var filter = IsSessionFilter() || CurrentCard.CardType != ProjectTemplatePageType.Custom && "app/roadmap/view".Equals(CurrentCard.Url, StringComparison.InvariantCultureIgnoreCase) ? HttpSessionManager.GetFilter(CurrentCard.Id, IssuesFilter.CreateProjectFilter(CurrentUser.Entity.Id, CurrentProject.Entity.Id)) : CurrentCard.Filter; HttpSessionManager.SetFilter(CurrentCard.Id, filter); int? currentProjectId = 0; bool includeSubversions = false; int versionId = 0; HttpSessionManager.Set <List <UserIssuesView> >(null, Constants.RoadmapSessionView); // Safety check required because of http://gemini.countersoft.com/project/DEV/21/item/5088 PageSettings pageSettings = null; try { if (CurrentCard.Options.ContainsKey(AppGuid)) { pageSettings = CurrentCard.Options[AppGuid].FromJson <PageSettings>(); if (pageSettings.PageData != null) { currentProjectId = pageSettings.PageData.projectId; versionId = pageSettings.PageData.versionId; includeSubversions = pageSettings.PageData.includeSubversions; } } } catch { } //If no project is selected, select the first workspace project. if ((!currentProjectId.HasValue || currentProjectId.Value == 0) && filter.Projects.HasValue()) { try { var workspaceProjects = filter.Projects.Split('|'); if (workspaceProjects.Count() > 0) { currentProjectId = Convert.ToInt32(workspaceProjects[0]); } } catch { } } var viewableProjects = ProjectManager.GetAppViewableProjects(this).ToList(); if (!viewableProjects.Any(s => s.Entity.Id == currentProjectId.Value)) { currentProjectId = viewableProjects.Count > 0 ? viewableProjects.First().Entity.Id : 0; } UserContext.Project = ProjectManager.Get(currentProjectId); IEnumerable <Countersoft.Gemini.Commons.Entity.Version> versions = null; // get all versions that are released or not according to settings passed (BUT - NEVER show archived projects) versions = Cache.Versions.GetAll().Where(v => v.ProjectId == currentProjectId && v.Released == false && v.Archived == false).OrderBy(o => o.Sequence); if (versionId == 0) { VersionDto version = VersionManager.GetFirstRoadmapVersion(UserContext.Project.Entity.Id); if (version != null) { versionId = version.Entity.Id; } else { versionId = versions.Count() > 0 ? versions.First().Id : 0; } } List <IssueDto> issues; issues = IssueManager.GetRoadmap(UserContext.Project.Entity.Id, filter, versionId); if (includeSubversions) { var child = versions.Where(v => v.ParentId == versionId).ToList(); AddChildVersions(versions.ToList(), UserContext.Project.Entity.Id, filter, child, ref issues); } RoadmapAppModel model = BuildModelData(versionId, versions, issues); model.ProjectList = new SelectList(viewableProjects, "Entity.Id", "Entity.Name", currentProjectId.GetValueOrDefault()); model.IncludeSubVersions = includeSubversions; if (pageSettings == null) { pageSettings = new PageSettings(); } pageSettings.PageData.versionId = versionId; pageSettings.PageData.projectId = currentProjectId.GetValueOrDefault(); CurrentCard.Options[AppGuid] = pageSettings.ToJson(); //var view = RenderPartialViewToString(this, "~/views/Roadmap.cshtml", model); return(new WidgetResult() { Success = true, Markup = new WidgetMarkup("views/Roadmap.cshtml", model) }); }
private void AddChildVersions(List <Countersoft.Gemini.Commons.Entity.Version> versions, int projectId, IssuesFilter filter, List <Countersoft.Gemini.Commons.Entity.Version> child, ref List <IssueDto> issues) { foreach (var version in child) { issues.AddRange(IssueManager.GetRoadmap(projectId, filter, version.Id)); AddChildVersions(versions, projectId, filter, versions.FindAll(v => v.ParentId == version.Id), ref issues); } }
public RepeaterModel GetRepeatingModel() { RepeaterModel model = new RepeaterModel(); var filter = new IssuesFilter(); if (IsSessionFilter() || !CurrentCard.Options.ContainsKey(AppGuid)) { filter = HttpSessionManager.GetFilter(CurrentCard.Id, IssuesFilter.CreateProjectFilter(CurrentUser.Entity.Id, CurrentProject.Entity.Id)); } else if (CurrentCard.Options.ContainsKey(AppGuid)) { filter = CurrentCard.Options[AppGuid].FromJson <IssuesFilter>(); } else { filter = CurrentCard.Filter; } if (filter.Repeat.IsEmpty() || filter.Repeat == "-|3") { filter.Repeat = "-|1"; } var transformedFilter = ItemFilterManager.TransformFilter(filter); SetCurrentProjectFromFilter(transformedFilter); model.Filter = IssueFilterHelper.PopulateModel(model.Filter, filter, transformedFilter, PermissionsManager, ItemFilterManager, IssueFilterHelper.GetViewableFields(filter, ProjectManager, MetaManager), false); model.GeminiDateFormat = CurrentUser.GeminiDateFormat; model.BaseUrl = string.Format("{0}workspace/{1}/", UserContext.Url, CurrentCard.Id); var allIssues = IssueManager.GetFiltered(filter); var allIssuesRelatedRepeating = allIssues.Count > 0 ? allIssues.FindAll(s => s.Repeated.HasValue() || s.Entity.OriginatorData.HasValue() && s.Entity.OriginatorType == IssueOriginatorType.Repeat) : new List <IssueDto>(); var masterIssues = allIssuesRelatedRepeating.Count > 0 ? allIssuesRelatedRepeating.FindAll(i => i.Repeated.HasValue()) : new List <IssueDto>(); List <string> repeatValues = new List <string>(); repeatValues.Add("-|1"); repeatValues.Add("-|2"); repeatValues.Add("-|3"); int totalNumberOfRepeatedItems = 0; if (masterIssues.Count > 0) { foreach (var masterIssue in masterIssues) { ItemsGrid item = new ItemsGrid(); item.MasterItem = masterIssue; item.RepeatedItems = allIssuesRelatedRepeating.FindAll(s => s.OriginatorData.HasValue() && s.OriginatorData.Equals(masterIssue.Entity.Id.ToString())); if (item.RepeatedItems.Count > 0 || filter.Repeat == "-|2" || !repeatValues.Contains(filter.Repeat)) { item.RepeatedItems = item.RepeatedItems.OrderBy("Created").ToList(); IssueDto lastRepeated = IssueManager.GetLastCreatedIssueForOriginator(IssueOriginatorType.Repeat, masterIssue.Id.ToString()); if (lastRepeated != null) { item.LastRepitition = lastRepeated.Created.ToString(UserContext.User.DateFormat); } } //Create Next repitition RepeatParser repeat = new RepeatParser(masterIssue.Repeated); for (DateTime date = DateTime.Today; item.NextRepitition.IsEmpty(); date = date.AddDays(1)) { repeat.CurrentDateTime = date; DateTime lastRepeatedDate = masterIssue.Created; if (item.RepeatedItems.Count > 0) { lastRepeatedDate = item.RepeatedItems.Last().Entity.Created; } if (item.RepeatedItems.Count >= repeat.MaximumRepeats) { break; } if (repeat.NeedsToRepeat(lastRepeatedDate)) { item.NextRepitition = date.ToShortDateString(); break; } } totalNumberOfRepeatedItems += item.RepeatedItems.Count; model.Items.Add(item); } } else if (allIssuesRelatedRepeating.Count > 0) { foreach (var repeatedIssue in allIssuesRelatedRepeating) { ItemsGrid item = new ItemsGrid() { MasterItem = repeatedIssue, RepeatedItems = new List <IssueDto>() }; model.Items.Add(item); } } model.ItemCount = masterIssues.Count + totalNumberOfRepeatedItems; return(model); }
public override WidgetResult Show(IssueDto issue = null) { var filter = IsSessionFilter() || CurrentCard.CardType != ProjectTemplatePageType.Custom && "app/changelog/view".Equals(CurrentCard.Url, StringComparison.InvariantCultureIgnoreCase) ? HttpSessionManager.GetFilter(CurrentCard.Id, IssuesFilter.CreateProjectFilter(CurrentUser.Entity.Id, CurrentProject.Entity.Id)) : CurrentCard.Filter; HttpSessionManager.SetFilter(CurrentCard.Id, filter); var workspaceProjects = new List <int>(); int?currentProjectId = 0; int versionId = 0; HttpSessionManager.Set <List <UserIssuesView> >(null, Constants.ChangelogSessionView); // Safety check required because of http://gemini.countersoft.com/project/DEV/21/item/5088 PageSettings pageSettings = null; try { if (CurrentCard.Options.ContainsKey(AppGuid)) { pageSettings = CurrentCard.Options[AppGuid].FromJson <PageSettings>(); if (pageSettings.PageData != null) { currentProjectId = pageSettings.PageData.projectId; versionId = pageSettings.PageData.versionId; } } } catch (Exception ex) {} var activeProjects = ProjectManager.GetActive(); var viewableProjects = new List <ProjectDto>(); if (activeProjects == null || activeProjects.Count == 0) { activeProjects = new List <ProjectDto>(); } else { viewableProjects = ProjectManager.GetAppViewableProjects(this); } if (!viewableProjects.Any(s => s.Entity.Id == currentProjectId.Value)) { currentProjectId = viewableProjects.Count > 0 ? viewableProjects.First().Entity.Id : 0; } UserContext.Project = ProjectManager.Get(currentProjectId); IEnumerable <Countersoft.Gemini.Commons.Entity.Version> versions = null; // get all versions that are released or not according to settings passed (BUT - NEVER show archived projects) versions = Cache.Versions.GetAll().Where(v => v.ProjectId == currentProjectId && v.Released == true && v.Archived == false).OrderBy(o => o.Sequence); if (versionId == 0) { VersionDto version = VersionManager.GetFirstChangeLogVersion(UserContext.Project.Entity.Id); if (version != null) { versionId = version.Entity.Id; } else { versionId = versions.Count() > 0 ? versions.First().Id : 0; } } Changelog.Models.ChangelogpAppModel model = BuildModelData(versionId, versions); model.ProjectList = new SelectList(viewableProjects, "Entity.Id", "Entity.Name", currentProjectId.GetValueOrDefault()); if (pageSettings == null) { pageSettings = new PageSettings(); } pageSettings.PageData.versionId = versionId; pageSettings.PageData.projectId = currentProjectId.GetValueOrDefault(); CurrentCard.Options[AppGuid] = pageSettings.ToJson(); return(new WidgetResult() { Success = true, Markup = new WidgetMarkup("views/Changelog.cshtml", model) }); }
public override WidgetResult Show(IssueDto issue = null) { var filter = IsSessionFilter() || CurrentCard.CardType != ProjectTemplatePageType.Custom && "app/projectAdmin/view".Equals(CurrentCard.Url, StringComparison.InvariantCultureIgnoreCase) ? HttpSessionManager.GetFilter(CurrentCard.Id, IssuesFilter.CreateProjectFilter(CurrentUser.Entity.Id, CurrentProject.Entity.Id)) : CurrentCard.Filter; HttpSessionManager.SetFilter(CurrentCard.Id, filter); int?currentProjectId = 0; HttpSessionManager.Set <List <UserIssuesView> >(null, Constants.ProjectAdminSessionView); // Safety check required because of http://gemini.countersoft.com/project/DEV/21/item/5088 PageSettings pageSettings = null; try { if (CurrentCard.Options.ContainsKey(AppGuid)) { pageSettings = CurrentCard.Options[AppGuid].FromJson <PageSettings>(); if (pageSettings.PageData != null) { currentProjectId = pageSettings.PageData.projectId; } } } catch (Exception ex) {} //If no project is selected, select the first workspace project. if ((!currentProjectId.HasValue || currentProjectId.Value == 0) && filter.Projects.HasValue()) { try { var workspaceProjects = filter.Projects.Split('|'); if (workspaceProjects.Count() > 0) { currentProjectId = Convert.ToInt32(workspaceProjects[0]); } } catch (Exception ex) { } } var viewableProjects = ProjectManager.GetAppViewableProjects(this).ToList(); //If you can't view the selected project, select first from viewable projects if (!viewableProjects.Any(s => s.Entity.Id == currentProjectId.Value)) { currentProjectId = viewableProjects.Count > 0 ? viewableProjects.First().Entity.Id : 0; } UserContext.Project = ProjectManager.Convert(Cache.Projects.Get(currentProjectId.Value)); ProjectAdminAppModel model = BuildModelData(); model.ProjectList = new SelectList(viewableProjects, "Entity.Id", "Entity.Name", currentProjectId.GetValueOrDefault()); if (pageSettings == null) { pageSettings = new PageSettings(); } pageSettings.PageData.projectId = currentProjectId.GetValueOrDefault(); CurrentCard.Options[AppGuid] = pageSettings.ToJson(); return(new WidgetResult() { Success = true, Markup = new WidgetMarkup("views/ProjectAdmin.cshtml", model) }); }
private void ProcessWatcherAlerts() { SchedulerSettings settings = _issueManager.UserContext.Config.SchedulerSettings.HasValue() ? _issueManager.UserContext.Config.SchedulerSettings.FromJson<SchedulerSettings>() : new SchedulerSettings(); DateTime lastChecked = settings.LastCheckedWatchers.HasValue ? settings.LastCheckedWatchers.Value : DateTime.UtcNow; IssuesFilter filter = new IssuesFilter(); filter.RevisedAfter = lastChecked.ToString(); filter.IncludeClosed = true; LogDebugMessage("Last checked for watched item alerts: " + lastChecked); List<IssueDto> issues = _issueManager.GetFiltered(filter); LogDebugMessage("Item that have changed: " + issues.Count); if (issues.Count > 0) ProcessWatchers(issues, lastChecked); settings.LastCheckedWatchers = DateTime.UtcNow; /*serviceManager.Admin.UpdateSchedulerSettings(settings);*/ IConfiguration configuration = GeminiApp.Container.Resolve<IConfiguration>(); GeminiConfiguration config = configuration.Get(); config.SchedulerSettings = settings.ToJson(); ConfigurationItem item = new ConfigurationItem(); item.SettingId = GeminiConfigurationOption.SchedulerSettings.ToString(); item.SettingValue = config.SchedulerSettings; configuration.Update(item); GeminiApp.RefreshConfig(config); }