Пример #1
0
        protected override void OnStart(string[] args)
        {
            base.OnStart(args);
            log.Info("Service starting");
            try
            {
                scanner     = new MMMDocumentScanner();
                scanSink    = new ScanSinkWebService(_configFileName);
                serviceHost = RemoteFactory.CreateServiceHost(this);
                BindSourceToSink(scanner, scanSink);

                serviceHost.Open();
                scanner.Activate();
                log.Info("Service started");
            }
            catch (Exception e)
            {
                log.ErrorFormat("Service exception while starting [{0}]", e);
                EventLog.WriteEntry(this.ServiceName, e.Message,
                                    System.Diagnostics.EventLogEntryType.Warning);
                EventLog.WriteEntry(this.ServiceName, e.StackTrace,
                                    System.Diagnostics.EventLogEntryType.Warning);
                OnStop();
                throw e;
            }
        }
Пример #2
0
        public void Dispose()
        {
            if (documentSink != null)
            {
                documentSink.Dispose();
                documentSink = null;
            }
            ;

            if (scanner != null)
            {
                scanner.Dispose();
                scanner = null;
            }
        }
Пример #3
0
        protected override void OnStop()
        {
            log.Info("Service stopping");
            if (serviceHost != null)
            {
                serviceHost.Close();
                serviceHost = null;
            }

            cleanup(scanner);
            scanner = null;
            cleanup(scanSink);
            scanSink = null;
            log.Info("Service stopped");
        }
Пример #4
0
 public void Activate()
 {
     log.Info("Activating connection to local 3M Scanner and remote web service for delivery");
     scanner      = new MMMDocumentScanner();
     documentSink = new ScanSinkWebService(_configFileName);
     try
     {
         documentSink.OnScanSinkEvent += HandleScanSinkEvent;
         scanner.OnCodeLineScanEvent  += documentSink.HandleCodeLineScan;
         scanner.Activate();
         Console.WriteLine(scanner);
     }
     catch (PosHardwareException e)
     {
         Console.WriteLine(e.Message);
     }
 }