public bool ReadLogin(NetworkStream NewStream) { byte[] RxBuffer = new byte[Configs.DataByteSize]; while (true) { try { int RxLength = NewStream.Read(RxBuffer, 0, Configs.DataByteSize); string Msg = Encoding.GetEncoding("gb2312").GetString(RxBuffer, 0, RxLength); ManageOrder MO = new ManageOrder(Msg); if (MO.Oder1 == "login") { if (XML.ReadLogin(MO.Oder2, MO.Oder3)) { RxBuffer = Encoding.GetEncoding("gb2312").GetBytes("True"); NewStream.Write(RxBuffer, 0, RxBuffer.Length); return(true); } } RxBuffer = Encoding.GetEncoding("gb2312").GetBytes("False"); NewStream.Write(RxBuffer, 0, RxBuffer.Length); } catch { return(false); } } }
public string UserFaceAnswered(byte[] RxBuffer, int RxLength, ref bool LoginOk) { string Msg = Encoding.GetEncoding("gb2312").GetString(RxBuffer, 0, RxLength); ManageOrder MO = new ManageOrder(Msg); if (MO.Oder1 == "login") { if (XML.ReadLogin(MO.Oder2, MO.Oder3)) { CreateInfor.WriteLogs("用户【" + MO.Oder2 + "】登录!"); LoginOk = true; return("LoginOk"); } } if (!LoginOk) { return("LoginError"); } if (MO.Oder1 == "begin") { switch (MO.Oder2) { case "get": switch (MO.Oder3) { case "end": break; case "clientcount": return(SysFlag.ClientCount.ToString()); case "usercount": return(SysFlag.UserCount.ToString()); case "sqlconnectok": return(SysFlag.SqlConnectOk.ToString()); case "sqlpassword": return(Configs.SqlPassWord); case "sqlname": return(Configs.SqlName); case "sqldatabase": return(Configs.SqlDataBase); case "sqldatasource": return(Configs.SqlDataSource); case "sqldensitysheet": return(Configs.SqlDensitySheet); case "sqlrealtimesheet": return(Configs.SqlRealTimeSheet); case "sqlstationinfor": return(Configs.SqlStationInforSheet); case "configspath": return(Configs.Path); case "densityqueuesize": return(Configs.DensityPacketQueue.Count.ToString()); case "realtimequeuesize": return(Configs.RealTimePacketQueue.Count.ToString()); case "listenok": return(SysFlag.ListenOk.ToString()); case "runpath": return(Directory.GetCurrentDirectory()); case "realtimepacketcount": return(SysFlag.RealTimePacketCount.ToString()); case "densitypacketcount": return(SysFlag.DensityPacketCount.ToString()); } break; case "set": switch (MO.Oder3) { case "sqlname": return(XML.SetConfigS(ref Configs.SqlName, MO.Oder4).ToString()); case "sqlpassword": return(XML.SetConfigS(ref Configs.SqlPassWord, MO.Oder4).ToString()); case "sqldatasource": return(XML.SetConfigS(ref Configs.SqlDataSource, MO.Oder4).ToString()); case "sqldatabase": return(XML.SetConfigS(ref Configs.SqlDataBase, MO.Oder4).ToString()); case "sqldensitysheet": return(XML.SetConfigS(ref Configs.SqlDensitySheet, MO.Oder4).ToString()); case "sqlrealtimesheet": return(XML.SetConfigS(ref Configs.SqlRealTimeSheet, MO.Oder4).ToString()); case "servicepoint": return(XML.SetConfigD(ref Configs.ServicePoint, MO.Oder4).ToString()); case "sqlstationinforsheet": return(XML.SetConfigS(ref Configs.SqlStationInforSheet, MO.Oder4).ToString()); case "userrootpassword": return(XML.SetConfigS(ref Configs.UserRootPassWord, MO.Oder4).ToString()); } break; case "open": switch (MO.Oder3) { case "end": break; } break; case "restart": switch (MO.Oder3) { case "end": break; } break; default: break; } } return("False"); }