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 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); }