update Program.cs
This commit is contained in:
parent
29c6217990
commit
d7b91d4dec
|
@ -58,7 +58,6 @@ internal static class Program
|
|||
private static Boolean _subscribedToQueue = false;
|
||||
private static Boolean _subscribeToQueueForTheFirstTime = false;
|
||||
private static SalimaxAlarmState _prevSalimaxState = SalimaxAlarmState.Green;
|
||||
//private static Int32 _heartBitInterval = 0;
|
||||
private const UInt16 NbrOfFileToConcatenate = 30;
|
||||
private static UInt16 _counterOfFile = 0;
|
||||
private static SalimaxAlarmState _salimaxAlarmState = SalimaxAlarmState.Green;
|
||||
|
@ -704,13 +703,13 @@ internal static class Program
|
|||
_counterOfFile = 0;
|
||||
|
||||
var logFileConcatenator = new LogFileConcatenator();
|
||||
var csvToSend = logFileConcatenator.ConcatenateFiles(NbrOfFileToConcatenate);
|
||||
|
||||
|
||||
var s3Path = timeStamp.ToUnixTime() + ".csv";
|
||||
s3Path.WriteLine("");
|
||||
var csvToSend = logFileConcatenator.ConcatenateFiles(NbrOfFileToConcatenate);
|
||||
|
||||
var request = s3Config.CreatePutRequest(s3Path);
|
||||
|
||||
"Sending to S3".WriteLine();
|
||||
|
||||
//Use this for no compression
|
||||
//var response = await request.PutAsync(new StringContent(csv));
|
||||
var compressedBytes = CompresseBytes(csvToSend);
|
||||
|
@ -729,34 +728,39 @@ internal static class Program
|
|||
Console.WriteLine("ERROR: PUT");
|
||||
var error = await response.GetStringAsync();
|
||||
Console.WriteLine(error);
|
||||
Heartbit(0);
|
||||
return false;
|
||||
}
|
||||
|
||||
Console.WriteLine("----------------------------------------Sending Heartbit----------------------------------------");
|
||||
|
||||
var s3Bucket = Config.Load().S3?.Bucket;
|
||||
int.TryParse(s3Bucket?.Split("-")[0], out var installationId);
|
||||
int.TryParse(timeStamp.ToUnixTime().ToString(), out var nameOfCsvFile);
|
||||
|
||||
var returnedStatus = new StatusMessage
|
||||
{
|
||||
InstallationId = installationId,
|
||||
Product = 0,
|
||||
Status = _salimaxAlarmState,
|
||||
Type = MessageType.Heartbit,
|
||||
Timestamp = nameOfCsvFile
|
||||
};
|
||||
|
||||
|
||||
if (s3Bucket != null)
|
||||
RabbitMqManager.InformMiddleware(returnedStatus);
|
||||
|
||||
Heartbit(timeStamp);
|
||||
}
|
||||
_counterOfFile++;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void Heartbit(DateTime timeStamp)
|
||||
{
|
||||
var s3Bucket = Config.Load().S3?.Bucket;
|
||||
int.TryParse(s3Bucket?.Split("-")[0], out var installationId);
|
||||
int.TryParse(timeStamp.ToUnixTime().ToString(), out var nameOfCsvFile);
|
||||
|
||||
var returnedStatus = new StatusMessage
|
||||
{
|
||||
InstallationId = installationId,
|
||||
Product = 0,
|
||||
Status = _salimaxAlarmState,
|
||||
Type = MessageType.Heartbit,
|
||||
Timestamp = nameOfCsvFile
|
||||
};
|
||||
|
||||
|
||||
if (s3Bucket != null)
|
||||
RabbitMqManager.InformMiddleware(returnedStatus);
|
||||
}
|
||||
|
||||
private static Byte[] CompresseBytes(String csvToSend)
|
||||
{
|
||||
//Compress CSV data to a byte array
|
||||
|
|
Loading…
Reference in New Issue