Exemple #1
0
        public static int RenewToken(string username, ref byte[] renewToken)
        {
            var rp = new RenewProcedure();

            try
            {
                var ret = rp.Step1(username, renewToken);

                if (CheckVendor.NotValidResponseCode(ret))
                {
                    return(ret);
                }

                return(rp.Step2(out renewToken));
            }
            catch (HttpRequestException e)
            {
                return(02_0000 + (int)e.Data["StatusCode"]);
            }
        }
Exemple #2
0
        public static bool ValidateAndRenewToken()
        {
            if (DataHolder.RenewToken == null || CheckVendor.NotValidUsername(DataHolder.Username))
            {
                return(false);
            }

            int ret;
            var renew = new RenewProcedure();

            try
            {
                ret = renew.Step1(DataHolder.Username, DataHolder.RenewToken);

                byte[] token = null;

                ret = CheckVendor.NotValidResponseCode(ret) ? ret : renew.Step2(out token);

                if (CheckVendor.NotValidResponseCode(ret))
                {
                    return(false);
                }

                SetRenew(token);
            }
            catch (HttpRequestException ex)
            {
                ret = 02_0000 + (int)(ex.Data["StatusCode"]);
            }
            catch (Exception)
            {
                ret = 02_0000;
            }

            return(!CheckVendor.NotValidResponseCode(ret) && HasToken());
        }