public static bool SetMemberCoinsMsgCacheData(SAppMessageType sAppMessageType, string orderId, string form_id, string mobile, object dataObj, out string errMsg) { string openId = string.Empty; string accessToken = string.Empty; errMsg = string.Empty; try { if (MobileTokenBusiness.GetOpenId(mobile, out openId, out errMsg) && SAppTokenMana.GetAccessToken(out accessToken, out errMsg)) { SAppPushMessageCacheModel msgModel = new SAppPushMessageCacheModel(orderId, mobile, openId, form_id, CommonConfig.SAppMessagePushXmlFilePath, accessToken, sAppMessageType, dataObj); SAppPushMessageBusiness.Add(msgModel); } return(true); } catch { return(false); } }
public static bool SetMemberCoinsMsgCacheData(string orderId, string form_id, string mobile, SAppMessageType sAppMessageType, object dataObj, out string errMsg) { string openId = string.Empty; string accessToken = string.Empty; errMsg = string.Empty; try { if (MobileTokenBusiness.GetOpenId(mobile, out openId, out errMsg) && SAppTokenMana.GetAccessToken(out accessToken, out errMsg)) { string xmlFilePath = HttpContext.Current.Server.MapPath("/Config/SAppMessageTemplate.xml"); SAppPushMessageCacheModel msgModel = new SAppPushMessageCacheModel(orderId, mobile, openId, form_id, xmlFilePath, accessToken, sAppMessageType, dataObj); SAppPushMessageBusiness.Add(msgModel); } return(true); } catch { return(false); } }
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")); } } }