예제 #1
0
        /// <summary>
        /// View the Status and Information of all Licenses
        /// </summary>
        /// <param name="licenses">List of all LicenseInstance</param>
        /// <param name="showCMID">Display Client Machine ID Once</param>
        /// <param name="showUnlicensed">Show Licenses with no installed Product Keys</param>
        /// <returns>String Representation of all Licenses</returns>
        public static string CheckActivation(LicenseList licenses, bool showCMID = false, bool showUnlicensed = false)
        {
            using (StringWriter output = new StringWriter())
            {
                // Show Activation Errors if No Licenses or Keys Exist
                if (licenses.GetListLicensed().Count == 0 && licenses.GetListUnlicensed().Count > 0 && !showUnlicensed)
                {
                    return(LicenseErrorCode.ErrKeyless);
                }
                if (licenses.GetListLicensed().Count == 0 && licenses.GetListUnlicensed().Count == 0)
                {
                    return(LicenseErrorCode.ErrBroken);
                }
                // Show CMID
                if (showCMID)
                {
                    output.WriteLine("---------------------------------------");
                    output.WriteLine("CMID: " + licenses.GetCMID());
                }
                // Show Active Licenses
                foreach (LicenseInstance license in licenses.GetListLicensed())
                {
                    output.WriteLine("---------------------------------------");
                    output.WriteLine(license.ToString());
                }
                // Show Inactive Licenses
                if (showUnlicensed)
                {
                    foreach (LicenseInstance license in licenses.GetListUnlicensed())
                    {
                        output.WriteLine("---------------------------------------");
                        output.WriteLine(license.ToString());
                    }
                }
                output.Write("---------------------------------------");

                return(output.ToString());
            }
        }