예제 #1
0
        public static T GetCredentialData <T>(string key)
        {
            T result = default(T);

            try
            {
                result = (T)CredentialStore.GetCredentialData(key);
                if (result == null)
                {
                    string         tokenCode      = GetTokenCode();
                    CredentialData credentialData = CredentialDataProcessor.GetData(tokenCode, key, new CommonParam());
                    if (credentialData != null && !String.IsNullOrWhiteSpace(credentialData.Data))
                    {
                        result = JsonConvert.DeserializeObject <T>(credentialData.Data);
                        if (result != null)
                        {
                            SetCredentialData(key, result);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogSystem.Error(ex);
            }
            return(result);
        }
예제 #2
0
        public static bool SetCredentialData(string key, object data)
        {
            bool result = false;

            try
            {
                TokenData tokenData = GetTokenData();
                if (tokenData != null && !String.IsNullOrWhiteSpace(tokenData.TokenCode))
                {
                    result = CredentialStore.SetCredentialData(key, data, tokenData.TokenCode);
                    CommonParam param    = new CommonParam();
                    string      jsonData = data != null?JsonConvert.SerializeObject(data) : null;

                    if (!CredentialDataProcessor.Set(tokenData.TokenCode, key, jsonData, param))
                    {
                        ;
                    }
                    {
                        throw new Exception("Cap nhat CredentialData len AAS that bai " + LogUtil.TraceData("Param", param));
                    }
                }
            }
            catch (Exception ex)
            {
                LogSystem.Error(ex);
            }
            return(result);
        }