Ejemplo n.º 1
0
        private bool CheckLicenseDog()
        {
            GWLicenseAgent a = new GWLicenseAgent();

            _license = a.LoginGetLicenseLogout(this, Program.Log);
            return(_license != null);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            if (args == null || args.Length < 1)
            {
                return;
            }

            string header = args[0];

            if (header.Length < 1)
            {
                return;
            }

            GWLicenseAgent agt        = new GWLicenseAgent(true);
            GWLicense      gatewaylic = agt.LoginGetLicenseLogout();

            StringBuilder sb = new StringBuilder();

            sb.Append(header);

            if (gatewaylic == null)
            {
                // Login dog or read license data failed.
                //sb.Append("NOTFOUND");
                sb.Append("00000000");
            }
            else
            {
                DeviceLicense licSender = gatewaylic.FindDevice(
                    DeviceName.HL7_SENDER.ToString(), DeviceType.HL7, DirectionType.OUTBOUND);
                DeviceLicense licReceiver = gatewaylic.FindDevice(
                    DeviceName.HL7_RECEIVER.ToString(), DeviceType.HL7, DirectionType.INBOUND);

                getEncodedLicense(sb, licSender, gatewaylic);
                getEncodedLicense(sb, licReceiver, gatewaylic);
            }

            DataCrypto dc = new DataCrypto(
                "DES",                                                             // Encrypt algorithm name.
                "skic8fh35l093kg8vj5u98jnx01plm938vuikjmna45hgjvnmyqtxzap09lxtsei" // Key
                );

            string content = dc.Encrypto(sb.ToString());

            using (StreamWriter sw = File.CreateText(Application.StartupPath + "\\CheckDog.dat"))
            {
                sw.Write(content);
            }

            //using (StreamWriter sw = File.CreateText(Application.StartupPath + "\\CheckDog.DescryptoTest.txt"))
            //{
            //    sw.Write(dc.Decrypto(content));
            //}
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        private void ReadDog()
        {
            LogHanlder     log = new LogHanlder();
            GWLicenseAgent a   = new GWLicenseAgent();

            lic = a.LoginGetLicenseLogout(this, log);
            if (lic == null)
            {
                log.Write("license: NULL");
            }
            else
            {
                StringBuilder sb = new StringBuilder();
                foreach (DeviceLicense l in lic.Devices)
                {
                    byte[] blist = l.GetValue();
                    sb.AppendLine(l.Name + "(" + blist[0].ToString() + "," + blist[1].ToString() + ") ");
                }
                log.Write("license: " + sb.ToString());
            }
        }