public object GetLicenseInfo()
        {
            var sn  = new SerialNumber();
            var mid = sn.MachineId;

            if (File.Exists(_licensePath))
            {
                string lic = File.ReadAllText(_licensePath);
                sn           = SerialNumber.DeSerialize(lic.Substring(8), Global.Config.InstallTime);
                sn.MachineId = mid;
            }

            string type = null;

            if (sn.License == LicenseType.Demo)
            {
                type = "Trial";
            }
            else if (sn.License == LicenseType.Professional)
            {
                type = "Professional";
            }

            List <object> array = new List <object>();

            array.Add(new { name = "Version", value = "2.0.0" });
            array.Add(new { name = "LicenseType", value = type });
            array.Add(new { name = "MachineId", value = sn.MachineId });
            array.Add(new { name = "CreateTime", value = sn.CreateTime > DateTime.MinValue ? sn.CreateTime.ToLongDateString() : null });
            array.Add(new { name = "ExpireTime", value = sn.ExpireTime > DateTime.MinValue ? sn.ExpireTime.ToLongDateString() : null });
            array.Add(new { name = "IsValid", value = sn.IsValid() });
            array.Add(new { name = "Website", value = "<a href='http://www.ultragis.com' target='_blank'>http://www.ultragis.com</a>" });
            return(new { total = array.Count, rows = array.ToArray() });
        }
示例#2
0
        private void UpdateLicenseInfo(object state)
        {
            try
            {
                Global.Config.SerialKey  = null;
                Global.Config.LicenseKey = null;

                string path = Path.Combine(Path.GetDirectoryName(Application.StartupPath), "license.sn");
                if (File.Exists(path))
                {
                    var config = _storage.GetConfigurations();
                    bfbd.UltraRecord.Global.Config.SetConfigurations(config);

                    TraceLogger.Instance.WriteLineVerbos("License file exists.");
                    string lic = File.ReadAllText(path);
                    var    sn  = SerialNumber.DeSerialize(lic.Substring(8), Global.Config.InstallTime);
                    TraceLogger.Instance.WriteLineVerbos(string.Format("SN: {0}: {1}, {2}", sn.License, sn.CreateTime, sn.ExpireTime));
                    if (sn.IsValid())
                    {
                        TraceLogger.Instance.WriteLineVerbos("License file valid: " + lic.Length);
                        Global.Config.SerialKey  = sn.MachineId;
                        Global.Config.LicenseKey = lic.Substring(8);
                    }
                }
            }
            catch (Exception ex) { TraceLogger.Instance.WriteException(ex); throw; }
        }
示例#3
0
        public object GetLicenseInfo()
        {
            string lic = Database.Invoke(db => db.GetConfiguration("LicenseKey"));
            var    sn  = new SerialNumber();

            if (!string.IsNullOrEmpty(lic))
            {
                Call.Execute(() =>
                {
                    sn = SerialNumber.DeSerialize(lic.Substring(8), "Monkey", Global.Config.InstallTime);
                });
            }

            List <object> array = new List <object>();

            array.Add(new { name = "Version", value = "2.0.0" });
            array.Add(new { name = "LicenseType", value = sn.LicenseType.ToString() });
            array.Add(new { name = "MachineId", value = sn.MachineId });
            array.Add(new { name = "CreateTime", value = sn.CreateTime > DateTime.MinValue ? sn.CreateTime.ToLongDateString() : null });
            array.Add(new { name = "ExpireTime", value = sn.ExpireTime > DateTime.MinValue ? sn.ExpireTime.ToLongDateString() : null });
            array.Add(new { name = "IsValid", value = sn.IsValid() });
            array.Add(new { name = "Website", value = "<a href='http://www.ultragis.com' target='_blank'>http://www.ultragis.com</a>" });
            array.Add(new { name = "Support", value = "<a href='mailto:[email protected]' target='_blank'>[email protected]</a>" });
            return(new { total = array.Count, rows = array.ToArray() });
        }
 public bool RegisterLicense(string lic)
 {
     try
     {
         lic = lic.Replace('*', '+').Replace('-', '/').Replace('_', '=');
         var sn = SerialNumber.DeSerialize(lic.Substring(8), Global.Config.InstallTime);
         if (sn.IsValid())
         {
             File.WriteAllText(_licensePath, lic);
             bfbd.Common.Task.PeriodTask.PostMessage("License");
             bfbd.Common.Task.PeriodTask.PostMessage("Configuration");
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex) { TraceLogger.Instance.WriteException(ex); return(false); }
 }
示例#5
0
 public bool RegisterLicense(string lic)
 {
     try
     {
         lic = lic.Replace('*', '+').Replace('-', '/').Replace('_', '=');
         var sn = SerialNumber.DeSerialize(lic.Substring(8), "Monkey", Global.Config.InstallTime);
         if (sn.IsValid())
         {
             Database.Invoke(db => db.SetConfiguration("LicenseKey", lic));
             bfbd.Common.Tasks.PeriodTask.PostMessage("License");
             bfbd.Common.Tasks.PeriodTask.PostMessage("Configuration");
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex) { TraceLog.WriteException(ex); return(false); }
 }