Beispiel #1
0
        private string GenerateToken(ProfileRouter router)
        {
            var password = DateTime.UtcNow.ToString("yyyyMMddHHmmss") + router.ClientKey;
            var token    = AES128.Encrypt(password, router.SecretKey);

            return(token);
        }
 public bool UpdateRouter(ProfileRouter router)
 {
     using (var con = WriteConnection())
     {
         return(con.Execute("UPDATE ProfileRouters set ServerAddress=@ServerAddress, ClientKey=@ClientKey,SecretKey=@SecretKey WHERE Country=@Country", router) > 0);
     }
 }
Beispiel #3
0
        public UserProfileRPC(ProfileRouter server)
        {
            this.server = server;
            baseAddress = $"{server.ServerAddress}/User";
            headers     = new Dictionary <string, string>();
            var token = GenerateToken();

            headers.Add("Authorization", "Bearer " + token);
        }
Beispiel #4
0
        public static bool UpdateRouter(ProfileRouter router)
        {
            var dac    = new ProfileRouterDAC();
            var result = dac.UpdateRouter(router);

            if (result)
            {
                Init();
            }
            return(false);
        }
Beispiel #5
0
        private UserProfile GetProfileByAccountId(ProfileRouter router, Guid id)
        {
            var url = $"{router.ServerAddress}/User/GetById";

            System.Collections.Generic.Dictionary <string, string> headers = new System.Collections.Generic.Dictionary <string, string>();
            var token = GenerateToken(router);

            headers.Add("Authorization", "Bearer " + token);
            var obj = new
            {
                Id = id
            };
            var result = RestUtilities.PostJson(url, headers, JsonConvert.SerializeObject(obj));
            var data   = JsonConvert.DeserializeObject <ServiceResult <UserProfile> >(result);

            if (data.Code == 0)
            {
                return(data.Data);
            }
            throw new CommonException(10000, data.Message);
        }
Beispiel #6
0
 public RegionImageAgent(int countryId)
 {
     _router = new ProfileRouterDAC().GetRouter(countryId);
 }