private void OnTimer(object state)
 {
     this._sdkCallbackQueue.Switch();
     while (!this._sdkCallbackQueue.isEmpty)
     {
         GBuffer buffer = this._sdkCallbackQueue.Pop();
         if (buffer.data == ( int )GCToLS.MsgID.EMsgToLsfromGcAskLogin)
         {
             uint         gcnetID = buffer.ReadUInt();
             UserPlatform eplat   = ( UserPlatform )buffer.ReadInt();
             if (IfTestPlatform(eplat))
             {
                 this.AsynHandleLoiginCheckMsg_PC(gcnetID);
             }
             // 其他渠道暂不实现 todo
             //else
             //{
             //bool bState = IfPostVisit( platform );
             //string str = gBuffer.ReadUTF8E();
             //new_conn( gcNetID, gBuffer.data, str, this.gGlobalInfoInstance, platform, bState );
             //}
         }
         buffer.position = 0;
         this._sdkCallbackQueuePool.Push(buffer);
     }
 }
示例#2
0
        public UserPlatform GetByAppKey(string appkey, string appsecrect)
        {
            ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings["connectStr"];
            string conStr = SysInfoManage.DENString(settings.ConnectionString);

            using (ULinker.Common.DB.DBHelper db = new Common.DB.DBHelper(conStr))
            {
                UserPlatform item = null;
                try
                {
                    string           strCmd    = @"SELECT * FROM `userplatform` WHERE `AppKey`=@AppKey AND `AppSecrect`=@AppSecrect";
                    MySqlParameter[] paramters = new MySqlParameter[]
                    {
                        new MySqlParameter("@AppKey", MySqlDbType.String),
                        new MySqlParameter("@AppSecrect", MySqlDbType.String)
                    };

                    paramters[0].Value = appkey;
                    paramters[1].Value = appsecrect;

                    DataRow dr = db.GetDataRow(strCmd, paramters);
                    if (dr != null)
                    {
                        item = RowToObject(dr);
                    }
                }
                catch (Exception ex)
                {
                    Log4Helper.Error(this.GetType(), String.Format("UserPlatformDao.GetByAppKey.{0}", ex.Message), new Exception("error"));
                }

                return(item);
            }
        }
示例#3
0
 public void Clear()
 {
     this.un64ObjIdx                = 0;
     this.userPlatform              = 0;
     this.un16HeaderID              = 0;
     this.n16Sex                    = 0;
     this.n64Diamond                = 0;
     this.n64Gold                   = 0;
     this.tRegisteUTCMillisec       = 0;
     this.n64Score                  = 0;
     this.un32TotalGameInns         = 0;
     this.un32TotalWinInns          = 0;
     this.un32TotalHeroKills        = 0;
     this.un32TotalDestoryBuildings = 0;
     this.un32TotalDeadTimes        = 0;
     this.un32TotalAssist           = 0;
     this.un8UserLv                 = 0;
     this.un32UserCurLvExp          = 0;
     this.tLastFirstWinTime         = 0;
     this.un16Cldays                = 0;
     this.un32LastGetLoginRewardDay = 0;
     this.un16VipLv                 = 0;
     this.vipScore                  = 0;
     Array.Clear(this._ifChangeArr, 0, this._ifChangeArr.Length);
 }
        private Object ToJson(UserPlatform model, DataTableParams dtParams)
        {
            var json = model.AsJson() as Hashtable;

            json.Add("Actions", RenderViewHelper.RenderToString("_Actions", model, dtParams.Controller));

            return(json);
        }
示例#5
0
 public object Remove(UserPlatform userPlatform)
 {
     try {
         _repo.Remove(userPlatform);
         return(NoContent());
     } catch (Exception error) {
         throw error;
     }
 }
        private void PostMsg(string msg, int msgID, uint gcnetID, UserPlatform eplat)
        {
            GBuffer buffer = this._sdkCallbackQueuePool.Pop();

            buffer.Write(gcnetID);
            buffer.Write(( int )eplat);
            buffer.WriteUTF8E(msg);
            buffer.position = 0;
            buffer.data     = msgID;
            this._sdkCallbackQueue.Push(buffer);
        }
        private static bool IfTestPlatform(UserPlatform platform)
        {
            switch (platform)
            {
            case UserPlatform.PC:
            case UserPlatform.AndroidUC:
            case UserPlatform.OnlineGame:
                return(true);

            default:
                return(false);
            }
        }
示例#8
0
        private List <UserPlatform> _Filter(int appId, int platformId, int limit, int pageSize)
        {
            ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings["connectStr"];
            string conStr = SysInfoManage.DENString(settings.ConnectionString);

            using (ULinker.Common.DB.DBHelper db = new Common.DB.DBHelper(conStr))
            {
                List <UserPlatform> _Platforms = new List <UserPlatform>();
                try
                {
                    string strCmd = @"SELECT * FROM `userplatform` WHERE 1=1";

                    if (platformId != 0)
                    {
                        strCmd += @"  AND `PlatformId`=@PlatformId";
                    }

                    if (appId != 0)
                    {
                        strCmd += @"  AND `AppId`=@AppId";
                    }

                    strCmd += " ORDER BY CreateTime DESC";
                    strCmd += " LIMIT " + limit + "," + pageSize;

                    MySqlParameter[] paramters = new MySqlParameter[]
                    {
                        new MySqlParameter("@PlatformId", MySqlDbType.Int32),
                        new MySqlParameter("@AppId", MySqlDbType.Int32)
                    };

                    paramters[0].Value = platformId;
                    paramters[1].Value = appId;

                    DataTable dt = db.GetDataSet(strCmd, paramters);
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        foreach (DataRow row in dt.Rows)
                        {
                            UserPlatform item = RowToObject(row);
                            _Platforms.Add(item);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Log4Helper.Error(this.GetType(), String.Format("PlatformDao._Filter.{0}", ex.Message), new Exception("error"));
                }
                return(_Platforms);
            }
        }
示例#9
0
        public object Add(UserPlatform userPlatform)
        {
            try {
                userPlatform.Id           = Guid.NewGuid().ToString();
                userPlatform.CreationDate = DateTime.Now;

                _repo.Add(userPlatform);

                var controllerAction = new ControllerActionDescriptor();

                string actionName = controllerAction.ActionName;

                return(CreatedAtAction(actionName, userPlatform));
            } catch (Exception error) {
                throw error;
            }
        }
示例#10
0
        public bool Update(UserPlatform model)
        {
            ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings["connectStr"];
            string conStr = SysInfoManage.DENString(settings.ConnectionString);

            using (ULinker.Common.DB.DBHelper db = new Common.DB.DBHelper(conStr))
            {
                try
                {
                    string strCmd = @"UPDATE `userplatform` 
                                      SET `PlatformId`=@PlatformId,`AppId`=@AppId,`AppKey`=@AppKey,`AppSecrect`=@AppSecrect,`ModifyTime`=NOW()
                                      WHERE `Id`=@Id";

                    MySqlParameter[] paramters = new MySqlParameter[]
                    {
                        new MySqlParameter("@PlatformId", MySqlDbType.Int32),
                        new MySqlParameter("@AppId", MySqlDbType.Int32),
                        new MySqlParameter("@AppKey", MySqlDbType.String),
                        new MySqlParameter("@AppSecrect", MySqlDbType.String),
                        new MySqlParameter("@Id", MySqlDbType.Int32),
                    };

                    paramters[0].Value = model.PlatformId;
                    paramters[1].Value = model.AppId;
                    paramters[2].Value = model.AppKey;
                    paramters[3].Value = model.AppSecrect;
                    paramters[4].Value = model.Id;

                    int count = db.ExecuteNonQuery(strCmd, paramters);
                    return(count > 0 ? true : false);
                }
                catch (Exception ex)
                {
                    Log4Helper.Error(this.GetType(), String.Format("UserPlatformDao.Update.{0}", ex.Message), new Exception("error"));
                    return(false);
                }
            }
        }
        public ErrorCode CheckLogin(GCToLS.AskLogin askLogin, int msgID, uint gcnetID)
        {
            UserPlatform  platform  = ( UserPlatform )askLogin.Platform;
            UserLoginData loginData = new UserLoginData
            {
                platFrom  = askLogin.Platform,
                sessionid = askLogin.Sessionid,
                uin       = askLogin.Uin
            };

            lock (this._userLoginDataMapMutex)
            {
                if (this._userLoginDataMap.ContainsKey(gcnetID))
                {
                    Logger.Warn($"client({askLogin.Uin}) login multiple times, but the server data has not been returned to the client");
                    return(ErrorCode.Success);
                }
                this._userLoginDataMap[gcnetID] = loginData;
            }
            Logger.Log($"GC Try To Login with uin:{askLogin.Uin}({gcnetID}), sessionid:{askLogin.Sessionid}, platform:{platform}");

            string sendData = string.Empty;

            switch (platform)
            {
            case UserPlatform.PC:
                sendData = "PCTest";
                break;

            default:
                this.PostToLoginFailQueue(ErrorCode.UnknowPlatform, gcnetID);
                break;
            }
            Logger.Log($"{sendData}");
            this.PostMsg(sendData, msgID, gcnetID, platform);
            return(0);
        }
示例#12
0
 public void Copy(PODUsrDBData other)
 {
     this.un64ObjIdx                = other.un64ObjIdx;
     this.userPlatform              = other.userPlatform;
     this.un16HeaderID              = other.un16HeaderID;
     this.n16Sex                    = other.n16Sex;
     this.n64Diamond                = other.n64Diamond;
     this.n64Gold                   = other.n64Gold;
     this.tRegisteUTCMillisec       = other.tRegisteUTCMillisec;
     this.n64Score                  = other.n64Score;
     this.un32TotalGameInns         = other.un32TotalGameInns;
     this.un32TotalWinInns          = other.un32TotalWinInns;
     this.un32TotalHeroKills        = other.un32TotalHeroKills;
     this.un32TotalDestoryBuildings = other.un32TotalDestoryBuildings;
     this.un32TotalDeadTimes        = other.un32TotalDeadTimes;
     this.un32TotalAssist           = other.un32TotalAssist;
     this.un8UserLv                 = other.un8UserLv;
     this.un32UserCurLvExp          = other.un32UserCurLvExp;
     this.tLastFirstWinTime         = other.tLastFirstWinTime;
     this.un16Cldays                = other.un16Cldays;
     this.un32LastGetLoginRewardDay = other.un32LastGetLoginRewardDay;
     this.un16VipLv                 = other.un16VipLv;
     this.vipScore                  = other.vipScore;
 }
示例#13
0
 public bool Update(UserPlatform model)
 {
     return(UserPlatformDao.Instance.Update(model));
 }
示例#14
0
 public bool Create(UserPlatform model)
 {
     return(UserPlatformDao.Instance.Create(model));
 }
示例#15
0
        /// <summary>
        /// 根据用户名获取token
        /// </summary>
        /// <param name="appkey"></param>
        /// <param name="appsecrect"></param>
        /// <returns></returns>
        public HttpResponseMessage GetToken(string appkey, string appsecrect)
        {
            lock (this)
            {
                //根据用户名获取token
                ResultMsg resultMsg = null;

                //判断参数是否合法
                if (String.IsNullOrEmpty(appkey))
                {
                    resultMsg            = new ResultMsg();
                    resultMsg.StatusCode = (int)StatusCodeEnum.ParameterError;
                    resultMsg.Info       = StatusCodeEnum.ParameterError.GetEnumText();
                    resultMsg.Data       = "";
                    Log4Helper.Error(this.GetType(), "ServiceController.GetToken失败。参数appkey为空!");
                    return(HttpResponseExtension.toJson(JsonConvert.SerializeObject(resultMsg)));
                }

                //检查是否存在
                UserPlatform userPlatform = UserPlatformService.Instance.GetByAppKey(appkey, appsecrect);
                string       token        = String.Empty;
                if (userPlatform == null)
                {
                    resultMsg            = new ResultMsg();
                    resultMsg.StatusCode = (int)StatusCodeEnum.TokenInvalid;
                    resultMsg.Info       = StatusCodeEnum.TokenInvalid.GetEnumText();
                    resultMsg.Data       = "";
                    Log4Helper.Error(this.GetType(), String.Format("ServiceController.GetToken失败。请检查AppKey:{0}是否注册过!", appkey));
                    return(HttpResponseExtension.toJson(JsonConvert.SerializeObject(resultMsg)));
                }

                //token
                if (userPlatform != null && String.IsNullOrEmpty(userPlatform.Token))
                {
                    FeedBackResult result = RefreshToken(appkey);
                    if (!result.Result)
                    {
                        resultMsg            = new ResultMsg();
                        resultMsg.StatusCode = (int)StatusCodeEnum.TokenInvalid;
                        resultMsg.Info       = StatusCodeEnum.TokenInvalid.GetEnumText();
                        resultMsg.Data       = "";
                        Log4Helper.Error(this.GetType(), String.Format("ServiceController.GetToken失败。刷新token:{0}失败!", token));
                        return(HttpResponseExtension.toJson(JsonConvert.SerializeObject(resultMsg)));
                    }
                }

                //重新获取一次
                userPlatform = UserPlatformService.Instance.GetByAppKey(appkey, appsecrect);

                //是否过期
                if (DateTime.Now > userPlatform.TokenExpireTime)
                {
                    //过期 重新生成
                    FeedBackResult result = RefreshToken(appkey);
                    if (!result.Result)
                    {
                        resultMsg            = new ResultMsg();
                        resultMsg.StatusCode = (int)StatusCodeEnum.TokenInvalid;
                        resultMsg.Info       = StatusCodeEnum.TokenInvalid.GetEnumText();
                        resultMsg.Data       = "";
                        Log4Helper.Error(this.GetType(), String.Format("ServiceController.GetToken失败。刷新token:{0}失败!", token));
                        return(HttpResponseExtension.toJson(JsonConvert.SerializeObject(resultMsg)));
                    }
                }

                token = userPlatform.Token;

                //返回token信息
                resultMsg            = new ResultMsg();
                resultMsg.StatusCode = (int)StatusCodeEnum.Success;
                resultMsg.Info       = "";
                resultMsg.Data       = token;

                return(HttpResponseExtension.toJson(JsonConvert.SerializeObject(resultMsg)));
            }
        }
        public JsonResult Create(
            int platformId,
            int appId,
            string appKey,
            string appSecrect
            )
        {
            var oResult = new Object();

            try
            {
                //登录验证
                var currentAdminUser = Session[AccountHashKeys.CurrentAdminUser] as AdminUser;
                if (currentAdminUser == null)
                {
                    oResult = new
                    {
                        Bresult = false,
                        Notice  = "登录超时!",
                        Url     = "/admins/account/login"
                    };
                    return(Json(oResult, JsonRequestBehavior.AllowGet));
                }

                //必填参数验证
                if (platformId == 0)
                {
                    oResult = new
                    {
                        Bresult = false,
                        Notice  = "请选择平台!",
                    };
                    return(Json(oResult, JsonRequestBehavior.AllowGet));
                }

                if (appId == 0)
                {
                    oResult = new
                    {
                        Bresult = false,
                        Notice  = "请选择应用!",
                    };
                    return(Json(oResult, JsonRequestBehavior.AllowGet));
                }

                if (String.IsNullOrEmpty(appKey) || String.IsNullOrEmpty(appSecrect))
                {
                    oResult = new
                    {
                        Bresult = false,
                        Notice  = "请填写AppKey和AppSecrect!",
                    };
                    return(Json(oResult, JsonRequestBehavior.AllowGet));
                }

                UserPlatform up = new UserPlatform
                {
                    CreatorId  = currentAdminUser.Id,
                    PlatformId = platformId,
                    AppId      = appId,
                    AppKey     = appKey,
                    AppSecrect = appSecrect
                };

                //20180315
                bool isExist = UserPlatformService.Instance.IsExist(platformId, appId);
                if (isExist)
                {
                    oResult = new
                    {
                        Bresult = false,
                        Notice  = "该应用已经在该平台申请过!",
                    };
                    return(Json(oResult, JsonRequestBehavior.AllowGet));
                }

                bool bRet = UserPlatformService.Instance.Create(up);

                oResult = new
                {
                    Bresult = bRet,
                    Notice  = bRet ? "操作成功!" : "操作失败!"
                };

                return(Json(oResult, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                oResult = new
                {
                    Bresult = false,
                    Notice  = String.Format("操作失败!异常:{0}", ex.Message)
                };
                return(Json(oResult, JsonRequestBehavior.AllowGet));
            }
        }
示例#17
0
        /// <summary>
        /// 根据用户名获取token
        /// </summary>
        /// <param name="appkey"></param>
        /// <returns></returns>
        public HttpResponseMessage GetToken(string appkey, string appsecrect)
        {
            lock (this)
            {
                //增加对appkey+secrect的解密

                Log4Helper.Info(this.GetType(), String.Format("进入ServiceController.GetToken。appkey:{0},appsecrect:{1}", appkey, appsecrect));

                //根据用户名获取token
                ResultMsg resultMsg = null;

                //判断参数是否合法
                if (String.IsNullOrEmpty(appkey) || String.IsNullOrEmpty(appsecrect))
                {
                    resultMsg            = new ResultMsg();
                    resultMsg.StatusCode = (int)StatusCodeEnum.ParameterError;
                    resultMsg.Info       = StatusCodeEnum.ParameterError.GetEnumText();
                    resultMsg.Data       = "";
                    Log4Helper.Error(this.GetType(), "ServiceController.GetToken失败。请检查参数appkey或appsecrect为空!");
                    return(HttpResponseExtension.toJson(JsonConvert.SerializeObject(resultMsg)));
                }

                //1.检查缓存中是否有,有就结束
                Token token = (Token)HttpRuntime.Cache.Get(appkey);
                if (token == null)
                {
                    //1.1 从数据库取
                    UserPlatform userPlatform = UserPlatformService.Instance.GetByAppKey(appkey, appsecrect);
                    if (userPlatform == null)
                    {
                        resultMsg            = new ResultMsg();
                        resultMsg.StatusCode = (int)StatusCodeEnum.TokenInvalid;
                        resultMsg.Info       = StatusCodeEnum.TokenInvalid.GetEnumText();
                        resultMsg.Data       = "";
                        Log4Helper.Error(this.GetType(), String.Format("ServiceController.GetToken失败。请检查AppKey:{0}是否注册过!", appkey));
                        return(HttpResponseExtension.toJson(JsonConvert.SerializeObject(resultMsg)));
                    }

                    if (userPlatform != null && String.IsNullOrEmpty(userPlatform.Token))
                    {
                        FeedBackResult result = RefreshToken(appkey);
                        if (!result.Result)
                        {
                            resultMsg            = new ResultMsg();
                            resultMsg.StatusCode = (int)StatusCodeEnum.TokenInvalid;
                            resultMsg.Info       = StatusCodeEnum.TokenInvalid.GetEnumText();
                            resultMsg.Data       = "";
                            Log4Helper.Error(this.GetType(), String.Format("ServiceController.GetToken失败。刷新token:{0}失败!", token));
                            return(HttpResponseExtension.toJson(JsonConvert.SerializeObject(resultMsg)));
                        }

                        //重新获取一次
                        userPlatform = UserPlatformService.Instance.GetByAppKey(appkey, appsecrect);
                    }

                    //是否过期
                    if (DateTime.Now > userPlatform.TokenExpireTime)
                    {
                        //过期 刷新
                        FeedBackResult result = RefreshToken(appkey);
                        if (!result.Result)
                        {
                            resultMsg            = new ResultMsg();
                            resultMsg.StatusCode = (int)StatusCodeEnum.TokenInvalid;
                            resultMsg.Info       = StatusCodeEnum.TokenInvalid.GetEnumText();
                            resultMsg.Data       = "";
                            Log4Helper.Error(this.GetType(), String.Format("ServiceController.GetToken失败。刷新token:{0}失败!", token));
                            return(HttpResponseExtension.toJson(JsonConvert.SerializeObject(resultMsg)));
                        }
                        //获取
                        userPlatform = UserPlatformService.Instance.GetByAppKey(appkey, appsecrect);
                    }

                    token = new Token
                    {
                        AppKey     = userPlatform.AppKey,
                        SignToken  = userPlatform.Token,
                        ExpireTime = userPlatform.TokenExpireTime
                    };

                    //插入缓存
                    HttpRuntime.Cache.Insert(token.AppKey, token, null, token.ExpireTime, TimeSpan.Zero);
                }
                else if (token.ExpireTime < DateTime.Now)
                {
                    //过期 刷新
                    FeedBackResult result = RefreshToken(appkey);
                    if (!result.Result)
                    {
                        resultMsg            = new ResultMsg();
                        resultMsg.StatusCode = (int)StatusCodeEnum.TokenInvalid;
                        resultMsg.Info       = StatusCodeEnum.TokenInvalid.GetEnumText();
                        resultMsg.Data       = "";
                        Log4Helper.Error(this.GetType(), String.Format("ServiceController.GetToken失败。刷新token:{0}失败!", token));
                        return(HttpResponseExtension.toJson(JsonConvert.SerializeObject(resultMsg)));
                    }

                    //获取
                    UserPlatform userPlatform = UserPlatformService.Instance.GetByAppKey(appkey, appsecrect);

                    token = new Token
                    {
                        AppKey     = userPlatform.AppKey,
                        SignToken  = userPlatform.Token,
                        ExpireTime = userPlatform.TokenExpireTime
                    };

                    //移除缓存
                    HttpRuntime.Cache.Remove(token.AppKey);

                    //插入缓存
                    HttpRuntime.Cache.Insert(token.AppKey, token, null, token.ExpireTime, TimeSpan.Zero);
                }

                //返回token信息
                resultMsg            = new ResultMsg();
                resultMsg.StatusCode = (int)StatusCodeEnum.Success;
                resultMsg.Info       = "";
                resultMsg.Data       = token;

                return(HttpResponseExtension.toJson(JsonConvert.SerializeObject(resultMsg)));
            }
        }