public static void RadarHeat(string requestDataJson, UDPClientItemBusiness.ClientItem item) { object outModel = null; object requestModel = null; DataFactory.CreateResponseProtocolData(TransmiteEnum.雷达心跳, requestDataJson, ref requestModel, ref outModel); RadarHeartbeatOutParamsModel outDataModel = (RadarHeartbeatOutParamsModel)outModel; Send(((IPEndPoint)item.remotePoint).Address.ToString(), ((IPEndPoint)item.remotePoint).Port, ((RadarHeartbeatOutParamsModel)outModel).ResponsePackages); RadarHeartbeatRequestDataModel requestDataModel = (RadarHeartbeatRequestDataModel)requestModel; //记录心跳日志 bool bHeadSuccess = false; if (outDataModel.ResponseModel.GetType().Name.Equals("ComonErrorResponseModel")) { ComonErrorResponseModel model = (ComonErrorResponseModel)(outDataModel.ResponseModel); bHeadSuccess = model.Result_Code == "1" ? true : false; } else if (outDataModel.ResponseModel.GetType().Name.Equals("ComonSuccessResponseModel")) { ComonSuccessResponseModel model = (ComonSuccessResponseModel)(outDataModel.ResponseModel); bHeadSuccess = model.Result_Code == "1" ? true : false; } string logTxt = "[接收:" + requestDataJson + "]" + "[响应:" + Utils.SerializeObject(outModel) + "]" + System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); UDPLogHelper.SaveRadarHeatLog(((IPEndPoint)item.remotePoint).Address.ToString(), ((IPEndPoint)item.remotePoint).Port, requestDataModel.StoreId, requestDataModel.Segment, requestDataModel.Token, bHeadSuccess, requestDataJson, outDataModel.ResponseJson, logTxt); ClientList.UpdateClientHeatTime(requestDataModel.Token); string message = "[接收:" + requestDataJson + "]" + "[响应:" + outDataModel.ResponseJson + "]"; SignalrServerToClient.BroadcastMessage(Convert.ToInt32(TransmiteEnum.雷达心跳), "雷达心跳", requestDataModel.Token, message, System.DateTime.Now); }
public static void DeviceStateChange(string requestDataJson, UDPClientItemBusiness.ClientItem item) { object outModel = null; object requestModel = null; DataFactory.CreateResponseProtocolData(TransmiteEnum.设备状态变更通知, requestDataJson, ref requestModel, ref outModel); DeviceStateOutParamsModel responseOutModel = (DeviceStateOutParamsModel)outModel; Send(((IPEndPoint)item.remotePoint).Address.ToString(), ((IPEndPoint)item.remotePoint).Port, ((DeviceStateOutParamsModel)outModel).ResponsePackages); DeviceStateRequestDataModel requestDataModel = (DeviceStateRequestDataModel)requestModel; //记录心跳日志 bool bChangeSuccess = false; if (responseOutModel.ResponseModel.GetType().Name.Equals("ComonErrorResponseModel")) { ComonErrorResponseModel model = (ComonErrorResponseModel)(responseOutModel.ResponseModel); bChangeSuccess = model.Result_Code == "1" ? true : false; } else if (responseOutModel.ResponseModel.GetType().Name.Equals("ComonSuccessResponseModel")) { ComonSuccessResponseModel model = (ComonSuccessResponseModel)(responseOutModel.ResponseModel); bChangeSuccess = model.Result_Code == "1" ? true : false; } string logTxt = "[接收:" + requestDataJson + "]" + "[响应:" + Utils.SerializeObject(outModel) + "]" + System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); UDPLogHelper.SaveDeviceStateChangeLog(((IPEndPoint)item.remotePoint).Address.ToString(), ((IPEndPoint)item.remotePoint).Port, requestDataModel.StoreId, requestDataModel.Token, requestDataModel.MCUId, requestDataModel.Status, bChangeSuccess, requestDataJson, responseOutModel.ResponseJson, logTxt); string message = "[接收:" + requestDataJson + "]" + "[响应:" + responseOutModel.ResponseJson + "]"; SignalrServerToClient.BroadcastMessage(Convert.ToInt32(TransmiteEnum.设备状态变更通知), "设备状态变更通知", requestDataModel.Token, message, System.DateTime.Now); }
public static void RadarRegister(string requestDataJson, UDPClientItemBusiness.ClientItem item) { //通知服务器上线 object outModel = null; object requestModel = null; bool bRegister = false; DataFactory.CreateResponseProtocolData(TransmiteEnum.雷达注册授权, requestDataJson, ref requestModel, ref outModel); RadarRegisterOutParamsModel parmasModel = (RadarRegisterOutParamsModel)outModel; if (!string.IsNullOrEmpty(parmasModel.Token)) { bRegister = true; item.gID = parmasModel.Token; item.StoreID = parmasModel.StoreId; item.Segment = parmasModel.Segment; ClientList.UpdateClient(item); } Send(((IPEndPoint)item.remotePoint).Address.ToString(), ((IPEndPoint)item.remotePoint).Port, parmasModel.ResponsePackages); string logTxt = "[接收:" + requestDataJson + "]" + "[响应:" + Utils.SerializeObject(parmasModel) + "]" + System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); UDPLogHelper.SaveRadarRegisterLog(((IPEndPoint)item.remotePoint).Address.ToString(), ((IPEndPoint)item.remotePoint).Port, parmasModel.StoreId, parmasModel.Segment, parmasModel.Token, bRegister, requestDataJson, parmasModel.ResponseJson, logTxt); string message = "[接收:" + requestDataJson + "]" + "[响应:" + parmasModel.ResponseJson + "]"; SignalrServerToClient.BroadcastMessageByRadarRegister("雷达注册授权", item.StoreID, item.Segment, message, System.DateTime.Now); }
public static void DeviceControl(string requestDataJson, UDPClientItemBusiness.ClientItem item) { object outModel = null; object requestModel = null; DataFactory.CreateResponseProtocolData(TransmiteEnum.远程设备控制指令, requestDataJson, ref requestModel, ref outModel); DeviceControlAnswerRequestDataModel requestDataModel = (DeviceControlAnswerRequestDataModel)requestModel; DeviceControlOutParmasModel responseDataModel = (DeviceControlOutParmasModel)outModel; UDPSocketAnswerModel answerModel = null; string orderId = string.Empty; bool bSuccess = GetResponseModelResultCode(responseDataModel.ResponseModel); answerModel = UDPSocketAnswerBusiness.GetAnswerModel(requestDataModel.SN); if (requestDataModel.Result_Code == "1" && bSuccess && UDPSocketAnswerBusiness.ExistSN(requestDataModel.SN)) { //如果应答结果正确,清除应答缓存,添加对手机号的接口调用锁定 UDPSocketAnswerBusiness.Remove(requestDataModel.SN); } string logTxt = "[接收:" + requestDataJson + "]" + System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); string radarToken = string.Empty; if (answerModel != null && XCGameRadarDeviceTokenBusiness.GetRouteDeviceToken(requestDataModel.StoreId, answerModel.Segment, out radarToken)) { } UDPLogHelper.SaveUDPDeviceControlLog(requestDataModel.StoreId, requestDataModel.OrderId, ((IPEndPoint)item.remotePoint).Address.ToString(), ((IPEndPoint)item.remotePoint).Port, requestDataModel.SN, requestDataJson, responseDataModel.ResponseJson, bSuccess, logTxt); string message = "[接收:" + requestDataJson + "]" + "[响应:" + responseDataModel.ResponseJson + "]"; SignalrServerToClient.BroadcastMessage(Convert.ToInt32(TransmiteEnum.雷达心跳), "远程设备控制指令响应", radarToken, message, System.DateTime.Now); }
public static void RadarNotify(string requestDataJson, UDPClientItemBusiness.ClientItem item) { object outModel = null; object requestModel = null; DataFactory.CreateResponseProtocolData(TransmiteEnum.雷达通知指令, requestDataJson, ref requestModel, ref outModel); RadarNotifyRequestModel rnrModel = Utils.DataContractJsonDeserializer <RadarNotifyRequestModel>(requestDataJson); RadarNotifyOutParamsModel responseOutModel = (RadarNotifyOutParamsModel)outModel; XCGameRadarDeviceTokenModel radarTokenModel = XCGameRadarDeviceTokenBusiness.GetRadarDeviceTokenModel(rnrModel.Token); Send(((IPEndPoint)item.remotePoint).Address.ToString(), ((IPEndPoint)item.remotePoint).Port, ((RadarNotifyOutParamsModel)outModel).ResponsePackages); RadarNotifyRequestModel requestDataModel = (RadarNotifyRequestModel)requestModel; //验证相应模式 bool bCoinSuccess = false; if (responseOutModel.ResponseModel.GetType().Name.Equals("ComonErrorResponseModel")) { ComonErrorResponseModel model = (ComonErrorResponseModel)(responseOutModel.ResponseModel); bCoinSuccess = model.Result_Code == "1" ? true : false; } else if (responseOutModel.ResponseModel.GetType().Name.Equals("ComonSuccessResponseModel")) { ComonSuccessResponseModel model = (ComonSuccessResponseModel)(responseOutModel.ResponseModel); bCoinSuccess = model.Result_Code == "1" ? true : false; } //记录日志 string logTxt = "[接收:" + requestDataJson + "]" + "[响应:" + responseOutModel.ResponseJson + "]" + System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); UDPLogHelper.SaveUDPRadarNotifyLog(requestDataModel.StoreId, requestDataModel.OrderId, requestDataModel.Token, requestDataModel.SN, int.Parse(requestDataModel.Coins), int.Parse(requestDataModel.Action), requestDataModel.Result, ((IPEndPoint)item.remotePoint).Address.ToString(), ((IPEndPoint)item.remotePoint).Port, requestDataJson, responseOutModel.ResponseJson, bCoinSuccess, logTxt); string message = "[接收:" + requestDataJson + "]" + "[响应:" + responseOutModel.ResponseJson + "]"; SignalrServerToClient.BroadcastMessage(Convert.ToInt32(TransmiteEnum.雷达通知指令), "雷达通知指令", requestDataModel.Token, message, System.DateTime.Now); if (rnrModel.Result == "成功" && bCoinSuccess) { //出币后向客户端发送成功信息 try { TCPAnswerOrderModel taoModel = null; //如果订单缓存信息存在 if (MPOrderBusiness.ExistTCPAnswerOrder(rnrModel.OrderId, ref taoModel)) { string coinType = CoinBusiess.GetCoinOpetionName(taoModel.Action); string notifyMsg = string.Empty; string answerMsgType = string.Empty; string errMsg = string.Empty; SAppPushMessageCacheModel msgModel = null; if (taoModel.Action == "1") { notifyMsg = "成功出币" + taoModel.Coins.ToString() + "个"; answerMsgType = ((int)(TCPAnswerMessageType.出币)).ToString(); if (SAppPushMessageBusiness.GetModel(rnrModel.OrderId, ref msgModel)) { if (msgModel.SAppMessageType == SAppMessageType.MemberCoinsOperationNotify) { MemberCoinsOperationNotifyDataModel dataModel = (MemberCoinsOperationNotifyDataModel)(msgModel.DataObj); SAppMessageMana.PushMemberCoinsMsg(msgModel.OpenId, msgModel.SAppAccessToken, "提币", dataModel.StoreName, dataModel.Mobile, dataModel.ICCardId, int.Parse(requestDataModel.Coins), dataModel.LastBalance, msgModel.FormId, "", out errMsg); } else if (msgModel.SAppMessageType == SAppMessageType.MemberFoodSaleNotify) { MemberFoodSaleNotifyDataModel dataModel = (MemberFoodSaleNotifyDataModel)(msgModel.DataObj); SAppMessageMana.PushMemberFoodSaleMsg(msgModel.OpenId, msgModel.SAppAccessToken, "购币", dataModel.StoreName, msgModel.Mobile, msgModel.OrderId, dataModel.FoodName, dataModel.FoodNum, dataModel.ICCardId, dataModel.Money, dataModel.Coins, msgModel.FormId, out errMsg); } } } else if (taoModel.Action == "2") { notifyMsg = "成功存币" + requestDataModel.Coins.ToString() + "个"; answerMsgType = ((int)(TCPAnswerMessageType.存币)).ToString(); IconOutLockBusiness.RemoveByNoTimeList(taoModel.Mobile); if (int.Parse(requestDataModel.Coins) > 0) { try { int lastBalance = 0; string storeName = string.Empty; string mobile = string.Empty; if (MemberPreservationBusiness.PreservationBusiness(int.Parse(taoModel.ICCardId), int.Parse(taoModel.StoreId), int.Parse(requestDataModel.Coins), out lastBalance, out storeName, out mobile)) { if (SAppPushMessageBusiness.GetModel(rnrModel.OrderId, ref msgModel)) { MemberCoinsOperationNotifyDataModel dataModel = (MemberCoinsOperationNotifyDataModel)(msgModel.DataObj); SAppMessageMana.PushMemberCoinsMsg(msgModel.OpenId, msgModel.SAppAccessToken, "存币", dataModel.StoreName, dataModel.Mobile, dataModel.ICCardId, int.Parse(requestDataModel.Coins), dataModel.LastBalance, msgModel.FormId, "", out errMsg); } } } catch (Exception e) { LogHelper.SaveLog(TxtLogType.Api, TxtLogContentType.Debug, TxtLogFileType.Day, "MemberPreservationBusiness.PreservationBusiness:" + e.Message); } } } else if (taoModel.Action == "6")//投币 { MemberCoinsOperationNotifyDataModel dataModel = (MemberCoinsOperationNotifyDataModel)(msgModel.DataObj); SAppMessageMana.PushMemberCoinsMsg(msgModel.OpenId, msgModel.SAppAccessToken, "投币", dataModel.StoreName, dataModel.Mobile, dataModel.ICCardId, int.Parse(requestDataModel.Coins), dataModel.LastBalance, msgModel.FormId, "", out errMsg); } else if (taoModel.Action == "7")//退币 { MemberCoinsOperationNotifyDataModel dataModel = (MemberCoinsOperationNotifyDataModel)(msgModel.DataObj); SAppMessageMana.PushMemberCoinsMsg(msgModel.OpenId, msgModel.SAppAccessToken, "退币", dataModel.StoreName, dataModel.Mobile, dataModel.ICCardId, int.Parse(requestDataModel.Coins), dataModel.LastBalance, msgModel.FormId, "", out errMsg); } var dataObj = new { result_code = "1", answerMsg = notifyMsg, answerMsgType = answerMsgType }; MPOrderBusiness.RemoveTCPAnswerOrder(rnrModel.OrderId); TCPServiceBusiness.Send(taoModel.Mobile, dataObj); } } catch (Exception ex) { LogHelper.SaveLog(TxtLogType.UPDService, TxtLogContentType.Exception, TxtLogFileType.Day, "Exception:" + rnrModel.OrderId + Utils.GetException(ex) + System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")); } } }