Example #1
0
        public void ImportLicence(Token token, string goodLicenceKey)
        {
            var securityInfo = SecurityManager.EnsureAuthentication(token);
            var service      = new LicenceService(Session, securityInfo, Configuration);

            service.ImportLicence(goodLicenceKey);
        }
 public ActivationsController(MyContext context
                              , HtmlService htmlService
                              , IOptions <EmailSettings> emailSettings
                              , EmailService emailService
                              , LicenceService licenceService
                              ) : base(context)
 {
     _emailService   = emailService;
     _htmlService    = htmlService;
     _emailSettings  = emailSettings.Value;
     _licenceService = licenceService;
 }
Example #3
0
        public void CreateLicenseFile(LicenceService service, string fileName)

        {
            var ms = new MemoryStream();

            new XmlSerializer(typeof(LicenceService)).Serialize(ms, service);



            // Create a new CspParameters object to specify

            // a key container.



            // Create a new RSA signing key and save it in the container.

            RSACryptoServiceProvider rsaKey = new RSACryptoServiceProvider();

            rsaKey.FromXmlString(PrivateKey);



            // Create a new XML document.

            XmlDocument xmlDoc = new XmlDocument();



            // Load an XML file into the XmlDocument object.

            xmlDoc.PreserveWhitespace = true;

            ms.Seek(0, SeekOrigin.Begin);

            xmlDoc.Load(ms);



            // Sign the XML document.

            SignXml(xmlDoc, rsaKey);



            // Save the document.

            xmlDoc.Save(fileName);
        }
Example #4
0
        static void Main(string[] args)
        {
            if (args.Any(a => a == "--generate"))
            {
                GenerateNewKeyPair();
            }

            var service = new LicenceService()
            {
                ValidUntil = DateTime.Now.AddDays(7)
            };

            var fileName = string.Join("", DateTime.Now.ToString().Where(c => char.IsDigit(c)));

            new LicenceGenerator().CreateLicenseFile(service, fileName + ".s_licence");
        }
Example #5
0
        public FormMain(AppSettingsService appSettingsService, MemoStorageService memoStorageService, PasswordStorage passwordStorage, ILifetimeScope scope)
        {
            if (DesignMode)
            {
                return;
            }

            _appSettingsService = appSettingsService;
            _memoStorageService = memoStorageService;
            _passwordStorage    = passwordStorage;
            _scope = scope;

            _applicationState      = new ApplicationState();
            _tabPageDataCollection = TabPageDataCollection.CreateNewPageDataCollection(_appSettingsService.Settings.DefaultEmptyTabPages);
            _licenseService        = LicenceService.Instance;
            InitializeComponent();
        }
        public async Task disableLicenceItem_ValidLicenceID_ReturnsTrue()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase(databaseName: "TestDisableLicenceItem").Options;

            using (var context = new ApplicationDbContext(options))
            {
                var    service = new LicenceService(context);
                string User    = "******";
                await service.addLicenceItemAsync(new LicenceItem
                {
                    User       = User,
                    Key        = "qwerty?",
                    IsDisabled = false
                }, "test");

                var licenceItem = await service.FindLicenceAsync(User);

                Assert.True(await service.disableLicenceItemAsync(licenceItem.Id, "test"));
            }
        }
        public async Task addLicenceItem_ValidLicenceItem_ReturnsTrue()
        {
            //Arrange
            var options = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase(databaseName: "TestAddLicenceItem").Options;

            using (var context = new ApplicationDbContext(options))
            {
                var service = new LicenceService(context);
                //Act
                await service.addLicenceItemAsync(new LicenceItem
                {
                    User = "******",
                    Key  = "qwerty?"
                }, "test");
            };

            //Assert
            using (var context = new ApplicationDbContext(options))
            {
                Assert.Equal(1, await context.LicenceItems.CountAsync());
            }
        }
        public void Can_Import_Station_Data()
        {
            var doc = XDocument.Load(@"C:\Temp\Silo_Station_Data.xml");
            var service = new LicenceService();

            importStations(doc, service);

            foreach(var x in doc.Descendants("spectrum_licence"))
            {
                var licence = new Licence
                {
                    Name = getLicenceName(x.Element("licence_number")),
                    Number = (int)x.Element("licence_number"),
                    OfficeNumber = (int)x.Element("office_number"),
                    CompanyCode = (int)x.Element("company_code"),
                    ReferenceNumber = x.Element("reference_number").Value,
                    ContactName = x.Element("contact_name").Value,
                    BusinessTelephone = (long)x.Element("business_telephone"),
                    Extension = (int?)x.Element("extension") ?? null,
                    Email = x.Element("email_address").Value
                };

                foreach (var stationElem in x.Descendants("stations"))
                {
                    var location = stationElem.Element("location").Value;

                    foreach (var channel in stationElem.Descendants("channels"))
                    {
                        var azimuth = (decimal)channel.Element("tx_ant_azimuth");

                        try
                        {
                            var match = service.Channels
                                .Where(c => c.Station.Location == location)
                                .Where(c => c.TxAntAzimuth == azimuth)
                                .Single();

                            if (licence.Channels == null)
                            {
                                licence.Channels = new List<Channel> { match };
                            }
                            else
                            {
                                licence.Channels.Add(match);
                            }
                        }
                        catch (Exception ex)
                        {
                            throw ex;
                        }
                    }
                }

                service.Add(licence);
            }

            service.SaveChanges();

            var target = service.Licences;
            Assert.AreEqual(5, target.Count());
        }