public void Start() { // Transport message has no headers for Processing endpoint and the ReplyToAddress is set to null var transportMessage = new TransportMessage(); transportMessage.Headers[Headers.ProcessingEndpoint] = "ServerEndpoint"; transportMessage.Headers[Headers.MessageId] = SystemMessageTestContext.MessageId; transportMessage.Headers[Headers.ConversationId] = "a59395ee-ec80-41a2-a728-a3df012fc707"; transportMessage.Headers["$.diagnostics.hostid"] = "bdd4b0510bff5a6d07e91baa7e16a804"; transportMessage.Headers["$.diagnostics.hostdisplayname"] = "SELENE"; transportMessage.Headers["NServiceBus.ExceptionInfo.ExceptionType"] = "2014-11-11 02:26:57:767462 Z"; transportMessage.Headers["NServiceBus.ExceptionInfo.Message"] = "An error occurred while attempting to extract logical messages from transport message NServiceBus.TransportMessage"; transportMessage.Headers["NServiceBus.ExceptionInfo.InnerExceptionType"] = "System.Exception"; transportMessage.Headers["NServiceBus.ExceptionInfo.HelpLink"] = String.Empty; transportMessage.Headers["NServiceBus.ExceptionInfo.Source"] = "NServiceBus.Core"; transportMessage.Headers["NServiceBus.ExceptionInfo.StackTrace"] = String.Empty; transportMessage.Headers["NServiceBus.FailedQ"] = "SomeEndpoint@SELENE"; transportMessage.Headers["NServiceBus.TimeOfFailure"] = "2014-11-11 02:26:58:000462 Z"; transportMessage.Headers["NServiceBus.TimeSent"] = "2014-11-11 02:26:01:174786 Z"; if (!string.IsNullOrEmpty(SystemMessageTestContext.EnclosedMessageType)) { transportMessage.Headers[Headers.EnclosedMessageTypes] = SystemMessageTestContext.EnclosedMessageType; } if (SystemMessageTestContext.IncludeControlMessageHeader) { transportMessage.Headers[Headers.ControlMessageHeader] = SystemMessageTestContext.ControlMessageHeaderValue != null && (bool)SystemMessageTestContext.ControlMessageHeaderValue ? SystemMessageTestContext.ControlMessageHeaderValue.ToString() : null; } SendMessages.Send(transportMessage, new SendOptions(Address.Parse("error"))); }
private void SendErrorButton_Click(object sender, RoutedEventArgs e) { var m = new MailMessage(); var source = GetMetaContent(LogHelper.XLogHelperErrorSource); if (!string.IsNullOrEmpty(source)) { m.Headers.Add(LogHelper.XLogHelperErrorSource, source); } var errType = GetMetaContent(LogHelper.XLogHelperErrorType); if (!string.IsNullOrEmpty(errType)) { m.Headers.Add(LogHelper.XLogHelperErrorType, errType); } var errCode = GetMetaContent(LogHelper.XLogHelperErrorCode); if (!string.IsNullOrEmpty(errCode)) { m.Headers.Add(LogHelper.XLogHelperErrorCode, errCode); } m.Subject = SubjectTextBox.Text; if (!string.IsNullOrEmpty(FromEmailTextBox.Text)) { m.From = new MailAddress(FromEmailTextBox.Text); } m.To.Add(new MailAddress(ToEmailTextBox.Text)); m.IsBodyHtml = true; m.Body = GetBody(); var messages = new List <MailMessage>(); messages.Add(m); SendMessages?.Invoke(this, new EventArgs <List <MailMessage> >(messages)); }
static void 관리서버에_통보하기(bool 관리서버와_연결중, string time, string userCount) { if (관리서버와_연결중) { SendMessages.관리서버에_App서버_상태통보(time, userCount); } }
public void Start() { // Transport message has no headers for Processing endpoint and the ReplyToAddress is set to null var transportMessage = new TransportMessage(); if (MyContext.IncludeProcessingEndpointHeader) { transportMessage.Headers[Headers.ProcessingEndpoint] = "SomeEndpoint"; } transportMessage.Headers[Headers.MessageId] = MyContext.MessageId; transportMessage.Headers[Headers.ConversationId] = "a59395ee-ec80-41a2-a728-a3df012fc707"; transportMessage.Headers["$.diagnostics.hostid"] = "bdd4b0510bff5a6d07e91baa7e16a804"; transportMessage.Headers["$.diagnostics.hostdisplayname"] = "SELENE"; transportMessage.Headers["NServiceBus.ExceptionInfo.ExceptionType"] = "2014-11-11 02:26:57:767462 Z"; transportMessage.Headers["NServiceBus.ExceptionInfo.Message"] = "An error occurred while attempting to extract logical messages from transport message NServiceBus.TransportMessage"; transportMessage.Headers["NServiceBus.ExceptionInfo.InnerExceptionType"] = "System.Exception"; transportMessage.Headers["NServiceBus.ExceptionInfo.HelpLink"] = String.Empty; transportMessage.Headers["NServiceBus.ExceptionInfo.Source"] = "NServiceBus.Core"; transportMessage.Headers["NServiceBus.ExceptionInfo.StackTrace"] = String.Empty; transportMessage.Headers["NServiceBus.FailedQ"] = "SomeEndpoint@SELENE"; transportMessage.Headers["NServiceBus.TimeOfFailure"] = "2014-11-11 02:26:58:000462 Z"; transportMessage.Headers["NServiceBus.TimeSent"] = "2014-11-11 02:26:01:174786 Z"; transportMessage.Headers[Headers.EnclosedMessageTypes] = "SendOnlyError.SendSomeCommand, TestSendOnlyError, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"; SendMessages.Send(transportMessage, new SendOptions(Address.Parse("error"))); }
public void Start() { //hack until we can fix the types filtering in default server if (SystemMessageTestContext == null || string.IsNullOrEmpty(SystemMessageTestContext.MessageId)) { return; } if (Configure.EndpointName != "Particular.ServiceControl") { return; } // Transport message has no headers for Processing endpoint and the ReplyToAddress is set to null var transportMessage = new TransportMessage(); transportMessage.Headers[Headers.ProcessingEndpoint] = "ServerEndpoint"; transportMessage.Headers[Headers.MessageId] = SystemMessageTestContext.MessageId; transportMessage.Headers[Headers.ConversationId] = "a59395ee-ec80-41a2-a728-a3df012fc707"; transportMessage.Headers["$.diagnostics.hostid"] = "bdd4b0510bff5a6d07e91baa7e16a804"; transportMessage.Headers["$.diagnostics.hostdisplayname"] = "SELENE"; if (!string.IsNullOrEmpty(SystemMessageTestContext.EnclosedMessageType)) { transportMessage.Headers[Headers.EnclosedMessageTypes] = SystemMessageTestContext.EnclosedMessageType; } if (SystemMessageTestContext.IncludeControlMessageHeader) { transportMessage.Headers[Headers.ControlMessageHeader] = SystemMessageTestContext.ControlMessageHeaderValue != null && (bool)SystemMessageTestContext.ControlMessageHeaderValue ? SystemMessageTestContext.ControlMessageHeaderValue.ToString() : null; } transportMessage.ReplyToAddress = null; SendMessages.Send(transportMessage, Address.Parse("audit")); }
public void Start() { var transportMessage = new TransportMessage(); transportMessage.Headers[Headers.MessageId] = MyContext.MessageId; transportMessage.Headers[Headers.ProcessingEndpoint] = Settings.EndpointName(); SendMessages.Send(transportMessage, new SendOptions(Address.Parse("audit"))); }
public void ReInit(ref SendMsgDelegate sm) { if (sm == null) { SendMsgDelegate msgSend = new SendMsgDelegate(SendMessage); sm = msgSend; } smsg = new SendMessages(sm); }
public void ExerciseDerivedObjects() { Console.WriteLine($"Starting method: {MethodBase.GetCurrentMethod().Name}()"); SendMessages.WriteConsoleMessageStatic("Static func in regular class. Cannot access through an instance"); Messages msgs = new SendMessages(); msgs.WriteMessage("Writing msg using abstract class"); // msgs.WriteConsoleMessageStatic("..."); // Cannot call a static func through a class instance var sendMsgs = new SendMessages(); sendMsgs.WriteMessage("Calling implementation of abstract method"); sendMsgs.WriteConsoleMessage("Calling the override method in the derived class"); var bc = new BaseClass(); var dc = new DerivedClass(); BaseClass bcdc = new DerivedClass(); // Slicing occurs if assign an object of a derived class to an instance of a base class BaseClass bcdc2 = new DerivedClass2(); Console.WriteLine("Calling bc.Method1()"); bc.Method1(); Console.WriteLine("Calling dc.Method1()"); dc.Method1(); Console.WriteLine("Calling dc.Method2()"); dc.Method2(); Console.WriteLine("Calling bcdc.Method1()"); bcdc.Method1(); // Will call method1 in derived class because it is overridden Console.WriteLine("Calling bcdc.Method2()"); bcdc.Method2(); // Will call method2 in base class because it is not overridden Console.WriteLine("Calling dc.Method3()"); dc.Method3(); // Will call method3 in derived class because it is overridden // and will also call the base class method throught base.Method3() dc.Name = ""; // Assign a value to a property override dc.Name = "Bart"; dc.Name = null; Console.WriteLine("Call methods in DerivedClass2 from BaseClass Instance"); bcdc2.Method1(); bcdc2.Method2(); bcdc2.Method3(); // bc.staticValue = 500; // Not assesible through instance BaseClass.staticValue = 500; // Assesible only through type Mystatic.Y = 777; Mystatic.WriteValue(); // var m = new Mystatic(); // Cannot create an instance of a static class }
public void Init(SocketSettings sockSet, ref SendMsgDelegate sm, ReceiveMsgDelegate rm = null) { Url = sockSet.url; Port = sockSet.port; name = sockSet.name; this.sockSet = sockSet; Logger.Info($"Client Socket Connection Init: {name}"); if (rm == null) { rm = new ReceiveMsgDelegate(MsgProcessor.ReceiveMessage); } srvr = new ClientToServerConnection(sockSet, ref sm, rm); smsg = new SendMessages(sm); }
private async void Sendtext_ClickAsync(object sender, EventArgs e) { datetime = DateTime.Now.ToLocalTime(); SendMessages sendMessageJson = new SendMessages(); if (IsDoctor == false) // to ID tou asthenh prepei na stalei prwto { sendMessageJson.PatientID = myID; sendMessageJson.DoctorID = receiverID; sendMessageJson.Sender = 0; } else { sendMessageJson.PatientID = receiverID; sendMessageJson.DoctorID = myID; sendMessageJson.Sender = 1; } sendMessageJson.Text = message2.Text; sendMessageJson.Seen = false; sendMessageJson.Date = datetime.ToString(); sendMessageJson.Send = false; string output = JsonConvert.SerializeObject(sendMessageJson); Address address = new Address(); string endpoint = address.Endpoint + "DataSenders"; var uri = new Uri(endpoint); var StrRespPost = await PostRest.Post(output, uri, true); if (StrRespPost == "Created") // tsekare to giati mporei na stalei kai na epistrepsei diaforetiko mhnuma { new AlertDialog.Builder(this) .SetMessage("Successfully Send") .SetTitle("Message") .Show(); } else { new AlertDialog.Builder(this) .SetMessage("Unsuccessfull Send!!" + "\n" + "Something went wrong" + "\n" + StrRespPost) .SetTitle("Message") .SetIcon(Resource.Drawable.error) .Show(); } }
private void SendErrorButton_Click(object sender, RoutedEventArgs e) { var message = new MailMessage(); message.Subject = SubjectTextBox.Text; if (!string.IsNullOrEmpty(FromEmailTextBox.Text)) { message.From = new MailAddress(FromEmailTextBox.Text); } message.To.Add(new MailAddress(ToEmailTextBox.Text)); message.IsBodyHtml = true; message.Body = GetBody(); var messages = new List <MailMessage>(); messages.Add(message); SendMessages?.Invoke(this, new EventArgs <List <MailMessage> >(messages)); }
public async Task <string> InsertAdress(Adress adress) { await Collection.InsertOneAsync(adress); var coord = new Coordinates(); var Uid = Guid.NewGuid(); coord.IdOperacion = Uid.ToString(); coord.Latitud = ""; coord.Longitud = ""; coord.Estado = "PROCESANDO"; adress.IdOperacion = coord.IdOperacion; await CollectionCD.InsertOneAsync(coord); _send = new SendMessages(); _send.SendMessage(adress); return(Uid.ToString()); }
public void Start() { //hack until we can fix the types filtering in default server if (MyContext == null || string.IsNullOrEmpty(MyContext.MessageId)) { return; } if (Configure.EndpointName != "Particular.ServiceControl") { return; } var transportMessage = new TransportMessage(); transportMessage.Headers[Headers.MessageId] = MyContext.MessageId; transportMessage.Headers[Headers.ProcessingEndpoint] = Configure.EndpointName; SendMessages.Send(transportMessage, Address.Parse("audit")); }
public ActionResult SendMessage(SendMessages message) { var user = (Member)Session["LogonUser"]; if (Session["LogonUser"] == null) { return(RedirectToAction("Login", "Account")); } Message mesaj = new Message() { AddedDate = DateTime.Now, IsRead = false, Subject = message.Subject, MemberFromId = user.ID, MemberToId = message.ToUserId }; db.Messages.Add(mesaj); int messageId = db.MessageReplies.OrderByDescending(x => x.AddedDate).Select(x => x.MessageId).Take(1).SingleOrDefault(); MessageReply mr = new MessageReply() { AddedDate = DateTime.Now, MemberFromId = user.ID, Text = message.MessageBody, MemberToId = message.ToUserId, }; if (mr.MessageId == 0) { mr.MessageId = messageId + 1; } else { mr.MessageId = 1; } db.MessageReplies.Add(mr); db.SaveChanges(); return(RedirectToAction("Index", "Messages")); }
public void Start() { // Transport message has no headers for Processing endpoint and the ReplyToAddress is set to null var transportMessage = new TransportMessage(); transportMessage.Headers[Headers.ProcessingEndpoint] = "ServerEndpoint"; transportMessage.Headers[Headers.MessageId] = SystemMessageTestContext.MessageId; transportMessage.Headers[Headers.ConversationId] = "a59395ee-ec80-41a2-a728-a3df012fc707"; transportMessage.Headers["$.diagnostics.hostid"] = "bdd4b0510bff5a6d07e91baa7e16a804"; transportMessage.Headers["$.diagnostics.hostdisplayname"] = "SELENE"; if (!string.IsNullOrEmpty(SystemMessageTestContext.EnclosedMessageType)) { transportMessage.Headers[Headers.EnclosedMessageTypes] = SystemMessageTestContext.EnclosedMessageType; } if (SystemMessageTestContext.IncludeControlMessageHeader) { transportMessage.Headers[Headers.ControlMessageHeader] = SystemMessageTestContext.ControlMessageHeaderValue != null && (bool)SystemMessageTestContext.ControlMessageHeaderValue ? SystemMessageTestContext.ControlMessageHeaderValue.ToString() : null; } SendMessages.Send(transportMessage, new SendOptions(Address.Parse("audit"))); Bus.SendLocal(new DoQueryAllowed()); }
private string RandomSendMessage() { return(SendMessages[new Random().Next(0, SendMessages.Count() - 1)].Message); }
public static async Task Main(string[] args) { // // get configuration information // MessageQueueAppConfig messageQueueAppConfig = new MessageQueueAppConfig(); ConnectionStrings connectionStrings = new ConnectionStrings(); string environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"); string jsonFile = $"appsettings.{environment}.json"; var configBuilder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile(jsonFile, optional: true, reloadOnChange: true); IConfigurationRoot configuration = configBuilder.Build(); configuration.GetSection("MessageQueueAppConfig").Bind(messageQueueAppConfig); configuration.GetSection("ConnectionStrings").Bind(connectionStrings); // // set up sending queue // IMessageQueueConnection sendingQueueConnection = new MessageQueueConnection(messageQueueAppConfig); sendingQueueConnection.CreateConnection(); List <IMessageQueueConfiguration> messageQueueConfigurations = new List <IMessageQueueConfiguration>(); // // Inventory Received Transactions // IMessageQueueConfiguration inventoryReceivedConfiguration = new MessageQueueConfiguration(MessageQueueExchanges.InventoryReceived, messageQueueAppConfig, sendingQueueConnection); inventoryReceivedConfiguration.AddQueue(MessageQueueEndpoints.SalesOrderQueue); inventoryReceivedConfiguration.AddQueue(MessageQueueEndpoints.PurchaseOrderQueue); inventoryReceivedConfiguration.AddQueue(MessageQueueEndpoints.LoggingQueue); inventoryReceivedConfiguration.InitializeOutboundMessageQueueing(); messageQueueConfigurations.Add(inventoryReceivedConfiguration); // // Product Creation and Updates // IMessageQueueConfiguration productUpdatedConfiguration = new MessageQueueConfiguration(MessageQueueExchanges.ProductUpdated, messageQueueAppConfig, sendingQueueConnection); productUpdatedConfiguration.AddQueue(MessageQueueEndpoints.SalesOrderQueue); productUpdatedConfiguration.AddQueue(MessageQueueEndpoints.PurchaseOrderQueue); productUpdatedConfiguration.AddQueue(MessageQueueEndpoints.LoggingQueue); productUpdatedConfiguration.InitializeOutboundMessageQueueing(); messageQueueConfigurations.Add(productUpdatedConfiguration); // // Inventory Shipped Transactions // IMessageQueueConfiguration inventoryShippedConfiguration = new MessageQueueConfiguration(MessageQueueExchanges.InventoryShipped, messageQueueAppConfig, sendingQueueConnection); inventoryShippedConfiguration.AddQueue(MessageQueueEndpoints.SalesOrderQueue); inventoryShippedConfiguration.AddQueue(MessageQueueEndpoints.LoggingQueue); inventoryShippedConfiguration.InitializeOutboundMessageQueueing(); messageQueueConfigurations.Add(inventoryShippedConfiguration); // // initialize Sending Messages // IInventoryManagementDataService inventoryManagementDataService = new InventoryManagementDataService(); IMessageQueueProcessing messageProcessing = new MessageProcessing(inventoryManagementDataService); IHostedService sendInventoryManagementMessages = new SendMessages(sendingQueueConnection, messageProcessing, messageQueueAppConfig, connectionStrings, messageQueueConfigurations, MessageQueueEndpoints.InventoryQueue); // // set up receiving queue // IMessageQueueConnection receivingConnection = new MessageQueueConnection(messageQueueAppConfig); receivingConnection.CreateConnection(); List <IMessageQueueConfiguration> inboundMessageQueueConfigurations = new List <IMessageQueueConfiguration>(); IMessageQueueConfiguration inboundConfiguration = new MessageQueueConfiguration(messageQueueAppConfig, receivingConnection); inboundMessageQueueConfigurations.Add(inboundConfiguration); inboundConfiguration.InitializeInboundMessageQueueing(MessageQueueEndpoints.InventoryQueue); inboundConfiguration.InitializeLoggingExchange(MessageQueueExchanges.Logging, MessageQueueEndpoints.LoggingQueue); IInventoryManagementDataService inboundInventoryManagementDataService = new InventoryManagementDataService(); IMessageQueueProcessing inboundMessageProcessing = new MessageProcessing(inboundInventoryManagementDataService); IHostedService receiveInventoryManagementMessages = new ReceiveMessages(receivingConnection, inboundMessageProcessing, messageQueueAppConfig, connectionStrings, inboundMessageQueueConfigurations); // // Set Up Message Processing // IInventoryManagementDataService inventoryManagementProcessingDataService = new InventoryManagementDataService(); IMessageQueueProcessing messageProcessor = new MessageProcessing(inventoryManagementProcessingDataService); ProcessMessages processMessages = new ProcessMessages(messageProcessor, messageQueueAppConfig, connectionStrings); var builder = new HostBuilder().ConfigureAppConfiguration((hostingContext, config) => {}) .ConfigureServices((hostContext, services) => { services.AddTransient <IHostedService>(provider => processMessages); }) .ConfigureServices((hostContext, services) => { services.AddTransient <IHostedService>(provider => sendInventoryManagementMessages); }) .ConfigureServices((hostContext, services) => { services.AddTransient <IHostedService>(provider => receiveInventoryManagementMessages); }) .ConfigureLogging((hostingContext, logging) => { logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging")); logging.AddConsole(); }); await builder.RunConsoleAsync(); }
private void Awake() { Instance = this; }
// Use this for initialization void Start() { Singleton = this; }
static void Main(string[] args) { //string remoteHostIP = "192.168.101.210"; //string remoteHostIP = "127.0.0.1"; //For testing change later for testing with other servers MessageCount = 100; LocalDelayRequest_Milliseconds = 10; string remoteHostIP = "10.170.4.84"; //For testing change later for testing with other servers string servername = "James Brooks"; int remoteHostPort = 2605; //string file = "scenario_1_output_log_james_brooks_"; string file = "Lab3.ScenarioC.BrooksJamesE_"; string localIP = "127.0.0.1"; string localPort = ""; int i = 0; int error = 0; //Initialize outgoing messages to template values and add in known info for (i = 0; i < MessageCount; i++) { txmessage txmsg = new txmessage(); //Initialize with predefined template values mc.makeOutgoingMessageTemplate(ref txmsg.msg); //Unique request id for each message //Request ID incremented in Fill_Message_RequestID pc.Fill_Message_RequestID(ref txmsg.msg, ref RequestID); pc.Fill_Message_SeverDelayTime_Milliseconds(ref txmsg.msg, RemoteDelayRequest_Milliseconds); pc.Fill_Message_Client_IP_Address(ref txmsg.msg, pc.GetLocalIP()); pc.Fill_Message_RemoteHost_IP_Address(ref txmsg.msg, remoteHostIP); outgoingMessages.Add(txmsg); } //Null incoming message array bytes for (i = 0; i < MessageCount; i++) { rcmessage rmsg = new rcmessage(); mc.nullIcomingMessage(ref rmsg.msg); incomingMessages.Add(rmsg); } //Open Socket Session IPEndPoint ipe = new IPEndPoint(IPAddress.Parse(remoteHostIP), remoteHostPort); socket = new Socket(ipe.AddressFamily, SocketType.Stream, ProtocolType.Tcp); socket.Connect(ipe); if (socket != null) { Console.WriteLine("Connected to " + remoteHostIP + " at " + remoteHostPort.ToString()); } else { Console.WriteLine("Connection failed to " + remoteHostIP + " at " + remoteHostPort.ToString()); } //Get socket statistics localIP = IPAddress.Parse(((IPEndPoint)socket.LocalEndPoint).Address.ToString()).ToString(); localPort = (((IPEndPoint)socket.LocalEndPoint).Port.ToString()).ToString(); //Fill in Session info to outgoing messages for (i = 0; i < MessageCount; i++) { pc.Fill_Message_Client_IP_Address(ref outgoingMessages[i].msg, localIP); pc.Fill_Message_ClientServicePort(ref outgoingMessages[i].msg, localPort); pc.Fill_Message_ClientSocket(ref outgoingMessages[i].msg, localPort); } //Transmit/Receive Threads SendMessages oSendMessages = new SendMessages(); ReceiveMessages oReceiveMessages = new ReceiveMessages(); SendStartTime = DateTime.Now; Thread oThread1 = new Thread(new ThreadStart(oSendMessages.sndmessages)); ReceiveStartTime = DateTime.Now; Thread oThread2 = new Thread(new ThreadStart(oReceiveMessages.RcvMessages)); // Start the threads oThread1.Start(); while (!oThread1.IsAlive) ; oThread2.Start(); while (!oThread2.IsAlive) ; oThread1.Join(); oThread2.Join(); // Do half session shutdowns // Close the transmitter socket.Shutdown(SocketShutdown.Send); // Close the listener socket.Shutdown(SocketShutdown.Receive); // Close the session socket.Close(); // Put messages into ascii strings for (i = 0; i < incomingMessages.Count; i++) { //Put entire message to ascii incomingMessages[i].msgAscii = enc.GetString(incomingMessages[i].msg); //Insert appropriate response type if (incomingMessages[i].msgAscii.Contains("Delayed")) { StringBuilder s = new StringBuilder(incomingMessages[i].msgAscii); s[144] = '3'; incomingMessages[i].msgAscii = s.ToString(); incomingMessages[i].msg[144] = (byte) '3'; } else { StringBuilder s = new StringBuilder(incomingMessages[i].msgAscii); s[144] = '1'; incomingMessages[i].msgAscii = s.ToString(); incomingMessages[i].msg[144] = (byte)'1'; } string tempstr1 = incomingMessages[i].msgAscii.Substring(2, incomingMessages[i].msgAscii.Length - 2); //Make length into int byte[] tempbytes = new byte[4]; tempbytes[2] = 0; tempbytes[3] = 0; tempbytes[1] = incomingMessages[i].msg[0]; tempbytes[0] = incomingMessages[i].msg[1]; int k = BitConverter.ToInt32(tempbytes, 0); //Put the components in seperated fields string[] messageParts = tempstr1.Split(incomingMessages[i].seperator); if (messageParts.Count() == 14) { incomingMessages[i].msgLength = k; incomingMessages[i].msgType = messageParts[0]; incomingMessages[i].msgTimeStamp = messageParts[1]; incomingMessages[i].msgRequestID = messageParts[2]; incomingMessages[i].msgStudentName = messageParts[3]; incomingMessages[i].msgStudentID = messageParts[4]; incomingMessages[i].msgServerDelay = messageParts[5]; incomingMessages[i].msgClientIPAddress = messageParts[6]; incomingMessages[i].msgClientServicePort = messageParts[7]; incomingMessages[i].msgClientSocketNumber = messageParts[8]; incomingMessages[i].msgHostIPAddress = messageParts[9]; incomingMessages[i].msgHostServicePort = messageParts[10]; incomingMessages[i].msgResponseID = messageParts[11]; incomingMessages[i].msgScenarioNumber = messageParts[12]; } else { error = 1; incomingMessages[i].msgScenarioNumber = "4"; incomingMessages[i].msgTimeStamp = "9999999999"; } } //Sort incoming messages by time stamp incomingMessages = incomingMessages.OrderBy(x => x.msgTimeStamp).ToList(); //Create the last line of the log string LastLine = "Requests transmitted = \t" + MessageCount.ToString().PadLeft(5, '0') + "\r\n"; LastLine = LastLine + "Responses received = \t" + MessageCount.ToString().PadLeft(5, '0') + "\r\n"; TimeSpan et = SendStopTime - SendStartTime; LastLine = LastLine + "Req. run duration = \t" + et.TotalMilliseconds.ToString().PadLeft(9, '0') + "\r\n"; et = ReceiveStopTime - ReceiveStartTime; LastLine = LastLine + "Rsp. Run duration = \t" + et.TotalMilliseconds.ToString().PadLeft(9, '0') + "\r\n"; et = ReceiveStopTime - SendStartTime; LastLine = LastLine + "Trans. Duration = \t" + et.TotalMilliseconds.ToString().PadLeft(9, '0') + "\r\n"; et = SendStopTime - SendStartTime; int durtime = (int)et.TotalMilliseconds / MessageCount; LastLine = LastLine + "Actual req. pace = \t" + durtime.ToString().PadLeft(5, '0') + "\r\n"; et = ReceiveStopTime - ReceiveStartTime; durtime = (int)et.TotalMilliseconds / MessageCount; LastLine = LastLine + "Actual rsp. Pace = \t" + durtime.ToString().PadLeft(5, '0') + "\r\n"; LastLine = LastLine + "Configured pace = \t" + LocalDelayRequest_Milliseconds.ToString().PadLeft(5, '0') + "\r\n"; et = ReceiveStopTime - SendStartTime; durtime = (int)et.TotalMilliseconds / MessageCount; LastLine = LastLine + "Transaction avg. = \t" + durtime.ToString().PadLeft(5, '0') + "\r\n"; LastLine = LastLine + "Your name: \t" + servername + "\r\n"; LastLine = LastLine + "Name of student whose client was used: \t" + "James Brooks\r\n"; //Create a log file file = file + DateTime.Now.ToString("yyyy.MM.dd_HH.mm.ss") + ".txt"; StreamWriter writer = new StreamWriter(file); for (i = 0; i < incomingMessages.Count; i++) { writer.WriteLine(outgoingMessages[i].msgAscii); writer.WriteLine(incomingMessages[i].msgAscii); } writer.WriteLine(LastLine); writer.Close(); }