示例#1
0
        //管理配置文件的类
        public SystemSettingViewModel(IUnityContainer container, IRegionManager regionManager)
        {
            this.container = container; this.regionManager = regionManager;
            //初始化时从配置文件中载入基本配置,并在点击保存按钮时把配置保存下来
            this.databaseAndSerialSettingsServices = new DatabaseAndSerialSettingsServices();
            this.bookInformationServerSettings     = databaseAndSerialSettingsServices.loadBookInformationServerSettings();
            this.bookLocationServerSettings        = databaseAndSerialSettingsServices.loadBookLocationServerSettings();
            this.serialSettings = databaseAndSerialSettingsServices.loadSerialSettings();
            //把配置信息放到容器中的相应对象中,因此这部分必须要比其他的viewModel和view首先被初始化
            //此后容器里的两个数据库服务,和一个RFID服务就有了配置信息
            IBookInformationService bookInformationSrv = this.container.Resolve <IBookInformationService>();

            bookInformationSrv.ServerIp       = BookInformationServer.IP;
            bookInformationSrv.ServerUsername = BookInformationServer.Username;
            bookInformationSrv.ServerPassword = BookInformationServer.Password;
            IBookLocationService bookLocationSrv = container.Resolve <IBookLocationService>();

            bookLocationSrv.ServerIp       = BookLocationServer.IP;
            bookLocationSrv.ServerUsername = BookLocationServer.Username;
            bookLocationSrv.ServerPassword = BookLocationServer.Password;
            ISerialService serialSrv = container.Resolve <ISerialService>();

            serialSrv.Serial = Serial.Serial;
            serialSrv.Speed  = Serial.Speed;

            //把系统配置信息放置在RFID服务中
            IRFIDService rfidService = container.Resolve <IRFIDService>();

            rfidService.HardwareInterface = serialSrv.Serial;
            rfidService.HardwareInterfaceConnectionSpeed = serialSrv.Speed;
        }
示例#2
0
        private static void readInputAndChangeStatus(UnityContainer container)
        {
            IRFIDService rfidService = container.Resolve <IRFIDService>();
            String       command     = "";

            while (true)
            {
                Console.Write("Input a command:");
                command = Console.ReadLine();
                if (command == "start")
                {
                    rfidService.start();
                    Console.WriteLine("Start RFID!");
                }
                if (command == "stop")
                {
                    rfidService.stop();
                    Console.WriteLine("Stop RFID!");
                }
                if (command.StartsWith("set"))
                {
                    String[] strArray = command.Split(' ');
                    if (strArray.Length != 3)
                    {
                        continue;
                    }
                    rfidService.HardwareInterface = strArray[1];
                    rfidService.HardwareInterfaceConnectionSpeed = strArray[2];
                }
            }
        }
示例#3
0
        public void OnNavigatedFrom(NavigationContext navigationContext)
        {
            IRFIDService rfidService = container.Resolve <IRFIDService>();

            rfidService.stop();
            eventAggregator.GetEvent <RFIDNewItemEvent>().Unsubscribe(handleNewItemFromRFID);
            eventAggregator.GetEvent <RFIDHardwareEvent>().Unsubscribe(handleErrorFromRFID);
            eventAggregator.GetEvent <DatabaseEvent>().Unsubscribe(handleErrorFromDatabase);
        }
示例#4
0
        public void OnNavigatedFrom(NavigationContext navigationContext)
        {
            //throw new NotImplementedException();
            //取消订阅该事件,在此之前先关闭rfid后台扫描线程
            IRFIDService rfidService = container.Resolve <IRFIDService>();

            rfidService.stop();
            eventAggregator.GetEvent <RFIDNewItemEvent>().Unsubscribe(handleNewItemFromRFID);
            eventAggregator.GetEvent <RFIDHardwareEvent>().Unsubscribe(handleErrorFromRFID);
        }
示例#5
0
        public static void testRFID(UnityContainer container)  //测试程序入口
        {
            IEventAggregator eventAggregator = container.Resolve <IEventAggregator>();

            eventAggregator.GetEvent <RFIDHardwareEvent>().Subscribe(RFIDFailureHander);
            eventAggregator.GetEvent <RFIDNewItemEvent>().Subscribe(RFIDNewItemHander);
            IRFIDService rfidService = container.Resolve <IRFIDService>();

            rfidService.HardwareInterface = "";
            rfidService.HardwareInterfaceConnectionSpeed = "";
            rfidService.start();
            readInputAndChangeStatus(container);
            Console.ReadLine();
        }
示例#6
0
        public void OnNavigatedTo(NavigationContext navigationContext)
        {
            //ISerialService serialService = container.Resolve<ISerialService>();
            //IBookInformationService bookInformationService = container.Resolve<IBookInformationService>();
            //IBookLocationService bookLocationService = container.Resolve<IBookLocationService>();
            IRFIDService rfidService = container.Resolve <IRFIDService>();

            //开始读取RFID的信息,并查询数据库
            eventAggregator.GetEvent <RFIDNewItemEvent>().Subscribe(handleNewItemFromRFID);
            //开始订阅RFID服务发出的事件,这个事件是扫描到的条码的信息,在该view非激活时务必取消此事件的订阅
            eventAggregator.GetEvent <RFIDHardwareEvent>().Subscribe(handleErrorFromRFID);
            eventAggregator.GetEvent <DatabaseEvent>().Subscribe(handleErrorFromDatabase);

            rfidService.start();//开启rfid的后台扫描线程
        }
示例#7
0
 public RFIDController(IRFIDService objSvc, IStockDetailsService objSDC)
 {
     this.objSvc = objSvc as RFIDService;
     this.objSDC = objSDC as StockDetailsService;
 }