Ejemplo n.º 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;
            }
        }
Ejemplo n.º 2
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);
     }
 }