コード例 #1
0
        private void radarNotify(HttpContext context)
        {
            string errMsg  = string.Empty;
            string token   = context.Request["token"];
            string action  = context.Request["action"];
            string result  = context.Request["result"];
            string orderid = context.Request["orderid"];
            string sn      = context.Request["sn"];
            string signkey = context.Request["signkey"];

            ClientService service = new ClientService();

            service.Connection();
            RadarNotifyRequestModel dataModel = new RadarNotifyRequestModel();

            dataModel.Token   = token;
            dataModel.SN      = sn;
            dataModel.Result  = result;
            dataModel.OrderId = orderid;
            dataModel.SignKey = "";
            dataModel.Action  = "1";
            dataModel.Coins   = "5";
            byte[] data = DataFactory.CreateRequesProtocolData(TransmiteEnum.雷达通知指令, dataModel);
            service.Send(data);

            RadarSendObject sendObj = new RadarSendObject("100010", "0001");
            //手机号码构建TCP接受对象
            MemberReceiveObject receiveObj     = new MemberReceiveObject("15618920033");
            RadarAnswerObj      radarAnswerObj = new RadarAnswerObj("1", ((int)(TCPAnswerMessageType.出币)).ToString(), "成功出币5");

            SocketDataModel <RadarSendObject, MemberReceiveObject, RadarAnswerObj> socketDataModel = new SocketDataModel <RadarSendObject, MemberReceiveObject, RadarAnswerObj>("3", "0", sendObj, receiveObj, radarAnswerObj);
            //string str = Utils.DataContractJsonSerializer(socketDataModel);

            var dataObj = new {
                answerMsgType = "1",
                answerOjb     = new {
                    result_code = "1",
                    answerMsg   = "成功出币10个"
                }
            };

            TCPServiceBusiness.Send("15618920033", dataObj);
        }
コード例 #2
0
ファイル: CommandHandler.cs プロジェクト: tongxin3267/XCCloud
        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"));
                }
            }
        }