Beispiel #1
0
        private void handleNewItemFromRFID(RFIDContent newItem)
        {
            if (newItem.bookRfidList.Count() != 0)
            {
                IBookLocationService    bookLocationService    = this.container.Resolve <IBookLocationService>();
                IBookInformationService bookInformationService = this.container.Resolve <IBookInformationService>();

                List <String> bookNameList       = bookInformationService.getBookNameListByRfidList(newItem.bookRfidList);
                List <String> bookAccessCodeList = bookInformationService.getBookAccessCodeListByRfidList(newItem.bookRfidList);
                this.dispatcherService.Dispatch(() =>
                {//显示图书基本信息
                    this.BookName       = bookNameList[0];
                    this.BookAccessCode = bookAccessCodeList[0];
                });

                String shelfRfid          = bookLocationService.getShelfRfidbyBookRfid(newItem.bookRfidList[0]);
                String bookLocationString = bookLocationService.getShelfNameByShelfRfid(shelfRfid);

                //在选定的书架层上绘图
                this.dispatcherService.Dispatch(() =>
                {
                    this.BookLocation = bookLocationString;
                    //test code here ,delete it
                    this.libraryMapService.reinitOneShapMap();//刷新UI
                    this.libraryMapService.drawOneShapeMapBackground();
                    this.libraryMapService.drawSelectedLayerOneShapeMap(bookLocationString);
                    //this.LibraryMapService = this.LibraryMapService; //通知更新UI,没必要重复了,等下面操作一起刷新

                    this.libraryMapService.reinitLibraryShelfMap();
                    this.libraryMapService.drawLibraryShelfMapBackgroundByLibraryName(bookLocationString);
                    this.libraryMapService.drawSelectedShelfLibraryShelfMapByLibraryName(shelfRfid);
                    this.LibraryMapService = this.LibraryMapService;//通知更新UI
                });
            }
        }
Beispiel #2
0
 private void handleNewItemFromRFID(RFIDContent newItem)
 {
     if (newItem.bookRfidList.Count() != 0)
     {//只有当当前在某个书架上的图书不为空的时候才继续处理
         IBookInformationService bookInformationService = container.Resolve <IBookInformationService>();
         IBookLocationService    bookLocationService    = this.container.Resolve <IBookLocationService>();
         if (!String.IsNullOrEmpty(this.ShelfLocationString))//  书架位置信息不空,这时有必要继续执行
         {
             //如果出现不在该架位的图书,则提示该书不属于当前书架
             foreach (String bookrfid in newItem.bookRfidList)
             {
                 String shelfRfid = bookLocationService.getShelfRfidbyBookRfid(bookrfid);
                 if (shelfRfid != this.shelfRfid)
                 {
                     try
                     {
                         List <String> bookNameList = bookInformationService.getBookNameListByRfidList(new List <String>()
                         {
                             bookrfid
                         });
                         String bookName = bookNameList[0];
                         String message  = "图书名称:" + bookName + "图书扫描码:" + bookrfid + "不属于该书架";
                         MessageBox.Show(message);
                     }
                     catch (Exception)
                     {
                         String message = "查询数据库出错,图书扫描码为:" + bookrfid + ",请检查是否登记该图书 !";
                         MessageBox.Show(message);
                     }
                 }
             }
             //图书的rfid是否有重复,删除掉重复的部分,并刷新UI,但ID编号可能不连续,重新更新ID编号
             this.dispatcherService.Dispatch(() =>
             {
                 List <BookItemOfWrongLocation> tempList = new List <BookItemOfWrongLocation>();
                 //把原始的datagrid中的内容存入临时的列表中,并清空该列表
                 foreach (BookItemOfWrongLocation item in this.NotOnThisShelfBookList)
                 {
                     tempList.Add(item);
                 }
                 this.NotOnThisShelfBookList.Clear();
                 //查看临时列表中与新读入标签重复的地方
                 int index = 0;
                 while (true)
                 {
                     if (index >= tempList.Count())
                     {
                         break;
                     }
                     BookItemOfWrongLocation item = tempList[index];
                     if (newItem.bookRfidList.Contains(item.BookRFIDCode))
                     {
                         tempList.Remove(item);
                     }
                     index = index + 1;
                 }
                 //把临时标签的内容复制入datagrid,并重新计算ID,因为ID可能经过删除有不连续的现象
                 int count = 1;
                 foreach (BookItemOfWrongLocation item in tempList)
                 {
                     item.ID = Convert.ToString(count);
                     this.NotOnThisShelfBookList.Add(item);
                     count = count + 1;
                 }
                 //刷新UI
                 this.NotOnThisShelfBookList = this.NotOnThisShelfBookList;
             });
         }
     }
     if (newItem.shelfRfidList.Count() != 0) //发现有新的书架信息
     {
         //清除原有信息
         this.dispatcherService.Dispatch(() =>
         {
             this.OnThisShelfAllBookList.Clear();
             this.NotOnThisShelfBookList.Clear();
         });
         //在书架位置的文本框内显示数据的位置
         IBookInformationService bookInformationService = container.Resolve <IBookInformationService>();
         IBookLocationService    bookLocationService    = this.container.Resolve <IBookLocationService>();
         this.shelfRfid           = newItem.shelfRfidList[0];
         this.ShelfLocationString = bookLocationService.getShelfNameByShelfRfid(newItem.shelfRfidList[0]);
         //查询数据库,在本书架应有图书中显示所有的图书
         List <String> bookRfidList       = bookLocationService.getBookRfidListOnShelfRfid(this.shelfRfid);
         List <String> bookNameList       = bookInformationService.getBookNameListByRfidList(bookRfidList);
         List <String> bookAccessCodeList = bookInformationService.getBookAccessCodeListByRfidList(bookRfidList);
         if ((bookRfidList.Count() == bookNameList.Count()) && (bookNameList.Count() == bookAccessCodeList.Count()))
         {//查询到的图书名称和图书索取码必须与图书rfid字符串长度相等
             for (int i = 0; i < bookRfidList.Count(); i++)
             {
                 BookItemOfWrongLocation newBookItem = new BookItemOfWrongLocation()
                 {
                     ID             = Convert.ToString(i + 1),
                     BookName       = bookNameList[i],
                     BookAccessCode = bookAccessCodeList[i],
                     BookRFIDCode   = bookRfidList[i]
                 };
                 BookItemOfWrongLocation newBookItemInOtherGrid = (BookItemOfWrongLocation)newBookItem.Clone();
                 this.dispatcherService.Dispatch(() =>
                 {
                     this.OnThisShelfAllBookList.Add(newBookItem);
                     this.notOnThisShelfBookList.Add(newBookItemInOtherGrid);
                 });
             }
             this.dispatcherService.Dispatch(() =>
             {
                 this.OnThisShelfAllBookList = this.OnThisShelfAllBookList;
                 this.NotOnThisShelfBookList = this.NotOnThisShelfBookList;
             });
         }
     }
 }