private static XmlDocument CreateDocument(Guid id, string name, DateTime expirationDate, IDictionary <string, string> attributes, LicenseType licenseType)
        {
            var doc     = new XmlDocument();
            var license = doc.CreateElement("license");

            doc.AppendChild(license);
            var idAttr = doc.CreateAttribute("id");

            license.Attributes.Append(idAttr);
            idAttr.Value = id.ToString();

            var expirDateAttr = doc.CreateAttribute("expiration");

            license.Attributes.Append(expirDateAttr);
            expirDateAttr.Value = expirationDate.ToString("yyyy-MM-ddTHH:mm:ss.fffffff", CultureInfo.InvariantCulture);

            var licenseAttr = doc.CreateAttribute("type");

            license.Attributes.Append(licenseAttr);
            licenseAttr.Value = licenseType.ToString();

            var nameEl = doc.CreateElement("name");

            license.AppendChild(nameEl);
            nameEl.InnerText = name;

            foreach (var attribute in attributes)
            {
                var attrib = doc.CreateAttribute(attribute.Key);
                attrib.Value = attribute.Value;
                license.Attributes.Append(attrib);
            }

            return(doc);
        }
Exemple #2
0
        private void setName()
        {
            if (Owner != null)
            {
                this.Name = Owner.Name + ", ";
            }
            this.Name += LicenseType.ToString();

            if (NewsletterLicenseType != NewsletterLicenceTypeEnum.BitnewsletterNone)
            {
                this.Name += " + " + NewsletterLicenseType.ToString();
                if (this.MaxNumberOfNewsletterMailings != 0)
                {
                    this.Name += "(" + this.MaxNumberOfNewsletterMailings + ")";
                }
                else
                {
                    this.Name += "(onbeperkt)";
                }
            }
            if (WebshopLicenseType != WebshopLicenceTypeEnum.BitshopNone)
            {
                this.Name += " + " + WebshopLicenseType.ToString();
            }
        }
Exemple #3
0
        /// <summary>
        /// Creates a new License file with the given information
        /// </summary>
        /// <param name="expirationDate">Data at which the license should exprice. Format: YYYYMMDD</param>
        /// <param name="clientDetails">Brief client details e.g. name or company, can be max 20 characters</param>
        /// <param name="licenseType">LicenseType from the supported enums</param>
        public string Create(string expirationDate, string clientDetails, LicenseType licenseType)
        {
            // Add padding to create a 10 char long string
            expirationDate = expirationDate.PadLeft(10);

            // Add padding to complete the 20 char length
            clientDetails = clientDetails.PadRight(20);

            // Convert enum to string and add padding to fill 10 char limit
            string licenseTypeString = (licenseType.ToString()).PadLeft(10);

            // Combine all the information in a single block
            string sampleData = @expirationDate + clientDetails + licenseTypeString;

            // Initialze enrcyptor
            Encryptor encryptor = new Encryptor();

            // Get the encrypted string
            string encryptedString = encryptor.EncryptToString(sampleData);

            // Write encrypted string to create license file
            WriteBinaryData(encryptedString);

            return(sampleData);
        }
Exemple #4
0
 internal LicenseHelper(LicenseType type)
 {
     _licenseType = type;
     _codeLength = 8;
     var codeLength = type.GetType().GetField(type.ToString()).GetCustomAttribute<CodeLengthAttribute>();
     if (codeLength != null)
         _codeLength = codeLength.Length;
     _cacheCodes = new List<string>();
 }
Exemple #5
0
        public override string GetSpecificDetails()
        {
            string details = string.Format(
                @"License type: {0}
Engine volume: {1}",
                m_LicenseType.ToString(),
                m_EngineVolume.ToString());

            return(details);
        }
Exemple #6
0
 /// <summary>
 /// 获取调用api token
 /// </summary>
 /// <typeparam name="TResult"></typeparam>
 /// <param name="tokenReq"></param>
 /// <returns></returns>
 private TResult GetAccessTokenInner <TResult>(dynamic tokenReq)
 {
     lock (LOCK_CREATETOKEN)
     {
         QPSControl();
         log.Info("LicenseType:" + LicenseType.ToString() + "——Url:" + APITOKENURL + ",Param:" + JsonConvert.SerializeObject(tokenReq));
         string result = PostWebRequest(APITOKENURL, tokenReq);
         if (string.IsNullOrEmpty(result))
         {
             log.Info("获取APIToken接口调用失败");
             return(default);
        public string GetTimeLeftDescription()
        {
            if (!this.Expires)
            {
                return(string.Empty);
            }
            TimeSpan    expirationDateUTC = this.ExpirationDateUTC - DateTime.UtcNow.ToUniversalDate();
            object      days          = expirationDateUTC.Days;
            LicenseType typeOfLicense = this.TypeOfLicense;

            return(string.Format(" ({0} day(s) left in {1} period)", days, typeOfLicense.ToString().ToLowerInvariant()));
        }
        /// <summary>
        /// Sets the license for a photo.
        /// </summary>
        /// <param name="photoId">The photo to update the license for.</param>
        /// <param name="license">The license to apply, or <see cref="LicenseType.AllRightsReserved"/> (0) to remove the current license.
        /// Note : as of this writing the <see cref="LicenseType.NoKnownCopyrightRestrictions"/> license (7) is not a valid argument.</param>
        public void PhotosLicensesSetLicense(string photoId, LicenseType license)
        {
            CheckRequiresAuthentication();

            var parameters = new Dictionary <string, string>();

            parameters.Add("method", "flickr.photos.licenses.setLicense");
            parameters.Add("photo_id", photoId);
            parameters.Add("license_id", license.ToString("d"));

            GetResponseNoCache <NoResponse>(parameters);
        }
Exemple #9
0
        internal LicenseHelper(LicenseType type)
        {
            _licenseType = type;
            _codeLength  = 8;
            var codeLength = type.GetType().GetField(type.ToString()).GetCustomAttribute <CodeLengthAttribute>();

            if (codeLength != null)
            {
                _codeLength = codeLength.Length;
            }
            _cacheCodes = new List <string>();
        }
Exemple #10
0
        public override string                          ToString()
        {
            StringBuilder electricMotorcycleDetails = new StringBuilder(base.ToString());

            electricMotorcycleDetails.AppendLine(string.Format(
                                                     @"
Motorcycle Properties:
License type: {0}
Engine volume: {1}cc",
                                                     LicenseType.ToString(),
                                                     EngineVolume));

            return(electricMotorcycleDetails.ToString());
        }
Exemple #11
0
        public void Save(XmlElement parent)
        {
            XmlElement el = parent.OwnerDocument.CreateElement("Product");

            el.SetAttribute("AssemblyName", _assemblyName);
            el.SetAttribute("Version", _version);
            el.SetAttribute("ExpirationDate", _expirationDate.ToString("yyyy-MM-dd"));
            el.SetAttribute("Type", _type.ToString());
            el.SetAttribute("Scope", _scope.ToString());

            if (!string.IsNullOrEmpty(LicenseUrl))
            {
                el.SetAttribute("LicenseUrl", LicenseUrl);
            }

            parent.AppendChild(el);
        }
        public SortedDictionary <String, String> GetParam()
        {
            SortedDictionary <String, String> map = base.GetBaseParam();

            if (Name == null)
            {
                throw new SimbossException("param name is required");
            }
            map.Add("name", Name);
            if (this.LicenseType == null)
            {
                throw new SimbossException("param licenseType is required");
            }
            map.Add("licenseType", LicenseType.ToString().ToLower());
            if (LicenseCode == null)
            {
                throw new SimbossException("param licenseCode is required");
            }
            map.Add("licenseCode", LicenseCode);
            if (Phone == null)
            {
                throw new SimbossException("param phone is required");
            }
            map.Add("phone", Phone);
            if (ExtenalUserName != null)
            {
                map.Add("extenalUserName", ExtenalUserName);
            }
            if (String.IsNullOrWhiteSpace(Pic1))
            {
                throw new SimbossException("param pic1 is required");
            }
            map.Add("pic1", Pic1);

            if (String.IsNullOrWhiteSpace(Pic2))
            {
                throw new SimbossException("param pic2 is required");
            }
            map.Add("pic2", Pic2);

            if (!String.IsNullOrWhiteSpace(Pic3))
            {
                map.Add("pic3", Pic3);
            }
            return(map);
        }
Exemple #13
0
        private static NameValueCollection PrepareParameters(LicenseType licenseType, LicenseKey licenseKey, string userName, string company, string data)
        {
            NameValueCollection parameters = new NameValueCollection();

            parameters.Add("Culture", CultureInfo.CurrentCulture.LCID.ToString(CultureInfo.InvariantCulture));
            parameters.Add("Product", LicenseConsoleData.Singleton.Product);
            parameters.Add("Version", LicenseConsoleData.Singleton.Version.ToString());
            parameters.Add("LicenseType", licenseType.ToString());
            if (!licenseKey.IsEmpty)
            {
                parameters.Add("LicenseKey", licenseKey.ToString());
            }
            parameters.Add("UserName", userName);
            parameters.Add("Company", company);
            parameters.Add("Data", data);

            return(parameters);
        }
Exemple #14
0
        public List <KeyValuePair <string, string> > GetParameterList()
        {
            var parameterList = new List <KeyValuePair <string, string> >();

            parameterList.Add(new KeyValuePair <string, string>(nameof(Title), Title));
            parameterList.Add(new KeyValuePair <string, string>(nameof(Version), Version));
            parameterList.Add(new KeyValuePair <string, string>(nameof(Author), Author));
            parameterList.Add(new KeyValuePair <string, string>(nameof(ContactInformation), ContactInformation));
            parameterList.Add(new KeyValuePair <string, string>(nameof(Reference), Reference));
            parameterList.Add(new KeyValuePair <string, string>(nameof(AllowedUser), AllowedUser.ToString()));
            parameterList.Add(new KeyValuePair <string, string>(nameof(ViolentUssage), ViolentUssage.ToString()));
            parameterList.Add(new KeyValuePair <string, string>(nameof(SexualUssage), SexualUssage.ToString()));
            parameterList.Add(new KeyValuePair <string, string>(nameof(CommercialUssage), CommercialUssage.ToString()));
            parameterList.Add(new KeyValuePair <string, string>(nameof(OtherPermissionUrl), OtherPermissionUrl));
            parameterList.Add(new KeyValuePair <string, string>(nameof(LicenseType), LicenseType.ToString()));
            parameterList.Add(new KeyValuePair <string, string>(nameof(OtherLicenseUrl), OtherLicenseUrl));

            return(parameterList);
        }
        public static string GenerateTestToken(
            LicenseType licenseType,
            String productId,
            UserLimit userLimit,
            ExpirationPeriod expirationDays,
            String purchaserId)
        {
            //Note that the AssetId matches that of the Cheezburgers app on the marketplace.
            //This is just for TEST purposes so that the storefront URL takes you to a valid app page
            string hardCodedBaseToken = "<r v=\"0\"><t aid=\"WA103524926\"  did=\"{3F47392A-2308-4FC6-BF24-740626612B26}\"  ad=\"2012-06-19T21:48:56Z\"  te=\"2112-07-15T23:47:42Z\" sd=\"2012-02-01\" test=\"true\"/><d>449JFz+my0wNoCm0/h+Ci9DsF/W0Q8rqEBqjpe44KkY=</d></r>";



            string userLimitString = string.Empty;

            switch (userLimit)
            {
            case UserLimit.Ten:
                userLimitString = "10";
                break;

            case UserLimit.Twenty:
                userLimitString = "20";
                break;

            case UserLimit.Unlimited:
                userLimitString = "Unlimited";
                break;
            }

            int expirationDaysNumber = 0;

            switch (expirationDays)
            {
            case ExpirationPeriod.Month:
                expirationDaysNumber = 30;
                break;

            case ExpirationPeriod.Unlimited:
                expirationDaysNumber = 9999;
                break;

            default:
                expirationDaysNumber = -1;
                break;
            }

            string tokenXml = hardCodedBaseToken;

            tokenXml = AddAttributesToToken(tokenXml, "pid", productId);
            tokenXml = AddAttributesToToken(tokenXml, "et", UppercaseFirst(licenseType.ToString()));
            tokenXml = AddAttributesToToken(tokenXml, "cid", purchaserId);

            //Set user limit
            if (licenseType == LicenseType.Free)
            {
                tokenXml = AddAttributesToToken(tokenXml, "ts", "0");
            }
            else
            {
                tokenXml = AddAttributesToToken(tokenXml, "ts", userLimitString);
            }

            //Set site license == unlimited users
            if (userLimitString == "Unlimited")
            {
                tokenXml = AddAttributesToToken(tokenXml, "sl", "true");
            }
            else
            {
                tokenXml = AddAttributesToToken(tokenXml, "sl", "false");
            }

            //Set expiration (only supported for Trials)
            if (licenseType == LicenseType.Trial)
            {
                DateTime expirationDate;
                if (expirationDaysNumber == -1)
                {
                    //expired token
                    expirationDate = DateTime.UtcNow.Subtract(TimeSpan.FromDays(10));
                }
                else if (expirationDaysNumber == 9999)
                {
                    //Unlimited trial
                    expirationDate = DateTime.MaxValue;
                }
                else
                {
                    //today + the selected number of days
                    expirationDate = DateTime.UtcNow.AddDays(expirationDaysNumber);
                }
                tokenXml = AddAttributesToToken(tokenXml, "ed", expirationDate.ToString("o"));
            }
            return(tokenXml);
        }
        /// <summary>
        /// Sets the license for a photo.
        /// </summary>
        /// <param name="photoId">The photo to update the license for.</param>
        /// <param name="license">The license to apply, or <see cref="LicenseType.AllRightsReserved"/> (0) to remove the current license. Note : as of this writing the <see cref="LicenseType.NoKnownCopyrightRestrictions"/> license (7) is not a valid argument.</param>
        /// <param name="callback">Callback method to call upon return of the response from Flickr.</param>
        public void PhotosLicensesSetLicenseAsync(string photoId, LicenseType license, Action<FlickrResult<NoResponse>> callback)
        {
            CheckRequiresAuthentication();

            Dictionary<string, string> parameters = new Dictionary<string, string>();

            parameters.Add("method", "flickr.photos.licenses.setLicense");
            parameters.Add("photo_id", photoId);
            parameters.Add("license_id", license.ToString("d"));

            GetResponseAsync<NoResponse>(parameters, callback);
        }
Exemple #17
0
        private static XmlDocument CreateDocument(Guid id, string name, DateTime expirationDate, IDictionary<string, string> attributes, LicenseType licenseType)
        {
            var doc = new XmlDocument();
            var license = doc.CreateElement("license");
            doc.AppendChild(license);
            var idAttr = doc.CreateAttribute("id");
            license.Attributes.Append(idAttr);
            idAttr.Value = id.ToString();

            var expirDateAttr = doc.CreateAttribute("expiration");
            license.Attributes.Append(expirDateAttr);
            expirDateAttr.Value = expirationDate.ToString("yyyy-MM-ddTHH:mm:ss.fffffff", CultureInfo.InvariantCulture);

            var licenseAttr = doc.CreateAttribute("type");
            license.Attributes.Append(licenseAttr);
            licenseAttr.Value = licenseType.ToString();

            var nameEl = doc.CreateElement("name");
            license.AppendChild(nameEl);
            nameEl.InnerText = name;

            foreach (var attribute in attributes)
            {
                var attrib = doc.CreateAttribute(attribute.Key);
                attrib.Value = attribute.Value;
                license.Attributes.Append(attrib);
            }

            return doc;
        }
        public static string GenerateTestToken(
            LicenseType licenseType, 
            String productId, 
            UserLimit userLimit, 
            ExpirationPeriod expirationDays, 
            String purchaserId)
        {
            //Note that the AssetId matches that of the Cheezburgers app on the marketplace. 
            //This is just for TEST purposes so that the storefront URL takes you to a valid app page
            string hardCodedBaseToken = "<r v=\"0\"><t aid=\"WA103524926\"  did=\"{3F47392A-2308-4FC6-BF24-740626612B26}\"  ad=\"2012-06-19T21:48:56Z\"  te=\"2112-07-15T23:47:42Z\" sd=\"2012-02-01\" test=\"true\"/><d>449JFz+my0wNoCm0/h+Ci9DsF/W0Q8rqEBqjpe44KkY=</d></r>";



            string userLimitString = string.Empty;
            switch (userLimit){
                case UserLimit.Ten:
                    userLimitString = "10";
                    break;
                case UserLimit.Twenty:
                    userLimitString = "20";
                    break;
                case UserLimit.Unlimited:
                    userLimitString = "Unlimited";
                    break;
            }

            int expirationDaysNumber = 0;
            switch (expirationDays)
            {
                case ExpirationPeriod.Month:
                    expirationDaysNumber = 30;
                    break;
                case ExpirationPeriod.Unlimited:
                    expirationDaysNumber = 9999;
                    break;
                default:
                    expirationDaysNumber = -1;
                    break;

            }

            string tokenXml = hardCodedBaseToken;
            tokenXml = AddAttributesToToken(tokenXml, "pid", productId);
            tokenXml = AddAttributesToToken(tokenXml, "et", UppercaseFirst(licenseType.ToString()));
            tokenXml = AddAttributesToToken(tokenXml, "cid", purchaserId);

            //Set user limit
            if (licenseType == LicenseType.Free)
            {
                tokenXml = AddAttributesToToken(tokenXml, "ts", "0");
            }
            else
            {
                tokenXml = AddAttributesToToken(tokenXml, "ts", userLimitString);
            }

            //Set site license == unlimited users
            if (userLimitString == "Unlimited")
            {
                tokenXml = AddAttributesToToken(tokenXml, "sl", "true");
            }
            else
            {
                tokenXml = AddAttributesToToken(tokenXml, "sl", "false");
            }

            //Set expiration (only supported for Trials)
            if (licenseType == LicenseType.Trial)
            {
                DateTime expirationDate;
                if (expirationDaysNumber == -1)
                {
                    //expired token
                    expirationDate = DateTime.UtcNow.Subtract(TimeSpan.FromDays(10));
                }
                else if (expirationDaysNumber == 9999)
                {
                    //Unlimited trial
                    expirationDate = DateTime.MaxValue;
                }
                else
                {
                    //today + the selected number of days
                    expirationDate = DateTime.UtcNow.AddDays(expirationDaysNumber);
                }
                tokenXml = AddAttributesToToken(tokenXml, "ed", expirationDate.ToString("o"));

            }
            return tokenXml;
        }
Exemple #19
0
        /// <summary>
        /// Sets the license for a photo.
        /// </summary>
        /// <param name="photoId">The photo to update the license for.</param>
        /// <param name="license">The license to apply, or <see cref="LicenseType.AllRightsReserved"/> (0) to remove the current license. Note : as of this writing the <see cref="LicenseType.NoKnownCopyrightRestrictions"/> license (7) is not a valid argument.</param>
        /// <param name="callback">Callback method to call upon return of the response from Flickr.</param>
        public async Task<FlickrResult<NoResponse>> PhotosLicensesSetLicenseAsync(string photoId, LicenseType license)
        {
            CheckRequiresAuthentication();

            Dictionary<string, string> parameters = new Dictionary<string, string>();

            parameters.Add("method", "flickr.photos.licenses.setLicense");
            parameters.Add("photo_id", photoId);
            parameters.Add("license_id", license.ToString("d"));

            return await GetResponseAsync<NoResponse>(parameters);
        }
 public void PhotosLicensesSetLicense(string photoId, LicenseType licenseId)
 {
     var dictionary = new Dictionary<string, string>();
     dictionary.Add("method", "flickr.photos.licenses.setLicense");
     dictionary.Add("photo_id", photoId);
     dictionary.Add("license_id", licenseId.ToString("d"));
     GetResponse<NoResponse>(dictionary);
 }
Exemple #21
0
        internal static LicenseInfo Verify(string signedXml, Action <string, string> messageReporterFunc, Action <string, string> errorDisplayFunc, Action <string, string> noLicenseFoundReporterFunc, DateTime nullDate, string publicKey)
        {
            LicenseInfo licenseInfo;
            SignedXml   signedXml1 = new SignedXml();

            using (RSACryptoServiceProvider rSACryptoServiceProvider = new RSACryptoServiceProvider())
            {
                rSACryptoServiceProvider.FromXmlString(publicKey);
                if (!string.IsNullOrEmpty(signedXml))
                {
                    XmlDocument xmlDocument = new XmlDocument()
                    {
                        PreserveWhitespace = true
                    };
                    xmlDocument.LoadXml(signedXml);
                    XmlNodeList elementsByTagName = xmlDocument.GetElementsByTagName("Signature");
                    signedXml1.LoadXml((XmlElement)elementsByTagName[0]);
                    if (signedXml1.CheckSignature(rSACryptoServiceProvider))
                    {
                        LicenseInfo licenseInfo1 = LicenseInfo.CreateLicenseInfo(xmlDocument.SelectSingleNode(".//LLBLGenProLicense"));
                        switch (licenseInfo1.TypeOfLicense)
                        {
                        case LicenseType.Trial:
                        case LicenseType.Beta:
                        {
                            if (!licenseInfo1.Expires)
                            {
                                if (errorDisplayFunc != null)
                                {
                                    errorDisplayFunc("The license file is invalid", "Invalid license file");
                                }
                                licenseInfo1 = null;
                                goto case LicenseType.Lite;
                            }
                            else
                            {
                                if (!(licenseInfo1.LicenseCreationDateTimeUTC > DateTime.UtcNow) && !(licenseInfo1.ExpirationDateUTC < DateTime.UtcNow.ToUniversalDate()) && !(nullDate > DateTime.UtcNow))
                                {
                                    goto case LicenseType.Lite;
                                }
                                if (messageReporterFunc != null)
                                {
                                    LicenseType typeOfLicense = licenseInfo1.TypeOfLicense;
                                    messageReporterFunc(string.Format("The {0} period has ended as your license has expired.", typeOfLicense.ToString().ToLowerInvariant()), "License expired");
                                }
                                licenseInfo1 = null;
                                goto case LicenseType.Lite;
                            }
                        }

                        case LicenseType.Normal:
                        {
                            DateTime linkerTimeUTC = typeof(Project).Assembly.GetLinkerTimeUTC();
                            if (linkerTimeUTC <= licenseInfo1.SubscriptionEndDateUTC)
                            {
                                goto case LicenseType.Lite;
                            }
                            if (messageReporterFunc != null)
                            {
                                string   str = linkerTimeUTC.ToString("dd-MMM-yyyy");
                                DateTime subscriptionEndDateUTC = licenseInfo1.SubscriptionEndDateUTC;
                                messageReporterFunc(string.Format("Sorry, but this build isn't allowed to be used with your license as it was released after your subscription expired (Build is from {0}, your subscription expired on {1}). Please renew your subscription to use this build and newer builds, or go to the LLBLGen Pro website and download a build released before {1}.", str, subscriptionEndDateUTC.ToString("dd-MMM-yyyy")), "Build is incompatible with expired subscription");
                            }
                            licenseInfo1 = null;
                            goto case LicenseType.Lite;
                        }

                        case LicenseType.Lite:
                        {
                            licenseInfo = licenseInfo1;
                            break;
                        }

                        default:
                        {
                            goto case LicenseType.Lite;
                        }
                        }
                    }
                    else
                    {
                        if (errorDisplayFunc != null)
                        {
                            errorDisplayFunc("The license file signature is invalid", "Invalid license file");
                        }
                        licenseInfo = null;
                    }
                }
                else
                {
                    if (noLicenseFoundReporterFunc != null)
                    {
                        noLicenseFoundReporterFunc("No license files found. Please install your LLBLGen Pro license file in the application's folder and restart the application. If you downloaded the trial version, be sure to request a trial license. You can request one on the LLBLGen Pro website or by clicking the 'Request Trial License' button below.", "No license file found");
                    }
                    licenseInfo = null;
                }
            }
            return(licenseInfo);
        }
        /// <summary>
        /// Sets the license for a photo.
        /// </summary>
        /// <param name="photoId">The photo to update the license for.</param>
        /// <param name="license">The license to apply, or <see cref="LicenseType.AllRightsReserved"/> (0) to remove the current license. Note : as of this writing the <see cref="LicenseType.NoKnownCopyrightRestrictions"/> license (7) is not a valid argument.</param>
        public void PhotosLicensesSetLicense(string photoId, LicenseType license)
        {
            CheckRequiresAuthentication();

            Dictionary<string, string> parameters = new Dictionary<string, string>();

            parameters.Add("method", "flickr.photos.licenses.setLicense");
            parameters.Add("photo_id", photoId);
            parameters.Add("license_id", license.ToString("d"));

            GetResponseNoCache<NoResponse>(parameters);
        }
Exemple #23
0
        private void GenerateLicense()
        {
            var privateKeyPath = GetWorkDirFile("privateKey.xml");
            var publicKeyPath  = GetWorkDirFile("publicKey.xml");

            if (!File.Exists(privateKeyPath))
            {
                MessageBox.Show("Please create a license key first");
                return;
            }

            if (string.IsNullOrWhiteSpace(txtName.Text) || string.IsNullOrWhiteSpace(txtComputerKey.Text))
            {
                MessageBox.Show("Some field is missing");
                return;
            }

            var privateKey = File.ReadAllText(privateKeyPath);
            var generator  = new LicenseGenerator(privateKey);

            var dict = new Dictionary <string, string>();

            dict["name"] = txtName.Text;
            dict["key"]  = txtComputerKey.Text;

            LicenseType licenseType  = LicenseType.None;
            var         selectedType = (type.SelectedItem as System.Windows.Controls.ComboBoxItem)?.Tag;

            Enum.TryParse <LicenseType>(selectedType.ToString(), out licenseType);

            var expireDate = DateTime.Now.AddYears(10);

            if (licenseType == LicenseType.None)
            {
                MessageBox.Show("授权类型不能为空");
                return;
            }

            switch (licenseType)
            {
            case LicenseType.None:
                break;

            case LicenseType.Trial:
                expireDate = expireDatePicker.SelectedDate.Value;
                break;

            case LicenseType.Standard:
                break;

            case LicenseType.Personal:
                break;

            case LicenseType.Floating:
                break;

            case LicenseType.Subscription:
                break;

            default:
                break;
            }


            // generate the license
            var license = generator.Generate("W7.License", Guid.NewGuid(), expireDate, dict,
                                             licenseType);

            txtLicense.Text = license;
            var dir = $"{GetWorkDirFile("")}\\{dict["name"]}-{licenseType.ToString()}-{txtComputerKey.Text}-{expireDate.ToString("yyyyMMdd")}\\";

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }
            File.WriteAllText(dir + "license.lic", license);

            File.Copy(publicKeyPath, dir + "publicKey.xml", true);

            System.Diagnostics.Process.Start(dir);

            File.AppendAllText("license.log", $"License to {dict["name"]}, key is {dict["key"]}, Date is {DateTime.Now}");
        }