Example #1
0
        public void AddVariable(string expr, bool show_tab)
        {
            if (row_exists(expr))
            {
                return;
            }
            RetValue rv = DebugUtils.DebuggerManager.Evaluate(expr);
            int      i  = this.WdataGridView1.Rows.Count - 1;

            BottomTabsVisible = true;
            if (show_tab)
            {
                SelectContent(DebugWatchListWindow, false);
            }
            //this.BottomTabControl.SelectTab(this.tpWarningList);
            //if (this.WdataGridView1.Rows.Count == 1 && this.WdataGridView1.Rows[0].Cells[0].Value == null) i = 0;
            if (this.WdataGridView1.Rows[0].Cells[0].Value == null)
            {
                i = 0;
            }
            else //if (this.WdataGridView1.Rows[1].Cells[0].Value != null)
            {
                this.WdataGridView1.Rows.Insert(0, 1); i = 0;
                //i = this.WdataGridView1.Rows.Count-1;
            }
            if (this.WdataGridView1.Rows.Count == 1)
            {
                this.WdataGridView1.Rows.Insert(0, 1);
            }
            this.WdataGridView1.Rows[i].Cells[0].Value = expr;
            DebugWatchListWindow.RefreshRow(i);
        }
        public RetValue Post([FromBody] string jsonStr)
        {
            RetValue ret      = new RetValue();
            JsonData jsonData = JsonMapper.ToObject(jsonStr);


            string channelId    = jsonData["ChannelId"].ToString();
            string innerVersion = jsonData["InnerVersion"].ToString();

            ChannelEntity entity = ChannelCacheModel.Instance.GetEntity(string.Format("[ChannelId]={0} and [InnerVersion]={1}", channelId, innerVersion));

            if (entity == null)
            {
                ret.HasError = true;
                ret.ErrorMsg = "渠道号不存在";
            }
            else
            {
                JsonData data = new JsonData();

                data["ServerTime"]  = MFDSAUtil.GetTimestamp();
                data["SourceUrl"]   = entity.SourceUrl;
                data["RechargeUrl"] = entity.RechargeUrl;
                data["TDAppId"]     = entity.TDAppId;
                data["IsOpenTD"]    = entity.IsOpenTD;
                data["PayServerNo"] = entity.PayServerNo;

                ret.Value = JsonMapper.ToJson(data);
            }

            return(ret);
        }
Example #3
0
        public RetValue Post([FromBody] string jsonStr)
        {
            RetValue ret = new RetValue();

            JsonData jsonData = JsonMapper.ToObject(jsonStr);

            string channelId    = jsonData["ChannelId"].ToString();
            string innerVersion = jsonData["InnerVersion"].ToString();
            //ConnectionString	"Data Source=.;Initial Catalog=DBAccount;Persist Security Info=True;User ID=youyou;Password=123456"	string

            ChannelEntity entity = ChannelCacheModel.Instance.GetEntity(string.Format("[ChannelId]={0} and [InnerVersion]={1}", channelId, innerVersion));

            if (entity == null)
            {
                ret.HasError  = true;
                ret.ErrorCode = 1001;//"渠道号不存在";
            }
            else
            {
                JsonData data = new JsonData();

                data["ServerTime"]    = MFDSAUtil.GetTimestamp();
                data["SourceVersion"] = entity.SourceVersion;
                data["SourceUrl"]     = entity.SourceUrl;
                data["RechargeUrl"]   = entity.RechargeUrl;
                data["TDAppId"]       = entity.TDAppId;
                data["IsOpenTD"]      = entity.IsOpenTD;
                data["PayServerNo"]   = entity.PayServerNo;

                ret.Value = JsonMapper.ToJson(data);
            }

            return(ret);
        }
        private string  GetOperator()
        {
            string RetValue;

            RetValue = Options.Operator;
            if (RetValue == String.Empty)
            {
                Options.Operator = RetValue = Microsoft.Phone.Net.NetworkInformation.DeviceNetworkInformation.CellularMobileOperator;
                string Operator = Options.Operator.ToUpper();
            }
            else if (RetValue.ToUpper().IndexOf("PRIVET") >= 0)
            {
                RetValue = "PRIVET";
            }
            else if (RetValue.ToUpper().IndexOf("KORP") >= 0)
            {
                RetValue = "KORP";
            }
            else if (RetValue.ToUpper().IndexOf("JORN") >= 0)
            {
                RetValue = "JORN";
            }
            else if (RetValue.ToUpper().IndexOf("OTHER") >= 0)
            {
                RetValue = "OTHER";
            }

            return(RetValue);
        }
        // POST: api/Account
        public RetValue Post([FromBody] string value)
        {
            RetValue ret      = new RetValue();
            JsonData jsonData = JsonMapper.ToObject(value);
            //1.验证时间戳
            //2.验证签名
            int    type     = Convert.ToInt32(jsonData["Type"].ToString());
            string userName = jsonData["UserName"].ToString();
            string pwd      = jsonData["Pwd"].ToString();
            //客户端时间戳
            long t = Convert.ToInt64(jsonData["t"].ToString());
            //签名
            string sign = jsonData["sign"].ToString();
            //客户端驱动id
            string deviceIdentifier = jsonData["deviceIdentifier"].ToString();
            string deviceModel      = jsonData["DeviceModel"].ToString();
            long   st = MFDSAUtil.GetTimestamp();

            //第一重检验
            //if (st - t > 300)
            //{
            //    ret.IsError = true;
            //    ret.ErrorMsg = "请求失败";
            //    return ret;
            //}
            //第二重检验
            if (string.Format("{0},{1}", deviceIdentifier, t) != sign)
            {
                ret.IsError  = true;
                ret.ErrorMsg = "请求失败";
                return(ret);
            }

            if (type == 0)
            {
                string ChannelId         = JsonMapper.ToObject(value)["Channelld"].ToString();
                MFReturnValue <int> ret2 = AccountCacheModel.Instance.Register(userName, pwd, ChannelId, deviceIdentifier, deviceModel);
                ret.IsError  = ret2.HasError;
                ret.ErrorMsg = ret2.Message;
                AccountEntity entity = AccountCacheModel.Instance.GetEntity(ret2.Value);
                ret.RetData = JsonMapper.ToJson(new RetAccountEntity(entity));
            }
            else
            {
                AccountEntity entity = AccountCacheModel.Instance.LogOn(userName, pwd, deviceIdentifier, deviceModel);
                if (entity != null)
                {
                    ret.IsError = false;
                    ret.RetData = entity.Id;
                }
                else
                {
                    ret.IsError  = true;
                    ret.ErrorMsg = "账号或者密码错误";
                }
                RetAccountEntity retEnitity = new RetAccountEntity(entity);
                ret.RetData = JsonMapper.ToJson(retEnitity);
            }
            return(ret);
        }
Example #6
0
 private void OnRegCallBack(CallBackArgs obj)
 {
     if (obj.IsError)
     {
         Debug.Log("发送消息失败");
     }
     else
     {
         RetValue ret = LitJson.JsonMapper.ToObject <RetValue>(obj.Json);
         if (ret.IsError)
         {
             Debug.Log(ret.ErrorMsg);
         }
         else
         {
             RetAccountEntity accountEntity = LitJson.JsonMapper.ToObject <RetAccountEntity>(ret.RetData.ToString());
             Global.Instance.AccountEntity = accountEntity;
             SetLastGameServer(accountEntity);
             if (isAutoLogOn)
             {
             }
             else
             {
                 string userName = regView.UserNameInput.text;
                 string pwd      = regView.PwdInput.text;
                 PlayerPrefs.SetInt(ConstDefine.PlayerPrefs_AccountID_Key, accountEntity.Id);
                 PlayerPrefs.SetString(ConstDefine.PlayerPrefs_UserName_Key, userName);
                 PlayerPrefs.SetString(ConstDefine.PlayerPrefs_Pwd_Key, pwd);
             }
             regView.CloseAndOpenNextView(UIViewType.GameServerEnter);
             Debug.Log("注册成功" + ret.RetData);
         }
     }
 }
Example #7
0
        public static RetValue Export <T>(ExporyType et, T info)
        {
            RetValue retValue = new RetValue();

            switch (et)
            {
            default:
                retValue.Msg = "没有找到匹配的导出类型。";
                break;
            }
            return(retValue);
        }
Example #8
0
 private void PostCallBack(NetWorkHttp.CallBackArgs obj)
 {
     if (obj.HasError)
     {
         Debug.Log(obj.ErrorMsg);
     }
     else
     {
         RetValue entity = LitJson.JsonMapper.ToObject <RetValue>(obj.Json);
         Debug.Log(entity.RetData);
     }
 }
Example #9
0
        public RetValue DoAction(string actionName, string userData, object parameter)
        {
            RetValue retValue = null;

            switch (actionName.ToLower())
            {
            case "logon":
                retValue = LogOn(userData, parameter);
                break;

            case "getprepayid":
                retValue = GetPrepayId(userData);
                break;
            }
            return(retValue);
        }
Example #10
0
        public RetValue<List<String>> StartUpload()
        {
            var result = new RetValue<List<String>>();
            result.Value = new List<String>();
            try
            {
                _tasks.ForEach(task => { result.Value.Add(this.UploadTask(task)); });
            }
            catch (Exception ex)
            {
                result.Description = ex.Message;
                _logger.Error(ex.ToString());
                _logger.WriteLogs();
            }

            return result;
        }
Example #11
0
        public RetValue Post([FromBody] string jsonStr)
        {
            RetValue ret = new RetValue();

            JsonData jsonData = JsonMapper.ToObject(jsonStr);

            //时间戳
            long   t = Convert.ToInt64(jsonData["t"].ToString());
            string deviceIdentifier = jsonData["deviceIdentifier"].ToString();
            string deviceModel      = jsonData["deviceModel"].ToString();
            string sign             = jsonData["sign"].ToString();

            //1.判断时间戳 如果大于3秒 直接返回错误
            if (MFDSAUtil.GetTimestamp() - t > 3)
            {
                ret.HasError  = true;
                ret.ErrorCode = 1002; //"请求无效";
                return(ret);
            }

            //2.验证签名
            string signServer = MFEncryptUtil.Md5(string.Format("{0}:{1}", t, deviceIdentifier));

            if (!signServer.Equals(sign, StringComparison.CurrentCultureIgnoreCase))
            {
                ret.HasError  = true;
                ret.ErrorCode = 1002; //"请求无效";
                return(ret);
            }

            string sdkName    = jsonData["SDKName"].ToString();
            string actionName = jsonData["ActionName"].ToString();
            string userData   = jsonData["UserData"].ToString();

            IChannelSDK sdk = null;

            m_SDKDic.TryGetValue(sdkName, out sdk);
            if (sdk == null)
            {
                Type m_SdkType = Type.GetType(string.Format("WebAccount.Models.SDK.{0}", sdkName));
                sdk = Activator.CreateInstance(m_SdkType) as IChannelSDK;
                m_SDKDic[sdkName] = sdk;
            }

            return(sdk.DoAction(actionName, userData, new string[] { deviceIdentifier, deviceModel }));
        }
Example #12
0
        /// <summary>
        /// 通过微信重定向跳转后获取到的身份标识,获取当前用户在企业通讯录中的信息
        /// 微信接口:https://open.weixin.qq.com/connect/oauth2/authorize?appid=CORPID&amp;redirect_uri=REDIRECT_URI&amp;response_type=code&amp;scope=SCOPE&amp;state=STATE#wechat_redirect
        /// </summary>
        /// <param name="code">通过微信提供的重定向跳转获取到的用户身份标识,code参数。</param>
        /// <returns>用户企业通讯录信息</returns>
        public static WechatUser GetUserInfo(string code)
        {
            if (!string.IsNullOrWhiteSpace(AccessToken.Value))
            {
                //用access_token、code获取UserId
                string   url = string.Format("{0}?access_token={1}&code={2}", ServiceUrl.GetUserID, AccessToken.Value, code);
                RetValue rs  = HttpHelper.Get <RetValue>(url);

                if (rs.ErrorCode != 0)
                {
                    throw new Exception("根据code获取成员信息失败,ErrorCode:" + rs.ErrorCode.ToString() + "; ErrorMessage:" + rs.ErrorMessage);
                }

                if (string.IsNullOrEmpty(rs.UserID))
                {
                    throw new Exception("获取userId失败");
                }


                return(Wechat4net.QY.ContactManager.GetUserInfo(rs.UserID));

                /*
                 * //用UserId获取人员信息
                 * //url = "https://qyapi.weixin.qq.com/cgi-bin/user/get?access_token=" + AccessToken.Value + "&userid=" + rs.UserID;
                 * var data2 = new
                 * {
                 *  access_token = AccessToken.Value,
                 *  userid = rs.UserID
                 * };
                 * WechatUser user = Create().Get<WechatUser>(ServiceUrl.GetUserInfo, data2);
                 *
                 * if (user.ErrorCode != 0)
                 * {
                 *  throw new Exception("获取微信用户信息错误,ErrorCode:" + user.ErrorCode.ToString() + "; ErrorMessage:" + user.ErrorMessage);
                 * }
                 * return user;
                 */
            }
            else
            {
                throw new Exception("获取access_token失败");
            }
        }
Example #13
0
    private void PostCallBack(CallBackArgs obj)
    {
        if (obj.IsError)
        {
            Debug.Log(obj.Error);
        }
        else
        {
            RetValue ret = JsonMapper.ToObject <RetValue>(obj.jsonData);

            if (ret.isError)
            {
                Debug.LogError(ret.Error);
            }
            else
            {
                Debug.Log("新注册的用户编号为:" + ret.JsonData);
            }
        }
    }
Example #14
0
        /// <summary>
        /// 微信登录
        /// </summary>
        /// <param name="userData"></param>
        /// <param name="parameter"></param>
        /// <returns></returns>
        public RetValue LogOn(string userData, object parameter)
        {
            LitJson.JsonData data = LitJson.JsonMapper.ToObject(userData);

            short  channelId = data["ChannelId"].ToString().ToShort();
            string code      = data["Code"].ToString();

            string access_token = "";
            string openid       = "";

            //得到了token
            GetAccessTokenanAndOpenid(channelId, code, ref access_token, ref openid);

            string retAccount = GetUserInfo(channelId, access_token, openid, parameter);

            RetValue retValue = new RetValue();

            retValue.Value = retAccount;
            //retValue.Value= "{\"Id\":4035,\"UserName\":\"oy32t0d5ciW5ENgwYSNKdxGiKc-8\",\"Pwd\":null,\"YuanBao\":0,\"LastServerId\":38,\"LastServerName\":\"测试服2\",\"LastServerIP\":\"192.168.0.114\",\"LastServerPort\":1038,\"LastServerRunStatus\":2,\"CreateTime\":\"01/01/0001 00:00:00\",\"UpdateTime\":\"01/01/0001 00:00:00\",\"SDKNickName\":\"学无止境\"}";
            return(retValue);
        }
Example #15
0
        public RetValue <FileNameHfsFileCode> GetHfsFileInfo(string dbCode, string fileName, string dbName, string userIp, string orgId, string hfsfilecode, int taskType = 0)
        {
            RetValue <FileNameHfsFileCode> ret = new RetValue <FileNameHfsFileCode>();

            if (string.IsNullOrWhiteSpace(dbCode))
            {
                throw new ArgumentException("dbCode");
            }
            try
            {
                var entity = new OKMS.Proxy.WcfService.HfsFileEntity
                {
                    DbCode        = dbCode,
                    DbName        = dbName,
                    FileName      = fileName,
                    FileExtension = ".pdf",
                    UserIP        = userIp,
                    OrgId         = orgId,
                    TaskType      = taskType,
                    HfsFileCode   = hfsfilecode
                };

                //entity.OnlyDownloadPdf = true;
                //通过配置节点实例化通道工厂
                using (ChannelFactory <OKMS.Proxy.WcfService.IService> channel = new ChannelFactory <OKMS.Proxy.WcfService.IService>("okms.proxy"))
                {
                    var service = channel.CreateChannel();
                    ret = service.GetPdfChapterInfo(entity);
                }
            }
            catch (Exception ex)
            {
                ret.Status = -1;
                ret.Msg    = ex.Message;
            }
            return(ret);
        }
        public RetValue Register(string userName, string pwd)
        {
            RetValue ret = new RetValue();

            try
            {
                using (SqlConnection conn = new SqlConnection(connString))
                {
                    conn.Open();
                    SqlCommand com = new SqlCommand("Account_Register", conn);
                    com.CommandType = CommandType.StoredProcedure;
                    com.Parameters.Add(new SqlParameter("UserName", userName));
                    com.Parameters.Add(new SqlParameter("Pwd", pwd));
                    int data = Convert.ToInt32(com.ExecuteScalar().ToString());
                    ret.RetData = data;
                }
            }
            catch (Exception e)
            {
                ret.IsError  = true;
                ret.ErrorMsg = e.ToString();
            }
            return(ret);
        }
        public static decimal getReserveAmt(int clWfId, int isEmergency)
        {
            DataAccess dba = new DataAccess();

            dba.dxAddParameter("@WfId", clWfId);
            object RetValue;

            if (isEmergency == 1)
            {
                RetValue = dba.dxGetData("select IsNull(AppReserve1, 0) as AppReserve1 from ClaimPrelimReport where ClaimId = (select claimId from claims where wfId = @WfId)");
            }
            else
            {
                RetValue = dba.dxGetData("select IsNull(AppReserve2, 0) as AppReserve2 from ClaimPrelimReport where ClaimId = (select claimId from claims where wfId = @WfId)");
            }
            if (RetValue != null)
            {
                return(Decimal.Parse(RetValue.ToString()));
            }
            else
            {
                return(Decimal.Parse("0"));
            }
        }
Example #18
0
        public static bool MustHit(Breakpoint br)
        {
            BreakpointInfo bi = null;

            if (breakpoints_conditions.TryGetValue(br, out bi))
            {
                if (!bi.enabled)
                {
                    return(true);
                }
                string cond = bi.condition.Trim(' ', '\t');
                if (string.IsNullOrEmpty(cond))
                {
                    return(true);
                }
                try
                {
                    RetValue res = WorkbenchServiceFactory.DebuggerManager.Evaluate(cond);
                    if (bi.kind == hit_kind.is_true)
                    {
                        if (res.prim_val != null && res.prim_val is bool)
                        {
                            if ((bool)res.prim_val)
                            {
                                return(true);
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else if (res.obj_val != null && res.obj_val.IsPrimitive && res.obj_val.PrimitiveValue is bool)
                        {
                            if ((bool)res.obj_val.PrimitiveValue)
                            {
                                return(true);
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else
                        {
                            return(true);
                        }
                    }
                    else
                    {
                        if (res.obj_val != null && res.obj_val.IsPrimitive)
                        {
                            res.prim_val = res.obj_val.PrimitiveValue;
                            res.obj_val  = null;
                        }
                        if (!WorkbenchServiceFactory.DebuggerManager.evaluator.IsEqual(res, bi.val))
                        {
                            bi.val = res;
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                }
                catch
                {
                    return(true);
                }
            }
            else
            {
                return(true);
            }
        }
Example #19
0
        public RetValue Post([FromBody] string jsonStr)
        {
            RetValue ret = new RetValue();

            JsonData jsonData = JsonMapper.ToObject(jsonStr);

            //时间戳
            long   t = Convert.ToInt64(jsonData["t"].ToString());
            string deviceIdentifier = jsonData["deviceIdentifier"].ToString();
            string deviceModel      = jsonData["deviceModel"].ToString();
            string sign             = jsonData["sign"].ToString();

            //1.判断时间戳 如果大于3秒 直接返回错误
            if (MFDSAUtil.GetTimestamp() - t > 3)
            {
                ret.HasError  = true;
                ret.ErrorCode = 1002;// "请求无效";
                return(ret);
            }

            //2.验证签名
            string signServer = MFEncryptUtil.Md5(string.Format("{0}:{1}", t, deviceIdentifier));

            if (!signServer.Equals(sign, StringComparison.CurrentCultureIgnoreCase))
            {
                ret.HasError  = true;
                ret.ErrorCode = 1002; //"请求无效";
                return(ret);
            }

            //苹果回执
            string receipt = jsonData["receipt"].ToString();

            string strJosn = string.Format("{{\"receipt-data\":\"{0}\"}}", receipt);
            // 请求验证
            string strResult = CreatePostHttpResponse(strJosn, true);

            JsonData retJson = LitJson.JsonMapper.ToObject(strResult);

            int status = int.Parse(retJson["status"].ToString());

            if (status == 0)
            {
                //成功
                string   retreceipt        = retJson["receipt"].ToJson();
                JsonData retReceiptJson    = JsonMapper.ToObject(retreceipt);
                string   rechargeProductId = retReceiptJson["product_id"].ToString();
                ret.Value = rechargeProductId; //把充值产品编号传递给客户端
                //订单号 付费服务器识别码_玩家账号_要充值到哪个GameServerId_角色ID_充值的产品Id_时间
                string orderId = jsonData["orderId"].ToString();

                string[] arr = orderId.Split('_');
                if (arr.Length == 6)
                {
                    //1.记录充值日志
                    RechargeLogEntity rechargeLogEntity = new RechargeLogEntity();
                    rechargeLogEntity.AccountId = arr[1].ToInt();
                    short channelId = AccountCacheModel.Instance.GetEntity(rechargeLogEntity.AccountId).ChannelId;
                    rechargeLogEntity.Status            = Mmcoy.Framework.AbstractBase.EnumEntityStatus.Released;
                    rechargeLogEntity.ChannelId         = channelId;
                    rechargeLogEntity.GameServerId      = arr[2].ToInt();
                    rechargeLogEntity.RoldId            = arr[3].ToInt();
                    rechargeLogEntity.RechargeProductId = short.Parse(rechargeProductId);
                    rechargeLogEntity.OrderId           = orderId;
                    rechargeLogEntity.CreateTime        = DateTime.Now;

                    RechargeLogCacheModel.Instance.Create(rechargeLogEntity);


                    //2.找到对应的游戏服
                    int gameServerId = arr[2].ToInt();

                    GameServerEntity entity = GameServerCacheModel.Instance.GetEntity(gameServerId);
                    if (entity != null)
                    {
                        //发送socket请求 给游戏服
                        Socket rechargeServer = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                        rechargeServer.Connect(new IPEndPoint(IPAddress.Parse(entity.Ip), entity.Port));
                        string str = string.Format("{0}_{1}_{2}", channelId, arr[3], arr[4]);
                        rechargeServer.Send(System.Text.UTF8Encoding.UTF8.GetBytes(str));
                    }
                    else
                    {
                        ret.HasError  = true;
                        ret.ErrorCode = 1004; //"充值失败";
                    }
                }
                else
                {
                    ret.HasError  = true;
                    ret.ErrorCode = 1004; //"充值失败";
                }
            }
            else
            {
                ret.HasError  = true;
                ret.ErrorCode = 1004; //"充值失败";
            }


            return(ret);
        }
Example #20
0
        /// <summary>
        /// 获取统一下单
        /// </summary>
        /// <param name="userData"></param>
        /// <returns></returns>
        private RetValue GetPrepayId(string userData)
        {
            JsonData data = JsonMapper.ToObject(userData);

            short             channelId = data["ChannelId"].ToString().ToShort();
            SDK_Weixin_Config config    = GetWeixinConfig(channelId);

            string rechargeProductId = data["RechargeProductId"].ToString();
            string orderId           = data["OrderId"].ToString();

            //产品说明
            string body = "充值产品";

            //随机字符串
            string nonce_str = new Random().Next(0, 99999).ToString();

            //商户订单号
            string out_trade_no = DateTime.Now.ToString("yyyyMMddHHmmssfff");

            //终端IP
            string spbill_create_ip = MFSystemUtil.GetIP();


            //总金额 订单总金额,单位为分
            int total_fee = RechargeShopDBModel.Instance.Get(int.Parse(rechargeProductId)).Price * 100;

            total_fee = 1; //临时改成1分

            //交易类型
            string trade_type = @"APP";

            string attach = string.Format("{0}^{1}", channelId, orderId);

            string temp = string.Format("appid={0}&attach={1}&body={2}&mch_id={3}&nonce_str={4}&notify_url={5}&out_trade_no={6}&spbill_create_ip={7}&total_fee={8}&trade_type={9}&key={10}", config.appid, attach, body, config.mch_id, nonce_str, config.notify_url, out_trade_no, spbill_create_ip, total_fee, trade_type, config.payKey);

            string sign = MFEncryptUtil.Md5(temp).ToUpper(); //签名是MD5大写形式

            string urlString = "https://api.mch.weixin.qq.com/pay/unifiedorder";

            StringBuilder sbr = new StringBuilder();

            sbr.Append("<xml>");
            sbr.AppendFormat("<appid><![CDATA[{0}]]></appid>", config.appid);
            sbr.AppendFormat("<attach><![CDATA[{0}]]></attach>", attach);
            sbr.AppendFormat("<body><![CDATA[{0}]]></body>", body);
            sbr.AppendFormat("<mch_id><![CDATA[{0}]]></mch_id>", config.mch_id);
            sbr.AppendFormat("<nonce_str><![CDATA[{0}]]></nonce_str>", nonce_str);
            sbr.AppendFormat("<out_trade_no><![CDATA[{0}]]></out_trade_no>", out_trade_no);
            sbr.AppendFormat("<spbill_create_ip><![CDATA[{0}]]></spbill_create_ip>", spbill_create_ip);
            sbr.AppendFormat("<total_fee><![CDATA[{0}]]></total_fee>", total_fee);
            sbr.AppendFormat("<trade_type><![CDATA[{0}]]></trade_type>", trade_type);
            sbr.AppendFormat("<notify_url><![CDATA[{0}]]></notify_url>", config.notify_url);
            sbr.AppendFormat("<sign><![CDATA[{0}]]></sign>", sign);
            sbr.Append("</xml>");

            string resposeContent = NetWorkHttp.Instance.HttpPost(urlString, sbr.ToString());

            RetValue retValue = new RetValue();

            XDocument doc = XDocument.Parse(resposeContent);

            XElement rootElement = doc.Root;

            string return_code = rootElement.Element("return_code").Value;

            if (return_code.Equals("SUCCESS", StringComparison.CurrentCultureIgnoreCase))
            {
                string prepay_id = rootElement.Element("prepay_id").Value;
                retValue.Value = GetPayReqInfo(config, prepay_id);
            }
            else
            {
                retValue.HasError = true;
            }
            return(retValue);
        }
Example #21
0
 public void RefreshRow(int i)
 {
     if (this.watchList.Rows[i].Cells[0].Value != null)
     {
         if ((this.watchList.Rows[i] as AdvancedDataGridView.TreeGridNode).UserRow)
         {
             RetValue rv = WorkbenchServiceFactory.DebuggerManager.Evaluate(this.watchList.Rows[i].Cells[0].Value as string);
             if (rv.syn_err)
             {
                 this.watchList.Rows[i].Cells[1].Value = PascalABCCompiler.StringResources.Get("EXPR_VALUE_SYNTAX_ERROR_IN_EXPR");
                 this.watchList.Rows[i].Cells[2].Value = null;//PascalABCCompiler.StringResources.Get("EXPR_VALUE_UNDEFINED_TYPE");
             }
             else
             if (rv.obj_val != null)
             {
                 try
                 {
                     ValueItem vi = new ValueItem(rv.obj_val, this.watchList.Rows[i].Cells[0].Value as string, WorkbenchServiceFactory.DebuggerManager.evaluator.declaringType);
                     (this.watchList.Rows[i] as AdvancedDataGridView.TreeGridNode)._grid   = this.watchList;
                     (this.watchList.Rows[i] as AdvancedDataGridView.TreeGridNode).Content = vi;
                     this.watchList.Rows[i].Cells[1].Value = WorkbenchServiceFactory.DebuggerManager.MakeValueView(rv.obj_val);    //rv.obj_val.AsString;
                     this.watchList.Rows[i].Cells[2].Value = DebugUtils.WrapTypeName(rv.obj_val.Type);
                     this.watchList.InvalidateCell(0, i);
                 }
                 catch (System.Exception e)
                 {
                     this.watchList.Rows[i].Cells[1].Value = PascalABCCompiler.StringResources.Get("EXPR_VALUE_UNDEFINED_VALUE");
                     this.watchList.Rows[i].Cells[2].Value = PascalABCCompiler.StringResources.Get("EXPR_VALUE_UNDEFINED_TYPE");
                     //								  FixedItem fi = new FixedItem(this.watchList.Rows[i].Cells[0].Value as string,PascalABCCompiler.StringResources.Get("EXPR_VALUE_UNDEFINED_VALUE"),PascalABCCompiler.StringResources.Get("EXPR_VALUE_UNDEFINED_TYPE"));
                     //								  fi.imageIndex = CodeCompletionProvider.ImagesProvider.IconNumberEvalError;
                     //								  (this.watchList.Rows[i] as AdvancedDataGridView.TreeGridNode)._grid = this.watchList;
                     //                                (this.watchList.Rows[i] as AdvancedDataGridView.TreeGridNode).Content = fi;
                 }
             }
             else if (rv.prim_val != null)
             {
                 FixedItem fi = new FixedItem(this.watchList.Rows[i].Cells[0].Value as string, WrapPrimValue(rv.prim_val), DebugUtils.WrapTypeName(rv.prim_val.GetType()));
                 this.watchList.Rows[i].Cells[1].Value = fi.Text;
                 this.watchList.Rows[i].Cells[2].Value = fi.Type;
                 (this.watchList.Rows[i] as AdvancedDataGridView.TreeGridNode)._grid   = this.watchList;
                 (this.watchList.Rows[i] as AdvancedDataGridView.TreeGridNode).Content = fi;
             }
             else
             {
                 this.watchList.Rows[i].Cells[1].Value = PascalABCCompiler.StringResources.Get("EXPR_VALUE_UNDEFINED_VALUE");
                 this.watchList.Rows[i].Cells[2].Value = PascalABCCompiler.StringResources.Get("EXPR_VALUE_UNDEFINED_TYPE");
                 //                            FixedItem fi = new FixedItem(this.watchList.Rows[i].Cells[0].Value as string,PascalABCCompiler.StringResources.Get("EXPR_VALUE_UNDEFINED_VALUE"),PascalABCCompiler.StringResources.Get("EXPR_VALUE_UNDEFINED_TYPE"));
                 //							fi.imageIndex = CodeCompletionProvider.ImagesProvider.IconNumberEvalError;
                 //							(this.watchList.Rows[i] as AdvancedDataGridView.TreeGridNode)._grid = this.watchList;
                 //                            (this.watchList.Rows[i] as AdvancedDataGridView.TreeGridNode).Content = fi;
                 this.ClearRow(i);
             }
         }
         else
         {
         }
     }
     else
     {
         this.watchList.Rows[i].Cells[1].Value = null;
         this.watchList.Rows[i].Cells[2].Value = null;
     }
 }
        // POST: api/GameServer
        public object Post([FromBody] string jsonStr)
        {
            RetValue ret = new RetValue();

            JsonData jsonData = JsonMapper.ToObject(jsonStr);

            //时间戳
            long   t = Convert.ToInt64(jsonData["t"].ToString());
            string deviceIdentifier = jsonData["deviceIdentifier"].ToString();
            string deviceModel      = jsonData["deviceModel"].ToString();
            string sign             = jsonData["sign"].ToString();

            ////1.判断时间戳 如果大于3秒 直接返回错误
            //if (MFDSAUtil.GetTimestamp() - t > 3)
            //{
            //    ret.HasError = true;
            //    ret.ErrorMsg = "请求无效";
            //    return ret;
            //}

            ////2.验证签名
            //string signServer = MFEncryptUtil.Md5(string.Format("{0}:{1}", t, deviceIdentifier));
            //if (!signServer.Equals(sign, StringComparison.CurrentCultureIgnoreCase))
            //{
            //    ret.HasError = true;
            //    ret.ErrorMsg = "请求无效";
            //    return ret;
            //}

            int type = Convert.ToInt32(jsonData["Type"].ToString());

            if (type == 0)
            {
                string channelId    = jsonData["ChannelId"].ToString();
                string innerVersion = jsonData["InnerVersion"].ToString();

                //先获取渠道状态 根据渠道状态 来加载不同的区服

                //ChannelEntity entity = ChannelCacheModel.Instance.GetEntity(string.Format("[ChannelId]={0} and [InnerVersion]={1}", channelId, innerVersion));

                // 暂时写死   chanId = 0, innerVersion = 1001
                ChannelEntity entity = ChannelCacheModel.Instance.GetEntity(string.Format("[ChannelId]={0} and [InnerVersion]={1}", channelId, innerVersion));
                if (entity == null)
                {
                    ret.HasError = true;
                    ret.ErrorMsg = "渠道号不存在";
                }

                //获取页签
                return(GameServerCacheModel.Instance.GetGameServerPageList(string.Format("[ChannelStatus]={0}", entity.ChannelStatus)));
            }
            else if (type == 1)
            {
                string channelId    = jsonData["ChannelId"].ToString();
                string innerVersion = jsonData["InnerVersion"].ToString();


                //先获取渠道状态 根据渠道状态 来加载不同的区服
                ChannelEntity entity = ChannelCacheModel.Instance.GetEntity(string.Format("[ChannelId]={0} and [InnerVersion]={1}", channelId, innerVersion));
                if (entity == null)
                {
                    ret.HasError = true;
                    ret.ErrorMsg = "渠道号不存在";
                }
                int pageIndex = int.Parse(jsonData["pageIndex"].ToString());
                //获取区服列表
                return(GameServerCacheModel.Instance.GetGameServerList(pageIndex, string.Format("[ChannelStatus]={0}", entity.ChannelStatus)));
            }
            else if (type == 2)
            {
                //更新最后登录信息
                int    userId         = int.Parse(jsonData["userId"].ToString());
                int    lastServerId   = int.Parse(jsonData["lastServerId"].ToString());
                string lastServerName = jsonData["lastServerName"].ToString();

                Dictionary <string, object> dic = new Dictionary <string, object>();
                dic["Id"] = userId;
                dic["LastLogOnServerId"]   = lastServerId;
                dic["LastLogOnServerName"] = lastServerName;
                dic["LastLogOnServerTime"] = DateTime.Now;

                AccountCacheModel.Instance.Update("LastLogOnServerId=@LastLogOnServerId, LastLogOnServerName=@LastLogOnServerName, LastLogOnServerTime=@LastLogOnServerTime", "Id=@Id", dic);
            }

            return(ret);
        }
Example #23
0
        PluginResult NewCallOpNode(ref ExpressionNode Node)
        {
            var OpNode = Node as OpExpressionNode;
            var Op     = OpNode.Operator;
            var Ch     = OpNode.Children;

            var Ok = true;

            for (var i = 1; i < Ch.Length; i++)
            {
                if (!(Ch[i] is ConstExpressionNode))
                {
                    Ok = false;
                    break;
                }
            }

            // ------------------------------------------------------------------------------------
            var IdCh0 = Ch[0] as IdExpressionNode;

            if (IdCh0 != null && IdCh0.Identifier is Function && Ok)
            {
                var Func     = IdCh0.Identifier as Function;
                var FuncType = Func.TypeOfSelf.RealId as TypeOfFunction;
                var RetType  = FuncType.RetType;
                var Name     = Func.AssemblyNameWithoutDecorations;
                var RetValue = (ConstValue)null;

                if (Name != null && Name.StartsWith("_System_Math_"))
                {
                    if (Ch.Length == 2)
                    {
                        var Param0Node   = Ch[1] as ConstExpressionNode;
                        var Param0RealId = Param0Node.Type.RealId;
                        var Param0Value  = Param0Node.Value;

                        if (!(Param0RealId is NumberType))
                        {
                            return(PluginResult.Succeeded);
                        }

                        if (Name == "_System_Math_Abs")
                        {
                            RetValue = Param0Value;
                            if (Param0RealId is FloatType)
                            {
                                var FractionValue = Param0Value as DoubleValue;
                                FractionValue.Value = Math.Abs(FractionValue.Value);
                            }
                            else
                            {
                                var IntegerValue = Param0Value as IntegerValue;
                                IntegerValue.Value = BigInteger.Abs(IntegerValue.Value);
                            }
                        }
                        else if (Name == "_System_Math_Sqrt")
                        {
                            if (Param0RealId is FloatType)
                            {
                                RetValue = Param0Value;
                                var FractionValue = Param0Value as DoubleValue;
                                FractionValue.Value = Math.Sqrt(FractionValue.Value);
                            }
                            else
                            {
                                var IntegerValue = Param0Value as IntegerValue;
                                RetValue = new DoubleValue(Math.Sqrt((double)IntegerValue.Value));
                            }
                        }
                        else if (Name == "_System_Math_Sign")
                        {
                            RetValue = Param0Value;
                            if (Param0RealId is FloatType)
                            {
                                var FractionValue = Param0Value as DoubleValue;
                                FractionValue.Value = Math.Sign(FractionValue.Value);
                            }
                            else
                            {
                                var IntegerValue = Param0Value as IntegerValue;
                                if (IntegerValue.Value < 0)
                                {
                                    IntegerValue.Value = -1;
                                }
                                else if (IntegerValue.Value > 0)
                                {
                                    IntegerValue.Value = 1;
                                }
                                else
                                {
                                    IntegerValue.Value = 0;
                                }
                            }
                        }
                        else if (Name == "_System_Math_Log")
                        {
                            RetValue = new DoubleValue(Math.Log(Param0Value.Double));
                        }
                        else if (Name == "_System_Math_Log2")
                        {
                            RetValue = new DoubleValue(Math.Log(Param0Value.Double, 2));
                        }
                        else if (Name == "_System_Math_Log10")
                        {
                            Param0Value = new DoubleValue(Math.Log10(Param0Value.Double));
                        }
                        else if (Name == "_System_Math_Exp")
                        {
                            RetValue = new DoubleValue(Math.Exp(Param0Value.Double));
                        }
                        else if (Name == "_System_Math_Pow2")
                        {
                            Param0Value = new DoubleValue(Math.Pow(2, Param0Value.Double));
                        }
                        else if (Name == "_System_Math_Sin")
                        {
                            RetValue = new DoubleValue(Math.Sin(Param0Value.Double));
                        }
                        else if (Name == "_System_Math_Cos")
                        {
                            RetValue = new DoubleValue(Math.Cos(Param0Value.Double));
                        }
                        else if (Name == "_System_Math_Tan")
                        {
                            RetValue = new DoubleValue(Math.Tan(Param0Value.Double));
                        }
                        else if (Name == "_System_Math_Asin")
                        {
                            RetValue = new DoubleValue(Math.Asin(Param0Value.Double));
                        }
                        else if (Name == "_System_Math_Acos")
                        {
                            RetValue = new DoubleValue(Math.Acos(Param0Value.Double));
                        }
                        else if (Name == "_System_Math_Atan")
                        {
                            RetValue = new DoubleValue(Math.Atan(Param0Value.Double));
                        }
                        else if (Name == "_System_Math_Sinh")
                        {
                            RetValue = new DoubleValue(Math.Sinh(Param0Value.Double));
                        }
                        else if (Name == "_System_Math_Cosh")
                        {
                            RetValue = new DoubleValue(Math.Cosh(Param0Value.Double));
                        }
                        else if (Name == "_System_Math_Tanh")
                        {
                            RetValue = new DoubleValue(Math.Tanh(Param0Value.Double));
                        }
                        else if (Name == "_System_Math_Asinh")
                        {
                            var X = Param0Value.Double;
                            RetValue = new DoubleValue(Math.Log(X + Math.Sqrt(X * X + 1)));
                        }
                        else if (Name == "_System_Math_Acosh")
                        {
                            var X = Param0Value.Double;
                            RetValue = new DoubleValue(Math.Log(X + Math.Sqrt(X * X - 1)));
                        }
                        else if (Name == "_System_Math_Atanh")
                        {
                            var X = Param0Value.Double;
                            RetValue = new DoubleValue(0.5d * Math.Log((1 + X) / (1 - X)));
                        }
                    }
                    else if (Ch.Length == 3)
                    {
                        var Param0Node   = Ch[1] as ConstExpressionNode;
                        var Param0RealId = Param0Node.Type.RealId;
                        var Param0Value  = Param0Node.Value;

                        var Param1Node   = Ch[2] as ConstExpressionNode;
                        var Param1RealId = Param1Node.Type.RealId;
                        var Param1Value  = Param1Node.Value;

                        if (!(Param0RealId is NumberType && Param1RealId is NumberType))
                        {
                            return(PluginResult.Succeeded);
                        }

                        if (Name == "_System_Math_Pow")
                        {
                            var X = Param0Value.Double;
                            var Y = Param1Value.Double;
                            RetValue = new DoubleValue(Math.Pow(X, Y));
                        }
                        else if (Name == "_System_Math_Log")
                        {
                            var X = Param0Value.Double;
                            var Y = Param1Value.Double;
                            RetValue = new DoubleValue(Math.Log(X, Y));
                        }
                        else if (Name == "_System_Math_Atan2")
                        {
                            var X = Param0Value.Double;
                            var Y = Param1Value.Double;
                            RetValue = new DoubleValue(Math.Atan2(X, Y));
                        }
                    }
                }

                if (RetValue != null)
                {
                    Node = RetValue.ToExpression(Parent, RetType, Node.Code);
                    return(Node == null ? PluginResult.Failed : PluginResult.Ready);
                }
            }

            return(PluginResult.Succeeded);
        }
Example #24
0
 public void RefreshRow(int i)
 {
     if (this.watchList.Rows[i].Cells[0].Value != null)
     {
         if ((this.watchList.Rows[i] as AdvancedDataGridView.TreeGridNode).UserRow)
         {
             string   s  = this.watchList.Rows[i].Cells[0].Value as string;
             RetValue rv = WorkbenchServiceFactory.DebuggerManager.Evaluate(s);
             if (rv.syn_err)
             {
                 this.ClearRow(i);
                 FixedItem fi = new FixedItem(this.watchList.Rows[i].Cells[0].Value as string, PascalABCCompiler.StringResources.Get("EXPR_VALUE_SYNTAX_ERROR_IN_EXPR"), "");
                 fi.imageIndex = CodeCompletionProvider.ImagesProvider.IconNumberEvalError;
                 this.watchList.Rows[i].Cells[1].Value = fi.Text;
                 this.watchList.Rows[i].Cells[2].Value = fi.Type;
                 (this.watchList.Rows[i] as AdvancedDataGridView.TreeGridNode)._grid   = this.watchList;
                 (this.watchList.Rows[i] as AdvancedDataGridView.TreeGridNode).Content = fi;
             }
             else
             if (rv.obj_val != null)
             {
                 //this.ClearRow(i);
                 try
                 {
                     ValueItem vi = new ValueItem(rv.obj_val, s, WorkbenchServiceFactory.DebuggerManager.evaluator.declaringType);
                     (this.watchList.Rows[i] as AdvancedDataGridView.TreeGridNode)._grid   = this.watchList;
                     (this.watchList.Rows[i] as AdvancedDataGridView.TreeGridNode).Content = vi;
                     this.watchList.Rows[i].Cells[1].Value = WorkbenchServiceFactory.DebuggerManager.MakeValueView(rv.obj_val);    //rv.obj_val.AsString;
                     this.watchList.Rows[i].Cells[2].Value = DebugUtils.WrapTypeName(rv.obj_val.Type);
                     this.watchList.InvalidateCell(0, i);
                 }
                 catch (System.Exception e)
                 {
                 }
             }
             else if (rv.prim_val != null)
             {
                 //this.ClearRow(i);
                 FixedItem fi = new FixedItem(s, WrapPrimValue(rv.prim_val), DebugUtils.WrapTypeName(rv.prim_val.GetType()));
                 this.watchList.Rows[i].Cells[1].Value = fi.Text;
                 this.watchList.Rows[i].Cells[2].Value = fi.Type;
                 (this.watchList.Rows[i] as AdvancedDataGridView.TreeGridNode)._grid   = this.watchList;
                 (this.watchList.Rows[i] as AdvancedDataGridView.TreeGridNode).Content = fi;
                 this.watchList.InvalidateCell(0, i);
             }
             else if (rv.type != null)
             {
                 //this.ClearRow(i);
                 BaseTypeItem bti = new BaseTypeItem(rv.type, rv.managed_type);
                 (this.watchList.Rows[i] as AdvancedDataGridView.TreeGridNode)._grid   = this.watchList;
                 (this.watchList.Rows[i] as AdvancedDataGridView.TreeGridNode).Content = bti;
             }
             else
             {
                 this.ClearRow(i);
                 FixedItem fi = null;
                 if (WorkbenchServiceFactory.DebuggerManager.IsRunning)
                 {
                     fi            = new FixedItem(s, rv.err_mes != null ? rv.err_mes : PascalABCCompiler.StringResources.Get("EXPR_VALUE_UNDEFINED_VALUE"), /*PascalABCCompiler.StringResources.Get("EXPR_VALUE_UNDEFINED_TYPE")*/ "");
                     fi.imageIndex = CodeCompletionProvider.ImagesProvider.IconNumberEvalError;
                 }
                 else
                 {
                     fi = new FixedItem(s, "", "");
                 }
                 this.watchList.Rows[i].Cells[1].Value = fi.Text;
                 this.watchList.Rows[i].Cells[2].Value = fi.Type;
                 (this.watchList.Rows[i] as AdvancedDataGridView.TreeGridNode)._grid   = this.watchList;
                 (this.watchList.Rows[i] as AdvancedDataGridView.TreeGridNode).Content = fi;
                 this.watchList.InvalidateCell(0, i);
             }
         }
         else
         {
         }
     }
     else
     {
         //this.watchList.Rows[i].Cells[1].Value = null;
         //this.watchList.Rows[i].Cells[2].Value = null;
         if (i != this.watchList.Rows.Count - 1)
         {
             this.ClearRow(i);
             FixedItem fi = new FixedItem("", "", "");
             this.watchList.Rows[i].Cells[1].Value = "";
             this.watchList.Rows[i].Cells[2].Value = "";
             (this.watchList.Rows[i] as AdvancedDataGridView.TreeGridNode)._grid   = this.watchList;
             (this.watchList.Rows[i] as AdvancedDataGridView.TreeGridNode).Content = fi;
             this.watchList.InvalidateCell(0, i);
             this.watchList.Rows.RemoveAt(i);
         }
         //this.watchList.InvalidateCell(0,i);
     }
 }
Example #25
0
        // POST: api/Account
        public RetValue Post([FromBody] string jsonStr)
        {
            RetValue ret = new RetValue();

            JsonData jsonData = JsonMapper.ToObject(jsonStr);

            //时间戳
            long   t = Convert.ToInt64(jsonData["t"].ToString());
            string deviceIdentifier = jsonData["deviceIdentifier"].ToString();
            string deviceModel      = jsonData["deviceModel"].ToString();
            string sign             = jsonData["sign"].ToString();

            //1.判断时间戳 如果大于3秒 直接返回错误
            if (MFDSAUtil.GetTimestamp() - t > 3)
            {
                ret.HasError = true;
                ret.ErrorMsg = "请求无效";
                return(ret);
            }

            ////  2.验证签名
            string signServer = MFEncryptUtil.Md5(string.Format("{0}:{1}", t, deviceIdentifier));

            if (!signServer.Equals(sign, StringComparison.CurrentCultureIgnoreCase))
            {
                ret.HasError = true;
                ret.ErrorMsg = "请求无效";
                return(ret);
            }


            int    type     = Convert.ToInt32(jsonData["Type"].ToString());
            string userName = jsonData["UserName"].ToString();
            string pwd      = jsonData["Pwd"].ToString();

            if (type == 0)
            {
                string channelId = jsonData["ChannelId"].ToString();
                ret.Type = "0";
                //注册
                MFReturnValue <int> retValue = AccountCacheModel.Instance.Register(userName, pwd, channelId, deviceIdentifier, deviceModel);
                ret.HasError = retValue.HasError;
                ret.ErrorMsg = retValue.Message;

                int userID = retValue.Value;

                AccountEntity entity = AccountCacheModel.Instance.GetEntity(userID);

                RetAccountEntity retAccountEntity = new RetAccountEntity(entity);
                ret.Value = JsonMapper.ToJson(retAccountEntity);
            }
            else
            {
                ret.Type = "1";
                //登录
                AccountEntity entity = AccountCacheModel.Instance.LogOn(userName, pwd, deviceIdentifier, deviceModel);
                if (entity != null)
                {
                    RetAccountEntity rect = new RetAccountEntity(entity);
                    ret.objValue = rect;
                }
                else
                {
                    // 登录失败
                    ret.HasError = true;
                    ret.ErrorMsg = "帐户取出来为空";
                }
            }

            return(ret);
        }
Example #26
0
        // POST: api/Account
        public RetValue Post([FromBody] string jsonStr)
        {
            RetValue ret = new RetValue();

            JsonData jsonData = JsonMapper.ToObject(jsonStr);

            //时间戳

            long   t = Convert.ToInt64(jsonData["t"].ToString());
            string deviceIdentifier = jsonData["deviceIdentifier"].ToString();
            string deviceModel      = jsonData["deviceModel"].ToString();
            string sign             = jsonData["sign"].ToString();

            //1.判断时间戳 如果大于3秒 直接返回错误
            if (MFDSAUtil.GetTimestamp() - t > 3)
            {
                ret.HasError  = true;
                ret.ErrorCode = ProtoCode.RequestDelay;//"url请求无效";
                return(ret);
            }

            //2.验证签名
            string signServer = MFEncryptUtil.Md5(string.Format("{0}:{1}", t, deviceIdentifier));

            if (!signServer.Equals(sign, StringComparison.CurrentCultureIgnoreCase))
            {
                ret.HasError  = true;
                ret.ErrorCode = ProtoCode.SignatureInvalid;//"签名无效";
                return(ret);
            }

            int    type     = Convert.ToInt32(jsonData["Type"].ToString());
            string userName = jsonData["UserName"].ToString();

            string pwd = jsonData["Pwd"].ToString();

            if (type == 0)
            {
                short channelId = jsonData["ChannelId"].ToString().ToShort();

                //注册
                MFReturnValue <int> retValue = AccountCacheModel.Instance.Register(userName, pwd, channelId, deviceIdentifier, deviceModel);
                ret.HasError = retValue.HasError;
                //ret.ErrorMsg = retValue.Message;
                ret.ErrorCode = ProtoCode.AccountRegistrationFailed;

                int           userID = retValue.Value;
                AccountEntity entity = AccountCacheModel.Instance.GetEntity(userID);
                ret.Value = JsonMapper.ToJson(new RetAccountEntity(entity));
            }
            else
            {
                //登录
                AccountEntity entity = AccountCacheModel.Instance.LogOn(userName, pwd, deviceIdentifier, deviceModel);
                if (entity != null)
                {
                    ret.Value = JsonMapper.ToJson(new RetAccountEntity(entity));
                }
                else
                {
                    ret.HasError  = true;
                    ret.ErrorCode = ProtoCode.AccountDoesNotExist; //"帐户不存在";
                }
            }

            return(ret);
        }
Example #27
0
        public RetValue Post([FromBody] string jsonStr)
        {
            RetValue ret = new RetValue();

            JsonData jsonData = JsonMapper.ToObject(jsonStr);

            //时间戳
            long   t = Convert.ToInt64(jsonData["t"].ToString());
            string deviceIdentifier = jsonData["deviceIdentifier"].ToString();
            string deviceModel      = jsonData["deviceModel"].ToString();
            string sign             = jsonData["sign"].ToString();

            //1.判断时间戳 如果大于3秒 直接返回错误
            if (MFDSAUtil.GetTimestamp() - t > 3)
            {
                ret.HasError = true;
                ret.ErrorMsg = "请求无效";
                return(ret);
            }

            //2.验证签名
            string signServer = MFEncryptUtil.Md5(string.Format("{0}:{1}", t, deviceIdentifier));

            if (!signServer.Equals(sign, StringComparison.CurrentCultureIgnoreCase))
            {
                ret.HasError = true;
                ret.ErrorMsg = "请求无效";
                return(ret);
            }

            //订单号 付费服务器识别码_玩家账号_要充值到哪个GameServerId_角色ID_充值的产品Id_时间
            string orderId = jsonData["orderId"].ToString();

            string[] arr = orderId.Split('_');
            if (arr.Length == 6)
            {
                //1.记录充值日志
                RechargeLogEntity rechargeLogEntity = new RechargeLogEntity();
                rechargeLogEntity.AccountId = arr[1].ToInt();
                string channelId = AccountCacheModel.Instance.GetEntity(rechargeLogEntity.AccountId).ChannelId;

                rechargeLogEntity.ChannelId         = channelId;
                rechargeLogEntity.GameServerId      = arr[2].ToInt();
                rechargeLogEntity.RoldId            = arr[3].ToInt();
                rechargeLogEntity.RechargeProductId = arr[4].ToString();
                rechargeLogEntity.OrderId           = orderId;
                rechargeLogEntity.CreateTime        = DateTime.Now;

                RechargeLogCacheModel.Instance.Create(rechargeLogEntity);


                //2.找到对应的游戏服
                int gameServerId = arr[2].ToInt();

                GameServerEntity entity = GameServerCacheModel.Instance.GetEntity(gameServerId);
                if (entity != null)
                {
                    //发送socket请求 给游戏服
                    Socket rechargeServer = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                    rechargeServer.Connect(new IPEndPoint(IPAddress.Parse(entity.Ip), entity.Port));
                    string str = string.Format("{0}_{1}_{2}", channelId, arr[3], arr[4]);
                    rechargeServer.Send(System.Text.UTF8Encoding.UTF8.GetBytes(str));
                }
                else
                {
                    ret.HasError = true;
                    ret.ErrorMsg = "充值失败";
                }
            }
            else
            {
                ret.HasError = true;
                ret.ErrorMsg = "充值失败";
            }
            return(ret);
        }
        // POST: api/GameServer
        public object Post([FromBody] string value)
        {
            RetValue ret      = new RetValue();
            JsonData jsonData = JsonMapper.ToObject(value);
            //1.验证时间戳
            //2.验证签名

            //客户端时间戳
            long t = Convert.ToInt64(jsonData["t"].ToString());
            //签名
            string sign = jsonData["sign"].ToString();
            //客户端驱动id
            string deviceIdentifier = jsonData["deviceIdentifier"].ToString();
            string deviceModel      = jsonData["DeviceModel"].ToString();
            long   st = MFDSAUtil.GetTimestamp();

            //第一重检验
            //if (st - t > 300)
            //{
            //    ret.IsError = true;
            //    ret.ErrorMsg = "请求失败";
            //    return ret;
            //}
            //第二重检验
            if (string.Format("{0},{1}", deviceIdentifier, t) != sign)
            {
                ret.IsError  = true;
                ret.ErrorMsg = "请求失败";
                return(ret);
            }
            //0.获取页签列表  1.获取服务器列表
            int type = Convert.ToInt32(jsonData["Type"].ToString());

            if (type == 0)
            {
                int pageIndex = Convert.ToInt32(jsonData["PageIndex"].ToString());
                List <RetGameserverEntity> gameServerList = GameServerCacheModel.Instance.GetGameServerList(pageIndex);
                return(gameServerList);
            }
            else if (type == 1)
            {
                List <RetGameServerPageEntity> pageList = GameServerCacheModel.Instance.GetGameServerPageList();
                return(pageList);
            }
            //更新登录结果
            else if (type == 2)
            {
                IDictionary <string, object> dic = new Dictionary <string, object>();
                int    userID         = Convert.ToInt32(jsonData["UserID"].ToString());
                int    lastServerId   = Convert.ToInt32(jsonData["LastServerId"].ToString());
                string lastServerName = jsonData["LastServerName"].ToString();
                dic["Id"] = userID;
                dic["LastLogOnServerId"]   = lastServerId;
                dic["LastLogOnServerName"] = lastServerName;
                dic["LastLogOnServerTime"] = DateTime.Now;
                AccountCacheModel.Instance.Update("LastLogOnServerId=@LastLogOnServerId,LastLogOnServerName=@LastLogOnServerName,LastLogOnServerTime=@LastLogOnServerTime", "Id=@Id", dic);
            }

            ret.IsError  = true;
            ret.ErrorMsg = "请求失败";
            return(ret);
        }
Example #29
0
        protected RetValue<List<BaseStoreParser>> LoadStores()
        {
            var result = new RetValue<List<BaseStoreParser>>();
            result.Value = new List<BaseStoreParser>();
            try
            {
                var serializer = new JsonSerializer();

                result.Value.Add(serializer.Load<DirectcodParser>(@"configs\directcod.config"));
                result.Value.Add(serializer.Load<SteamParser>(@"configs\steam.config"));
                result.Value.Add(serializer.Load<YuplayParser>(@"configs\yuplay.config"));
                result.Value.Add(serializer.Load<OriginParser>(@"configs\origin.config"));
                result.Value.Add(serializer.Load<RoxenParser>(@"configs\roxen.config"));
                result.Value.Add(serializer.Load<GamagamaParser>(@"configs\gamagama.config"));
                result.Value.Add(serializer.Load<GamazavrParser>(@"configs\gamazavr.config"));
                result.Value.Add(serializer.Load<IgromagazParser>(@"configs\igromagaz.config"));
                result.Value.Add(serializer.Load<Shop1cParser>(@"configs\shop1c.config"));
            }
            catch (Exception ex)
            {
                result.Description = ex.Message;
                _logger.Error(ex.ToString());
                _logger.WriteLogs();
            }

            return result;
        }