Esempio n. 1
0
        protected override void OnStart(string[] args)
        {
            base.OnStart(args);
            log.Info("Service starting");
            try
            {
                subscribers    = new SubscriberGroup();
                scanner        = new MMMSwipeReader();
                scanStoreCloud = new ScanStoreCloud(_configFileName);
                serviceHost    = RemoteFactory.CreateServiceHost(this);
                BindScanSourceToScanStore(scanner, scanStoreCloud);

                serviceHost.Open();
                scanner.Activate();
                log.InfoFormat("Service started and listening at ", RemoteFactory.PipeLocation);
            }
            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;
            }
        }
Esempio n. 2
0
        public void Dispose()
        {
            if (documentSink != null)
            {
                documentSink.Dispose();
                documentSink = null;
            }
            ;

            if (scanner != null)
            {
                scanner.Dispose();
                scanner = null;
            }
        }
Esempio n. 3
0
 public void Activate()
 {
     log.Info("Activating connection to local 3M Scanner and remote web service for delivery");
     scanner      = new MMMSwipeReader();
     documentSink = new ScanStoreCloud(_configFileName);
     try
     {
         documentSink.OnScanStoreEvent += HandleScanSinkEvent;
         scanner.OnScanSourceEvent     += HandleScanSourceEvent;
         scanner.OnCodeLineScanEvent   += HandleCodeLineScanEvent;
         scanner.Activate();
     }
     catch (PosHardwareException e)
     {
         Console.WriteLine(e.Message);
     }
 }
Esempio n. 4
0
        protected override void OnStop()
        {
            log.Info("Service stopping");
            if (serviceHost != null)
            {
                serviceHost.Close();
                serviceHost = null;
            }

            cleanup(scanner);
            scanner = null;
            cleanup(scanStoreCloud);
            scanStoreCloud = null;
            cleanup(subscribers);
            subscribers = null;
            log.Info("Service stopped");
        }