Ejemplo n.º 1
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            try 
            {
                //param格式://int templateID, int count, int validDate, int StrengthenLevel, int AttackCompose, int DefendCompose, int AgilityCompose, int LuckCompose, bool isBinds
                //result:0:成功 1:失败 2:没有该账号 3:ip无效  4:param不合法 5:key错误 6:content内参数列不正确 7:超时
                int result=1;

                //判断IP是否合法
                if (ValidSentRewardIP(context.Request.UserHostAddress))
                {
                    string content = HttpUtility.UrlDecode(context.Request["content"]);

                    
                    string key = GetSentRewardKey;
                  
                    BaseInterface inter = BaseInterface.CreateInterface();
                    string[] str_param = inter.UnEncryptSentReward(content, ref  result, key);

                    if (str_param.Length == 8 && result != 5 && result != 6 && result != 7)  
                     {
                        string mailTitle = str_param[0];
                        string mailContent = str_param[1];
                        string username = str_param[2];
                        int gold = Int32.Parse(str_param[3]);
                        int money = Int32.Parse(str_param[4]);
                        string param = str_param[5];

                        //判断para是否合法,并将不合法的数值设为默认合法值
                        if (checkParam(ref param))  
                        {
                            PlayerBussiness pb = new PlayerBussiness();
                            result = pb.SendMailAndItemByUserName(mailTitle, mailContent, username, gold, money, param);
                        }
                        else
                        {
                            result = 4;
                        }

                    }

                }
                else 
                {
                    result = 3;
                }

                context.Response.Write(result);
               
            }
            catch(Exception ex)
            {
                log.Error("SentReward", ex);
            }

            
        }