Пример #1
0
        public ProjectGridRow[] GenerateProjectGridRows(ProjectStatusOnServer[] statusList, string forceBuildActionName,
		                                                ProjectGridSortColumn sortColumn, bool sortIsAscending, string categoryFilter,
                                                        ICruiseUrlBuilder urlBuilder, Translations translations)
        {
            ArrayList rows = new ArrayList();
            foreach (ProjectStatusOnServer statusOnServer in statusList)
            {
                ProjectStatus status = statusOnServer.ProjectStatus;
                IServerSpecifier serverSpecifier = statusOnServer.ServerSpecifier;
                DefaultProjectSpecifier projectSpecifier = new DefaultProjectSpecifier(serverSpecifier, status.Name);

                if ((categoryFilter != string.Empty) && (categoryFilter != status.Category))
                    continue;

                rows.Add(
                    new ProjectGridRow(status,
                                       serverSpecifier,
                                       urlBuilder.BuildProjectUrl(ProjectReportProjectPlugin.ACTION_NAME, projectSpecifier),
                                       urlBuilder.BuildProjectUrl(ProjectParametersAction.ActionName, projectSpecifier),
                                       translations));
            }

            rows.Sort(GetComparer(sortColumn, sortIsAscending));

            return (ProjectGridRow[]) rows.ToArray(typeof (ProjectGridRow));
        }
        public IResponse Execute(ICruiseRequest request)
        {
            var velocityContext = new Hashtable();
            this.translations = Translations.RetrieveCurrent();

            var projectStatus = farmService.GetProjectStatusListAndCaptureExceptions(request.RetrieveSessionToken());
            var urlBuilder = request.UrlBuilder;
            var category = request.Request.GetText("Category");

            var gridRows = this.projectGrid.GenerateProjectGridRows(projectStatus.StatusAndServerList, BaseActionName, 
                                                                    ProjectGridSortColumn.Category, true, 
                                                                    category, urlBuilder,this.translations);

            var categories = new SortedDictionary<string, CategoryInformation>();
           
            foreach (var row in gridRows)
            {
                var rowCategory = row.Category;
                CategoryInformation categoryRows;
                if (!categories.TryGetValue(rowCategory, out categoryRows))
                {
                    categoryRows = new CategoryInformation(rowCategory);
                    categories.Add(rowCategory, categoryRows);                    
                }

                categoryRows.AddRow(row);                
            }

            velocityContext["categories"] = categories.Values;          

            return viewGenerator.GenerateView("CategorizedFarmReport.vm", velocityContext);
        }
Пример #3
0
 public ProjectGridRow(ProjectStatus status, IServerSpecifier serverSpecifier,
     string url, string parametersUrl, Translations translations)
 {
     this.status = status;
     this.serverSpecifier = serverSpecifier;
     this.url = url;
     this.parametersUrl = parametersUrl;
 }
        public IResponse Execute(ICruiseRequest request)
        {
            var velocityContext = new Hashtable();
            this.translations = Translations.RetrieveCurrent();

            var projectStatus = farmService.GetProjectStatusListAndCaptureExceptions(request.RetrieveSessionToken());
            var urlBuilder = request.UrlBuilder;
            var category = request.Request.GetText("Category");

            var sessionToken = request.RetrieveSessionToken();
            velocityContext["forceBuildMessage"] = ForceBuildIfNecessary(request.Request, sessionToken);

            var gridRows = this.projectGrid.GenerateProjectGridRows(projectStatus.StatusAndServerList, BaseActionName,
                                                                    ProjectGridSortColumn.Category, true,
                                                                    category, urlBuilder, this.translations);

            var categories = new SortedDictionary<string, CategoryInformation>();

            foreach (var row in gridRows)
            {
                var rowCategory = row.Category;
                CategoryInformation categoryRows;
                if (!categories.TryGetValue(rowCategory, out categoryRows))
                {
                    categoryRows = new CategoryInformation(rowCategory);
                    categories.Add(rowCategory, categoryRows);
                }

                categoryRows.AddRow(row);
            }

            // there is a category specified via a link, so expand that category by default
            // it's annoying to specify a category and still have to press the show link
            if (!string.IsNullOrEmpty(category))
            {
                    categories[category].Display = true;
            }



            velocityContext["categories"] = categories.Values;

            return viewGenerator.GenerateView("CategorizedFarmReport.vm", velocityContext);
        }
		private HtmlFragmentResponse GenerateView(ProjectStatusListAndExceptions projectStatusListAndExceptions,
            string actionName, ICruiseRequest request, IServerSpecifier serverSpecifier)
		{
            this.translations = Translations.RetrieveCurrent();
            cruiseUrlBuilder = request.UrlBuilder;
            urlBuilder = request.UrlBuilder.InnerBuilder;
			Hashtable velocityContext = new Hashtable();
            velocityContext["forceBuildMessage"] = ForceBuildIfNecessary(request.Request);
            velocityContext["parametersCall"] = new ServerLink(cruiseUrlBuilder, new DefaultServerSpecifier("null"), string.Empty, ProjectParametersAction.ActionName).Url;

			velocityContext["wholeFarm"] = serverSpecifier == null ?  true : false;

			string category = request.Request.GetText("Category");
			velocityContext["showCategoryColumn"] = string.IsNullOrEmpty(category) ? true : false;

			ProjectGridSortColumn sortColumn = GetSortColumn(request.Request);
			bool sortReverse = SortAscending(request.Request);

			velocityContext["projectNameSortLink"] = GenerateSortLink(serverSpecifier, actionName, ProjectGridSortColumn.Name, sortColumn, sortReverse);
			velocityContext["buildStatusSortLink"] = GenerateSortLink(serverSpecifier, actionName, ProjectGridSortColumn.BuildStatus, sortColumn, sortReverse);
			velocityContext["lastBuildDateSortLink"] = GenerateSortLink(serverSpecifier, actionName, ProjectGridSortColumn.LastBuildDate, sortColumn, sortReverse);
			velocityContext["serverNameSortLink"] = GenerateSortLink(serverSpecifier, actionName, ProjectGridSortColumn.ServerName, sortColumn, sortReverse);
			velocityContext["projectCategorySortLink"] = GenerateSortLink(serverSpecifier, actionName, ProjectGridSortColumn.Category, sortColumn, sortReverse);

            ProjectGridRow[] projectGridRows = projectGrid.GenerateProjectGridRows(projectStatusListAndExceptions.StatusAndServerList, actionName, sortColumn, sortReverse, category, cruiseUrlBuilder, this.translations);

            velocityContext["projectGrid"] = projectGridRows;
			velocityContext["exceptions"] = projectStatusListAndExceptions.Exceptions;

            Array categoryList = this.GenerateCategoryList(projectGridRows);
            velocityContext["categoryList"] = categoryList;
            velocityContext["barAtTop"] = (this.SuccessIndicatorBarLocation == IndicatorBarLocation.Top) ||
                (this.SuccessIndicatorBarLocation == IndicatorBarLocation.TopAndBottom);
            velocityContext["barAtBottom"] = (this.SuccessIndicatorBarLocation == IndicatorBarLocation.Bottom) ||
                (this.SuccessIndicatorBarLocation == IndicatorBarLocation.TopAndBottom);

			return viewGenerator.GenerateView(@"ProjectGrid.vm", velocityContext);
		}
Пример #6
0
 public BuildGraph(IBuildSpecifier[] buildSpecifiers, ILinkFactory linkFactory, Translations translations)
 {
     mybuildSpecifiers = buildSpecifiers;
     mylinkFactory = linkFactory;
     this.translations = translations;
 }
Пример #7
0
 public GraphBuildDayInfo(GraphBuildInfo buildInfo, Translations translations)
 {
     this.translations = translations;
     myBuildDate = buildInfo.BuildDate();
     myBuilds = new List<GraphBuildInfo>();
     //myBuilds.Add(buildInfo);
     AddBuild(buildInfo);
 }
Пример #8
0
 /// <summary>
 /// Retrieves the current instance of the translations for a request.
 /// </summary>
 /// <returns>The <see cref="Translations"/> for the current request.</returns>
 public static Translations RetrieveCurrent()
 {
     var context = HttpContext.Current;
     if ((context == null) || (context.Items == null))
     {
         // Bypass for unit testing
         return new Translations();
     }
     else
     {
         if (context.Items.Contains("translations"))
         {
             // Return the existing translations instance
             return context.Items["translations"] as Translations;
         }
         else
         {
             // Start a new instance
             var value = new Translations();
             context.Items.Add("translations", value);
             return value;
         }
     }
 }
Пример #9
0
        /// <summary>
        /// Executes the action.
        /// </summary>
        /// <param name="cruiseRequest"></param>
        /// <returns></returns>
        public IResponse Execute(ICruiseRequest cruiseRequest)
        {
            this.translations = Translations.RetrieveCurrent();
            Hashtable velocityContext = new Hashtable();
            velocityContext["Error"] = string.Empty;
            if (ValidateSession(velocityContext))
            {
                // Initialise the default values
                velocityContext["Result"] = string.Empty;
                velocityContext["InstallPackage"] = string.Empty;

                // Retrieve the form values
                string action = cruiseRequest.Request.GetText("Action") ?? string.Empty;
                string type = cruiseRequest.Request.GetText("Type");
                string name = cruiseRequest.Request.GetText("Name");

                // Check to see if there is an action to perform
                if (action == this.translations.Translate("Reload dashboard"))
                {
                    CachingDashboardConfigurationLoader.ClearCache();
                    velocityContext["Result"] = this.translations.Translate("The dashboard configuration has been reloaded");
                }
                else if (action == string.Empty)
                {
                    // Do nothing, the user hasn't asked for anything but this is needed so the
                    // default doesn't display an error
                }
                else if (action == this.translations.Translate("Save"))
                {
                    SaveServer(cruiseRequest.Request, velocityContext);
                }
                else if (action == this.translations.Translate("Delete"))
                {
                    DeleteServer(cruiseRequest.Request, velocityContext);
                }
                else if (action == this.translations.Translate("Import"))
                {
                    ImportPackage(HttpContext.Current, velocityContext);
                }
                else if (action == this.translations.Translate("Install"))
                {
                    InstallPackage(cruiseRequest, velocityContext);
                }
                else if (action == this.translations.Translate("Uninstall"))
                {
                    UninstallPackage(cruiseRequest, velocityContext);
                }
                else if (action == this.translations.Translate("Remove"))
                {
                    RemovePackage(cruiseRequest, velocityContext);
                }
                else if (action == this.translations.Translate("Logout"))
                {
                    Logout();
                }
                else
                {
                    velocityContext["Error"] = this.translations.Translate("Unknown action '{0}'", action);
                }

                // Retrieve the services and packages
                velocityContext["Servers"] = servicesConfiguration.Servers;
                List<PackageManifest> packages = manager.ListPackages();
                packages.Sort();
                velocityContext["Packages"] = packages;

                // Generate the view
                if (action == "Logout")
                {
                    return viewGenerator.GenerateView("AdminLogin.vm", velocityContext);
                }
                else
                {
                    return viewGenerator.GenerateView("AdministerDashboard.vm", velocityContext);
                }
            }
            else
            {
                // Generate the view
                return viewGenerator.GenerateView("AdminLogin.vm", velocityContext);
            }
        }