diff --git a/cicm_web/Program.cs b/cicm_web/Program.cs index 9bbeabab..448cc49c 100644 --- a/cicm_web/Program.cs +++ b/cicm_web/Program.cs @@ -124,6 +124,12 @@ namespace cicm_web Console.WriteLine("\u001b[31;1mRendering new country flags...\u001b[0m"); SvgRender.RenderCountries(); DateTime end = DateTime.Now; + Console.WriteLine("\u001b[31;1mTook \u001b[32;1m{0} seconds\u001b[31;1m...\u001b[0m", + (end - start).TotalSeconds); + start = DateTime.Now; + Console.WriteLine("\u001b[31;1mImporting company logos...\u001b[0m"); + SvgRender.ImportCompanyLogos(); + end = DateTime.Now; Console.WriteLine("\u001b[31;1mTook \u001b[32;1m{0} seconds\u001b[31;1m...\u001b[0m", (end - start).TotalSeconds); Console.WriteLine("\u001b[31;1mStarting web server...\u001b[0m"); diff --git a/cicm_web/SvgRender.cs b/cicm_web/SvgRender.cs index dcb40591..6843c6a2 100644 --- a/cicm_web/SvgRender.cs +++ b/cicm_web/SvgRender.cs @@ -1,6 +1,8 @@ using System; using System.IO; +using Cicm.Database.Schemas; using SkiaSharp; +using Console = System.Console; using SKSvg = SkiaSharp.Extended.Svg.SKSvg; namespace cicm_web @@ -71,5 +73,34 @@ namespace cicm_web } } } + + public static void ImportCompanyLogos() + { + if(!Directory.Exists("wwwroot/assets/incoming")) return; + + foreach(string file in Directory.GetFiles("wwwroot/assets/incoming", "company_*.svg", + SearchOption.TopDirectoryOnly)) + { + string filename = Path.GetFileNameWithoutExtension(file); + + if(!filename.StartsWith("company_")) continue; + + string[] pieces = filename.Split('_'); + + if(pieces.Length != 3) continue; + + Guid guid = Guid.NewGuid(); + + if(!int.TryParse(pieces[1], out int companyId)) continue; + + if(!int.TryParse(pieces[2], out int year)) continue; + + CompanyLogo entry = new CompanyLogo {CompanyId = companyId, Year = year, Guid = guid}; + + if(!Program.Database.Operations.AddCompanyLogo(entry, out _)) continue; + + File.Move(file, $"wwwroot/assets/logos/{guid}.svg"); + } + } } } \ No newline at end of file diff --git a/cicm_web/cicm_web.csproj b/cicm_web/cicm_web.csproj index 3e88690d..b736a441 100644 --- a/cicm_web/cicm_web.csproj +++ b/cicm_web/cicm_web.csproj @@ -2,7 +2,7 @@ netcoreapp2.0 - 3.0.99.143 + 3.0.99.148 Canary Islands Computer Museum Copyright © 2003-2018 Natalia Portillo Canary Islands Computer Museum Website diff --git a/cicm_web/wwwroot/assets/flags/countries/.donotremove b/cicm_web/wwwroot/assets/flags/countries/.donotremove new file mode 100644 index 00000000..e69de29b diff --git a/cicm_web/wwwroot/assets/incoming/.donotremove b/cicm_web/wwwroot/assets/incoming/.donotremove new file mode 100644 index 00000000..e69de29b