Esempio n. 1
0
        public override License GetLicense(LicenseContext context, Type type, object instance, bool allowExceptions)
        {
            LicenseResult ret = WebLisenceUtils.Check(Url, LocalInformation.HardwareId, type.GUID.ToString());

            return(new WebLicense(type, ret));

            /*
             * if (context.UsageMode == LicenseUsageMode.Runtime || context.UsageMode == LicenseUsageMode.Designtime)
             * {
             *
             *
             *  LicenseResult ret = WebLisenceUtils.Check(Url,LocalInformation.HardwareId, type.GUID.ToString());
             *
             *  if (ret.Result.IsOK && ret.Data.state == LicenseState.Ok)
             *  {
             *      return new WebLicense(type,ret);
             *  }
             *  else
             *  {
             *      if (ret.Result.IsOK)
             *      {
             *          if (ret.Data == null)
             *          {
             *              //throw new Exception("fatal error, illegal response format");
             *              MessageBox.Show("Fatal error, illegal response format", "License error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             *          }
             *          if (ret.Data.state == LicenseState.Expired)
             *          {
             *              //throw new Exception("license expired");
             *              MessageBox.Show("License expired", "License error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             *          }
             *          if (ret.Data.state == LicenseState.NotRegisted)
             *          {
             *              //throw new Exception("custom not registed");
             *              MessageBox.Show("Custom has not registed", "License error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             *          }
             *      }
             *      else
             *      {
             *          //throw new Exception(ret.WebResult.Error);
             *          MessageBox.Show(ret.Result.Message, "License error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             *      }
             *
             *      return null;
             *  }
             *
             * }
             */
        }
Esempio n. 2
0
 public static LicenseResult Check(string url, string hardwareId, string guid)
 {
     try
     {
         //const string Url = "http://www.netkidxp.cn:8000/checkLisence/";
         var dic = new SortedDictionary <string, string>
         {
             { "hardware_id", hardwareId },
             { "guid", guid },
         };
         var           jsonParam   = JsonConvert.SerializeObject(dic);
         string        responseStr = Post(url, jsonParam);
         ResponseData  response    = JsonConvert.DeserializeObject <ResponseData>(responseStr);
         LicenseResult result      = new LicenseResult(ResponseResult.SUCCESS, response);
         return(result);
     }
     catch (Exception exp)
     {
         ResponseResult r = new ResponseResult(false, exp.Message);
         return(new LicenseResult(r, null));
     }
 }
Esempio n. 3
0
 public static LicenseResult Regist(string url, string hardwareId, string componentName, string guid, int dayCount)
 {
     try
     {
         //const string Url = "http://www.netkidxp.cn:8000/registLisence";
         var dic = new SortedDictionary <string, string>
         {
             { "hardware_id", hardwareId },
             { "guid", guid },
             { "component_name", componentName },
             { "day_count", dayCount.ToString() },
         };
         var           jsonParam   = JsonConvert.SerializeObject(dic);
         string        responseStr = Post(url, jsonParam);
         ResponseData  response    = JsonConvert.DeserializeObject <ResponseData>(responseStr);
         LicenseResult result      = new LicenseResult(ResponseResult.SUCCESS, response);
         return(result);
     }
     catch (Exception exp)
     {
         ResponseResult r = new ResponseResult(false, exp.Message);
         return(new LicenseResult(r, null));
     }
 }
Esempio n. 4
0
 public WebLicense(Type type, LicenseResult licenseResult) : this(type)
 {
     this.LicenseResult = licenseResult ?? throw new NullReferenceException();
 }