/// <summary> /// 获取控制项信息 /// </summary> /// <param name="err"></param> /// <param name="licMan"></param> private SmcErr GetControlLicItem(List <ConfigItem> configList) { LoggerEx logEx = new LoggerEx(log); SmcErr smcErr = new SmcErr(); CLicenseManagedAdapter licMan = new CLicenseManagedAdapter(); List <LKItemValue> licItemTypeList = new List <LKItemValue>(); smcErr = Convert2ErrNo(licMan.GetLicenseInfo(ref licItemTypeList)); if (smcErr.IsSuccess()) { licenseInfo.IsMonitorPlatform = false; licenseInfo.IsEltePlatform = false; foreach (LKItemValue item in licItemTypeList) { if (LicItemfType.LicItemMaxChannelNum == item.ItemID) { int licCountNew = Convert.ToInt32(item.ItemValue); if (licCount != licCountNew) { SessionManage.Instance().RemoveAllSession(); logEx.Trace("License have changed! the New Count is:{0}, the Old Count:{1} ", licCountNew.ToString(), licCount.ToString()); licCount = licCountNew; } } if (item.ItemID.ToString() == "LicItemMonitorEnable" && item.ItemValue.ToString() == "1") { licenseInfo.IsMonitorPlatform = true; } if (item.ItemID.ToString() == "LicItemELTEEnable" && item.ItemValue.ToString() == "1") { licenseInfo.IsEltePlatform = true; } logEx.Info("GetControlLicItem item:{0},{1}", item.ItemID, item.ItemValue); } } else { logEx.Warn("GetControlLicItem errNo:{0}", smcErr.ErrNo); } return(smcErr); }
/// <summary> /// 读取license信息 /// </summary> /// <param name="licMsg"></param> /// <returns></returns> public uint ReceiveLicMsg(ref LicMsg licMsg) { CLicenseManagedAdapter licMan = new CLicenseManagedAdapter(); SmcErr smcErr = new SmcErr(); LoggerEx logEx = new LoggerEx(log); if (null == licMsg) { smcErr.ErrNo = SmcErr.SMC_INVALID_PARAM; logEx.Warn("Perform ReceiveLicMsg's licMsg is null msg!"); return(smcErr.ErrNo); } else { logEx.Trace("ReceiveLicMsg licMsg msg: {0}", licMsg.GetType()); } if (LicCallBackType.LicLKReadRevokeTicket == licMsg.MsgID) { LicMsg license = new LicMsg(); if (LicPersisFileType.LicPersistentSafemem == licMsg.FileType) { if (File.Exists(strPathPersistent)) { license.MsgParam = File.ReadAllBytes(strPathPersistent); logEx.Info("LoadLicPersistentSafemem is successful!"); } else { //string str = "0x"; //byte[] b = Encoding.Default.GetBytes(str); byte[] b = new byte[0]; license = new LicMsg(); license.MsgParam = b; } } else if (LicPersisFileType.LicPersistentInfo == licMsg.FileType) { if (this.licenseFileOperateLock.TryEnterWriteLock(CgwConst.ENTER_LOCK_WAIT_TIME)) { try { try { if (File.Exists(strPathLic)) { license.MsgParam = File.ReadAllBytes(strPathLic); logEx.Info("LoadLicenseInfo is successful!"); } else { byte[] b = new byte[0]; license = new LicMsg(); license.MsgParam = b; } } catch (System.Exception ex) { logEx.Error(ex, "LicLKReadRevokeTicket faild!"); //记录系统加载License失败 SmcErr recordErr = new SmcErr(SmcErr.LICENSE_LOAD_ERR); recordErr.ErrorInfoParam = new ErrorInfo(); recordErr.ErrorInfoParam.AddSmcErrInfo(smcErr); logEx.Error(recordErr); } } finally { this.licenseFileOperateLock.ExitWriteLock(); } } } licMsg = license; } //License变更 else if (LicCallBackType.LicLKStateChange == licMsg.MsgID) { GetControlLicItem(null); } //保存Licsense失效信息 else if (LicCallBackType.LicLKWriteRevokeTicket == licMsg.MsgID) { File.WriteAllBytes(strPathPersistent, licMsg.MsgParam); } return(smcErr.ErrNo); }