public void TestFastSending() { var configSource = StartBootstrap(DefaultServerConfig, c => new ServerConfig(c) { LogBasicSessionActivity = false, SendingQueueSize = 100 }); var serverConfig = configSource.Servers.FirstOrDefault(); EndPoint serverAddress = new IPEndPoint(IPAddress.Parse("127.0.0.1"), serverConfig.Port); using (Socket socket = CreateClientSocket()) { socket.Connect(serverAddress); Stream socketStream = GetSocketStream(socket); using (StreamReader reader = new StreamReader(socketStream, m_Encoding, true)) using (ConsoleWriter writer = new ConsoleWriter(socketStream, m_Encoding, 1024 * 8)) { reader.ReadLine(); string sendLine = string.Empty; int i = 0; int testRound = 5000; while (i < testRound) { sendLine = Guid.NewGuid().ToString(); writer.Write("ECHO " + sendLine + "\r\n"); writer.Flush(); var line = reader.ReadLine(); //Console.WriteLine("C: {0}, S: {1}", sendLine, line); if (line == null) { //CustomThreadPoolTaskScheduler.Reset(); } Assert.AreEqual(sendLine, line); i++; } Console.WriteLine("Client sent: {0}", i); Console.WriteLine("Server sent: {0}", ECHO.Sent); ECHO.Reset(); Assert.AreEqual(testRound, i); } } }
/// <summary> 格式化文件 </summary> public void Format() { RUNSPEC runspec = this.Key.CreateSingle <RUNSPEC>("RUNSPEC"); REGIONS region = this.Key.CreateSingle <REGIONS>("REGIONS"); if (region != null) { INCLUDE include = new INCLUDE("INCLUDE"); include.FileName = this.FileName.GetFileNameWithoutExtension() + "_REG.INC"; include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName; region.Add(include); } GRID grid = this.Key.CreateSingle <GRID>("GRID"); var includesOld = grid.FindAll <INCLUDE>(); if (grid != null) { INCLUDE include = new INCLUDE("INCLUDE"); include.FileName = this.FileName.GetFileNameWithoutExtension() + "_GOPP.INC"; include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName; grid.Add(include); include = new INCLUDE("INCLUDE"); include.FileName = this.FileName.GetFileNameWithoutExtension() + "_GGO.INC"; include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName; grid.Add(include); #region - ggo - var echo = this.Key.FindAll <ECHO>(); if (echo != null) { grid.DeleteAll <ECHO>(); include.AddRange(echo); } var mapaxes = this.Key.FindAll <MAPAXES>(); if (mapaxes != null) { grid.DeleteAll <MAPAXES>(); include.AddRange(mapaxes); } var gridunit = this.Key.FindAll <GRIDUNIT>(); if (gridunit != null) { grid.DeleteAll <GRIDUNIT>(); include.AddRange(gridunit); } var coordsys = this.Key.FindAll <COORDSYS>(); if (coordsys != null) { grid.DeleteAll <COORDSYS>(); include.AddRange(coordsys); } var mapunits = this.Key.FindAll <MAPUNITS>(); if (mapunits != null) { grid.DeleteAll <MAPUNITS>(); include.AddRange(mapunits); } var noecho = this.Key.FindAll <NOECHO>(); if (noecho != null) { grid.DeleteAll <NOECHO>(); include.AddRange(noecho); } var coord = this.Key.FindAll <COORD>(); if (coord != null) { grid.DeleteAll <COORD>(); include.AddRange(coord); } var zcorn = this.Key.FindAll <ZCORN>(); if (zcorn != null) { grid.DeleteAll <ZCORN>(); include.AddRange(zcorn); } // 清空原有INCLUDE foreach (var v in includesOld) { grid.Delete(v); } #endregion include = new INCLUDE("INCLUDE"); include.FileName = this.FileName.GetFileNameWithoutExtension() + "_GPRO.INC"; include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName; grid.Add(include); include = new INCLUDE("INCLUDE"); include.FileName = this.FileName.GetFileNameWithoutExtension() + "_GOTH.INC"; include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName; grid.Add(include); ECHO echo1 = grid.Find <ECHO>(); if (echo1 != null) { grid.DeleteAll <ECHO>(); include.Add(echo1); } List <FAULTS> faults = grid.FindAll <FAULTS>(); if (faults != null) { grid.DeleteAll <FAULTS>(); foreach (var v in faults) { include.Add(v); } } MULTFLT multflt = grid.Find <MULTFLT>(); if (multflt != null) { grid.DeleteAll <MULTFLT>(); include.Add(multflt); } } END end = this.Key.CreateSingle <END>("END"); }
/// <summary> /// Entry form constructor - get the full object. /// /// Might add a hook to see if we can keep this from becoming visible. /// </summary> /// <param name="entry">Entry value to split into the entry box.</param> /// <param name="addenda">Addenda value to split into the addenda box.</param> /// <param name="visible_">determine if the new form is visible</param> /// <param name="entry_number">determine where in the sequence the new entry belongs.</param> public ENTRY_FORM(string entry = "", string addenda = "", bool visible_ = true, int entry_number = 0) { // go ahead and store the last entry value at the beginning then update as we go. ENTRY_FORM.last_entry = entry; InitializeComponent(); // we'll add this update in each of these. #if UPDATE_20190725 foreach (Control c in this.Controls) { Program.set_font(c); // let's see if this works. } #endif this.entry_number = entry_number; this.Visible = visible_; // will offer a way to hide these in the background, since I'm going to need to run one for every main object. // we'll be trying to search these out by the amount and record name, and if only one is provided, try best matches. // we'll want to make sure the objects are set to a consistent font... makes life a bit easieer. this.input_reference = new Dictionary <string, TextBox>(); this.output_reference = new Dictionary <string, string>(); this.label_reference = new Dictionary <string, Tuple <Label, TextBox> > { { "E. Rec Type", new Tuple <Label, TextBox>(this.label1, this.textBox1) }, { "Trans. Code", new Tuple <Label, TextBox>(this.label2, this.textBox2) }, { "Routing Num", new Tuple <Label, TextBox>(this.label3, this.textBox3) }, { "Check Digit", new Tuple <Label, TextBox>(this.label4, this.textBox4) }, { "Account Num", new Tuple <Label, TextBox>(this.label5, this.textBox5) }, { "Amount ", new Tuple <Label, TextBox>(this.label6, this.textBox6) }, { "ID Number ", new Tuple <Label, TextBox>(this.label7, this.textBox7) }, { "Rec. Name ", new Tuple <Label, TextBox>(this.label8, this.textBox8) }, { "Disc. Data ", new Tuple <Label, TextBox>(this.label9, this.textBox9) }, { "Addenda Ind", new Tuple <Label, TextBox>(this.label10, this.textBox10) }, { "Trace Num. ", new Tuple <Label, TextBox>(this.label11, this.textBox11) }, { "A. Rec Type", new Tuple <Label, TextBox>(this.label12, this.textBox12) }, { "Adden. Type", new Tuple <Label, TextBox>(this.label13, this.textBox13) }, { "Paymnt Info", new Tuple <Label, TextBox>(this.label14, this.textBox14) }, { "Add Seq Num", new Tuple <Label, TextBox>(this.label15, this.textBox15) }, { "Ent Seq Num", new Tuple <Label, TextBox>(this.label19, this.textBox16) } }; // in the original box, we'll display the original value. this.label16.Text = entry; // list the record. this.label17.Text = "Entry Values"; this.label18.Text = "Addenda Values"; this.button1.Text = "SAVE"; this.button2.Text = "CANCEL"; #if DEBUG this.button3.Visible = true; this.button3.Text = "CLEAR"; #else this.button3.Visible = false; this.button3.Enabled = false; #endif foreach (Control c in this.Controls) { // not the best work but I think it'll help. if (c.Name.Contains("button")) { c.Click += button_click; // will this work? #if DEBUG Console.WriteLine($"Setting {c.Name} to button handle"); #endif } } // If I'm going to adjust the display values for the labels, I can assign it here. foreach (string a in this.label_reference.Keys) { try { // I think these will be updated in real time.. this.label_reference[a].Item1.Text = a; // set all of the names. this.input_reference.Add(a, label_reference[a].Item2); this.output_reference.Add(a, label_reference[a].Item2.Text); // this should be fine. }catch (Exception ECHO) { Console.WriteLine(ECHO.ToString()); // not too surprised. } } // last steps in the constructor: try { // I must have left that in the middle of handling the DEBUG call removal split_entry(entry); // we never included split_addenda - if (Program.EXPERT_MODE || Program.HANDLE_ADDENDA) { try { split_addenda(addenda); } catch (Exception e) { Console.WriteLine(e); } } } catch (Exception e) { Console.WriteLine(e); } } // terminates the object constructor.