Exemple #1
0
        public async Task <IActionResult> CreateLicense(int licenseTypeId, int institutionId)
        {
            var userId  = _userContext.GetUserId();
            var license = await _licenseService.CreateLicense(licenseTypeId, userId, institutionId);

            return(Ok(license));
        }
Exemple #2
0
        public void HandleEvent(OrderPaidEvent eventMessage)
        {
            IList <LicenseKey> licenses = new List <LicenseKey>();

            foreach (var item in eventMessage.Order.OrderItems)
            {
                var license = _licenseService.CreateLicense(item);
                if (!String.IsNullOrEmpty(license.License))
                {
                    licenses.Add(license);
                }
            }

            if (licenses.Count > 0)
            {
                //create info table
                StringBuilder sb = new StringBuilder();
                sb.Append("<table cellspacing=\"5\"><tr><th>Type</th><th>Product</th><th>Url</th><th>License</th></tr>");
                foreach (var license in licenses)
                {
                    sb.Append(string.Format("<tr><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td></tr>", license.LicenseType, license.ProductName, license.Url, license.License));
                }
                sb.Append("</table>");
                string licenseTable = sb.ToString();

                sb = new StringBuilder();
                sb.Append("License Keys: " + Environment.NewLine);
                foreach (var license in licenses)
                {
                    sb.Append(string.Format("{0} - {1}: {2}{3}", license.ProductName, license.Url, license.License, Environment.NewLine));
                }
                string licensePlainText = sb.ToString();

                //add to order notes
                eventMessage.Order.OrderNotes.Add(new OrderNote()
                {
                    CreatedOnUtc      = DateTime.UtcNow,
                    DisplayToCustomer = true,
                    Note    = licensePlainText,
                    OrderId = eventMessage.Order.Id,
                });
                _orderService.UpdateOrder(eventMessage.Order);

                //send email
                var emailId = _licenseService.SendCustomerNotice(eventMessage.Order, licenseTable, _workContext.WorkingLanguage.Id);
                eventMessage.Order.OrderNotes.Add(new OrderNote()
                {
                    CreatedOnUtc      = DateTime.UtcNow,
                    DisplayToCustomer = false,
                    Note    = "\"License Key\" email (to customer) has been queued. Queued email identifier: " + emailId.ToString() + ".",
                    OrderId = eventMessage.Order.Id
                });
                _orderService.UpdateOrder(eventMessage.Order);
            }
        }
Exemple #3
0
        public async Task <IActionResult> CreateTodo([FromBody] LicenseRequest newTodo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            await using var stream = new FileStream(newTodo.filePath, FileMode.Open, FileAccess.Read);
            using var reader       = new StreamReader(stream);
            string xmlString = await reader.ReadToEndAsync();

            bool isCreated = await _licenseService.CreateLicense(xmlString, newTodo.Name);

            if (isCreated == false)
            {
                return(BadRequest());
            }

            return(Ok());
        }
        public ActionResult CreateLicense(ConfigurationModel model)
        {
            if (String.IsNullOrEmpty(model.ProductKey) || model.ProductKey.Length < 16)
            {
                ErrorNotification(_localizationService.GetResource("Nop.Plugin.Misc.Licenses.Settings.ProductKey.Hint"));
                return(Configure());
            }

            try
            {
                var createKey = _licenseService.CreateLicense((LicenseType)model.LicenseType, model.Url, model.ProductKey);
                SuccessNotification(createKey);
                return(Configure());
            }
            catch (Exception ex)
            {
                ErrorNotification(ex.Message);
                return(Configure());
            }
        }