public static string ShowTimeBySQL() { DateTime Dt = DateTime.Now; string dt = Dt.ToString("yyyyMMdd"); //最新开奖时间 string a; DataSet ds = BLL.UserMessage.SelectNewLotterys(); DataTable datat = ds.Tables[0]; if (datat.Rows.Count == 0) { a = DateTime.Now.ToString(); } else { //开奖时间 a = datat.Rows[1]["Timer"].ToString(); } string NetTime = GetNetDateTime(); DateTime Te; if (DateTime.TryParse(NetTime, out Te)) { intertime = Te.ToString("yyyy-MM-dd HH:mm:ss") + "/" + a; //网络时间 } else { intertime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "/" + a; //系统时间 } return(intertime); }
void Update() { //CURRENT STATE: WAIT FOR THE USER TO ENTER SETUP INFORMATION if (clientAuto.CurrState == PongClientAutomaton.WAIT_USER_SETUP_INFO) { //if the Role has been assigned if (GeneralUtils.RoleChosen()) { //enact transition to the next state clientAuto.Transition(PongClientAutomaton.TRY_CONNECT_SERVER); } } //CURRENT STATE: TRY TO CONNECT TO THE SERVER else if (clientAuto.CurrState == PongClientAutomaton.TRY_CONNECT_SERVER) { //initiate connection clientSocket = new ClientSocket(NetUtils.GetMyClientPort(), 1, serverIP); //if connected successfully if (clientSocket.Connected) { //enact transition to the next state clientAuto.Transition(PongClientAutomaton.WAIT_RECV_ENV_SETTINGS); } } //CURRENT STATE: WAIT TO RECV ENVIRONMENT SETTINGS FROM SERVER else if (clientAuto.CurrState == PongClientAutomaton.WAIT_RECV_ENV_SETTINGS) { //if received something from server if (clientSocket.pollAndReceiveData(clientSocket.Client, recvdData, 10) >= 1) { //extract the json part of the message string jsonString = recvdData.timeStamp.Substring(recvdData.timeStamp.IndexOf(",") + 1); envState = JsonConvert.DeserializeObject <EnvState>(jsonString); //respond with acknowledgement clientSocket.sendData(new StreamData("00:00:00")); //store communication time begin for Throughput analysis if (doAnalysis) { Tb = DateTime.Now; } //enact transition to the next state clientAuto.Transition(PongClientAutomaton.NORMAL_COMMUNICATION); } } //CURRENT STATE: NORMAL COMMUNICATION WITH THE SERVER else if (clientAuto.CurrState == PongClientAutomaton.NORMAL_COMMUNICATION) { //if received something from server if (clientSocket.pollAndReceiveData(clientSocket.Client, recvdData, 10) >= 1) { //extract the json part of the message //Debug.Log ( "recvd = " + recvdData.timeStamp ); string jsonString = recvdData.timeStamp.Substring(recvdData.timeStamp.IndexOf(",") + 1); envState = JsonConvert.DeserializeObject <EnvState>(jsonString); //update the environment to reflect the contents of the EnvState object GeneralUtils.SetEnvState(envState); //get human input InputData inputData = GeneralUtils.PackageInputData(); if (inputData == null) { inputData = new InputData(); } //send InputData to the server string message = "InputData," + inputData.ToJsonString(); StreamData dataToSend = new StreamData(message); clientSocket.sendData(dataToSend); //increment Throughpput counter N if (doAnalysis) { N += 1; } } //if user stops, stop Throughput analysis if (doAnalysis && Input.GetKeyDown(KeyCode.C)) { Te = DateTime.Now; T = ((float)N / (float)(Te - Tb).TotalSeconds); string outputFileName = GeneralUtils.GetTAFileName(); StreamWriter sw = new StreamWriter(outputFileName, true); sw.Write(T.ToString() + "," + N.ToString() + "," + Tb.ToString().Replace(",", "_") + "," + Te.ToString().Replace(",", "_")); sw.Close(); } //if the connection is lost if (!clientSocket.Connected) { //enact transition to the next state clientAuto.Transition(PongClientAutomaton.ERROR_STATE); } } //CURRENT STATE: ERROR OCCURRED else if (clientAuto.CurrState == PongClientAutomaton.ERROR_STATE) { } }