Rimozione proj transfer (riportato in proj orig)

This commit is contained in:
Samuele Locatelli
2024-10-02 17:00:35 +02:00
parent 190f9ba22c
commit a33b9c4bd4
16 changed files with 0 additions and 615 deletions
-36
View File
@@ -134,22 +134,6 @@ stages:
# --------------------------------
# BUILD
# --------------------------------
Transfer:build:
stage: build
tags:
- win
except:
- EgwAppControlCenter
variables:
SOL_NAME: LiMan
APP_NAME: LiMan.Transfer
before_script:
- *nuget-fix
- dotnet restore "$env:SOL_NAME.sln"
script:
- dotnet build $env:APP_NAME/$env:APP_NAME.csproj
EgwProxy.LiMan:build:
stage: build
tags:
@@ -171,26 +155,6 @@ EgwProxy.LiMan:build:
# --------------------------------
# DEPLOY
# --------------------------------
Transfer:deploy:
stage: deploy
tags:
- win
except:
- EgwAppControlCenter
variables:
SOL_NAME: LiMan
APP_NAME: LiMan.Transfer
needs: ["Transfer:build"]
before_script:
- *nuget-fix
script:
- dotnet build $env:APP_NAME/$env:APP_NAME.csproj
- dotnet publish -p:PublishProfile=SingleFileX86.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release $env:APP_NAME/$env:APP_NAME.csproj
- *zipper
- *hashBuild
- *nexusUpload
EgwProxy.LiMan:deploy:
stage: deploy
needs: ["EgwProxy.LiMan:build"]
-36
View File
@@ -1,36 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<None Include="..\.editorconfig" Link=".editorconfig" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NLog" Version="5.3.2" />
<PackageReference Include="RestSharp" Version="106.15.0" />
<PackageReference Include="RestSharp.Serializers.NewtonsoftJson" Version="106.15.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Core\Core.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="logs\.placeholder">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="NLog.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="powershell.exe -ExecutionPolicy Unrestricted -NoProfile -NonInteractive -File $(ProjectDir)\post-build.ps1 -ProjectDir $(ProjectDir) -ProjectPath $(ProjectPath)" />
</Target>
</Project>
-39
View File
@@ -1,39 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
autoReload="true"
throwExceptions="false"
internalLogLevel="Off" internalLogFile="c:\temp\nlog-internal.log">
<variable name="logDir" value="${basedir}/logs"/>
<targets>
<target xsi:type="File"
name="f_base"
fileName="${logDir}/${shortdate}.log"
layout="${longdate} [${uppercase:${level}}] ${logger:shortName=true}|${message}"
archiveFileName="${logDir}/${shortdate}.{###}.zip"
archiveNumbering="Sequence"
archiveAboveSize="10240000"
maxArchiveFiles="60"
enableArchiveFileCompression="false"
keepFileOpen="false"
/>
<target xsi:type="File"
name="f_error"
fileName="${logDir}/${shortdate}.log"
layout="${longdate} [${uppercase:${level}}] ${logger:shortName=true}|${message}${newline}${exception:format=tostring}"
archiveFileName="${logDir}/${shortdate}.{###}.zip"
archiveNumbering="Sequence"
archiveAboveSize="10240000"
maxArchiveFiles="60"
enableArchiveFileCompression="false"
keepFileOpen="false"
/>
</targets>
<rules>
<!-- Logging Levels (Trace, Debug, Info, Warn, Error, Fatal)-->
<logger name="*" minlevel="Trace" maxlevel="Warn" final="true" writeTo="f_base" />
<logger name="*" minlevel="Error" writeTo="f_error" />
</rules>
</nlog>
-206
View File
@@ -1,206 +0,0 @@
using Core;
using LiMan.Transfer;
using Newtonsoft.Json;
using NLog;
using RestSharp;
using RestSharp.Serializers.NewtonsoftJson;
using System;
using System.Diagnostics;
using static Core.Enum;
namespace MyApp // Note: actual namespace depends on the project name.
{
internal class Program
{
protected static string dataFolder = "";
protected static string archFolder = "";
protected static string reqName = "request.json";
protected static int numDayKeep = 30;
protected static string apiUrl = "https://liman.egalware.com/ELM.Api/";
/// <summary>
/// Classe logger
/// </summary>
public static Logger lg = LogManager.GetCurrentClassLogger();
static void Main(string[] args)
{
string myLine = "--------------------------------------";
logInfo(myLine);
logInfo("LiMan data transfer");
logInfo(myLine);
//verifico di avere parametro x directory con contenuto...
if (args == null || args.Count() < 2)
{
logError("Warning: Missing args !!!");
logError("");
logError("Syntax: LiMan.Transfer.exe data_folder archive_folder");
logError("data_folder: path to container for request.json file + *.zip file(s) to upload");
logError("archive_folder: where to put trasferred data");
logError("");
}
else
{
// verifico primo parametro
dataFolder = args[0];
archFolder = args[1];
if (!Directory.Exists(dataFolder))
{
logError("Error! data directory not found. Exiting");
}
else
{
// quella archivio se non ci fosse la creo
if (!Directory.Exists(archFolder))
{
Directory.CreateDirectory(archFolder);
}
// cerco il file di conf x invio
string fileName = Path.Combine(dataFolder, reqName);
if (!File.Exists(fileName))
{
logError("Missing conf file!");
}
else
{
// deserializzo conf
logInfo($"Found file {fileName}");
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
bool fatto = callTicketAndUpload(fileName);
TimeSpan ts = stopWatch.Elapsed;
if (fatto)
{
logInfo($"Upload done, {ts.TotalSeconds:0.000} sec");
}
else
{
logError($"Error in upload, {ts.TotalSeconds:0.000} sec");
}
cleanupArchive();
}
}
}
}
private static void cleanupArchive()
{
logInfo("Start Archive cleanup");
DateTime oggi = DateTime.Today;
var candidates = Directory.GetDirectories(archFolder);
foreach (var folder in candidates)
{
var currDir = new DirectoryInfo(folder);
if (currDir.CreationTime < oggi.AddDays(-numDayKeep))
{
Directory.Delete(folder, true);
logInfo($"Folder deleted: {folder}");
}
}
logInfo("Archive cleanup done!");
}
private static bool callTicketAndUpload(string fileName)
{
bool fatto = false;
try
{
// client chiamate rest
var client = new RestClient(apiUrl);
client.UseNewtonsoftJson();
SupportRequest? newSuppReq = new SupportRequest();
string rawData = "";
if (File.Exists(fileName))
{
rawData = File.ReadAllText(fileName);
}
if (!string.IsNullOrEmpty(rawData))
{
// fare: composizione richiesta da parametri chiave
newSuppReq = JsonConvert.DeserializeObject<SupportRequest>(rawData);
}
else
{
string hostName = utils.machineName;
string listIP = string.Join(", ", utils.machineIp);
// genero il ticket
newSuppReq = new SupportRequest()
{
CodApp = "Uploader",
CodImp = "",
CodInst = "EgalWare",
ContactEmail = "info@egalware.com",
ContactName = "Utente Generico",
ContactPhone = "035-460560",
MasterKey = "4AIc8fMEXcSyDIMl1Ro05O/1xar7nrVHXAQzrh/fmxfvlczA13tQwXAqida6hTqV",
ReqBody = $"File Upload - MISSING license file | machine: {utils.machineName} | IP: {listIP}",
Tipo = TipologiaTicket.FileUpload,
idxSubLic = 0
};
}
if (newSuppReq == null)
{
logError("Error: support request conf is null! cannot proceed");
}
else
{
var ticketReq = new RestRequest("/api/ticket/sendReq", DataFormat.Json).AddJsonBody(newSuppReq);
var pUpd = Task.Run(async () =>
{
var ticketResp = await client.PostAsync<TicketDTO>(ticketReq);
logInfo($"Received ticket {ticketResp.idxTicket}");
// preparo richiesta x upload file
var fileUploadReq = new RestRequest("/api/filesave/single");
fileUploadReq.AddParameter("ticketId", ticketResp.idxTicket);
// cerco OGNI file zip nella folder indicata...
var fileList = Directory.GetFiles(dataFolder, "*.zip");
foreach (var file in fileList)
{
fileUploadReq.AddFile("file", file);
// ... infine INVIA file zip che li contiene...
var fileUploadResp = await client.PostAsync<UploadResult>(fileUploadReq);
logInfo($"Upload {file} completed!");
fileUploadReq.Files.Clear();
}
//var fileUploadResp = client.Post(fileUploadReq);
logInfo($"Uploaded {fileList.Count()} files");
// sposto folder in area archivio...
string destFolder = Path.Combine(archFolder, $"{DateTime.Now:yyyyMMdd_HHmmss}");
Directory.Move(dataFolder, destFolder);
logInfo($"Requested folder archived in {destFolder}");
fatto = true;
});
pUpd.Wait();
}
}
catch (Exception exc)
{
logError($"Eccezione in fase gestione REST services{Environment.NewLine}{exc}");
}
return fatto;
}
protected static void logInfo(string message)
{
lg.Info(message);
Console.WriteLine(message);
}
protected static void logError(string message)
{
lg.Error(message);
Console.WriteLine($"!!! {message}");
}
}
}
-57
View File
@@ -1,57 +0,0 @@
# LiMan.Transfer: Applicativo FIle Upload su LiMan
Sintassi
```
LiMan.Transfer.exe data_folder archive_folder
- data_folder: path to container for request.json file + *.zip file(s) to upload
- archive_folder: where to put trasferred data
```
L'applicativo si occupa delal fase di
* generazione ticket richiesta invio
* invio singoli files ZIP su piattaforma
E' necessario chiamarlo indicando 2 parametri:
* folder da trasferire
* deve contenere request.json
* deve contenere da 1+ files *.zip da inviare
* eventuali altri files saranno ignorati
* folder di archiviazione (i files inviati saranno mantenuti li per 30 gg)
## File request.json
Per effettuare l'invio è necessario sia presente nella foller richiesta, oltre ai files zip da inviare, un file json denominato **request.json** così strutturato
```json
{
"CodApp": "Uploader",
"CodImp": "",
"CodInst": "EgalWare",
"ContactEmail": "info@egalware.com",
"ContactName": "Utente",
"ContactPhone": "035-460560",
"IdxSubLic": 0,
"MasterKey": "4AIc8fMEXcSyDIMl1Ro05O/1xar7nrVHXAQzrh/fmxfvlczA13tQwXAqida6hTqV",
"ReqBody": "Upload da sendlog di EGT BeamWall",
"Tipo": 2
}
```
Descrizione campi
Campo | Tipo | Descrizione
---------|----------|----------
CodApp | STR | Nome dell'applicativo da LiMan (es Uploader, MAPO, GPW, STATS, EBW-UP)
CodImp | STR | Codice di impiego (user), lasciare ""
CodInst | STR | Codice del cliente, oppure EgalWare se invio "per applicativo"
ContactEmail | STR | email del richiedente
ContactName | STR | nome del richiedente
ContactPhone | STR | telefono cui contattare il richiedente
IdxSubLic | INT | Codice subLicenza (user) lasciare 0
MasterKey | STR | Chiave licenza associata ad applicazione x comunicazione protetta, può essere unica x ogni TIPO di applicativo o a scelta x cliente/installazione. Ha una scadenza da LiMan
ReqBody | STR | Testo della richiesta, tipicamente popolato da utente tramite form oppure dal SW se invio in automatico ad evento
Tipo | INT | Lasciare fisso 2 (= file upload)
Binary file not shown.
@@ -1,27 +0,0 @@
<body>
<i>License Manager</i>
<h4>Versione: {{CURRENT-REL}}</h4>
<br />
Note di rilascio:
<ul>
<li>
<b>Ultime modifiche:</b>
<ul>{{LAST-CHANGES}}</ul>
</li>
<li>
<b>v.1.* &rarr;</b>
<ul>
<li>Prima release dotnet5</li>
<li>Integrazione EFCore</li>
</ul>
</li>
</ul>
<div>
<div style="float: left;">
<img src="logoSteamware.png" />
</div>
<div style="float: right;">
<a href="https://www.steamware.net/" target="_blank">&copy; Steamware 2006-2021</a>
</div>
</div>
</body>
-27
View File
@@ -1,27 +0,0 @@
<body>
<i>License Manager</i>
<h4>Versione: 1.1.2410.0211</h4>
<br />
Note di rilascio:
<ul>
<li>
<b>Ultime modifiche:</b>
<ul>{{LAST-CHANGES}}</ul>
</li>
<li>
<b>v.1.* &rarr;</b>
<ul>
<li>Prima release dotnet5</li>
<li>Integrazione EFCore</li>
</ul>
</li>
</ul>
<div>
<div style="float: left;">
<img src="logoSteamware.png" />
</div>
<div style="float: right;">
<a href="https://www.steamware.net/" target="_blank">&copy; Steamware 2006-2021</a>
</div>
</div>
</body>
-1
View File
@@ -1 +0,0 @@
1.1.2410.0211
Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

@@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>1.0.0.0</version>
<url>https://nexus.steamware.net/repository/SWS/{{DIRNAME}}/{{BRANCHNAME}}/{{PACKNAME}}.zip</url>
<changelog>https://nexus.steamware.net/repository/SWS/{{DIRNAME}}/{{BRANCHNAME}}/ChangeLog.html</changelog>
<mandatory>false</mandatory>
</item>
-7
View File
@@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>1.1.2410.0211</version>
<url>https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/LiMan.Transfer.zip</url>
<changelog>https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>
</item>
-75
View File
@@ -1,75 +0,0 @@
using static Core.Enum;
namespace Core
{
public class TicketDTO
{
#region Public Properties
/// <summary>
/// Codice univoco della sub licenza (opzionale)
/// </summary>
public string codImpiego { get; set; } = "";
/// <summary>
/// Contatto email del cliente richiedente
/// </summary>
public string contactEmail { get; set; } = "";
/// <summary>
/// Contatto del cliente richiedente
/// </summary>
public string contactName { get; set; } = "";
/// <summary>
/// Contatto telefonico del cliente richiedente
/// </summary>
public string contactPhone { get; set; } = "";
public DateTime dtReq { get; set; } = DateTime.Now;
/// <summary>
/// IDX licenza master
/// </summary>
public int idxLic { get; set; } = 0;
/// <summary>
/// IDX licenza child (opzionale)
/// </summary>
public int idxSubLic { get; set; } = 0;
public int idxTicket { get; set; } = 0;
/// <summary>
/// Motivazione della richiesta
/// </summary>
public string reqBody { get; set; } = "";
/// <summary>
/// Stato richiesta
/// </summary>
public StatoRichiesta status { get; set; } = StatoRichiesta.ND;
/// <summary>
/// Risposta alla richiesta
/// </summary>
public string supplAnsw { get; set; } = "";
/// <summary>
/// Email del responsabile dell'azione (interno - supplier)
/// </summary>
public string supplEmail { get; set; } = "";
/// <summary>
/// Cod dell'user responsabile dell'azione (interno - supplier)
/// </summary>
public string supplUserCode { get; set; } = "";
/// <summary>
/// Tipologia di licenza gestita
/// </summary>
public TipoLicenza tipo { get; set; } = TipoLicenza.UserKey;
#endregion Public Properties
}
}
-1
View File
@@ -1 +0,0 @@

-32
View File
@@ -1,32 +0,0 @@
param([string]$ProjectDir, [string]$ProjectPath);
$FileMajMin = "..\MajMin.vers"
$FileVers = "Resources\VersNum.txt"
$FileManIn = "Resources\manifest-original.xml"
$FileManOut = "Resources\manifest.xml"
$FileCLogIn = "Resources\ChangeLog-original.html"
$FileCLogOut = "Resources\ChangeLog.html"
$MajMin = Get-Content $FileMajMin # "6.14."
$currentDate = get-date -format yyMM;
$currentTime = get-date -format ddHH;
$find = "<Version>(.|\n)*?</Version>";
$currRelNum = $MajMin + $currentDate +"." + $currentTime
$replace = "<Version>" + $MajMin + $currentDate +"." + $currentTime + "</Version>";
$csproj = Get-Content $ProjectPath
$csprojUpdated = $csproj -replace $find, $replace
Set-Content -Path $ProjectPath -Value $csprojUpdated
Set-Content -Path $FileVers -Value $currRelNum
# replace x manifest
$manData = Get-Content $FileManIn
$manData = $manData -replace "1.0.0.0", $currRelNum
$manData = $manData -replace "{{DIRNAME}}", "LiMan"
$manData = $manData -replace "{{BRANCHNAME}}", "stable/LAST"
$manData = $manData -replace "{{PACKNAME}}", "LiMan.Transfer"
Set-Content -Path $FileManOut -Value $manData
# replace x ChangeLog
$clogData = Get-Content $FileCLogIn
$clogData = $clogData -replace "{{CURRENT-REL}}", $currRelNum
Set-Content -Path $FileCLogOut -Value $clogData
-64
View File
@@ -1,64 +0,0 @@
using NLog;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
namespace LiMan.Transfer
{
public class utils
{
/// <summary>
/// Classe logger
/// </summary>
public static Logger lg = LogManager.GetCurrentClassLogger();
/// <summary>
/// Effettua logging INFO corretto impostanto anche la variabile IOB prima di scrivere...
/// </summary>
/// <param name="txt2log"></param>
public static void lgInfo(string txt2log)
{
lg.Info(txt2log);
}
/// <summary>
/// Effettua logging ERROR corretto impostanto anche la variabile IOB prima di scrivere...
/// </summary>
/// <param name="txt2log"></param>
public static void lgError(string txt2log)
{
lg.Error(txt2log);
}
public static string machineName
{
get
{
return Dns.GetHostName();
}
}
public static List<string> machineIp
{
get
{
List<string> ipList = new List<string>();
try
{
IPAddress[] ipAddresses = Dns.GetHostAddresses(machineName);
foreach (var ip in ipAddresses)
{
ipList.Add($"{ip}");
}
}
catch (Exception exc)
{
// Machine not found...
lgError($"Eccezione in recupero MachineIp{Environment.NewLine}{exc}");
}
return ipList;
}
}
}
}