mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Add import of new company logos.
This commit is contained in:
@@ -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");
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.0</TargetFramework>
|
||||
<Version>3.0.99.143</Version>
|
||||
<Version>3.0.99.148</Version>
|
||||
<Company>Canary Islands Computer Museum</Company>
|
||||
<Copyright>Copyright © 2003-2018 Natalia Portillo</Copyright>
|
||||
<Product>Canary Islands Computer Museum Website</Product>
|
||||
|
||||
0
cicm_web/wwwroot/assets/incoming/.donotremove
Normal file
0
cicm_web/wwwroot/assets/incoming/.donotremove
Normal file
Reference in New Issue
Block a user