Compare commits
30
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1041b21e96 | ||
|
|
96797141fa | ||
|
|
4ced92e3cc | ||
|
|
9b8c236ecf | ||
|
|
c7bb0fe543 | ||
|
|
2de68761af | ||
|
|
16806a90b9 | ||
|
|
800faf26ce | ||
|
|
a4623d1e60 | ||
|
|
6b2b6b3996 | ||
|
|
0998bf4b3f | ||
|
|
8a39d4a4b2 | ||
|
|
4edcac18eb | ||
|
|
36dc76f500 | ||
|
|
05154527db | ||
|
|
9732737d7d | ||
|
|
37d1057970 | ||
|
|
99407b6117 | ||
|
|
f01169b8fc | ||
|
|
536f0a6029 | ||
|
|
a5b19d112c | ||
|
|
2366863776 | ||
|
|
7237086810 | ||
|
|
fed8499119 | ||
|
|
48675b1291 | ||
|
|
451face0f3 | ||
|
|
b8ba273e0e | ||
|
|
80951ff41c | ||
|
|
45f318d8f2 | ||
|
|
1837e19968 |
@@ -10,7 +10,17 @@ jobs:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Compute next version
|
||||
id: versioning
|
||||
run: |
|
||||
latest="${{ vars.VERSION }}"
|
||||
next_version=$(echo "$latest" | awk -F. -v OFS=. '{$NF += 1 ; print}')
|
||||
echo "Next version: $next_version"
|
||||
echo "next_version=$next_version" >> $GITHUB_ENV
|
||||
|
||||
- name: Setup dotnet
|
||||
uses: actions/setup-dotnet@v3
|
||||
with:
|
||||
@@ -20,9 +30,15 @@ jobs:
|
||||
- name: Test with dotnet
|
||||
run: dotnet test --logger trx --results-directory "TestResults-${{ matrix.dotnet-version }}"
|
||||
- name: Build the package
|
||||
run: dotnet build
|
||||
run: dotnet build -p:Version=$next_version
|
||||
- name: Publish the package
|
||||
run: dotnet publish -p:PublishSingleFile=true --self-contained false --runtime win-x64
|
||||
- name: copy the release before compression
|
||||
run: cp -r /workspace/pi-ux-ce/Simpsons_generator/bin/Release/net8.0/win-x64/publish/ .
|
||||
- uses: montudor/action-zip@v1
|
||||
with:
|
||||
args: zip -qq -r Simpsons_generator.zip publish/
|
||||
#working-directory: path/to/work-dir
|
||||
- name: List all files
|
||||
run: |
|
||||
find /workspace/pi-ux-ce/Simpsons_generator/bin
|
||||
@@ -32,9 +48,42 @@ jobs:
|
||||
curl --user ${{ secrets.USERNAME_GITEA }}:${{ secrets.PASSWORD_GITEA }} -X DELETE \
|
||||
https://gitea.tryton.geeraert.eu/api/packages/pi-ux-ce/generic/Simpsons_generator/latest/Simpsons_generator.exe
|
||||
|
||||
- name: upload latest version
|
||||
- name: Delete existing latest version
|
||||
run: |
|
||||
curl --user ${{ secrets.USERNAME_GITEA }}:${{ secrets.PASSWORD_GITEA }} -X DELETE \
|
||||
https://gitea.tryton.geeraert.eu/api/packages/pi-ux-ce/generic/Simpsons_generator/latest/Simpsons_generator.zip
|
||||
|
||||
- name: upload latest zip version with version number
|
||||
run: |
|
||||
curl --user ${{ secrets.USERNAME_GITEA }}:${{ secrets.PASSWORD_GITEA }} \
|
||||
--upload-file Simpsons_generator.zip \
|
||||
https://gitea.tryton.geeraert.eu/api/packages/pi-ux-ce/generic/Simpsons_generator/$next_version/Simpsons_generator.zip
|
||||
|
||||
|
||||
- name: upload latest executable version with version number
|
||||
run: |
|
||||
curl --user ${{ secrets.USERNAME_GITEA }}:${{ secrets.PASSWORD_GITEA }} \
|
||||
--upload-file /workspace/pi-ux-ce/Simpsons_generator/bin/Release/net8.0/win-x64/publish/Simpsons_generator.exe \
|
||||
"https://gitea.tryton.geeraert.eu/api/packages/pi-ux-ce/generic/Simpsons_generator/$next_version/Simpsons_generator.exe"
|
||||
|
||||
|
||||
- name: upload latest zip version
|
||||
run: |
|
||||
curl --user ${{ secrets.USERNAME_GITEA }}:${{ secrets.PASSWORD_GITEA }} \
|
||||
--upload-file Simpsons_generator.zip \
|
||||
https://gitea.tryton.geeraert.eu/api/packages/pi-ux-ce/generic/Simpsons_generator/latest/Simpsons_generator.zip
|
||||
|
||||
|
||||
- name: upload latest executable version
|
||||
run: |
|
||||
curl --user ${{ secrets.USERNAME_GITEA }}:${{ secrets.PASSWORD_GITEA }} \
|
||||
--upload-file /workspace/pi-ux-ce/Simpsons_generator/bin/Release/net8.0/win-x64/publish/Simpsons_generator.exe \
|
||||
https://gitea.tryton.geeraert.eu/api/packages/pi-ux-ce/generic/Simpsons_generator/latest/Simpsons_generator.exe
|
||||
|
||||
|
||||
- name: update version in the variable
|
||||
run: |
|
||||
curl -X PUT -H "Content-Type: application/json" \
|
||||
--user ${{ secrets.USERNAME_GITEA }}:${{ secrets.PASSWORD_GITEA }} \
|
||||
https://gitea.tryton.geeraert.eu/api/v1/repos/pi-ux-ce/Simpsons_generator/actions/variables/VERSION \
|
||||
-d "{\"Value\":\"$next_version\"}"
|
||||
+67
-50
@@ -2,6 +2,7 @@
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Data.SQLite;
|
||||
using System.Net;
|
||||
using System.Runtime.InteropServices;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
|
||||
@@ -9,20 +10,29 @@ namespace Simpsons_generator;
|
||||
|
||||
class Program
|
||||
{
|
||||
/* public static void openit(string x) {
|
||||
System.Diagnostics.Process.Start("cmd", "/C start" + " " + x);
|
||||
}*/
|
||||
|
||||
public static readonly string folder_path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Simpsons_generator");
|
||||
public static readonly string filePath = Path.Combine(folder_path, "episodes-watched.csv");
|
||||
public static readonly string overrideBrowser = Path.Combine(folder_path, "overrideBrowser.xml");
|
||||
private static readonly string FolderPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Simpsons_generator");
|
||||
private static readonly string OverrideBrowser = Path.Combine(FolderPath, "overrideBrowser.xml");
|
||||
public static readonly string filePath = Path.Combine(FolderPath, "episodes-watched.csv");
|
||||
|
||||
|
||||
static SQLiteConnection CreateConnection()
|
||||
{
|
||||
|
||||
SQLiteConnection sqliteconn;
|
||||
|
||||
if (!(File.Exists($"{FolderPath}/database.db")))
|
||||
{
|
||||
Console.WriteLine("Creating database.db");
|
||||
using (var client = new WebClient())
|
||||
{
|
||||
client.DownloadFile("https://gitea.tryton.geeraert.eu//pi-ux-ce/Simpsons_generator/raw/branch/main/database.db", $"{FolderPath}/database.db");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Create a new database connection:
|
||||
var sqllitedatasource = $"Data Source={folder_path}/database.db;Version=3;New=True;Compress=True;";
|
||||
var sqllitedatasource = $"Data Source={FolderPath}/database.db;Version=3;New=True;Compress=True;";
|
||||
sqliteconn = new SQLiteConnection(sqllitedatasource);
|
||||
// Open the connection:
|
||||
try
|
||||
@@ -47,12 +57,13 @@ class Program
|
||||
// hack because of this: https://github.com/dotnet/corefx/issues/10361
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
Console.WriteLine("Using Windows");
|
||||
url = url.Replace("&", "^&");
|
||||
if (File.Exists(overrideBrowser))
|
||||
if (File.Exists(OverrideBrowser))
|
||||
{
|
||||
string browser_path = File.ReadAllText(overrideBrowser);
|
||||
Console.WriteLine("browser: "+browser_path);
|
||||
Process.Start(new ProcessStartInfo(browser_path, url) { CreateNoWindow = true });
|
||||
string browserPath = File.ReadAllText(OverrideBrowser);
|
||||
Console.WriteLine("browser: "+browserPath);
|
||||
Process.Start(new ProcessStartInfo(browserPath, url) { CreateNoWindow = true });
|
||||
}
|
||||
else {
|
||||
Process.Start(new ProcessStartInfo(url) { UseShellExecute = true });
|
||||
@@ -61,10 +72,21 @@ class Program
|
||||
}
|
||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
{
|
||||
Process.Start("xdg-open", url);
|
||||
Console.WriteLine("Using Linux");
|
||||
try
|
||||
{
|
||||
Process.Start("xdg-open", url);
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
||||
{
|
||||
Console.WriteLine("Using Mac");
|
||||
Process.Start("open", url);
|
||||
}
|
||||
else
|
||||
@@ -79,42 +101,16 @@ class Program
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static bool CheckEpisodeAlreadyRun(string url)
|
||||
static object RunSqlQuery(SQLiteConnection conn, string query)
|
||||
{
|
||||
if (File.Exists(filePath))
|
||||
SQLiteDataReader sqliteDatareader;
|
||||
SQLiteCommand sqliteCmd;
|
||||
sqliteCmd = conn.CreateCommand();
|
||||
sqliteCmd.CommandText = query;
|
||||
sqliteDatareader = sqliteCmd.ExecuteReader();
|
||||
if (sqliteDatareader.Read())
|
||||
{
|
||||
|
||||
|
||||
var linesRead = File.ReadLines(filePath);
|
||||
|
||||
// iterate through each element within the array and
|
||||
// print it out
|
||||
//
|
||||
foreach (var lineRead in linesRead)
|
||||
{
|
||||
if (lineRead == url)
|
||||
{
|
||||
Console.WriteLine("already watched");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
static object RunSQLQuery(SQLiteConnection conn, string query)
|
||||
{
|
||||
SQLiteDataReader sqlite_datareader;
|
||||
SQLiteCommand sqlite_cmd;
|
||||
sqlite_cmd = conn.CreateCommand();
|
||||
sqlite_cmd.CommandText = query;
|
||||
sqlite_datareader = sqlite_cmd.ExecuteReader();
|
||||
if (sqlite_datareader.Read())
|
||||
{
|
||||
return sqlite_datareader["result"];
|
||||
return sqliteDatareader["result"];
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -143,6 +139,27 @@ class Program
|
||||
|
||||
SQLiteConnection sqliteconn;
|
||||
sqliteconn = CreateConnection();
|
||||
|
||||
//check if the old excel exist and convert it to SQLLITE
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
Console.WriteLine("Excel file present");
|
||||
var linesRead = File.ReadLines(filePath);
|
||||
|
||||
foreach (var lineRead in linesRead)
|
||||
{
|
||||
Console.WriteLine(lineRead);
|
||||
string[] words = lineRead.Split('-');
|
||||
int season = Convert.ToInt16(words[3]);
|
||||
int episode = Convert.ToInt16(words[5]);
|
||||
SaveIntoDatabase(sqliteconn,season,episode);
|
||||
Console.WriteLine(season);
|
||||
Console.WriteLine(episode);
|
||||
|
||||
}
|
||||
System.IO.File.Move(filePath,filePath+"_converted.csv");
|
||||
}
|
||||
|
||||
bool restart = false;
|
||||
do
|
||||
{
|
||||
@@ -150,7 +167,7 @@ class Program
|
||||
|
||||
//get maximum number of seasons
|
||||
string maximumNumberOfSeasonsQuery = "SELECT COUNT(DISTINCT season) as result FROM episodes;";
|
||||
int maximumNumberSeasons = Convert.ToInt32(RunSQLQuery(sqliteconn, maximumNumberOfSeasonsQuery));
|
||||
int maximumNumberSeasons = Convert.ToInt32(RunSqlQuery(sqliteconn, maximumNumberOfSeasonsQuery));
|
||||
|
||||
|
||||
//random for the season
|
||||
@@ -161,19 +178,19 @@ class Program
|
||||
|
||||
//get maximum number of episodes for this season
|
||||
string maximumNumberOfEpisodesQuery = $"SELECT COUNT() as result FROM episodes WHERE season = {randomSeason};";
|
||||
int maximumNumberOfEpisodes = Convert.ToInt32(RunSQLQuery(sqliteconn, maximumNumberOfEpisodesQuery));
|
||||
int maximumNumberOfEpisodes = Convert.ToInt32(RunSqlQuery(sqliteconn, maximumNumberOfEpisodesQuery));
|
||||
|
||||
randomEpisode = rnd.Next(1, maximumNumberOfEpisodes);
|
||||
Console.WriteLine("random episode: "+randomEpisode);
|
||||
|
||||
//url generated
|
||||
string urlGeneratedQuery = $"SELECT url as result FROM episodes WHERE season = {randomSeason} and episode = {randomEpisode};";
|
||||
urlGenerated = Convert.ToString(RunSQLQuery(sqliteconn, urlGeneratedQuery));
|
||||
urlGenerated = Convert.ToString(RunSqlQuery(sqliteconn, urlGeneratedQuery));
|
||||
|
||||
|
||||
//CheckEpisodeAlreadyRun
|
||||
string checkEpisodeAlreadyRunQuery = $"SELECT seen as result FROM episodes WHERE season = {randomSeason} and episode = {randomEpisode};";
|
||||
bool checkEpisodeAlreadyRun = Convert.ToBoolean(RunSQLQuery(sqliteconn, checkEpisodeAlreadyRunQuery));
|
||||
bool checkEpisodeAlreadyRun = Convert.ToBoolean(RunSqlQuery(sqliteconn, checkEpisodeAlreadyRunQuery));
|
||||
|
||||
if (checkEpisodeAlreadyRun)
|
||||
{
|
||||
|
||||
Binary file not shown.
@@ -8,10 +8,12 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<ApplicationIcon>Simpson.ico</ApplicationIcon>
|
||||
<PublishSingleFile>true</PublishSingleFile>
|
||||
<PackAsTool>true</PackAsTool>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="Simpson.ico" />
|
||||
<PackageReference Include="System.Data.SQLite" Version="1.0.119" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user