Exemple #1
0
        private string getNugetExtraInfoHtml(NewNugetReportItem item)
        {
            if (item == null)
            {
                return("");
            }
            StringBuilder result = new StringBuilder();

            result.Append("<div class='extra-info-block'><table>");
            result.Append("<tr>");
            result.Append("<td class='t-label'>author: </td>");
            result.Append("<td class='t-value'>" + item.authors + "</td>");
            result.Append("</tr>");
            result.Append("<tr>");
            result.Append("<td class='t-label'>owner: </td>");
            result.Append("<td class='t-value'>" + item.owners + "</td>");
            result.Append("</tr>");
            if (item.projectUrl != null && item.projectUrl.Length > 0)
            {
                result.Append("<tr>");
                result.Append("<td class='t-label'>website: </td>");
                result.Append("<td class='t-value'>" + String.Format("<a href='{0}'>{0}</a>", item.projectUrl) + "</td>");
                result.Append("</tr>");
            }
            string nugetWebUrl = String.Format("https://www.nuget.org/packages/{0}", item.id);

            result.Append("<tr>");
            result.Append("<td class='t-label'>inspect: </td>");
            result.Append("<td class='t-value'>" + String.Format("<a href='{0}'>{0}</a>", nugetWebUrl) + "</td>");
            result.Append("</tr>");
            result.Append("</table></div>");
            return(result.ToString());
        }
Exemple #2
0
        // only add if it is newly downloaded
        public void AddNewNugetReportItem(Nuget nuget)
        {
            string key = nuget.GetFileName();

            if (newNugetHash.ContainsKey(key))
            {
                return;
            }
            NewNugetReportItem item = new NewNugetReportItem(nuget);

            newNugetHash[key] = item;
            newNugets.Add(item);
        }
Exemple #3
0
        // only update if was added to dict with above function
        public void UpdateNewNugetReportItem(Nuget nuget, XmlElement xMetadata)
        {
            string key = nuget.GetFileName();

            if (!newNugetHash.ContainsKey(key))
            {
                return;
            }
            NewNugetReportItem item = newNugetHash[key];

            item.authors    = GetElementValue(xMetadata, "authors");
            item.owners     = GetElementValue(xMetadata, "owners");
            item.projectUrl = GetElementValue(xMetadata, "projectUrl");
        }
Exemple #4
0
        private void GenerateReport()
        {
            NewNugetReportItemComparer comparer = new NewNugetReportItemComparer();

            newNugets.Sort(comparer);

            StringBuilder reportHtml = new StringBuilder();
            DateTime      timestamp  = DateTime.Now;

            reportHtml.Append("<html>");
            reportHtml.Append("<head>");
            reportHtml.Append(
                "<style>" +
                " html { background: #eee; } " +
                " * { font-family: 'Segoe UI', Sans-Serif; } " +
                ".nuget-item{" +
                " margin-bottom: 8px; padding: 8px; background: #fff; border-radius:3px; " +
                " box-shadow: 0 1px 3px rgba(0,0,0,0.15), 1px 1px 2px rgba(0,0,0,0.2); " +
                " transition: all 0.3s cubic-bezier(.25, .8, .25, 1); " +
                "} " +
                ".nuget-item:hover{" +
                " box-shadow: 0 4px 8px rgba(0,0,0,0.2), 1px 1px 3px rgba(0,0,0,0.3); " +
                "} " +
                ".id-ver-block{" +
                " display:inline-block; vertical-align: top; margin-right:24px; " +
                "} " +
                ".extra-info-block{" +
                " display:inline-block; vertical-align: top; " +
                "} " +
                " h2 {" +
                " margin-bottom:0; " +
                "} " +
                ".id {" +
                " font-weight:bold; " +
                "} " +
                ".version{" +
                " margin-left:20px; " +
                "} " +
                ".stage-path{" +
                " margin-left:10px; font-style:italic; " +
                "} " +
                ".timestamp{" +
                " margin-left:10px; margin-bottom:20px; font-style:italic; " +
                "} " +
                " td {" +
                " vertical-align:top; " +
                "} " +
                " .t-label {" +
                " color: #888; " +
                "} " +
                " .t-value {" +
                " color: #000; " +
                "} " +
                "</style>");
            reportHtml.Append("</head>");
            reportHtml.Append("<body>");
            reportHtml.Append("<h2>Downloaded Nugets</h2>");
            reportHtml.Append("<div class='stage-path'>" + mParams.stagingNugetPath + "</div>");
            reportHtml.Append("<div class='timestamp'>" + timestamp.ToString() + "</div>");
            if (newNugets.Count() <= 0)
            {
                reportHtml.Append("<div>No newly downloaded nugets!</div>");
            }
            else
            {
                string             previousId       = "";
                bool               openNugetItemDiv = false;
                NewNugetReportItem prevItem         = null;
                foreach (NewNugetReportItem item in newNugets)
                {
                    if (previousId != item.id)
                    {
                        if (openNugetItemDiv)
                        {
                            openNugetItemDiv = false;
                            reportHtml.Append("</div>");
                            reportHtml.Append(getNugetExtraInfoHtml(prevItem));
                            reportHtml.Append("</div>");
                        }
                        reportHtml.Append("<div class='nuget-item'>");
                        reportHtml.Append("<div class='id-ver-block'>");
                        reportHtml.Append("<div class='id'>" + item.id + "</div>");
                        openNugetItemDiv = true;
                        previousId       = item.id;
                    }
                    reportHtml.Append("<div class='version'>" + item.version + "</div>");
                    prevItem = item;
                }
                if (openNugetItemDiv)
                {
                    openNugetItemDiv = false;
                    reportHtml.Append("</div>");
                    reportHtml.Append(getNugetExtraInfoHtml(prevItem));
                    reportHtml.Append("</div>");
                }
            }
            reportHtml.Append("</body></html>");

            string reportName = "nugetdownloader-" + DateTime.Now.ToString("yyyy-M-dd--HHmmssff") + ".html";
            string reportPath = mParams.outputReportPath + reportName;

            File.WriteAllText(reportPath, reportHtml.ToString());
            WriteConsole("Report generated at " + reportPath);
            System.Diagnostics.Process.Start(@reportPath);
        }