Beispiel #1
0
        public ResponseLicenseStatusModel Check(string appName, MachineIdsModel machineUid, byte[] publicKey)
        {
            var cloudaddress = new AppConfiguration().Get().CloudAddress;

            if (string.IsNullOrEmpty(cloudaddress))
            {
                return(null);
            }
            if (cloudaddress.Contains("localhost"))
            {
                return(null);
            }
            if (!cloudaddress.EndsWith("/"))
            {
                cloudaddress = cloudaddress + "/";
            }
            var pk   = Encoding.ASCII.GetString(publicKey);
            var dict = new Dictionary <string, string> {
                { "AppName", appName },
                { "PartNumber", machineUid.PartNumber },
                { "SerialNumber", machineUid.SerialNumber },
                { "Uid", machineUid.MachineUid },
                { "PublicKey", pk }
            };
            var status = _api.Post <ResponseLicenseStatusModel>($"{cloudaddress}license/check", dict);

            return(status);
        }
Beispiel #2
0
 private static MachineIdsModel GetMachineId()
 {
     if (File.Exists(IdPath))
     {
         var checkFile = File.ReadAllText(IdPath);
         if (checkFile == "000000-000000-0000-0000")
         {
             File.Delete(IdPath);
         }
         else
         {
             try {
                 var x = JsonConvert.DeserializeObject <MachineIdsModel>(checkFile);
                 return(x);
             }
             catch (Exception) {
                 File.Delete(IdPath);
             }
         }
     }
     else
     {
         var machineUuid = new MachineIdsModel();
         var json        = JsonConvert.SerializeObject(machineUuid, Formatting.Indented);
         FileWithAcl.WriteAllText(IdPath, json, "644", "root", "wheel");
         return(machineUuid);
     }
     return(new MachineIdsModel());
 }
Beispiel #3
0
        public void Download(string appName, MachineIdsModel machineUid, byte[] publicKey)
        {
            if (File.Exists(_licensePath))
            {
                return;
            }
            var cloudaddress = new AppConfiguration().Get().CloudAddress;

            if (string.IsNullOrEmpty(cloudaddress))
            {
                return;
            }
            if (cloudaddress.Contains("localhost"))
            {
                return;
            }
            if (!cloudaddress.EndsWith("/"))
            {
                cloudaddress = cloudaddress + "/";
            }
            var pk   = Encoding.ASCII.GetString(publicKey);
            var dict = new Dictionary <string, string> {
                { "AppName", appName },
                { "PartNumber", machineUid.PartNumber },
                { "SerialNumber", machineUid.SerialNumber },
                { "Uid", machineUid.MachineUid },
                { "PublicKey", pk }
            };
            var lic = _api.Post <string>($"{cloudaddress}license/create", dict);

            if (lic != null)
            {
                FileWithAcl.WriteAllText(_licensePath, lic, "644", "root", "wheel");
            }
        }