private DeviceLicense ValidateLicense(bool retry) { DeviceLicense device = null; Program.Log.Write("==== Validate License Begin ===="); if (_name == GWLicenseHelper.LightMWLOutDeviceName) { device = GWLicenseHelper.LightMWLOutDeviceLicense; Program.Log.Write("Find Light MWL Outbound Interface License."); } else { GWLicenseAgent agent = new GWLicenseAgent(retry); GWLicense license = agent.LoginGetLicenseLogout(Program.Log); if (license == null) { goto ExitValidation; } device = license.FindDevice(_name, _type, _direction); if (device == null) { Program.Log.Write(LogType.Warning, "Cannot find license information for this device."); goto ExitValidation; } if (device.MaxInterfaceCount == 0) { device = null; Program.Log.Write(LogType.Warning, "License of this device was disabled. "); goto ExitValidation; } if (device.IsExpired(license.Header.CreateDate)) { device = null; Program.Log.Write(LogType.Warning, "License of this device was expired. License create date: " + license.Header.CreateDate.ToShortDateString()); goto ExitValidation; } } ExitValidation: Program.Log.Write("==== Validate License End ===="); if (device == null) { Program.Log.Write(LogType.Warning, "Validate license failed, stop NT service."); _service.Stop(); } return(device); }
private bool CheckLicense(InterfaceType type) { int icount = Program.ConfigMgt.Config.GetInterfaceCount(type);; string strDeviceName; DeviceType dType; DirectionType directType; if (InterfaceType.Receiver == type) { strDeviceName = "HL7_RECEIVER"; dType = DeviceType.HL7; directType = DirectionType.INBOUND; } else { strDeviceName = "HL7_SENDER"; dType = DeviceType.HL7; directType = DirectionType.OUTBOUND; } DeviceLicense lic = Program.License.FindDevice (strDeviceName, dType, directType); if (lic == null) { MessageBoxHelper.ShowInformation("Can not find licence for this type of interface."); return(false); } int maxCount = lic.MaxInterfaceCount; if (maxCount == 0) { MessageBoxHelper.ShowInformation("You licence is disabled"); return(false); } if (lic.IsExpired(Program.License.Header.CreateDate)) { MessageBoxHelper.ShowInformation("You licence is expired"); return(false); } if (icount >= maxCount) { MessageBoxHelper.ShowInformation("You interface number has reached the max count."); return(false); } return(true); }
static void getEncodedLicense(StringBuilder sb, DeviceLicense devicelic, GWLicense gatewaylic) { if (sb == null) { return; } if (devicelic == null || gatewaylic == null) { // There is not license information in the dog for this interface. sb.Append("0000"); //sb.Append("NULL"); } else { // Encoding license information. sb.Append(getString(devicelic.MaxInterfaceCount)); if (devicelic.IsExpired(gatewaylic.Header.CreateDate)) { sb.Append('0'); } else { sb.Append('1'); } string strFeature = getString(devicelic.FeatureCode); if (strFeature == null || strFeature.Length < 2) { sb.Append('0'); } else { sb.Append(strFeature[1]); } } }
private void FillDeviceList(GCDeviceCollection dlist) { this.listViewDevice.Items.Clear(); if (dlist == null) { return; } List <int> deviceIDs = new List <int>(); foreach (GCDevice d in dlist) { deviceIDs.Add(d.DeviceID); } Dictionary <int, int> countList = interfaceMgt.GetInterfaceCount(deviceIDs.ToArray()); foreach (GCDevice o in dlist) { GCDeviceAgent d = o as GCDeviceAgent; if (d == null) { continue; } // don't need to read DeviceDir file DeviceRec dr = d.DeviceRec; ListViewItem i = this.listViewDevice.Items.Add(dr.ID.ToString()); i.SubItems.Add(dr.Name); i.SubItems.Add(DataHelper.GetTypeName(dr.Type)); i.SubItems.Add(dr.Description); i.Tag = d; if (countList != null) { int icount = countList[d.DeviceID]; string str = icount.ToString(); //DeviceLicenseLevel level = Program.License.FindLicenseLevel // (dr.Name, DataHelper.GetType(dr.Type), DataHelper.GetDirection(dr.Direction)); DeviceLicense lic = Program.License.FindDevice (dr.Name, DataHelper.GetType(dr.Type), DataHelper.GetDirection(dr.Direction)); string strMax = ""; if (lic != null) { int maxCount = lic.MaxInterfaceCount; if (maxCount == 0) { strMax = " (Disable)"; i.ForeColor = Color.Gray; i.Tag = null; } else { if (lic.IsExpired(Program.License.Header.CreateDate)) { strMax = " (Expired)"; i.ForeColor = Color.Gray; i.Tag = null; } else { if (maxCount == DeviceLicense.InfiniteInterfaceCount) { strMax = " (Max: infinte)"; } else { strMax = " (Max: " + maxCount.ToString() + ")"; if (icount >= maxCount) { i.ForeColor = Color.Gray; i.Tag = null; } } } } } else { strMax = " (Unknown)"; //US28109-TA93905 #region //暂时去掉加接口时的权限验证 //i.ForeColor = Color.Gray; //i.Tag = null; #endregion } i.SubItems.Add(str + strMax); } else { i.ForeColor = Color.Gray; i.Tag = null; } } }