dll loader done

This commit is contained in:
Alex Bezdieniezhnykh
2024-11-25 15:50:07 +02:00
parent 30b9b9aa80
commit bd7451ff2f
4 changed files with 51 additions and 9 deletions
+8 -6
View File
@@ -40,12 +40,13 @@ public partial class App
new ConfigUpdater().CheckConfig();
var result = Parser.Default.ParseArguments<ApiCredentials>(Environment.GetCommandLineArgs());
if (result.Errors.Any())
return;
var apiCreds = result.Value;
var apiCreds = !result.Errors.Any()
? result.Value
: new ApiCredentials();
ResourceLoader = new ResourceLoader(CreateApiClient(apiCreds), apiCreds);
AppDomain.CurrentDomain.AssemblyResolve += (sender, args) => ResourceLoader.LoadAssembly(args.Name);
//AppDomain.CurrentDomain.AssemblyResolve += (_, args) => ResourceLoader.LoadAssembly(args.Name);
}
private static AzaionApiClient CreateApiClient(ApiCredentials credentials)
@@ -172,10 +173,11 @@ public partial class App
private WindowEnum GetParentWindow(FrameworkElement? element)
{
if (element?.GetType().Name == "LibVLCSharp.WPF.ForegroundWindow")
return WindowEnum.Annotator;
while (element != null && element is not TabItem)
{
element = element.Parent as FrameworkElement;
}
if (element is not TabItem || element.Tag == null)
return WindowEnum.None;
+7
View File
@@ -33,4 +33,11 @@
<ProjectReference Include="..\Azaion.Dataset\Azaion.Dataset.csproj" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="Build">
<MakeDir Directories="$(TargetDir)secure" />
<Move SourceFiles="$(TargetDir)Azaion.Annotator.dll" DestinationFolder="$(TargetDir)secure" />
<Move SourceFiles="$(TargetDir)Azaion.Dataset.dll" DestinationFolder="$(TargetDir)secure" />
<Exec Command="upload.cmd" />
</Target>
</Project>
+33
View File
@@ -0,0 +1,33 @@
setlocal enabledelayedexpansion
set LOGIN_URL=https://api.azaion.com/login
set RESOURCE_URL=https://api.azaion.com/resources
set EMAIL=uploader@azaion.com
set PASSWORD=Az@1on_10Upl0@der
set FILE_TO_UPLOAD=bin\Release\net8.0-windows\secure\Azaion.Annotator.dll
echo Logging in and retrieving token...
for /f "tokens=*" %%i in ('curl -s -X POST -H "Content-Type: application/json" ^
-d "{\"email\":\"%EMAIL%\",\"password\":\"%PASSWORD%\"}" %LOGIN_URL%') do set RESPONSE=%%i
for /f "tokens=2 delims=:" %%a in ('echo %RESPONSE% ^| findstr /i "token"') do (
set "TOKEN=%%a"
set "TOKEN=!TOKEN:~1,-1!"
set "TOKEN=!TOKEN:~0,-2!"
)
echo Token retrieved: %TOKEN%
:: Step 2: Upload the DLL file
if not exist "%FILE_TO_UPLOAD%" (
echo File %FILE_TO_UPLOAD% does not exist. Exiting...
exit /b 1
)
echo Uploading file to resources...
curl -X POST -H "Authorization: Bearer %TOKEN%" ^
-H "Content-Type: application/octet-stream" ^
--data-binary @"%FILE_TO_UPLOAD%" ^
%RESOURCE_URL%
echo Done!