diff options
-rw-r--r-- | spedytor/Form1.Designer.cs | 28 | ||||
-rw-r--r-- | spedytor/Form1.cs | 65 | ||||
-rw-r--r-- | spedytor/Form1.resx | 39 |
3 files changed, 125 insertions, 7 deletions
diff --git a/spedytor/Form1.Designer.cs b/spedytor/Form1.Designer.cs index 623e450..d504306 100644 --- a/spedytor/Form1.Designer.cs +++ b/spedytor/Form1.Designer.cs @@ -46,6 +46,8 @@ this.contextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components); this.closeMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.bSelectDBs = new System.Windows.Forms.Button(); + this.lDumpStats = new System.Windows.Forms.Label(); + this.lSendStats = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.nInterval)).BeginInit(); this.contextMenuStrip.SuspendLayout(); this.SuspendLayout(); @@ -167,12 +169,12 @@ // // tbLog // - this.tbLog.Location = new System.Drawing.Point(13, 210); + this.tbLog.Location = new System.Drawing.Point(13, 236); this.tbLog.Multiline = true; this.tbLog.Name = "tbLog"; this.tbLog.ReadOnly = true; this.tbLog.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.tbLog.Size = new System.Drawing.Size(282, 229); + this.tbLog.Size = new System.Drawing.Size(282, 203); this.tbLog.TabIndex = 11; // // tLogger @@ -212,11 +214,31 @@ this.bSelectDBs.UseVisualStyleBackColor = true; this.bSelectDBs.Click += new System.EventHandler(this.button1_Click); // + // lDumpStats + // + this.lDumpStats.AutoSize = true; + this.lDumpStats.Location = new System.Drawing.Point(12, 207); + this.lDumpStats.Name = "lDumpStats"; + this.lDumpStats.Size = new System.Drawing.Size(68, 13); + this.lDumpStats.TabIndex = 13; + this.lDumpStats.Text = "Ostatni zrzut:"; + // + // lSendStats + // + this.lSendStats.AutoSize = true; + this.lSendStats.Location = new System.Drawing.Point(12, 220); + this.lSendStats.Name = "lSendStats"; + this.lSendStats.Size = new System.Drawing.Size(91, 13); + this.lSendStats.TabIndex = 14; + this.lSendStats.Text = "Ostatnia wysyłka:"; + // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(307, 208); + this.Controls.Add(this.lSendStats); + this.Controls.Add(this.lDumpStats); this.Controls.Add(this.bSelectDBs); this.Controls.Add(this.tbLog); this.Controls.Add(this.bToggleLog); @@ -260,6 +282,8 @@ private System.Windows.Forms.ContextMenuStrip contextMenuStrip; private System.Windows.Forms.ToolStripMenuItem closeMenuItem; private System.Windows.Forms.Button bSelectDBs; + private System.Windows.Forms.Label lDumpStats; + private System.Windows.Forms.Label lSendStats; } } diff --git a/spedytor/Form1.cs b/spedytor/Form1.cs index 7742c3f..99011f5 100644 --- a/spedytor/Form1.cs +++ b/spedytor/Form1.cs @@ -18,6 +18,10 @@ namespace spedytor private List<string> selectedDBs = new List<string>(); private dbWindow dbSelectionWindow = new dbWindow(); private int runningDumps = 0; + private string lastDumpDB = null; + private DateTime lastDumpTime; + private string lastSendDB = null; + private DateTime lastSendTime; public Form1() { @@ -98,9 +102,9 @@ namespace spedytor return null; } - private Thread invokeSave(string filePath, string dbName, bool enableControls = false) + private Thread invokeSave(string filePath, string dbName, bool enableControls = false, bool updateStats = true) { - Thread t = new Thread(() => this.saveFile(filePath, dbName, this.getBucketID(), enableControls)); + Thread t = new Thread(() => this.saveFile(filePath, dbName, this.getBucketID(), enableControls, updateStats)); t.IsBackground = true; t.Start(); return t; @@ -138,7 +142,7 @@ namespace spedytor } } - private void saveFile(string filePath, string dbName, string s3Bucket = null, bool enableControls = false) + private void saveFile(string filePath, string dbName, string s3Bucket = null, bool enableControls = false, bool updateStats = true) { if (enableControls && this.runningDumps == 0) { @@ -150,12 +154,24 @@ namespace spedytor MySQL c = new MySQL(dbName); c.backup(filePath); c.close(); + if (updateStats) + { + this.lastDumpDB = dbName; + this.lastDumpTime = DateTime.Now; + this.refreshLastRunStats(); + } Logger.getLogger(this.tbLog, LOG_FILENAME).log("Wyeksportowano pomyślnie do pliku: " + filePath); if (s3Bucket != null) { S3 s3Client = new S3(); s3Client.send(s3Bucket, filePath, dbName + ".sql"); Logger.getLogger(this.tbLog, LOG_FILENAME).log("Wysłano bazę danych: " + dbName + "!"); + if (updateStats) + { + this.lastSendDB = dbName; + this.lastSendTime = DateTime.Now; + this.refreshLastRunStats(); + } } } catch (Exception ex) @@ -178,7 +194,7 @@ namespace spedytor { foreach (Control control in this.Controls) { - if (control != sender && control != this.tbLog && control != this.bToggleLog) + if (control != sender && control != this.tbLog && control != this.bToggleLog && control != this.lSendStats && control != this.lDumpStats) { control.Enabled = state; } @@ -220,7 +236,7 @@ namespace spedytor foreach (string dbName in this.selectedDBs) { string filePath = Path.Combine(this.repeatFilePath, dbName + DateTime.Now.ToString("-yyyyMMdd-HHmmss") + ".sql"); - threadList.Add(this.invokeSave(filePath, dbName, false)); + threadList.Add(this.invokeSave(filePath, dbName, false, sender != null)); } if (sender == null) // programmatic invoke, not actual button click { @@ -275,6 +291,45 @@ namespace spedytor this.notifyIcon.ShowBalloonTip(1000, "Spedytor", "Spedytor będzie działać w tle", ToolTipIcon.Info); } + private delegate void setStatsText(Label label, String text); + + private void setLabelText(Label label, String text) + { + label.Text = text; + } + + private void refreshLastRunStats() + { + StringBuilder sb = new StringBuilder("Spedytor\n"); + if (this.lastDumpDB != null) + { + sb.Append("↓ "); + sb.Append(this.lastDumpTime.ToShortTimeString()); + sb.Append(" "); + sb.Append(this.lastDumpDB.Substring(0, Math.Min(20, this.lastDumpDB.Length))); + sb.Append("\n"); + this.Invoke(new setStatsText(setLabelText), new object[] { this.lDumpStats, "Ostatni zrzut: " + this.lastDumpDB + " (" + this.lastDumpTime.ToString() + ")" }); + } + else + { + this.Invoke(new setStatsText(setLabelText), new object[] { this.lDumpStats, "" }); + } + if (this.lastSendDB != null) + { + sb.Append("↑ "); + sb.Append(this.lastSendTime.ToShortTimeString()); + sb.Append(" "); + sb.Append(this.lastSendDB.Substring(0, Math.Min(20, this.lastSendDB.Length))); + sb.Append("\n"); + this.Invoke(new setStatsText(setLabelText), new object[] { this.lSendStats, "Ostatnia wysyłka: " + this.lastSendDB + " (" + this.lastSendTime.ToString() + ")" }); + } + else + { + this.Invoke(new setStatsText(setLabelText), new object[] { this.lSendStats, "" }); + } + this.notifyIcon.Text = sb.ToString().Trim(); + } + private void Form1_Resize(object sender, EventArgs e) { if (this.WindowState == FormWindowState.Minimized) diff --git a/spedytor/Form1.resx b/spedytor/Form1.resx index f42db77..f5ce0de 100644 --- a/spedytor/Form1.resx +++ b/spedytor/Form1.resx @@ -117,9 +117,39 @@ <resheader name="writer"> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> + <metadata name="lChooseDatabase.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <value>True</value> + </metadata> + <metadata name="cSend.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <value>True</value> + </metadata> + <metadata name="nInterval.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <value>True</value> + </metadata> + <metadata name="label1.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <value>True</value> + </metadata> <metadata name="tInterval.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <value>17, 17</value> </metadata> + <metadata name="bTimer.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <value>True</value> + </metadata> + <metadata name="bExit.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <value>True</value> + </metadata> + <metadata name="bSettings.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <value>True</value> + </metadata> + <metadata name="bSave.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <value>True</value> + </metadata> + <metadata name="bToggleLog.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <value>True</value> + </metadata> + <metadata name="tbLog.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <value>True</value> + </metadata> <metadata name="tLogger.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <value>113, 17</value> </metadata> @@ -206,6 +236,15 @@ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= </value> </data> + <metadata name="bSelectDBs.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <value>True</value> + </metadata> + <metadata name="lDumpStats.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <value>True</value> + </metadata> + <metadata name="lSendStats.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <value>True</value> + </metadata> <metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>True</value> </metadata> |