Ok testing message queue su redis!!!
This commit is contained in:
Generated
+551
-457
File diff suppressed because it is too large
Load Diff
+162
-136
@@ -9,141 +9,167 @@ using System.Windows.Forms;
|
||||
|
||||
namespace TestBench
|
||||
{
|
||||
public partial class MainForm : Form
|
||||
{
|
||||
public MainForm()
|
||||
public partial class MainForm : Form
|
||||
{
|
||||
InitializeComponent();
|
||||
myInitComponent();
|
||||
public MainForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
myInitComponent();
|
||||
}
|
||||
|
||||
private void myInitComponent()
|
||||
{
|
||||
// imposto folders
|
||||
txtSourceDir.Text = @"C:\TMP\";
|
||||
txtDestDir.Text = @"L:\TMP\";
|
||||
|
||||
lblHwSwData.Text = SteamWare.HwSwInfo.man(Assembly.GetExecutingAssembly()).librariesVers;
|
||||
|
||||
// reset conf CDV
|
||||
memLayer.ML.resetAppConf();
|
||||
}
|
||||
|
||||
private void BtnCopyAll_Click(object sender, EventArgs e)
|
||||
{
|
||||
// effettuo copia con steamware libs...
|
||||
string sourceDir = txtSourceDir.Text.Trim();
|
||||
string destDir = txtDestDir.Text.Trim();
|
||||
if (sourceDir != "" && destDir != "")
|
||||
{
|
||||
lblOutMessage.Text = "inizio copia...";
|
||||
lblOutMessage.Refresh();
|
||||
fileMover.DirectoryCopy(sourceDir, destDir, chkRecursive.Checked);
|
||||
lblOutMessage.Text = "Copia completata!";
|
||||
}
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
// apro selettore file...
|
||||
openFileDialog1.ShowDialog();
|
||||
}
|
||||
|
||||
private void openFileDialog1_FileOk(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
// prendo i files selezionati --> merge in pdf e indico quanti...
|
||||
List<string> elencoFiles = new List<string>();
|
||||
foreach (var item in openFileDialog1.FileNames)
|
||||
{
|
||||
elencoFiles.Add(item);
|
||||
}
|
||||
int numFiles = 0;
|
||||
string outPath = $"{Directory.GetCurrentDirectory()}\\{txtMergedName.Text}";
|
||||
try
|
||||
{
|
||||
numFiles = pdfUtils.mergePdfFiles(txtMergedName.Text, elencoFiles);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
lblNumMerged.Text = $"Effettuato merge di {numFiles} files!";
|
||||
}
|
||||
|
||||
private void button2_Click(object sender, EventArgs e)
|
||||
{
|
||||
string answ = "";
|
||||
try
|
||||
{
|
||||
answ = memLayer.ML.getRedisInfoData();
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
|
||||
lblRedis.Text = answ;
|
||||
}
|
||||
|
||||
private void btnResetCdv_Click(object sender, EventArgs e)
|
||||
{
|
||||
memLayer.ML.resetAppConf();
|
||||
}
|
||||
|
||||
private void btnShowCdv_Click(object sender, EventArgs e)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.AppendLine("----- REDIS CDV data -----");
|
||||
foreach (var item in memLayer.ML.AppConf)
|
||||
{
|
||||
sb.AppendLine($"{item.Key}: {item.Value}");
|
||||
}
|
||||
lblRedCDV.Text = sb.ToString();
|
||||
}
|
||||
|
||||
private void btnStartSched_Click(object sender, EventArgs e)
|
||||
{
|
||||
// avvia uno scheduler che apre una messagebox secondo programmazione impostata...
|
||||
|
||||
// For Interval in Minutes
|
||||
// This Scheduler will start at 22:00 and call after every 30 Minutes
|
||||
// IntervalInSeconds(start_hour, start_minute, minutes)
|
||||
|
||||
// calcolo istante dal PROSSIMO minuto
|
||||
DateTime avvio = DateTime.Now;
|
||||
lblStartTimer.Text = $"Avvio timer: {avvio:ddd yyyy-MM-dd HH:mm:ss}";
|
||||
avvio = avvio.AddMinutes(1).AddSeconds(-avvio.Second);
|
||||
lblNextSched.Text = $"Scadenza timer: {avvio:ddd yyyy-MM-dd HH:mm:ss}";
|
||||
|
||||
clockTimer.Start();
|
||||
|
||||
// calcolo periodo in minuti guardando quanto selezionato
|
||||
int ore = 0;
|
||||
int min = 0;
|
||||
int sec = 0;
|
||||
int.TryParse(txtOre.Text, out ore);
|
||||
int.TryParse(txtMin.Text, out min);
|
||||
int.TryParse(txtSec.Text, out sec);
|
||||
// calcolo
|
||||
double intSecondi = ore * 60 * 60 + min * 60 + sec;
|
||||
|
||||
TaskSched.IntervalInSeconds(avvio.Hour, avvio.Minute, intSecondi,
|
||||
() =>
|
||||
{
|
||||
DateTime adesso = DateTime.Now;
|
||||
|
||||
// Initializes the variables to pass to the MessageBox.Show method.
|
||||
string message = $"E' scattato il timer alle ore {DateTime.Now}.";
|
||||
string caption = "Timer Elapsed";
|
||||
MessageBoxButtons buttons = MessageBoxButtons.OK;
|
||||
DialogResult result;
|
||||
|
||||
//lblNextSched.Text = $"Scadenza timer: {adesso.AddSeconds(intSecondi):ddd yyyy-MM-dd HH:mm:ss}";
|
||||
// Displays the MessageBox.
|
||||
result = MessageBox.Show(message, caption, buttons);
|
||||
});
|
||||
}
|
||||
|
||||
private void clockTimer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
DateTime adesso = DateTime.Now;
|
||||
lblClock.Text = $"Clock: {adesso:ddd yyyy-MM-dd HH:mm:ss}";
|
||||
|
||||
updateQueue();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Aggiorno da lettura coda...
|
||||
/// </summary>
|
||||
private void updateQueue()
|
||||
{
|
||||
// leggo da coda
|
||||
SteamWare.IO.Redis myRedis = new SteamWare.IO.Redis();
|
||||
string myKey = "testQueue";
|
||||
if (myRedis.ListLen(myKey) > 0)
|
||||
{
|
||||
// aggiorno coda
|
||||
lblQueueRead.Text = $"{myRedis.ListPop(myKey)}{Environment.NewLine}{lblQueueRead.Text}";
|
||||
}
|
||||
}
|
||||
|
||||
private void btnSend_Click(object sender, EventArgs e)
|
||||
{
|
||||
// pubblico su coda...
|
||||
SteamWare.IO.Redis myRedis = new SteamWare.IO.Redis();
|
||||
string myKey = "testQueue";
|
||||
myRedis.ListPush(myKey, $"{DateTime.Now} | {txtQueueMessage.Text.Trim()}");
|
||||
txtQueueMessage.Text = "";
|
||||
}
|
||||
}
|
||||
|
||||
private void myInitComponent()
|
||||
{
|
||||
// imposto folders
|
||||
txtSourceDir.Text = @"C:\TMP\";
|
||||
txtDestDir.Text = @"L:\TMP\";
|
||||
|
||||
lblHwSwData.Text = SteamWare.HwSwInfo.man(Assembly.GetExecutingAssembly()).librariesVers;
|
||||
|
||||
// reset conf CDV
|
||||
memLayer.ML.resetAppConf();
|
||||
}
|
||||
|
||||
private void BtnCopyAll_Click(object sender, EventArgs e)
|
||||
{
|
||||
// effettuo copia con steamware libs...
|
||||
string sourceDir = txtSourceDir.Text.Trim();
|
||||
string destDir = txtDestDir.Text.Trim();
|
||||
if (sourceDir != "" && destDir != "")
|
||||
{
|
||||
lblOutMessage.Text = "inizio copia...";
|
||||
lblOutMessage.Refresh();
|
||||
fileMover.DirectoryCopy(sourceDir, destDir, chkRecursive.Checked);
|
||||
lblOutMessage.Text = "Copia completata!";
|
||||
}
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
// apro selettore file...
|
||||
openFileDialog1.ShowDialog();
|
||||
}
|
||||
|
||||
private void openFileDialog1_FileOk(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
// prendo i files selezionati --> merge in pdf e indico quanti...
|
||||
List<string> elencoFiles = new List<string>();
|
||||
foreach (var item in openFileDialog1.FileNames)
|
||||
{
|
||||
elencoFiles.Add(item);
|
||||
}
|
||||
int numFiles = 0;
|
||||
string outPath = $"{Directory.GetCurrentDirectory()}\\{txtMergedName.Text}";
|
||||
try
|
||||
{
|
||||
numFiles = pdfUtils.mergePdfFiles(txtMergedName.Text, elencoFiles);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
lblNumMerged.Text = $"Effettuato merge di {numFiles} files!";
|
||||
}
|
||||
|
||||
private void button2_Click(object sender, EventArgs e)
|
||||
{
|
||||
string answ = "";
|
||||
try
|
||||
{
|
||||
answ = memLayer.ML.getRedisInfoData();
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
|
||||
lblRedis.Text = answ;
|
||||
}
|
||||
|
||||
private void btnResetCdv_Click(object sender, EventArgs e)
|
||||
{
|
||||
memLayer.ML.resetAppConf();
|
||||
}
|
||||
|
||||
private void btnShowCdv_Click(object sender, EventArgs e)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.AppendLine("----- REDIS CDV data -----");
|
||||
foreach (var item in memLayer.ML.AppConf)
|
||||
{
|
||||
sb.AppendLine($"{item.Key}: {item.Value}");
|
||||
}
|
||||
lblRedCDV.Text = sb.ToString();
|
||||
}
|
||||
|
||||
private void btnStartSched_Click(object sender, EventArgs e)
|
||||
{
|
||||
// avvia uno scheduler che apre una messagebox secondo programmazione impostata...
|
||||
|
||||
// For Interval in Minutes
|
||||
// This Scheduler will start at 22:00 and call after every 30 Minutes
|
||||
// IntervalInSeconds(start_hour, start_minute, minutes)
|
||||
|
||||
// calcolo istante dal PROSSIMO minuto
|
||||
DateTime avvio = DateTime.Now;
|
||||
lblStartTimer.Text = $"Avvio timer: {avvio:ddd yyyy-MM-dd HH:mm:ss}";
|
||||
avvio = avvio.AddMinutes(1).AddSeconds(-avvio.Second);
|
||||
lblNextSched.Text = $"Scadenza timer: {avvio:ddd yyyy-MM-dd HH:mm:ss}";
|
||||
|
||||
clockTimer.Start();
|
||||
|
||||
// calcolo periodo in minuti guardando quanto selezionato
|
||||
int ore = 0;
|
||||
int min = 0;
|
||||
int sec = 0;
|
||||
int.TryParse(txtOre.Text, out ore);
|
||||
int.TryParse(txtMin.Text, out min);
|
||||
int.TryParse(txtSec.Text, out sec);
|
||||
// calcolo
|
||||
double intSecondi = ore * 60 * 60 + min * 60 + sec;
|
||||
|
||||
TaskSched.IntervalInSeconds(avvio.Hour, avvio.Minute, intSecondi,
|
||||
() =>
|
||||
{
|
||||
DateTime adesso = DateTime.Now;
|
||||
|
||||
// Initializes the variables to pass to the MessageBox.Show method.
|
||||
string message = $"E' scattato il timer alle ore {DateTime.Now}.";
|
||||
string caption = "Timer Elapsed";
|
||||
MessageBoxButtons buttons = MessageBoxButtons.OK;
|
||||
DialogResult result;
|
||||
|
||||
lblNextSched.Text = $"Scadenza timer: {adesso.AddSeconds(intSecondi):ddd yyyy-MM-dd HH:mm:ss}";
|
||||
// Displays the MessageBox.
|
||||
result = MessageBox.Show(message, caption, buttons);
|
||||
});
|
||||
}
|
||||
|
||||
private void clockTimer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
DateTime adesso = DateTime.Now;
|
||||
lblClock.Text = $"Clock: {adesso:ddd yyyy-MM-dd HH:mm:ss}";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user