Time to go
99d83a027ed620318df9cedcb56c9b68894dd9fb
4 files changed
src/OpenKamer.LogicControllers/EntityController.cssrc/OpenKamer.LogicControllers/FeedController.cssrc/OpenKamer.WinForm/Form1.Designer.cssrc/OpenKamer.WinForm/Form1.cs
diff --git a/src/OpenKamer.LogicControllers/EntityController.cs b/src/OpenKamer.LogicControllers/EntityController.cs
index 83f9784..67680d3 100644
--- a/src/OpenKamer.LogicControllers/EntityController.cs
+++ b/src/OpenKamer.LogicControllers/EntityController.cs
@@ -24,18 +24,21 @@ public class EntityController
private readonly IMongoDatabase mongodb;
private readonly string FilesDirectory;
- public string SkipToken { get; set; }
- public int FileCount { get; set; }
+ public string Token { get; set; }
+ public int FilesTotal { get; set; }
+ public int FilesIndex { get; set; }
public int EntityCount { get; set; }
public int Error { get; set; }
- public EntityController(string MongoConnectionString, string MongoDbName, string FilesDirectory, string skiptoken)
+ public event EventHandler? OnLog;
+
+ public EntityController(string MongoConnectionString, string MongoDbName, string FilesDirectory, string token)
{
this.FilesDirectory = FilesDirectory;
- this.SkipToken = skiptoken;
+ this.Token = token;
- this.FileCount = 0;
+ this.FilesIndex = 0;
this.EntityCount = 0;
@@ -46,9 +49,6 @@ public class EntityController
this.mongodb = mongoClient.GetDatabase(MongoDbName);
}
-
- public event EventHandler? OnLog;
-
private void Log(string message)
{
OnLog?.Invoke(message, new EventArgs());
@@ -56,20 +56,26 @@ public class EntityController
async public Task DecodeEntriesAsync(CancellationToken cancellationToken)
{
+ Log($"MongoDB.MvcCore.BsonJsonSerializer: {typeof(BsonJsonSerializer).Assembly.GetName().Version}");
+
Log("DecodeEntriesAsync");
XmlSerializer serializer = new(typeof(Feed));
- if (string.IsNullOrWhiteSpace(SkipToken))
- SkipToken = "0";
+ if (string.IsNullOrWhiteSpace(Token))
+ Token = "0";
- do
- {
- await Task.Delay(100, cancellationToken);
+ var list = Directory
+ .GetFiles(this.FilesDirectory, "*.xml")
+ .Select(x => Path.GetFileNameWithoutExtension(x))
+ .ToList();
- this.FileCount++;
+ this.FilesTotal = list.Count;
+ this.FilesIndex = list.IndexOf(this.Token);
- var FileName = FilesDirectory + @"\" + SkipToken + ".xml";
+ do
+ {
+ var FileName = FilesDirectory + @"\" + Token + ".xml";
using StreamReader reader = new(FileName);
@@ -102,11 +108,15 @@ public class EntityController
return;
}
if (intI > 0)
- SkipToken = nextNode.Href[(intI + 10)..];
+ Token = nextNode.Href[(intI + 10)..];
await ProcessEntitiesAsync(feed, cancellationToken);
- } while (!string.IsNullOrWhiteSpace(SkipToken));
+ this.FilesIndex++;
+
+ await Task.Delay(100, cancellationToken);
+
+ } while (!string.IsNullOrWhiteSpace(Token));
Log("Abnormal empty skiptoken exit");
}
diff --git a/src/OpenKamer.LogicControllers/FeedController.cs b/src/OpenKamer.LogicControllers/FeedController.cs
index 3ed069a..08c8d69 100644
--- a/src/OpenKamer.LogicControllers/FeedController.cs
+++ b/src/OpenKamer.LogicControllers/FeedController.cs
@@ -5,6 +5,7 @@
// https://opendata.tweedekamer.nl/documentatie/syncfeed-api
//
+using MongoDB.MvcCore;
using System.Xml.Linq;
namespace OpenKamer.LogicControllers;
@@ -13,12 +14,12 @@ public class FeedController
{
private static readonly string FEED = "https://gegevensmagazijn.tweedekamer.nl/SyncFeed/2.0/";
- private string DB = @"\\192.168.28.195\f$\gegevensmagazijn";
+ private string FilesDirectory;
- public FeedController(string DB, string skipToken)
+ public FeedController(string FilesDirectory, string Token)
{
- this.DB = DB;
- this.SkipToken = skipToken;
+ this.FilesDirectory = FilesDirectory;
+ this.Token = Token;
this.Status = string.Empty;
}
@@ -26,9 +27,11 @@ public class FeedController
public string Status { get; set; }
- public string SkipToken { get; set; }
+ public string Token { get; set; }
- public int FileCount { get; set; }
+ public int FilesTotal { get; set; }
+
+ public int FilesIndex { get; set; }
private void Log(string message)
{
@@ -37,6 +40,8 @@ public class FeedController
async public Task SyncFeedAsync(CancellationToken cancellationToken)
{
+ Log($"MongoDB.MvcCore.BsonJsonSerializer: {typeof(BsonJsonSerializer).Assembly.GetName().Version}");
+
Log("SyncFeedAsync");
HttpClient httpclient = new();
@@ -47,19 +52,26 @@ public class FeedController
string? urlFeed = FEED;
- this.FileCount = 0;
+ if (string.IsNullOrWhiteSpace(Token) == false)
+ urlFeed += "?skiptoken=" + this.Token;
+
+ if (string.IsNullOrWhiteSpace(this.Token))
+ this.Token = "0";
+
+ var list = Directory
+ .GetFiles(this.FilesDirectory, "*.xml")
+ .Select(x => Path.GetFileNameWithoutExtension(x))
+ .ToList();
- if (string.IsNullOrWhiteSpace(SkipToken) == false)
- urlFeed += "?skiptoken=" + this.SkipToken;
+ this.FilesTotal = list.Count;
+ this.FilesIndex = list.IndexOf(this.Token);
- if (string.IsNullOrWhiteSpace(this.SkipToken))
- this.SkipToken = "0";
+ list.Clear();
+ GC.Collect();
do
{
- this.FileCount++;
-
- var FileName = DB + @"\" + this.SkipToken + ".xml";
+ var FileName = FilesDirectory + @"\" + this.Token + ".xml";
if (File.Exists(FileName))
{
@@ -75,6 +87,7 @@ public class FeedController
}
using var textReader = File.OpenText(FileName);
+
xDoc = await XDocument.LoadAsync(textReader, LoadOptions.None, cancellationToken);
var links = xDoc.Descendants(ns + "link");
@@ -110,9 +123,11 @@ public class FeedController
return;
}
- this.SkipToken = urlFeed[(intI + 10)..];
+ this.Token = urlFeed[(intI + 10)..];
+
+ this.FilesIndex++;
- } while (!string.IsNullOrWhiteSpace(this.SkipToken));
+ } while (!string.IsNullOrWhiteSpace(this.Token));
Log("Abnormal empty skiptoken exit");
}
diff --git a/src/OpenKamer.WinForm/Form1.Designer.cs b/src/OpenKamer.WinForm/Form1.Designer.cs
index ebcf2ed..4ac2187 100644
--- a/src/OpenKamer.WinForm/Form1.Designer.cs
+++ b/src/OpenKamer.WinForm/Form1.Designer.cs
@@ -33,30 +33,32 @@
this.button2 = new System.Windows.Forms.Button();
this.ButtonStop = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
- this.txtSkipToken = new System.Windows.Forms.TextBox();
+ this.txtToken = new System.Windows.Forms.TextBox();
this.txtMongoConnectionString = new System.Windows.Forms.TextBox();
- this.txtDbFileSystem = new System.Windows.Forms.TextBox();
+ this.txtFilesDirectory = new System.Windows.Forms.TextBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
- this.lblSpeed = new System.Windows.Forms.Label();
- this.lblErrors = new System.Windows.Forms.Label();
- this.label8 = new System.Windows.Forms.Label();
- this.lblCount = new System.Windows.Forms.Label();
- this.label5 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.txtDbName = new System.Windows.Forms.TextBox();
+ this.lblSpeed = new System.Windows.Forms.Label();
+ this.lblErrors = new System.Windows.Forms.Label();
+ this.label8 = new System.Windows.Forms.Label();
+ this.lblIndex = new System.Windows.Forms.Label();
+ this.lblStatus = new System.Windows.Forms.Label();
+ this.label5 = new System.Windows.Forms.Label();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.timer2 = new System.Windows.Forms.Timer(this.components);
- this.labelStatus = new System.Windows.Forms.Label();
this.progressBar1 = new System.Windows.Forms.ProgressBar();
+ this.lblDuration = new System.Windows.Forms.Label();
+ this.label6 = new System.Windows.Forms.Label();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// button1
//
- this.button1.Location = new System.Drawing.Point(143, 50);
+ this.button1.Location = new System.Drawing.Point(137, 22);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(94, 23);
this.button1.TabIndex = 0;
@@ -66,7 +68,7 @@
//
// button2
//
- this.button2.Location = new System.Drawing.Point(243, 50);
+ this.button2.Location = new System.Drawing.Point(237, 22);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(94, 23);
this.button2.TabIndex = 2;
@@ -77,7 +79,7 @@
// ButtonStop
//
this.ButtonStop.Enabled = false;
- this.ButtonStop.Location = new System.Drawing.Point(255, 187);
+ this.ButtonStop.Location = new System.Drawing.Point(249, 162);
this.ButtonStop.Name = "ButtonStop";
this.ButtonStop.Size = new System.Drawing.Size(94, 23);
this.ButtonStop.TabIndex = 16;
@@ -100,104 +102,54 @@
this.textBox1.Size = new System.Drawing.Size(306, 243);
this.textBox1.TabIndex = 1;
//
- // txtSkipToken
+ // txtToken
//
- this.txtSkipToken.Location = new System.Drawing.Point(67, 50);
- this.txtSkipToken.Name = "txtSkipToken";
- this.txtSkipToken.Size = new System.Drawing.Size(70, 23);
- this.txtSkipToken.TabIndex = 3;
+ this.txtToken.Location = new System.Drawing.Point(61, 22);
+ this.txtToken.Name = "txtToken";
+ this.txtToken.Size = new System.Drawing.Size(70, 23);
+ this.txtToken.TabIndex = 3;
//
// txtMongoConnectionString
//
- this.txtMongoConnectionString.Location = new System.Drawing.Point(69, 80);
+ this.txtMongoConnectionString.Location = new System.Drawing.Point(63, 52);
this.txtMongoConnectionString.Name = "txtMongoConnectionString";
this.txtMongoConnectionString.Size = new System.Drawing.Size(268, 23);
this.txtMongoConnectionString.TabIndex = 4;
this.txtMongoConnectionString.Text = "mongodb://127.0.0.1:27017";
//
- // txtDbFileSystem
+ // txtFilesDirectory
//
- this.txtDbFileSystem.Location = new System.Drawing.Point(69, 138);
- this.txtDbFileSystem.Name = "txtDbFileSystem";
- this.txtDbFileSystem.Size = new System.Drawing.Size(268, 23);
- this.txtDbFileSystem.TabIndex = 5;
- this.txtDbFileSystem.Text = "d:\\gegevensmagazijn";
+ this.txtFilesDirectory.Location = new System.Drawing.Point(63, 110);
+ this.txtFilesDirectory.Name = "txtFilesDirectory";
+ this.txtFilesDirectory.Size = new System.Drawing.Size(268, 23);
+ this.txtFilesDirectory.TabIndex = 5;
+ this.txtFilesDirectory.Text = "d:\\gegevensmagazijn";
//
// groupBox1
//
this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
- this.groupBox1.Controls.Add(this.lblSpeed);
- this.groupBox1.Controls.Add(this.lblErrors);
- this.groupBox1.Controls.Add(this.label8);
- this.groupBox1.Controls.Add(this.lblCount);
- this.groupBox1.Controls.Add(this.label5);
this.groupBox1.Controls.Add(this.label4);
this.groupBox1.Controls.Add(this.label3);
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Controls.Add(this.txtDbName);
this.groupBox1.Controls.Add(this.txtMongoConnectionString);
- this.groupBox1.Controls.Add(this.txtDbFileSystem);
+ this.groupBox1.Controls.Add(this.txtFilesDirectory);
this.groupBox1.Controls.Add(this.button1);
this.groupBox1.Controls.Add(this.button2);
- this.groupBox1.Controls.Add(this.txtSkipToken);
+ this.groupBox1.Controls.Add(this.txtToken);
this.groupBox1.Location = new System.Drawing.Point(12, 12);
this.groupBox1.Name = "groupBox1";
- this.groupBox1.Size = new System.Drawing.Size(342, 169);
+ this.groupBox1.Size = new System.Drawing.Size(342, 144);
this.groupBox1.TabIndex = 6;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "settings";
//
- // lblSpeed
- //
- this.lblSpeed.AutoSize = true;
- this.lblSpeed.Location = new System.Drawing.Point(273, 22);
- this.lblSpeed.Name = "lblSpeed";
- this.lblSpeed.Size = new System.Drawing.Size(16, 15);
- this.lblSpeed.TabIndex = 15;
- this.lblSpeed.Text = "...";
- //
- // lblErrors
- //
- this.lblErrors.AutoSize = true;
- this.lblErrors.Location = new System.Drawing.Point(173, 22);
- this.lblErrors.Name = "lblErrors";
- this.lblErrors.Size = new System.Drawing.Size(16, 15);
- this.lblErrors.TabIndex = 14;
- this.lblErrors.Text = "...";
- //
- // label8
- //
- this.label8.AutoSize = true;
- this.label8.Location = new System.Drawing.Point(126, 22);
- this.label8.Name = "label8";
- this.label8.Size = new System.Drawing.Size(40, 15);
- this.label8.TabIndex = 13;
- this.label8.Text = "Errors:";
- //
- // lblCount
- //
- this.lblCount.AutoSize = true;
- this.lblCount.Location = new System.Drawing.Point(69, 22);
- this.lblCount.Name = "lblCount";
- this.lblCount.Size = new System.Drawing.Size(16, 15);
- this.lblCount.TabIndex = 12;
- this.lblCount.Text = "...";
- //
- // label5
- //
- this.label5.AutoSize = true;
- this.label5.Location = new System.Drawing.Point(22, 22);
- this.label5.Name = "label5";
- this.label5.Size = new System.Drawing.Size(43, 15);
- this.label5.TabIndex = 11;
- this.label5.Text = "Count:";
- //
// label4
//
this.label4.AutoSize = true;
- this.label4.Location = new System.Drawing.Point(23, 53);
+ this.label4.Location = new System.Drawing.Point(17, 25);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(38, 15);
this.label4.TabIndex = 10;
@@ -206,7 +158,7 @@
// label3
//
this.label3.AutoSize = true;
- this.label3.Location = new System.Drawing.Point(6, 141);
+ this.label3.Location = new System.Drawing.Point(0, 113);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(58, 15);
this.label3.TabIndex = 9;
@@ -215,7 +167,7 @@
// label2
//
this.label2.AutoSize = true;
- this.label2.Location = new System.Drawing.Point(9, 112);
+ this.label2.Location = new System.Drawing.Point(3, 84);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(55, 15);
this.label2.TabIndex = 8;
@@ -224,7 +176,7 @@
// label1
//
this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(10, 83);
+ this.label1.Location = new System.Drawing.Point(4, 55);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(54, 15);
this.label1.TabIndex = 7;
@@ -232,12 +184,66 @@
//
// txtDbName
//
- this.txtDbName.Location = new System.Drawing.Point(69, 109);
+ this.txtDbName.Location = new System.Drawing.Point(63, 81);
this.txtDbName.Name = "txtDbName";
this.txtDbName.Size = new System.Drawing.Size(268, 23);
this.txtDbName.TabIndex = 6;
this.txtDbName.Text = "tweedekamer";
//
+ // lblSpeed
+ //
+ this.lblSpeed.AutoSize = true;
+ this.lblSpeed.Location = new System.Drawing.Point(183, 166);
+ this.lblSpeed.Name = "lblSpeed";
+ this.lblSpeed.Size = new System.Drawing.Size(16, 15);
+ this.lblSpeed.TabIndex = 15;
+ this.lblSpeed.Text = "...";
+ //
+ // lblErrors
+ //
+ this.lblErrors.AutoSize = true;
+ this.lblErrors.Location = new System.Drawing.Point(149, 166);
+ this.lblErrors.Name = "lblErrors";
+ this.lblErrors.Size = new System.Drawing.Size(16, 15);
+ this.lblErrors.TabIndex = 14;
+ this.lblErrors.Text = "...";
+ //
+ // label8
+ //
+ this.label8.AutoSize = true;
+ this.label8.Location = new System.Drawing.Point(103, 166);
+ this.label8.Name = "label8";
+ this.label8.Size = new System.Drawing.Size(40, 15);
+ this.label8.TabIndex = 13;
+ this.label8.Text = "Errors:";
+ //
+ // lblIndex
+ //
+ this.lblIndex.AutoSize = true;
+ this.lblIndex.Location = new System.Drawing.Point(57, 166);
+ this.lblIndex.Name = "lblIndex";
+ this.lblIndex.Size = new System.Drawing.Size(16, 15);
+ this.lblIndex.TabIndex = 12;
+ this.lblIndex.Text = "...";
+ //
+ // lblStatus
+ //
+ this.lblStatus.AutoSize = true;
+ this.lblStatus.Location = new System.Drawing.Point(57, 194);
+ this.lblStatus.Name = "lblStatus";
+ this.lblStatus.Size = new System.Drawing.Size(16, 15);
+ this.lblStatus.TabIndex = 17;
+ this.lblStatus.Text = "...";
+ //
+ // label5
+ //
+ this.label5.AutoSize = true;
+ this.label5.Location = new System.Drawing.Point(16, 166);
+ this.label5.Name = "label5";
+ this.label5.Size = new System.Drawing.Size(39, 15);
+ this.label5.TabIndex = 11;
+ this.label5.Text = "Index:";
+ //
// timer1
//
this.timer1.Interval = 1000;
@@ -248,15 +254,6 @@
this.timer2.Interval = 1000;
this.timer2.Tick += new System.EventHandler(this.FeedController_Tick);
//
- // labelStatus
- //
- this.labelStatus.AutoSize = true;
- this.labelStatus.Location = new System.Drawing.Point(22, 195);
- this.labelStatus.Name = "labelStatus";
- this.labelStatus.Size = new System.Drawing.Size(16, 15);
- this.labelStatus.TabIndex = 17;
- this.labelStatus.Text = "...";
- //
// progressBar1
//
this.progressBar1.Location = new System.Drawing.Point(10, 242);
@@ -264,14 +261,39 @@
this.progressBar1.Size = new System.Drawing.Size(339, 12);
this.progressBar1.TabIndex = 18;
//
+ // lblDuration
+ //
+ this.lblDuration.AutoSize = true;
+ this.lblDuration.Location = new System.Drawing.Point(297, 224);
+ this.lblDuration.Name = "lblDuration";
+ this.lblDuration.Size = new System.Drawing.Size(16, 15);
+ this.lblDuration.TabIndex = 19;
+ this.lblDuration.Text = "...";
+ //
+ // label6
+ //
+ this.label6.AutoSize = true;
+ this.label6.Location = new System.Drawing.Point(16, 194);
+ this.label6.Name = "label6";
+ this.label6.Size = new System.Drawing.Size(42, 15);
+ this.label6.TabIndex = 20;
+ this.label6.Text = "Status:";
+ //
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(678, 267);
+ this.Controls.Add(this.label6);
+ this.Controls.Add(this.lblSpeed);
+ this.Controls.Add(this.lblDuration);
+ this.Controls.Add(this.lblErrors);
this.Controls.Add(this.progressBar1);
- this.Controls.Add(this.labelStatus);
+ this.Controls.Add(this.label8);
+ this.Controls.Add(this.lblIndex);
+ this.Controls.Add(this.lblStatus);
this.Controls.Add(this.ButtonStop);
+ this.Controls.Add(this.label5);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.textBox1);
this.Name = "Form1";
@@ -290,9 +312,9 @@
private Button button2;
private Button ButtonStop;
private TextBox textBox1;
- private TextBox txtSkipToken;
+ private TextBox txtToken;
private TextBox txtMongoConnectionString;
- private TextBox txtDbFileSystem;
+ private TextBox txtFilesDirectory;
private GroupBox groupBox1;
private TextBox txtDbName;
private Label label4;
@@ -302,11 +324,13 @@
private Label lblSpeed;
private Label lblErrors;
private Label label8;
- private Label lblCount;
+ private Label lblIndex;
private Label label5;
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.Timer timer2;
- private Label labelStatus;
+ private Label lblStatus;
private ProgressBar progressBar1;
+ private Label lblDuration;
+ private Label label6;
}
}
\ No newline at end of file
diff --git a/src/OpenKamer.WinForm/Form1.cs b/src/OpenKamer.WinForm/Form1.cs
index b6a8dee..c1cb7e3 100644
--- a/src/OpenKamer.WinForm/Form1.cs
+++ b/src/OpenKamer.WinForm/Form1.cs
@@ -19,35 +19,32 @@ public partial class Form1 : Form
public Form1()
{
InitializeComponent();
-
- //this.Text += $" (MongoDB.MvcCore.BsonJsonSerializer: {typeof(BsonJsonSerializer).Assembly.GetName().Version})";
}
private void OnLog(object? sender, EventArgs e)
- {
- Log(sender + Environment.NewLine);
- }
-
- private void Log(string line)
{
this.textBox1.Invoke((MethodInvoker)delegate
{
- this.textBox1.AppendText(line);
+ this.textBox1.AppendText(sender + Environment.NewLine);
});
}
private void Form1_Load(object sender, EventArgs e)
{
- var lastXml = Directory.GetFileSystemEntries(this.txtDbFileSystem.Text, "*.xml")
- .OrderByDescending(x => x)
- .ToList()
- .FirstOrDefault();
-
- if (lastXml == null)
- return;
+ try
+ {
+ var lastXml = Directory
+ .GetFileSystemEntries(this.txtFilesDirectory.Text, "*.xml")
+ .Select(x => long.Parse(Path.GetFileNameWithoutExtension(x)))
+ .OrderByDescending(x => x)
+ .FirstOrDefault();
- var last = long.Parse(Path.GetFileNameWithoutExtension(lastXml));
- this.txtSkipToken.Text = last.ToString();
+ this.txtToken.Text = lastXml.ToString();
+ }
+ catch
+ {
+ this.txtToken.Text = "ERROR";
+ }
}
private void ButtonStop_Click(object sender, EventArgs e)
@@ -61,6 +58,8 @@ public partial class Form1 : Form
async private void Button1_Click(object sender, EventArgs e)
{
+ this.textBox1.Clear();
+
this.cancelSource = new();
this.groupBox1.Enabled = false;
@@ -71,12 +70,13 @@ public partial class Form1 : Form
this.progressBar1.Value = 0;
- // txtSkipToken whitespace tot start from 0
- this.feedController1 = new FeedController(this.txtDbFileSystem.Text, this.txtSkipToken.Text);
+ // txtToken whitespace tot start from 0
+ this.feedController1 = new FeedController(this.txtFilesDirectory.Text, this.txtToken.Text);
this.feedController1.OnLog += OnLog;
this.sw = Stopwatch.StartNew();
+
this.timer2.Start();
try
@@ -90,20 +90,18 @@ public partial class Form1 : Form
this.timer2.Stop();
- this.txtSkipToken.Text = this.feedController1.SkipToken;
+ this.txtToken.Text = this.feedController1.Token;
this.ButtonStop.Enabled = false;
this.groupBox1.Enabled = true;
- this.labelStatus.Text = "...";
-
this.progressBar1.Value = 0;
}
async private void Button2_Click(object sender, EventArgs e)
{
- this.labelStatus.Text = "...";
+ this.textBox1.Clear();
this.progressBar1.Value = 0;
@@ -114,10 +112,16 @@ public partial class Form1 : Form
this.ButtonStop.Enabled = true;
this.sw = Stopwatch.StartNew();
+
this.timer1.Start();
- // txtSkipToken whitespace tot start from beginning
- this.entityController1 = new EntityController(this.txtMongoConnectionString.Text, this.txtDbName.Text, this.txtDbFileSystem.Text, this.txtSkipToken.Text);
+ // txtToken whitespace tot start from beginning
+ this.entityController1 = new EntityController(
+ this.txtMongoConnectionString.Text,
+ this.txtDbName.Text,
+ this.txtFilesDirectory.Text,
+ this.txtToken.Text);
+
this.entityController1.OnLog += OnLog;
try
@@ -128,11 +132,10 @@ public partial class Form1 : Form
{
}
-
- this.txtSkipToken.Text = this.entityController1.SkipToken;
-
this.timer1.Stop();
+ this.txtToken.Text = this.entityController1.Token;
+
this.ButtonStop.Enabled = false;
this.groupBox1.Enabled = true;
@@ -147,18 +150,25 @@ public partial class Form1 : Form
if (this.sw == null || this.entityController1 == null)
return;
- this.lblCount.Text = this.entityController1.EntityCount.ToString();
- this.lblErrors.Text = this.entityController1.Error.ToString();
+ this.lblIndex.Text = this.entityController1.FilesIndex.ToString();
- this.progressBar1.Value = Math.Min(100, (this.entityController1.FileCount / 200));
+ this.lblErrors.Text = this.entityController1.Error.ToString();
- this.labelStatus.Text = $"Files: {this.entityController1.FileCount}";
+ this.progressBar1.Value = Math.Min(100, 100 * this.entityController1.FilesIndex / this.entityController1.FilesTotal);
var speed = (1000 * this.entityController1.EntityCount) / this.sw.ElapsedMilliseconds;
this.lblSpeed.Text = $"{speed} e/sec";
- this.txtSkipToken.Text = this.entityController1.SkipToken;
+ var secondstogo = (this.entityController1.FilesTotal - this.entityController1.FilesIndex) * sw.ElapsedMilliseconds / (1 + this.entityController1.FilesIndex) / 1000;
+
+ var takes = new DateTimeOffset().AddSeconds(secondstogo);
+
+ this.lblDuration.Text = $"{takes.Hour:00}:{takes.Minute:00}:{takes.Second:00}";
+
+ this.lblStatus.Text = $"{this.entityController1.EntityCount}";
+
+ this.txtToken.Text = this.entityController1.Token;
}
private void FeedController_Tick(object sender, EventArgs e)
@@ -166,17 +176,23 @@ public partial class Form1 : Form
if (this.sw == null || this.feedController1 == null)
return;
- this.lblCount.Text = this.feedController1.FileCount.ToString();
+ this.lblIndex.Text = this.feedController1.FilesIndex.ToString();
- this.progressBar1.Value = Math.Min(100, (this.feedController1.FileCount / 200) );
+ this.progressBar1.Value = Math.Min(100, 100 * this.feedController1.FilesIndex / this.feedController1.FilesTotal);
- var speed = (1000 * this.feedController1.FileCount) / this.sw.ElapsedMilliseconds;
+ var speed = (1000 * this.feedController1.FilesIndex) / this.sw.ElapsedMilliseconds;
- this.lblSpeed.Text = $"{speed} e/sec";
+ this.lblSpeed.Text = $"{speed} f/sec";
+
+ var secondstogo = (this.feedController1.FilesTotal - this.feedController1.FilesIndex) * sw.ElapsedMilliseconds / (1 + this.feedController1.FilesIndex) / 1000;
+
+ var takes = new DateTimeOffset().AddSeconds(secondstogo);
+
+ this.lblDuration.Text = $"{takes.Hour:00}:{takes.Minute:00}:{takes.Second:00}";
- this.txtSkipToken.Text = this.feedController1.SkipToken;
+ this.lblStatus.Text = this.feedController1.Status;
- this.labelStatus.Text = this.feedController1.Status;
+ this.txtToken.Text = this.feedController1.Token;
}
}
\ No newline at end of file