-
Notifications
You must be signed in to change notification settings - Fork 1
ipc/network: refazer a comunicação entre worker/system-tray e implementar API HTTP #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
5b4c567
[Wip](Tray): Console e conexão Named Pipes. Erro de I/O
glauberx86 d1cf6dc
[Feat](Worker): Agora age como Server invés de Client
glauberx86 db6bdc7
[Feat](Tray): Conexão com Pipe e debug
glauberx86 1655c93
[Feat]: Integração tray + worker
glauberx86 c865df4
[Chore]: Configuração Inno Setup
glauberx86 f2983c8
[Feat](WebSocket): Conexão via WebSocket básica
glauberx86 2b8e07f
[Feat](API): Removido WebSocket e feito HTTP POST básico
glauberx86 b8019db
README
glauberx86 e7f5f71
[Feat](Instalador): Adicionado etapa de API no instalador (fixes: #3)
glauberx86 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,172 @@ | ||
| ; Script generated by the Inno Setup Script Wizard. | ||
| ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! | ||
| ; Non-commercial use only | ||
|
|
||
| #define MyAppName "AssetManager" | ||
| #define MyAppVersion "1.0.2" | ||
| #define MyAppPublisher "Borgno" | ||
| #define MyAppExeName "AssetManager.tray.exe" | ||
|
|
||
| [Setup] | ||
| ; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications. | ||
| ; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) | ||
| AppId={{8E2374B6-2EE6-4C3A-B17A-AF32C9565CB1} | ||
| AppName={#MyAppName} | ||
| AppVersion={#MyAppVersion} | ||
| ;AppVerName={#MyAppName} {#MyAppVersion} | ||
| AppPublisher={#MyAppPublisher} | ||
| DefaultDirName={autopf}\{#MyAppPublisher}\{#MyAppName} | ||
| DisableDirPage=yes | ||
| UninstallDisplayIcon={app}\{#MyAppExeName} | ||
| ; "ArchitecturesAllowed=x64compatible" specifies that Setup cannot run | ||
| ; on anything but x64 and Windows 11 on Arm. | ||
| ArchitecturesAllowed=x64compatible | ||
| ; "ArchitecturesInstallIn64BitMode=x64compatible" requests that the | ||
| ; install be done in "64-bit mode" on x64 or Windows 11 on Arm, | ||
| ; meaning it should use the native 64-bit Program Files directory and | ||
| ; the 64-bit view of the registry. | ||
| ArchitecturesInstallIn64BitMode=x64compatible | ||
| DefaultGroupName={#MyAppName} | ||
| DisableProgramGroupPage=yes | ||
| ; Uncomment the following line to run in non administrative install mode (install for current user only). | ||
| ;PrivilegesRequired=lowest | ||
| OutputDir=Output | ||
| OutputBaseFilename=assetmanager_installer | ||
| Compression=lzma | ||
| SolidCompression=yes | ||
| WizardStyle=modern dynamic windows11 | ||
|
|
||
| [Languages] | ||
| Name: "brazilianportuguese"; MessagesFile: "compiler:Languages\BrazilianPortuguese.isl" | ||
|
|
||
| [Files] | ||
| Source: "C:\Users\GYNTI-N03.GYNTI-N03\source\repos\AssetManager\AssetManager.tray\bin\Release\net10.0-windows\win-x64\*"; \ | ||
| DestDir: "{app}\tray"; Flags: ignoreversion; \ | ||
| Excludes: "appsettings.json, appsettings_example.json" | ||
|
|
||
| Source: "C:\Users\GYNTI-N03.GYNTI-N03\source\repos\AssetManager\AssetManager.service\bin\Release\net10.0-windows\win-x64\*"; \ | ||
| DestDir: "{app}\service"; Flags: ignoreversion | ||
|
|
||
| Source: "C:\Users\GYNTI-N03.GYNTI-N03\source\repos\AssetManager\AssetManager.tray\bin\Release\net10.0-windows\win-x64\appsettings_example.json"; \ | ||
| DestDir: "{app}\tray"; \ | ||
| DestName: "appsettings.json"; Flags: ignoreversion | ||
| ; NOTE: Don't use "Flags: ignoreversion" on any shared system files | ||
|
|
||
| ; [Icons] | ||
| ; Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" | ||
| ; Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}" | ||
|
|
||
| [Run] | ||
| Filename: "sc.exe"; \ | ||
| Parameters: "create AssetManager binPath= ""{app}\service\AssetManager.service.exe"" start= auto"; \ | ||
| Flags: runhidden | ||
|
|
||
| Filename: "sc.exe"; \ | ||
| Parameters: "start AssetManager"; \ | ||
| Flags: runhidden | ||
|
|
||
| Filename: "schtasks.exe"; \ | ||
| Parameters: "/create /f /sc onlogon /rl highest /ru SYSTEM /tn ""AssetManagerTray"" /tr ""\""{app}\tray\AssetManager.tray.exe\"" """; \ | ||
| Flags: runhidden | ||
|
|
||
| Filename: "powershell.exe"; \ | ||
| Parameters: "-ExecutionPolicy Bypass -Command ""$t = Get-ScheduledTask -TaskName 'AssetManagerTray'; $s = $t.Settings; $s.ExecutionTimeLimit = [TimeSpan]::Zero; $s.AllowStartIfOnBatteries = $true; $s.DontStopIfGoingOnBatteries = $true; Set-ScheduledTask -TaskName 'AssetManagerTray' -Settings $s"""; \ | ||
| Flags: runhidden | ||
|
|
||
| ; Iniciar o tray após a instalação | ||
| ;Filename: "{app}\tray\{#MyAppExeName}"; \ | ||
| ;Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; \ | ||
| ;Flags: postinstall skipifsilent | ||
|
|
||
| [UninstallRun] | ||
| ; Parar e remover serviço | ||
| Filename: "sc.exe"; Parameters: "stop AssetManager"; Flags: runhidden | ||
| Filename: "sc.exe"; Parameters: "delete AssetManager"; Flags: runhidden | ||
|
|
||
| ; Remover tarefa agendada | ||
| Filename: "schtasks.exe"; Parameters: "/end /tn ""AssetManagerTray"""; Flags: runhidden | ||
| Filename: "schtasks.exe"; Parameters: "/delete /f /tn ""AssetManagerTray""" ; Flags: runhidden | ||
|
|
||
| [Code] | ||
| var | ||
| TokenPage: TInputQueryWizardPage; | ||
|
|
||
| procedure InitializeWizard; | ||
| begin | ||
| TokenPage := CreateInputQueryPage(wpWelcome, | ||
| 'Configuração da API', 'Autenticação do Agente', | ||
| 'Insira a URL e o Token de acesso da API para que o AssetManager possa enviar os dados.'); | ||
| TokenPage.Add('URL da API:', False); | ||
| TokenPage.Add('API Token:', False); | ||
| end; | ||
|
|
||
| function ShouldSkipPage(PageID: Integer): Boolean; | ||
| begin | ||
| if (PageID = TokenPage.ID) and FileExists(ExpandConstant('{src}\appsettings.json')) then | ||
| Result := True | ||
| else | ||
| Result := False; | ||
| end; | ||
|
|
||
| procedure CurStepChanged(CurStep: TSetupStep); | ||
| var | ||
| JsonDestino: String; | ||
| JsonOrigem: String; | ||
| FileContentAnsi: AnsiString; | ||
| FileContentString: String; | ||
| UserUrl: String; | ||
| UserToken: String; | ||
| HouveAlteracao: Boolean; | ||
| begin | ||
| if CurStep = ssPostInstall then | ||
| begin | ||
| JsonDestino := ExpandConstant('{app}\tray\appsettings.json'); | ||
| JsonOrigem := ExpandConstant('{src}\appsettings.json'); | ||
| HouveAlteracao := False; | ||
|
|
||
| if FileExists(JsonOrigem) then | ||
| begin | ||
| Log('Arquivo appsettings.json encontrado na origem. Copiando...'); | ||
| if FileCopy(JsonOrigem, JsonDestino, False) then | ||
| Log('Configuração importada automaticamente.') | ||
| else | ||
| Log('Falha ao copiar configuração automática.'); | ||
| end | ||
|
|
||
| else | ||
| begin | ||
| if (TokenPage <> nil) then | ||
| begin | ||
| UserUrl := TokenPage.Values[0]; | ||
| UserToken := TokenPage.Values[1]; | ||
| end | ||
| else | ||
| begin | ||
| UserUrl := ''; | ||
| UserToken := ''; | ||
| end; | ||
| if FileExists(JsonDestino) then | ||
| begin | ||
| if LoadStringFromFile(JsonDestino, FileContentAnsi) then | ||
| begin | ||
| FileContentString := String(FileContentAnsi); | ||
| if (UserUrl <> '') and (StringChange(FileContentString, '{{URL}}', UserUrl) > 0) then | ||
| begin | ||
| HouveAlteracao := True; | ||
| Log('URL atualizada.'); | ||
| end; | ||
| if (UserToken <> '') and (StringChange(FileContentString, '{{TOKEN}}', UserToken) > 0) then | ||
| begin | ||
| HouveAlteracao := True; | ||
| Log('Token atualizado.'); | ||
| end; | ||
| if HouveAlteracao then | ||
| begin | ||
| SaveStringToFile(JsonDestino, AnsiString(FileContentString), False); | ||
| Log('Arquivo JSON salvo com sucesso.'); | ||
| end; | ||
| end; | ||
| end; | ||
| end; | ||
| end; | ||
| end; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,18 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk.Worker"> | ||
| <Project Sdk="Microsoft.NET.Sdk.Worker"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>net10.0</TargetFramework> | ||
| <TargetFramework>net10.0-windows</TargetFramework> | ||
| <Nullable>enable</Nullable> | ||
| <ImplicitUsings>enable</ImplicitUsings> | ||
| <SatelliteResourceLanguages>pt-BR</SatelliteResourceLanguages> | ||
| <UserSecretsId>dotnet-AssetManager-7dd1a0f1-3fce-4c35-bc7b-8f9a71a59f68</UserSecretsId> | ||
| <SelfContained>true</SelfContained> | ||
| <PublishSingleFile>false</PublishSingleFile> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.0" /> | ||
| <PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="10.0.0" /> | ||
| <PackageReference Include="System.Diagnostics.PerformanceCounter" Version="10.0.0" /> | ||
| </ItemGroup> | ||
| </Project> | ||
| </Project> |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| param( | ||
| [string]$PipeName = "asset-monitor-pipe", | ||
| [int]$IntervalSeconds = 2 | ||
| ) | ||
|
|
||
| while ($true) { | ||
| Clear-Host | ||
| Write-Host "AssetManager Debug ($(Get-Date))" | ||
| Write-Host "-------------------------------" | ||
|
|
||
| try { | ||
| $pipe = New-Object System.IO.Pipes.NamedPipeClientStream(".", $PipeName, [System.IO.Pipes.PipeDirection]::In) | ||
| $pipe.Connect(3000) | ||
|
|
||
| $reader = New-Object System.IO.StreamReader($pipe) | ||
| $json = $reader.ReadLine() | ||
|
|
||
| $reader.Close() | ||
| $pipe.Close() | ||
|
|
||
| $obj = $json | ConvertFrom-Json | ||
| $obj | Format-List | ||
| } | ||
| catch { | ||
| Write-Host "Erro ao ler pipe: $_" -ForegroundColor Red | ||
| } | ||
|
|
||
| Start-Sleep -Seconds $IntervalSeconds | ||
| } |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.