Ejemplo n.º 1
0
        /// <summary>
        /// Get the license expiration date
        /// </summary>
        /// <param name="licenseInfo"></param>
        /// <returns></returns>
        internal static DateTime getLicenseExp(string licenseInfo)
        {
            string   expDate = "";
            DateTime DT      = DateTime.Now;

            try
            {
                //Days
                int a = licenseInfo.IndexOf("Time remaining") + 14;
                int b = licenseInfo.IndexOf("days");
                expDate = licenseInfo.Substring(a, b - a).Trim();
                DT      = DT.AddDays(Int32.Parse(expDate));
                string days = expDate;
                //Hours
                a       = licenseInfo.IndexOf("days,") + 5;
                b       = licenseInfo.IndexOf("hours");
                expDate = licenseInfo.Substring(a, b - a).Trim();
                DT      = DT.AddHours(Int32.Parse(expDate));
                //Minutes
                a       = licenseInfo.IndexOf("hours,") + 6;
                b       = licenseInfo.IndexOf("min");
                expDate = licenseInfo.Substring(a, b - a).Trim();
                DT      = DT.AddMinutes(Int32.Parse(expDate));
                //Seconds
                a       = licenseInfo.IndexOf("min,") + 4;
                b       = licenseInfo.IndexOf("sec");
                expDate = licenseInfo.Substring(a, b - a).Trim();
                DT      = DT.AddSeconds(Int32.Parse(expDate));
            }catch
            {
                //Something failed. subtracta year and return that
                DT = DateTime.Now.AddYears(-1);
            }

            return(DT);
        }