public static void getVKeyParams(string strVKey, out bool bPaid)
        {
            bPaid = true;
            try
            {
                string strKeyId = null;
                getVKeyStringParam(strVKey, ConfigurationSettings.AppSettings["keyKeyID"], out strKeyId);

                ASC.Core.Billing.PaymentOffice oPaymentOffice = getPaymentOffice(strKeyId);

                var vElement = Read <object>(strVKey, oPaymentOffice.Key2, true);
                if (null == vElement)
                {
                    return;
                }
                System.Collections.Generic.Dictionary <string, object> arrElements = (System.Collections.Generic.Dictionary <string, object>)vElement;
                object objValue = null;
                arrElements.TryGetValue(ConfigurationSettings.AppSettings["keyPaid"], out objValue);
                if (null == objValue)
                {
                    return;
                }
                bPaid = (bool)objValue;
            }
            catch { }
        }
        public static ASC.Core.Billing.PaymentOffice getPaymentOffice(string strKeyId)
        {
            ASC.Core.Billing.PaymentOffice oPaymentOffice = null;
            Cache  oCache    = HttpRuntime.Cache;
            object oCacheVal = oCache.Get(strKeyId);

            if (null == oCacheVal)
            {
                ASC.Core.Billing.BillingClient oBillingClient = new ASC.Core.Billing.BillingClient();
                oPaymentOffice = oBillingClient.GetPaymentOffice(strKeyId);
                string sWebCacheExpireSeconds = ConfigurationSettings.AppSettings["WebCacheExpireSeconds"];
                oCache.Add(strKeyId, oPaymentOffice, null, DateTime.Now.AddSeconds(int.Parse(sWebCacheExpireSeconds)), Cache.NoSlidingExpiration, CacheItemPriority.Normal, null);
            }
            else
            {
                oPaymentOffice = oCacheVal as ASC.Core.Billing.PaymentOffice;
            }
            return(oPaymentOffice);
        }
        public static ErrorTypes isAccept(string strVKey, string strCurrentKey, bool bCheckIP, string strCurrentIp)
        {
            try
            {
                string strKeyId = null;
                System.Collections.Generic.Dictionary <string, object> arrElements = null;
                ASC.Core.Billing.PaymentOffice oPaymentOffice = null;
                try
                {
                    getVKeyStringParam(strVKey, ConfigurationSettings.AppSettings["keyKeyID"], out strKeyId);

                    oPaymentOffice = getPaymentOffice(strKeyId);
                    var vElement = Read <object>(strVKey, oPaymentOffice.Key2, true);
                    if (null == vElement)
                    {
                        return(ErrorTypes.VKeyEncrypt);
                    }
                    arrElements = (System.Collections.Generic.Dictionary <string, object>)vElement;
                }
                catch
                {
                    return(ErrorTypes.VKeyEncrypt);
                }
                object objValue = null;

                DateTime oDateTimeNow = DateTime.UtcNow;

                if (false == ((oDateTimeNow - oPaymentOffice.EndDate).TotalSeconds < mc_dKeyDateEpsilon))
                {
                    return(ErrorTypes.VKeyKeyExpire);
                }

                int nUserCount = 0;

                arrElements.TryGetValue(ConfigurationSettings.AppSettings["keyUserCount"], out objValue);

                if (null != objValue)
                {
                    nUserCount = (int)objValue;
                }

                if (nUserCount > oPaymentOffice.UsersCount)
                {
                    return(ErrorTypes.VKeyUserCountExceed);
                }

                if (bCheckIP)
                {
                    arrElements.TryGetValue(ConfigurationSettings.AppSettings["keyIp"], out objValue);
                    if (null == objValue)
                    {
                        return(ErrorTypes.VKey);
                    }
                    string strUserIp = (string)objValue;
                    if (strCurrentIp != strUserIp)
                    {
                        return(ErrorTypes.VKey);
                    }
                }

                arrElements.TryGetValue(ConfigurationSettings.AppSettings["keyKey"], out objValue);
                if (null == objValue)
                {
                    return(ErrorTypes.VKey);
                }
                string strKey = (string)objValue;

                if (strCurrentKey.Length > strKey.Length)
                {
                    int nIndexStartFormat = strCurrentKey.LastIndexOf(".");
                    if (-1 != nIndexStartFormat)
                    {
                        strCurrentKey = strCurrentKey.Substring(0, nIndexStartFormat);
                    }
                }

                if (strKey != strCurrentKey && strKey + "_temp" != strCurrentKey)
                {
                    return(ErrorTypes.VKey);
                }

                arrElements.TryGetValue(ConfigurationSettings.AppSettings["keyDate"], out objValue);
                if (null != objValue)
                {
                    DateTime oDateTimeKey        = (DateTime)objValue;
                    DateTime oDateTimeKeyAddHour = oDateTimeKey;
                    oDateTimeKeyAddHour = oDateTimeKeyAddHour.AddHours(double.Parse(ConfigurationSettings.AppSettings["keyDateInterval"] ?? "1", Constants.mc_oCultureInfo));

                    if ((oDateTimeKey - oDateTimeNow).TotalSeconds > mc_dKeyDateEpsilon)
                    {
                        return(ErrorTypes.VKeyTimeIncorrect);
                    }

                    if (mc_dKeyDateEpsilon < (oDateTimeNow - oDateTimeKeyAddHour).TotalSeconds)
                    {
                        return(ErrorTypes.VKeyTimeExpire);
                    }
                }
            }
            catch { return(ErrorTypes.VKey); }
            return(ErrorTypes.NoError);
        }