示例#1
0
 public static void RemoveCardInfo(IGreenCardReaderInfo info)
 {
     if (ListCardInfo != null)
     {
         var cif = ListCardInfo.FirstOrDefault(c => c.Type == info.Type &&
                                               ((c.Type == "ModWinsCard" && c.SerialNumber == info.SerialNumber) ||
                                                (c.Type != "ModWinsCard" && c.TcpIp == info.TcpIp && c.Port == info.Port)
                                               )
                                               );
         if (cif != null)
         {
             ListCardInfo.Remove(cif);
         }
         cif = ListCardInfo.FirstOrDefault(c => c.Type == info.Type &&
                                           ((c.Type == "ModWinsCard" && c.SerialNumber == info.SerialNumber) ||
                                            (c.Type != "ModWinsCard" && c.TcpIp == info.TcpIp && c.Port == info.Port)
                                           )
                                           );
         if (cif == null && ListCard != null)
         {
             var crd = ListCard.FirstOrDefault(c => c.Info.Type == info.Type &&
                                               ((c.Info.Type == "ModWinsCard" && c.Info.SerialNumber == info.SerialNumber) ||
                                                (c.Info.Type != "ModWinsCard" && c.Info.TcpIp == info.TcpIp && c.Info.Port == info.Port)
                                               )
                                               );
             if (crd != null)
             {
                 crd.DisConnect();
                 ListCard.Remove(crd);
             }
         }
     }
 }
示例#2
0
 public static void RemoveCards()
 {
     if (ListCard != null)
     {
         foreach (var c in ListCard)
         {
             c.DisConnect();
         }
         ListCard.Clear();
     }
     if (ListCardInfo != null)
     {
         ListCardInfo.Clear();
     }
 }
示例#3
0
        public static void AddCardInfo(IGreenCardReaderInfo info)
        {
            if (ListCardInfo == null)
            {
                ListCardInfo = new List <IGreenCardReaderInfo>();
            }
            var cif = ListCardInfo.FirstOrDefault(c => c.Type == info.Type &&
                                                  ((c.Type == "ModWinsCard" && c.SerialNumber == info.SerialNumber) ||
                                                   (c.Type != "ModWinsCard" && c.TcpIp == info.TcpIp && c.Port == info.Port)
                                                  )
                                                  );

            if (cif == null)
            {
                ListCardInfo.Add(info);
            }
            if (ListCard == null)
            {
                ListCard = new List <IGreenCardReader>();
            }
            var crd = ListCard.FirstOrDefault(c => c.Info.Type == info.Type &&
                                              ((c.Info.Type == "ModWinsCard" && c.Info.SerialNumber == info.SerialNumber) ||
                                               (c.Info.Type != "ModWinsCard" && c.Info.TcpIp == info.TcpIp && c.Info.Port == info.Port)
                                              )
                                              );

            if (crd == null)
            {
                switch (info.Type)
                {
                //'ModWinsCard', 'Tcp Ip Client', 'Tcp Ip Server', 'Remode Card'
                case "ModWinsCard":
                    ListCard.Add(new ModWinsCardReader(info));
                    break;
                }
            }
        }