static void Main(string[] args) { Rooms room = new Rooms(); ClientS clientS = new ClientS(); clientS.OpenClient(); Console.WriteLine("等待客户端接入"); room.clientS = clientS; int t = 0; int ret = 0; while (true) { t++; Thread.Sleep(5); clientS.SendAll(); ret = clientS.UpdateTime(); if (ret > 0) { for (int i = 0; i < 6; i++) { if ((ret & (1 << i)) > 0) { room.DelPlayer(i); } } room.SendData_All(); room.SendData_PlayerAll(); } for (int i = 0; i < 6; i++) { room.DealSendData(i); if (t >= 20) { int delay = clientS.GetDelay(i); if (delay > 0) { //Console.WriteLine("clients " + i + " : " + delay + " ms"); } } } if (t >= 20) { t = 0; clientS.AddDataImpulseAll(); } //Console.WriteLine("Send : " + clientS.SendNum + " Recv : " + clientS.RecvNum); clientS.SendNum = 0; clientS.RecvNum = 0; } }
public Dictionary <string, Dictionary <string, List <ReliabilitySummary> > > SortbyDepartmentsRealitykeyValuePairs(List <RawReliability> listRawData) { Dictionary <string, Dictionary <string, List <ReliabilitySummary> > > keyValuePairs = new Dictionary <string, Dictionary <string, List <ReliabilitySummary> > >(); var listGroupByClient = listRawData .GroupBy(u => u.DepartmentCode) .Select(grp => grp.ToList()) .ToList(); foreach (var ClientS in listGroupByClient) { var ListGroupByDept = ClientS .GroupBy(u => u.ClientsEnd) .Select(grp => grp.ToList()) .ToList(); Dictionary <string, List <ReliabilitySummary> > DeptReliability = new Dictionary <string, List <ReliabilitySummary> >(); List <ReliabilitySummary> reliabilities = new List <ReliabilitySummary>(); List <ReliabilitySummary> reliabilitiesTotal = new List <ReliabilitySummary>(); foreach (var dept in ListGroupByDept) { ReliabilitySummary reliability = new ReliabilitySummary(); reliabilities = new List <ReliabilitySummary>(); reliability.Clients = dept[0].ClientsEnd; reliability.DepartmentCode = dept[0].DepartmentCode; int CountLate = dept.Where(d => d.Evaluation == "Late").Count(); int CountOntime = dept.Where(d => d.Evaluation == "On-time").Count(); int CountEarly = dept.Where(d => d.Evaluation == "Early").Count(); reliability.DeliveryQuantity = dept.Select(d => d.DeliveryQuantity).Sum(); reliability.OTS = dept.Select(d => d.OTS).Average(); reliability.SOMO = dept.Select(d => d.SOMO).Average(); reliability.ReqOTS = dept.Select(d => d.ReqOTS).Average(); reliability.Orders = CountLate + CountOntime + CountEarly; reliability.OrdersOT = CountOntime; reliability.OrdesEarly = CountEarly; reliability.OrdesLate = CountLate; reliability.Reliability = (reliability.OrdesEarly + reliability.OrdersOT) / reliability.Orders; reliabilities.Add(reliability); reliabilitiesTotal.Add(reliability); DeptReliability.Add(reliability.Clients, reliabilities); } DeptReliability.Add("Total", reliabilitiesTotal); keyValuePairs.Add(ClientS[0].DepartmentCode, DeptReliability); } return(keyValuePairs); }
/// <summary> /// Trasform the line of data received into a Message structure and raise /// the event linked. /// </summary> /// <param name="server">Server raising the event.</param> /// <param name="sender">Client sending the data.</param> /// <param name="Data">Line of data received.</param> void BaseMessageServer_OnDataReceived(Server server, ClientS sender, Data Data) { TCPMessage msg = null; try { msg = TCPMessage.FromByteArray(Data.Message); } catch (Exception) { } if (msg != null) { if (OnClientMessageReceived != null) { OnClientMessageReceived(this, (BaseMessageClientS)sender, msg); } } }
/// <summary> /// Trasform the line of data sent into a Message structure and raise /// the event linked. /// </summary> /// <param name="server">Server raising the event.</param> /// <param name="receiver">Client that will receive the Message.</param> /// <param name="Data">Line of data sent.</param> void BaseMessageServer_OnDataSent(Server server, ClientS receiver, Data Data) { TCPMessage msg = null; try { msg = TCPMessage.FromByteArray(Data.Message); } catch (Exception) { } if (msg != null) { if (OnClientAfterMessageSent != null) { OnClientAfterMessageSent(this, (BaseMessageClientS)receiver, msg); } } }
static void Main(string[] args) { ClientS clientS = new ClientS(); clientS.OpenClient(); while (true) { Thread.Sleep(5); clientS.SendAll(); for (int i = 0; i < 6; i++) { int delay = clientS.GetDelay(i); if (delay > 0) { Console.WriteLine("clients " + i + " : " + delay + " ms"); } } clientS.UpdateTime(); } }