/// <summary>
        /// Revoke License.
        /// Documentation https://developers.google.com/licensing/v1/reference/licenseAssignments/delete
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated Licensing service.</param>
        /// <param name="productId">Name for product</param>
        /// <param name="skuId">Name for sku</param>
        /// <param name="userId">email id or unique Id of the user</param>
        public static void Delete(LicensingService service, string productId, string skuId, string userId)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (productId == null)
                {
                    throw new ArgumentNullException(productId);
                }
                if (skuId == null)
                {
                    throw new ArgumentNullException(skuId);
                }
                if (userId == null)
                {
                    throw new ArgumentNullException(userId);
                }

                // Make the request.
                service.LicenseAssignments.Delete(productId, skuId, userId).Execute();
            }
            catch (Exception ex)
            {
                throw new Exception("Request LicenseAssignments.Delete failed.", ex);
            }
        }
        /// <summary>
        /// List license assignments for given product of the customer.
        /// Documentation https://developers.google.com/licensing/v1/reference/licenseAssignments/listForProduct
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated Licensing service.</param>
        /// <param name="productId">Name for product</param>
        /// <param name="customerId">CustomerId represents the customer for whom licenseassignments are queried</param>
        /// <param name="optional">Optional paramaters.</param>
        /// <returns>LicenseAssignmentListResponse</returns>
        public static LicenseAssignmentList ListForProduct(LicensingService service, string productId, string customerId, LicenseAssignmentsListForProductOptionalParms optional = null)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (productId == null)
                {
                    throw new ArgumentNullException(productId);
                }
                if (customerId == null)
                {
                    throw new ArgumentNullException(customerId);
                }

                // Building the initial request.
                var request = service.LicenseAssignments.ListForProduct(productId, customerId);

                // Applying optional parameters to the request.
                request = (LicenseAssignmentsResource.ListForProductRequest)SampleHelpers.ApplyOptionalParms(request, optional);

                // Requesting data.
                return(request.Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request LicenseAssignments.ListForProduct failed.", ex);
            }
        }
        /// <summary>
        /// Assign License.
        /// Documentation https://developers.google.com/licensing/v1/reference/licenseAssignments/update
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated Licensing service.</param>
        /// <param name="productId">Name for product</param>
        /// <param name="skuId">Name for sku for which license would be revoked</param>
        /// <param name="userId">email id or unique Id of the user</param>
        /// <param name="body">A valid Licensing v1 body.</param>
        /// <returns>LicenseAssignmentResponse</returns>
        public static LicenseAssignment Update(LicensingService service, string productId, string skuId, string userId, LicenseAssignment body)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (productId == null)
                {
                    throw new ArgumentNullException(productId);
                }
                if (skuId == null)
                {
                    throw new ArgumentNullException(skuId);
                }
                if (userId == null)
                {
                    throw new ArgumentNullException(userId);
                }

                // Make the request.
                return(service.LicenseAssignments.Update(body, productId, skuId, userId).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request LicenseAssignments.Update failed.", ex);
            }
        }
Пример #4
0
        public void LicenseLookup()
        {
            #region Arrange
            var           orderlookupmsg = _irepo.GetOrderLookupMsg();
            var           orderstore     = _irepo.GetOrderStore();
            var           orderquery     = _irepo.GetOrderLookupQuery();
            var           logininfo      = _irepo.GetLicenseLoginInfo();
            OrderQueryDTO lookupQuery;
            if (orderstore != 1)
            {
                lookupQuery = new OrderQueryDTO
                {
                    OrderSource = OrderSources.DnnMarketplace,
                    Email       = orderquery.Email,
                    InvoiceId   = orderquery.InvoiceId,
                };
            }
            else
            {
                lookupQuery = new OrderQueryDTO
                {
                    OrderSource = OrderSources.CompLicense,
                    Email       = orderquery.Email,
                    LicenseKey  = orderquery.LicenseKey
                };
            }
            #endregion

            //Act
            var service = new LicensingService(logininfo);
            var result  = service.LookupOrders(lookupQuery);

            //Assert
            Assert.AreEqual(OrderLookupResults.OrderNotFound, result);
        }
Пример #5
0
        public async Task AfterDeleteAsync(List <Guid> lstObjectsToValidate, IParams parameters)
        {
            LicenseParams licenseParams = parameters as LicenseParams;

            var service = new LicensingService(LicensingServiceProviderFactory.GetProvider());

            service.AumentEmployeeLicense(licenseParams.LicenseID, licenseParams.LicenseServiceID);
        }
Пример #6
0
        public async Task AfterUnregistered(IEnumerable <Guid> idsToUpdate, Guid identityWorkId, params object[] parameters)
        {
            LicenseParams licenseParams = parameters[0] as LicenseParams;
            var           service       = new LicensingService(LicensingServiceProviderFactory.GetProvider());

            service.AumentEmployeeLicense(licenseParams.LicenseID, licenseParams.LicenseServiceID);
            //Vacío (corte)
        }
Пример #7
0
        public void Register()
        {
            //Arrange
            var reginfo = _irepo.GetRegisterInfo();

            //Act
            var service = new LicensingService();

            //Assert
            Assert.IsTrue(service.Register(reginfo));
        }
Пример #8
0
        public void Login()
        {
            //Arrange
            var logininfo = _irepo.GetLoginInfo();

            //Act
            var service = new LicensingService(logininfo);

            //Assert
            Assert.IsTrue(service.CanLogin());
        }
 private void ServiceInstance(string accountId, string certPath)
 {
     var auth = new ServiceOAuth(accountId, certPath);
     DirectoryService = auth.DirectoryService();
     GroupSettingsService = auth.GroupSettingsService();
     LicensingService = auth.LicensingService();
     ReportsService = auth.ReportsService();
     CalendarService = auth.CalendarService();
     DriveService = auth.DriveService();
     AuditService = auth.AuditService();
     TasksService = auth.TasksService();
 }
Пример #10
0
        public void LoadLicenseOrders()
        {
            //Arrange
            var count     = _irepo.GetLicenseOrderCount();
            var logininfo = _irepo.GetLicenseLoginInfo();

            //Act
            var service = new LicensingService(logininfo);

            //Assert
            Assert.AreEqual(count, service.GetLicenseOrders().Count);
        }
Пример #11
0
            public async Task Should_Get_Cotorria_License_Then_Consume_Employeee_Then_Unconsume_Employee()
            {
                var service         = new LicensingService(LicensingServiceProviderFactory.GetProvider());
                var LoginServiceURL = ConfigManager.GetValue("LoginServiceHost");

                var token = await LicensingServiceCotorraProviderUT.LoginAsync("*****@*****.**", "Xq63zqw@", LoginServiceURL + "api/Auth/LoginUser");

                //Get license info
                var licenseinfo = await service.GetLicensesUserByAppAsync(token, CotorriaAppID);

                Assert.NotEmpty(licenseinfo);
                var license          = licenseinfo.FirstOrDefault();
                var CotorriaApp      = license.Apps.Where(x => x.AppID == CotorriaAppID).FirstOrDefault();
                var licenseServiceID = CotorriaApp.LicenseServiceID;
                // get feature info
                var employeeFeature         = CotorriaApp.Features.FirstOrDefault(x => x.ID == EmployeesFeature);
                var initialEmployeesApplied = employeeFeature.Applied;

                //Act
                await service.ConsumeEmployeeLicense(license.LicenseID, licenseServiceID);

                //Get For Assert
                licenseinfo = await service.GetLicensesUserByAppAsync(token, CotorriaAppID);

                Assert.NotEmpty(licenseinfo);
                license          = licenseinfo.FirstOrDefault();
                CotorriaApp      = license.Apps.Where(x => x.AppID == CotorriaAppID).FirstOrDefault();
                licenseServiceID = CotorriaApp.LicenseServiceID;
                employeeFeature  = CotorriaApp.Features.FirstOrDefault(x => x.ID == EmployeesFeature);
                var actualEmployees = employeeFeature.Applied;

                //Asert
                Assert.Equal(initialEmployeesApplied + 1, actualEmployees);

                //Act Again
                await service.AumentEmployeeLicense(license.LicenseID, licenseServiceID);


                //Get For Assert again
                licenseinfo = await service.GetLicensesUserByAppAsync(token, CotorriaAppID);

                Assert.NotEmpty(licenseinfo);
                license          = licenseinfo.FirstOrDefault();
                CotorriaApp      = license.Apps.Where(x => x.AppID == CotorriaAppID).FirstOrDefault();
                licenseServiceID = CotorriaApp.LicenseServiceID;
                employeeFeature  = CotorriaApp.Features.FirstOrDefault(x => x.ID == EmployeesFeature);
                actualEmployees  = employeeFeature.Applied;

                Assert.Equal(initialEmployeesApplied, actualEmployees);
            }
Пример #12
0
        public PurchaseController()
        {
            Func <StoreDbEntities> createStoreContext = () => new StoreDbEntities(  );
            var sqlRepository = new SqlPurchaseRecordRepository(createStoreContext);

            _purchaseService = new PurchaseService(sqlRepository);

            var sqlCatalogRepository = new SqlCatalogRepository(createStoreContext);

            _catalogService = new CatalogService(sqlCatalogRepository);

            _licensingService = new LicensingService(SoftwarePotentialConfiguration.File.ReadCredentials());

            var sqlOrderItemRepository = new SqlOrderItemRepository(createStoreContext);

            _orderItemService = new OrderItemService(sqlOrderItemRepository);
        }
Пример #13
0
        public LicensingServiceTests()
        {
            _userRepository             = Substitute.For <IUserRepository>();
            _organizationRepository     = Substitute.For <IOrganizationRepository>();
            _organizationUserRepository = Substitute.For <IOrganizationUserRepository>();
            _hostingEnvironment         = Substitute.For <IWebHostEnvironment>();
            _logger         = Substitute.For <ILogger <LicensingService> >();
            _globalSettings = new GlobalSettings();

            _sut = new LicensingService(
                _userRepository,
                _organizationRepository,
                _organizationUserRepository,
                _hostingEnvironment,
                _logger,
                _globalSettings
                );
        }
Пример #14
0
        public async Task AfterCreate(List <Employee> lstObjectsToValidate, IParams parameters)
        {
            var overdraftManager = new OverdraftManager();

            overdraftManager.CreateByEmployeesAsync(lstObjectsToValidate).Wait();
            LicenseParams licenseParams = parameters as LicenseParams;

            //Calculation async fire and forget
            IEnumerable <Guid> employeeIds = lstObjectsToValidate.Select(p => p.ID);
            var company    = lstObjectsToValidate.FirstOrDefault().company;
            var instanceID = lstObjectsToValidate.FirstOrDefault().InstanceID;
            var userId     = lstObjectsToValidate.FirstOrDefault().IdentityID;

            new OverdraftCalculationManager().CalculationFireAndForgetByEmployeesAsync(employeeIds, company, instanceID, userId);
            //Updatefeature
            var service = new LicensingService(LicensingServiceProviderFactory.GetProvider());
            await service.ConsumeEmployeeLicense(licenseParams.LicenseID, licenseParams.LicenseServiceID);
        }
Пример #15
0
        public void LicenseActivation()
        {
            #region Arrange
            var licOrderId     = _irepo.GetLicenseOrderId();
            var logininfo      = _irepo.GetLicenseLoginInfo();
            var activationInfo = new ActivationInfoDTO
            {
                LicenseOrderId = licOrderId,
                MachineName    = LicenseUtils.GetMachineName(),
                MetaPath       = LicenseUtils.GetInstanceMetaPath(),
                Host           = LicenseUtils.GetHostName(),
            };
            #endregion

            //Act
            var data    = LicenseUtils.SerializeActivationInfo(activationInfo);
            var service = new LicensingService(logininfo);

            //Assert
            Assert.AreNotEqual(string.Empty, service.ActivateLicense(data));
        }
 private void SimpleInstance(string clientId, string clientSecret)
 {
     var auth = new SimpleOAuth(clientId, clientSecret);
     DirectoryService = auth.DirectoryService();
     GroupSettingsService = auth.GroupSettingsService();
     LicensingService = auth.LicensingService();
 }