Ejemplo n.º 1
0
        protected override Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, System.Threading.CancellationToken cancellationToken)
        {
            var    reqTask    = request.Content.ReadAsStringAsync();
            string reqContent = reqTask.Result;
            var    task       = new Task <HttpResponseMessage>(() =>
            {
                var resMsg       = new HttpResponseMessage();
                string dateStamp = GetTimeStamp();

                CommonReq crq = new CommonReq
                {
                    timestamp    = dateStamp,
                    version      = "1.0",
                    method       = TypesModel.Operation.ArticleCrawl.ToString(),
                    requesttoken = Guid.NewGuid().ToString()
                };
                DataRes dr = new DataRes
                {
                    result_code = "1",
                    result_msg  = "success"
                };
                crq.data        = JsonConvert.SerializeObject(dr);
                var sendContent = JsonConvert.SerializeObject(crq);
                resMsg.Content  = new StringContent(sendContent, System.Text.Encoding.UTF8, "application/json");
                return(resMsg);
            });

            task.Start();
            Console.WriteLine("------------------------------------------------------------------------");
            Console.WriteLine(reqContent);
            return(task);
        }
        public override string OnResponse(string data)
        {
            CommonReq defaultReqData = null;

            try
            {
                defaultReqData = JsonConvert.DeserializeObject <CommonReq>(data);
            }
            catch (Exception e)
            {
                MySqlService.log.Warn("传入的参数有误:" + e);
                return(null);
            }
            string Tag    = defaultReqData.tag;
            int    connId = defaultReqData.connId;

            if (string.IsNullOrWhiteSpace(Tag))
            {
                MySqlService.log.Warn("字段有空");
                return(null);
            }
            //传给客户端的数据
            JObject responseData = new JObject();

            responseData.Add(MyCommon.TAG, Tag);
            responseData.Add(MyCommon.CONNID, connId);
            //查询
            GetRankSql(responseData);
            return(responseData.ToString());
        }
        public override string OnResponse(string data)
        {
            CommonReq defaultReq = null;

            try
            {
                defaultReq = JsonConvert.DeserializeObject <CommonReq>(data);
            }
            catch (Exception e)
            {
                MySqlService.log.Warn("传入的参数有误");
                return(null);
            }

            string Tag    = defaultReq.tag;
            int    connId = defaultReq.connId;

            //传给客户端的数据
            JObject _responseData = new JObject();

            _responseData.Add(MyCommon.TAG, Tag);
            _responseData.Add(MyCommon.CONNID, connId);

            //得到pvp数据
            OperatorSuccess(_responseData);
            return(_responseData.ToString());
        }
Ejemplo n.º 4
0
        public override string OnResponse(string data)
        {
            CommonReq defaultReq = null;

            try
            {
                defaultReq = JsonConvert.DeserializeObject <CommonReq>(data);
            }
            catch (Exception e)
            {
                MySqlService.log.Warn("传入的参数有误");
                return(null);
            }

            string Tag        = defaultReq.tag;
            int    connId     = defaultReq.connId;
            bool   isIosCheck = defaultReq.isIosCheck;

            if (string.IsNullOrWhiteSpace(Tag))
            {
                MySqlService.log.Warn("字段有空");
                return(null);
            }

            //传给客户端的数据
            JObject _responseData = new JObject();

            _responseData.Add(MyCommon.TAG, Tag);
            _responseData.Add(MyCommon.CONNID, connId);

            //得到pvp数据
            GetTurnTableDataSql(_responseData, isIosCheck);
            return(_responseData.ToString());
        }
Ejemplo n.º 5
0
        public override string OnResponse(string data)
        {
            CommonReq defaultReq = null;

            try
            {
                defaultReq = JsonConvert.DeserializeObject <CommonReq>(data);
            }
            catch (Exception e)
            {
                MySqlService.log.Warn("传入的参数有误");
                return(null);
            }

            string Tag       = defaultReq.tag;
            int    connId    = defaultReq.connId;
            string uid       = defaultReq.uid;
            int    duihuanId = defaultReq.duihuan_id;

            //传给客户端的数据
            JObject _responseData = new JObject();

            _responseData.Add(MyCommon.TAG, Tag);
            _responseData.Add(MyCommon.CONNID, connId);
            _responseData.Add("duihuan_id", duihuanId);

            //得到pvp数据

            ExchangeTeleFarePiece(uid, duihuanId, _responseData);

            return(_responseData.ToString());
        }
Ejemplo n.º 6
0
        public static string GenSignature(CommonReq request)
        {
            string key  = Config.Key;
            string date = DateTime.Now.ToString("yyyy-MM-dd");
            string str  = string.Format("method={0}&requesttoken={1}&timestamp={2}&version={3}&{4}&key={5}",
                                        request.method, request.requesttoken, request.timestamp, request.version, date, key);
            string encrypted = DecryptAndEncryptionHelper.MD5Encrypt(str);

            return(encrypted);
        }
        public override string OnResponse(string data)
        {
            CommonReq defaultReq = null;

            try
            {
                defaultReq = JsonConvert.DeserializeObject <CommonReq>(data);
            }
            catch (Exception e)
            {
                MySqlService.log.Warn("传入的参数有误:" + e);
                return(null);
            }

            string Tag        = defaultReq.tag;
            int    connId     = defaultReq.connId;
            var    uid        = defaultReq.uid;
            var    type       = defaultReq.type;
            var    isIosCheck = defaultReq.isIosCheck;

            if (string.IsNullOrWhiteSpace(Tag) || string.IsNullOrWhiteSpace(uid) || type < 1 || type > 2)
            {
                MySqlService.log.Warn("字段有空:" + uid);
                return(null);
            }

            //传给客户端的数据
            JObject _responseData = new JObject();

            _responseData.Add(MyCommon.TAG, Tag);
            _responseData.Add(MyCommon.CONNID, connId);
            _responseData.Add(MyCommon.UID, uid);
            _responseData.Add("type", type);

            UseTurnTableDataSql(uid, type, isIosCheck, _responseData);
            return(_responseData.ToString());
        }
Ejemplo n.º 8
0
        private void Excute(int serviceId, int messageId, string data, PerformContext context)
        {
            CommonReq req = new CommonReq();

            req.JobId     = context.BackgroundJob.Id;
            req.ServiceId = serviceId;
            req.MessageId = messageId;
            req.Data      = data;

            var reqMsg = AmpMessage.CreateRequestMessage(Constants.CONSUMER_SERVER_ID, Constants.CONSUMER_DEFAULT_MESSAGE_ID);

            reqMsg.Data = req.ToByteArray();

            context.WriteLine("Start Excute Task With serviceId={0},messageId={1},data ={2}", serviceId, messageId, data);

            var resMsg = _invoker.BlockingCall(reqMsg, 30000); //30秒超时

            if (resMsg != null)
            {
                if (resMsg.Code == 0)
                {
                    context.WriteLine("Excute Success!");
                }
                else
                {
                    context.SetTextColor(ConsoleTextColor.Red);
                    context.WriteLine("Excute failed, Code = {0}", resMsg.Code);
                    context.ResetTextColor();
                }
            }
            else
            {
                context.SetTextColor(ConsoleTextColor.Red);
                context.WriteLine("Excute Error, Response is null");
                context.ResetTextColor();
            }
        }