private async Task AddStatistic(SqlConnection con, PackageResult package) { const string sql = @"MERGE dbo.PackageStatistics AS t USING ( SELECT @name as 'Name', @latestSupportType as 'LatestSupportType' ) AS s ON t.Name = s.Name WHEN MATCHED THEN UPDATE SET LatestSupportType = s.LatestSupportType, [Count] = [Count] + 1 WHEN NOT MATCHED THEN INSERT (Name, LatestSupportType, Count) VALUES (s.Name, s.LatestSupportType, 1);"; try { using (var cmd = new SqlCommand(sql, con)) { cmd.Parameters.AddWithValue("@name", package.PackageName); cmd.Parameters.AddWithValue("@latestSupportType", package.SupportType.ToString()); await cmd.ExecuteNonQueryAsync(); } } catch (Exception ex) { Log.Logger.Error(ex, "Exception writing statistic {stat}", package.PackageName); } }
internal static void Format(StringBuilder sb, PackageResult result) { sb.Append(result.PackageName).Append(" "); switch (result.SupportType) { case SupportType.NotFound: sb.Append("[Not Found]"); break; case SupportType.Supported: sb.Append("[Supported]"); break; case SupportType.PreRelease: sb.Append("[Supported (Pre-Release)]"); break; case SupportType.Unsupported: sb.Append("[Unsupported]"); break; case SupportType.KnownReplacementAvailable: sb.Append("[Known Replacement Available]"); break; case SupportType.InvestigationTarget: sb.Append("[Your Project]"); break; case SupportType.Error: sb.Append(result.Error); break; default: throw new ArgumentException(); } if (result.MoreInformation.Some) { var info = result.MoreInformation.Value; if (info.Message != null) sb.Append(" ").Append(info.Message); if (info.Url != null) { sb.Append(" - "); if (info.LinkText != null) sb.Append(info.LinkText).Append(": "); sb.Append(info.Url); } } sb.AppendLine(); }
private static string GetResultColour(PackageResult result) { switch (result.SupportType) { case SupportType.NotFound: return "#E0E0E0"; // Grey case SupportType.Supported: return "#A5D6A7"; // green case SupportType.PreRelease: return "#80CBC4"; case SupportType.Unsupported: return "#FFCC80"; // orange case SupportType.KnownReplacementAvailable: return "#81D4FA"; //blue case SupportType.InvestigationTarget: return "#B39DDB"; // purple case SupportType.Error: return "#ef9a9a"; // red default: return "#FAFAFA"; // B&W } }
public static string Format(PackageResult result) { var allResults = result.GetDependenciesResursive().Distinct().ToArray(); return Format(allResults, result.PackageName); }