Example #1
0
        public async Task <IHttpActionResult> GetLicense()
        {
            try
            {
                var userIds = await _applicationUsersService.GetAllUserIds();

                if (userIds == null)
                {
                    userIds = Array.Empty <int>();
                }

                XmlDocument doc = new XmlDocument();
                doc.Load("Files/PublicKey.xml");
                ProductLicenseManager.Initialize(_traceManager, doc.OuterXml);
                var license = ProductLicenseManager.Current.LoadWebLicense(ActivationConstants.WebProductName);

                // Clean Userpool
                if (license != null && license.UsersPool != null && license.UsersPool.Any(u => !userIds.Contains(u)))
                {
                    license.UsersPool.RemoveWhere(u => !userIds.Contains(u));
                    ProductLicenseManager.Current.SaveWebLicense(ActivationConstants.WebProductName, license);
                }

                return(Ok(license));
            }
            catch (Exception ex)
            {
                _traceManager.TraceError(ex, ex.Message);
                return(InternalServerError(ex));
            }
        }
Example #2
0
        public IHttpActionResult GetMachineHash()
        {
            try
            {
                XmlDocument doc = new XmlDocument();
                doc.Load("Files/PublicKey.xml");
                ProductLicenseManager.Initialize(_traceManager, doc.OuterXml);
                var hash = ProductLicenseManager.Current.GetMachineHash();

                return(Ok(hash));
            }
            catch (Exception ex)
            {
                _traceManager.TraceError(ex, ex.Message);
                return(InternalServerError(ex));
            }
        }
Example #3
0
        public IHttpActionResult SetLicense([DynamicBody] dynamic param)
        {
            try
            {
                WebProductLicense productLicense = (WebProductLicense)param.productLicense;

                XmlDocument doc = new XmlDocument();
                doc.Load("Files/PublicKey.xml");
                ProductLicenseManager.Initialize(_traceManager, doc.OuterXml);
                ProductLicenseManager.Current.SaveWebLicense(ActivationConstants.WebProductName, productLicense);

                return(Ok());
            }
            catch (Exception ex)
            {
                _traceManager.TraceError(ex, ex.Message);
                return(InternalServerError(ex));
            }
        }
Example #4
0
        public IHttpActionResult ActivateLicense([DynamicBody] dynamic param)
        {
            try
            {
                ProductLicenseInfo productLicenseInfo = (ProductLicenseInfo)param.productLicenseInfo;

                XmlDocument doc = new XmlDocument();
                doc.Load("Files/PublicKey.xml");
                ProductLicenseManager.Initialize(_traceManager, doc.OuterXml);
                var license = ProductLicenseManager.Current.ActivateWebProduct(productLicenseInfo);

                return(Ok(license));
            }
            catch (Exception ex)
            {
                _traceManager.TraceError(ex, ex.Message);
                return(InternalServerError(ex));
            }
        }