Exemplo n.º 1
0
        private Models.Entity.License GenerateNewLicense(int licensePeriod)
        {
            Assembly assembly  = Assembly.GetExecutingAssembly();
            var      attribute = (GuidAttribute)assembly.GetCustomAttributes(typeof(GuidAttribute), true)[0];

            string appGuid            = attribute.Value;
            string serialNumber       = FingerPrint.GetMAC().Replace(':', '-');
            string summary            = FingerPrint.GetSummary() + "\nMAC\t" + serialNumber + "\nGUID\t" + appGuid;
            int    numberOfLicenses   = Licenses.Count;
            string authorizationKey   = FingerPrint.GetHash(appGuid + numberOfLicenses.ToString());
            string registrationNumber = FingerPrint.GetHash(serialNumber + authorizationKey + licensePeriod.ToString());


            Models.Entity.License NewLicense = new Models.Entity.License()
            {
                ID                 = Guid.NewGuid(),
                Count              = ++numberOfLicenses,
                SerialNumber       = serialNumber,
                AuthorizationKey   = authorizationKey,
                RegistrationNumber = registrationNumber,
                Period             = licensePeriod,
                Start              = DateTime.Today,
                End                = DateTime.Today.Add(new TimeSpan(licensePeriod, 0, 0, 0)),
                LastSession        = DateTime.Now,
                Summary            = summary
            };

            BackgroundWorker worker = new BackgroundWorker();

            worker.DoWork += (sender, e) =>
            {
                e.Result = DatabaseService.AddOrUpdate(e.Argument as Models.Entity.License);
            };
            worker.RunWorkerCompleted += (sender, e) =>
            {
                int dd = (int)e.Result;
                DataDB.RefreshLicenses();
            };
            worker.RunWorkerAsync(NewLicense);


            string LicenseDir   = @"\PHRDR\License";
            string documentPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

            if (!Directory.Exists(documentPath + LicenseDir))
            {
                Directory.CreateDirectory(documentPath + LicenseDir);
            }

            string licenseFile = String.Format(@"{0}\License.lph", documentPath + LicenseDir);

            File.Create(licenseFile).Close();
            string toFile = "Serial Number:\n\t" + serialNumber + "\n" +
                            "Authorization Key:\n\t" + authorizationKey + "\n" +
                            "Registration Number:\n\t" + registrationNumber + "\n" +
                            "Period:\n\t" + licensePeriod + "\n" +
                            "Start:\n\t" + DateTime.Today + "\n" +
                            "Last Session:\n\t" + DateTime.Now + "\n" +
                            "End:\n\t" + DateTime.Today.Add(new TimeSpan(licensePeriod, 0, 0, 0)) + "\n\n" +
                            "Summary PC:\n" + summary;

            File.WriteAllText(licenseFile, toFile);
            return(NewLicense);
        }
Exemplo n.º 2
0
 public static int AddUpdateSessions()
 {
     return(DatabaseService.AddOrUpdate(new List <Session>(TransferDB.SessionsList)));
 }
Exemplo n.º 3
0
 public static int AddUpdateARFCN()
 {
     return(DatabaseService.AddOrUpdate(new List <ARFCN>(TransferDB.ARFCNs)));
 }
Exemplo n.º 4
0
 public static int AddUpdateCalls()
 {
     return(DatabaseService.AddOrUpdate(new List <Call>(TransferDB.Calls)));
 }
Exemplo n.º 5
0
 public static int AddUpdateSMSs()
 {
     return(DatabaseService.AddOrUpdate(new List <SMS>(TransferDB.SMSs)));
 }
Exemplo n.º 6
0
 public static void DeleteSelectedSession(Session session)
 {
     DatabaseService.Delete <Session>(session);
 }