예제 #1
0
        static void Main(string[] args)
        {
            if (!PreLoading(args))
            {
                return;
            }

            // process arguments
            if (!ProcessArguments(args))
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                FormLogin dlg = new FormLogin();
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    NotifyAdapterServer server = new NotifyAdapterServer("StatusNotifier");
                    server.Start();

                    License = dlg.License;
                    FormMain frm = new FormMain();
                    frm.WindowState = FormWindowState.Maximized;
                    //US28109
                    #region
                    System.Threading.Thread.Sleep(4000);
                    #endregion
                    Application.Run(frm);

                    server.Stop();
                }
            }

            BeforeExit();
        }
예제 #2
0
        private bool CheckLicenseDog()
        {
            GWLicenseAgent a = new GWLicenseAgent();

            _license = a.LoginGetLicenseLogout(this, Program.Log);
            return(_license != null);
        }
예제 #3
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));
            //}
        }
예제 #4
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);
        }
예제 #5
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());
            }
        }
예제 #6
0
        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]);
                }
            }
        }
예제 #7
0
        static void Main(string[] args)
        {
            if (!PreLoading(args))
            {
                return;
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            if (!MultiInstanceCheck())
            {
                FormLogin dlg = new FormLogin();
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    License = dlg.License;
                    FormMain frm = new FormMain();
                    //frm.WindowState = FormWindowState.Normal;
                    Application.Run(frm);
                }
            }

            BeforeExit();
        }