From: <br...@us...> - 2008-06-09 13:19:25
|
Revision: 232 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=232&view=rev Author: brus07 Date: 2008-06-09 06:19:32 -0700 (Mon, 09 Jun 2008) Log Message: ----------- WorkingData event. When do something call this event. WorkingData append text to TextLog in main form. Scroll to end TextLog when change text. Modified Paths: -------------- ACMServer/trunk/MediatorSolution/Mediator/Form1.Designer.cs ACMServer/trunk/MediatorSolution/Mediator/Form1.cs ACMServer/trunk/MediatorSolution/Mediator/Form1.resx ACMServer/trunk/MediatorSolution/Mediator/Library/MediatorKernel.cs ACMServer/trunk/MediatorSolution/Mediator/Library/Plugins/BaseMediatorPlugin.cs ACMServer/trunk/MediatorSolution/Mediator/Library/Plugins/SocketGate/SocketServerPlugin.cs ACMServer/trunk/MediatorSolution/Mediator/Library/Plugins/WebGate/WebGatePlugin.cs Modified: ACMServer/trunk/MediatorSolution/Mediator/Form1.Designer.cs =================================================================== --- ACMServer/trunk/MediatorSolution/Mediator/Form1.Designer.cs 2008-06-09 13:08:31 UTC (rev 231) +++ ACMServer/trunk/MediatorSolution/Mediator/Form1.Designer.cs 2008-06-09 13:19:32 UTC (rev 232) @@ -34,9 +34,11 @@ this.button3 = new System.Windows.Forms.Button(); this.statusStrip1 = new System.Windows.Forms.StatusStrip(); this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); - this.timer1 = new System.Windows.Forms.Timer(this.components); + this.timerCountSocketClients = new System.Windows.Forms.Timer(this.components); this.textBox1 = new System.Windows.Forms.TextBox(); this.textBox2 = new System.Windows.Forms.TextBox(); + this.textBox3 = new System.Windows.Forms.TextBox(); + this.timerUpdateTextLog = new System.Windows.Forms.Timer(this.components); this.statusStrip1.SuspendLayout(); this.SuspendLayout(); // @@ -75,9 +77,9 @@ // this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.toolStripStatusLabel1}); - this.statusStrip1.Location = new System.Drawing.Point(0, 138); + this.statusStrip1.Location = new System.Drawing.Point(0, 295); this.statusStrip1.Name = "statusStrip1"; - this.statusStrip1.Size = new System.Drawing.Size(262, 22); + this.statusStrip1.Size = new System.Drawing.Size(369, 22); this.statusStrip1.TabIndex = 9; this.statusStrip1.Text = "statusStrip1"; // @@ -87,10 +89,10 @@ this.toolStripStatusLabel1.Size = new System.Drawing.Size(109, 17); this.toolStripStatusLabel1.Text = "toolStripStatusLabel1"; // - // timer1 + // timerCountSocketClients // - this.timer1.Enabled = true; - this.timer1.Tick += new System.EventHandler(this.timer1_Tick); + this.timerCountSocketClients.Enabled = true; + this.timerCountSocketClients.Tick += new System.EventHandler(this.timer1_Tick); // // textBox1 // @@ -109,11 +111,30 @@ this.textBox2.Size = new System.Drawing.Size(110, 20); this.textBox2.TabIndex = 11; // + // textBox3 + // + this.textBox3.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textBox3.Location = new System.Drawing.Point(12, 121); + this.textBox3.Multiline = true; + this.textBox3.Name = "textBox3"; + this.textBox3.ScrollBars = System.Windows.Forms.ScrollBars.Both; + this.textBox3.Size = new System.Drawing.Size(345, 171); + this.textBox3.TabIndex = 12; + // + // timerUpdateTextLog + // + this.timerUpdateTextLog.Enabled = true; + this.timerUpdateTextLog.Interval = 2000; + this.timerUpdateTextLog.Tick += new System.EventHandler(this.timerUpdateTextLog_Tick); + // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(262, 160); + this.ClientSize = new System.Drawing.Size(369, 317); + this.Controls.Add(this.textBox3); this.Controls.Add(this.textBox2); this.Controls.Add(this.textBox1); this.Controls.Add(this.statusStrip1); @@ -122,8 +143,8 @@ this.Controls.Add(this.button2); this.Name = "Form1"; this.Text = "Gate"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing); this.Load += new System.EventHandler(this.Form1_Load); - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing); this.statusStrip1.ResumeLayout(false); this.statusStrip1.PerformLayout(); this.ResumeLayout(false); @@ -138,9 +159,11 @@ private System.Windows.Forms.Button button3; private System.Windows.Forms.StatusStrip statusStrip1; private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1; - private System.Windows.Forms.Timer timer1; + private System.Windows.Forms.Timer timerCountSocketClients; private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.TextBox textBox2; + private System.Windows.Forms.TextBox textBox3; + private System.Windows.Forms.Timer timerUpdateTextLog; } } Modified: ACMServer/trunk/MediatorSolution/Mediator/Form1.cs =================================================================== --- ACMServer/trunk/MediatorSolution/Mediator/Form1.cs 2008-06-09 13:08:31 UTC (rev 231) +++ ACMServer/trunk/MediatorSolution/Mediator/Form1.cs 2008-06-09 13:19:32 UTC (rev 232) @@ -9,6 +9,7 @@ using System.Net.Sockets; using AcmContester.Mediator.Library.Plugins; using AcmContester.Mediator.Library.Plugins.SocketGate; +using System.IO; namespace Mediator { @@ -22,12 +23,38 @@ textBox2.Text = s; } + string fullLog = ""; + private void button2_Click(object sender, EventArgs e) { AcmContester.Mediator.Library.MediatorKernel kernel = new AcmContester.Mediator.Library.MediatorKernel(); + kernel.onWorkingData += WorkingData; kernel.LoadLists(); } + private void WorkingData(string message) + { + string s = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString() + ": "; + s += message; + + lock (fullLog) + { + fullLog += s; + fullLog += "\r\n"; + } + } + private void UpdateTextLog() + { + lock (fullLog) + { + //textBox3.SelectedText = fullLog; + textBox3.Text += fullLog; + textBox3.Select(textBox3.Text.Length, 0); + textBox3.ScrollToCaret(); + fullLog = ""; + } + } + private void button3_Click(object sender, EventArgs e) { Disconnnect(); @@ -62,5 +89,10 @@ { button2_Click(this, null); } + + private void timerUpdateTextLog_Tick(object sender, EventArgs e) + { + UpdateTextLog(); + } } } \ No newline at end of file Modified: ACMServer/trunk/MediatorSolution/Mediator/Form1.resx =================================================================== --- ACMServer/trunk/MediatorSolution/Mediator/Form1.resx 2008-06-09 13:08:31 UTC (rev 231) +++ ACMServer/trunk/MediatorSolution/Mediator/Form1.resx 2008-06-09 13:19:32 UTC (rev 232) @@ -120,7 +120,10 @@ <metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <value>17, 17</value> </metadata> - <metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> + <metadata name="timerCountSocketClients.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <value>127, 17</value> </metadata> + <metadata name="timerUpdateTextLog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> + <value>300, 17</value> + </metadata> </root> \ No newline at end of file Modified: ACMServer/trunk/MediatorSolution/Mediator/Library/MediatorKernel.cs =================================================================== --- ACMServer/trunk/MediatorSolution/Mediator/Library/MediatorKernel.cs 2008-06-09 13:08:31 UTC (rev 231) +++ ACMServer/trunk/MediatorSolution/Mediator/Library/MediatorKernel.cs 2008-06-09 13:19:32 UTC (rev 232) @@ -15,14 +15,24 @@ AcmContester.Mediator.Library.Plugins.WebGate.CreaterMediatorPlugin webCreater = new AcmContester.Mediator.Library.Plugins.WebGate.CreaterMediatorPlugin(); BaseMediatorPlugin b1 = webCreater.GetInstance(); b1.onDataArrived += DataArrivedFromClentList; + b1.onWorkingData += WorkingData; clientSideList.Add(b1); AcmContester.Mediator.Library.Plugins.SocketGate.CreaterMediatorPlugin socketCreater = new AcmContester.Mediator.Library.Plugins.SocketGate.CreaterMediatorPlugin(); BaseMediatorPlugin b2 = socketCreater.GetInstance(); b2.onDataArrived += DataArrivedFromTesterList; + b2.onWorkingData += WorkingData; testerSideList.Add(b2); } + public delegate void WorkingData_EventHandler(string message); + public event WorkingData_EventHandler onWorkingData; + private void WorkingData(string message) + { + if (onWorkingData != null) + onWorkingData(message); + } + private void DataArrivedFromClentList(string message) { for (int index = 0; index < testerSideList.Count; index++) Modified: ACMServer/trunk/MediatorSolution/Mediator/Library/Plugins/BaseMediatorPlugin.cs =================================================================== --- ACMServer/trunk/MediatorSolution/Mediator/Library/Plugins/BaseMediatorPlugin.cs 2008-06-09 13:08:31 UTC (rev 231) +++ ACMServer/trunk/MediatorSolution/Mediator/Library/Plugins/BaseMediatorPlugin.cs 2008-06-09 13:19:32 UTC (rev 232) @@ -7,12 +7,22 @@ public delegate void DataArrived_EventHandler(string message); public event DataArrived_EventHandler onDataArrived; + public delegate void WorkingData_EventHandler(string message); + public event WorkingData_EventHandler onWorkingData; + public abstract void Send(string message); protected virtual void DataArrived(string message) { + WorkingData("BaseMediatorPlugin::DataArrived(" + message + ")"); if (onDataArrived != null) onDataArrived(message); } + + protected virtual void WorkingData(string message) + { + if (onWorkingData != null) + onWorkingData(message); + } } } Modified: ACMServer/trunk/MediatorSolution/Mediator/Library/Plugins/SocketGate/SocketServerPlugin.cs =================================================================== --- ACMServer/trunk/MediatorSolution/Mediator/Library/Plugins/SocketGate/SocketServerPlugin.cs 2008-06-09 13:08:31 UTC (rev 231) +++ ACMServer/trunk/MediatorSolution/Mediator/Library/Plugins/SocketGate/SocketServerPlugin.cs 2008-06-09 13:19:32 UTC (rev 232) @@ -28,12 +28,15 @@ public override void Send(string message) { - if (dataContainer.Add(new Submit(message))) - server.Send(message); + WorkingData("SocketServerPlugin::Send(" + message + ")"); + if (server.CountClients() > 0) + if (dataContainer.Add(new Submit(message))) + server.Send(message); } protected override void DataArrived(string message) { + WorkingData("SocketServerPlugin::DataArrived(" + message + ")"); dataContainer.Return(new Result(message)); base.DataArrived(message); } @@ -47,6 +50,7 @@ internal void Stop() { + WorkingData("SocketServerPlugin::Stop()"); if (server != null) server.Stop(); server = null; Modified: ACMServer/trunk/MediatorSolution/Mediator/Library/Plugins/WebGate/WebGatePlugin.cs =================================================================== --- ACMServer/trunk/MediatorSolution/Mediator/Library/Plugins/WebGate/WebGatePlugin.cs 2008-06-09 13:08:31 UTC (rev 231) +++ ACMServer/trunk/MediatorSolution/Mediator/Library/Plugins/WebGate/WebGatePlugin.cs 2008-06-09 13:19:32 UTC (rev 232) @@ -25,6 +25,7 @@ public override void Send(string message) { + WorkingData("WebGatePlugin::Send(" + message + ")"); connector.Send(message); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |