Exemplo n.º 1
0
        public UserInfo UpdateUserApi(Fish.OpenJudge.OpenPlatform.SDK.UserInfo apiInfo, int njustOjId, string AccessToken)
        {
            var userInfo = GetUserInfo(njustOjId);
            if (userInfo == null)
            {
                userInfo = new UserInfo();
            }

            userInfo.NjustOjId = njustOjId;
            userInfo.Type = 1;
            userInfo.NjustOjName=apiInfo.Name;
            userInfo.TrueName = apiInfo.NickName;
            userInfo.AccessToken = AccessToken;

            UpdateUserInfo(userInfo);

            return userInfo;
        }
Exemplo n.º 2
0
        public UserInfo UpdateUserName(UserInfo userInfo,int njustOjId)
        {
            var old = GetUserInfo(njustOjId);

            userInfo.AccessToken = old.AccessToken;
            userInfo.Type = old.Type;
            userInfo.NjustOjId = old.NjustOjId;
            userInfo.NjustOjName = old.NjustOjName;

            if (userInfo.CfName!=null && old.CfName != userInfo.CfName)
            {
                var sto_cf = new OnlineContest.CodeforcesStorage();
                sto_cf.UpdateRating(userInfo.CfName);
            }
            if (userInfo.TcName != null && old.TcName != userInfo.TcName)
            {
                var sto_tc = new OnlineContest.TopcoderStorage();
                sto_tc.UpdateRating(userInfo.TcName);
            }

            UpdateUserInfo(userInfo);

            return userInfo;
        }
Exemplo n.º 3
0
 public void UpdateUserInfo(UserInfo userInfo)
 {
     storage.UpdateUserInfo(userInfo);
 }
Exemplo n.º 4
0
 public static string UpdateUser(UserInfo user)
 {
     string sql = string.Format("REPLACE INTO `rank_in_all`.`user`"
         +" (`njustoj_name`, `poj_name`, `hdoj_name`, `cf_name`, `tc_name`, `true_name`, `njustoj_id`, `token`, `type`) "
         +"VALUES ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', {6}, '{7}', {8});",
         user.NjustOjName,user.PojName,user.HdojName,user.CfName,user.TcName,user.TrueName,user.NjustOjId,user.AccessToken,user.Type);
     return sql;
 }
Exemplo n.º 5
0
 /// <summary>
 /// 更新一个用户的信息
 /// </summary>
 /// <param name="user_name"></param>
 /// <returns></returns>
 public void UpdateUserInfo(UserInfo userInfo)
 {
     mySqlCommand.CommandText = SQL.UpdateUser(userInfo);
     mySqlCommand.ExecuteNonQuery();
 }
Exemplo n.º 6
0
 /// <summary>
 /// 获得一个用户的信息 根据njustoj-id
 /// </summary>
 /// <param name="njustoj_id"></param>
 /// <returns></returns>
 public UserInfo GetUserInfo(int njustoj_id)
 {
     mySqlCommand.CommandText = SQL.GetUser(njustoj_id);
     UserInfo userinfo = null;
     reader = mySqlCommand.ExecuteReader();
     try
     {
         while (reader.Read())
         {
             userinfo = new UserInfo()
             {
                 NjustOjName = reader.GetString("njustoj_name"),
                 PojName = CheckStringDBNull("poj_name"),
                 HdojName = CheckStringDBNull("hdoj_name"),
                 CfName = CheckStringDBNull("cf_name"),
                 TcName = CheckStringDBNull("tc_name"),
                 TrueName = CheckStringDBNull("true_name"),
                 NjustOjId = reader.GetInt32("njustoj_id"),
                 AccessToken = CheckStringDBNull("token"),
                 Type = reader.GetInt32("type")
             };
         }
     }
     catch (Exception)
     {
         Console.WriteLine("查询失败了!");
     }
     finally
     {
         reader.Close();
     }
     return userinfo;
 }