Exemplo n.º 1
0
        public static void InitialLicense(string config, string lic)
        {
            dynamic ini;

            ini = new DynamicIniConfig(config);
            QcNetLicense   newnetlicense;
            QcLocalLicense newlocallicense;
            QcTimeLicense  newtimelicense;

            switch (((string)ini.License.IsLocal).ToUpper())
            {
            case "TRUE":
                LocalModel      = true;
                newlocallicense = new QcLocalLicense();
                newlocallicense.SetLicense(QcLicense.ReadLicFile(lic));
                License = newlocallicense;
                break;

            case "FALSE":
                LocalModel    = false;
                newnetlicense = new QcNetLicense();
                newnetlicense.SetServer(ini.MsgServer.Ip, Convert.ToUInt16(ini.MsgServer.Port));
                License = newnetlicense;
                break;

            case "ONLY_IGCES_SUPERTIME":    //HAHA 超级模式
                newtimelicense = new QcTimeLicense(DateTime.Parse("9999-01-01"));
                License        = newtimelicense;
                break;

            case "TRIAL":    //试用模式
                QcLicense timelic = new QcLicense(QcLicense.ReadLicFile(lic), false);
                XDocument doc     = timelic.LicDoc;
                LocalModel = false;
                if (doc.Root.Element("单位名称").Value == "TRIAL")
                {
                    if (DateTime.Now.Subtract(DateTime.Parse(doc.Root.Element("EndDate").Value)).Days <= 0)
                    {
                        newlocallicense = new QcLocalLicense();
                        newlocallicense.SetLicense(QcLicense.ReadLicFile(lic), false);
                        License = newlocallicense;
                    }
                    else
                    {
                        QcLog.LogString("初始授权失败,试用模式下,试用时间已经超出授权时间,请改用其他模式或重新申请授权");
                    }
                }
                else
                {
                    QcLog.LogString("初始授权失败,试用模式下,lic文件不是试用授权文件,请改用其他模式或重新申请授权");
                }

                break;
            }
            if (License == null)
            {
                License = new QcNullLicense();
                QcLog.LogString("初始授权失败,请检查授权模式是否正确");
            }
        }
Exemplo n.º 2
0
 public void SetLicense(QcLicense lic)
 {
     this.License = lic;
 }
Exemplo n.º 3
0
 public void SetLicense(string lic, bool chksn = true)
 {
     license = new QcLicense(lic, chksn);
 }