예제 #1
0
        public static string GetPlaneNameByPlaneID(int planeid)
        {
            if (dictPlane == null)
            {

                SecureDBEntities1 db=new SecureDBEntities1();
                dictPlane = new Dictionary<int, tblERPlane>();
                var q= from n in db.tblERPlane  select n;
                foreach (tblERPlane planedata in q)
                {
                    try
                    {
                        dictPlane.Add(planedata.PlaneID, planedata);
                    }
                    catch (Exception ex)
                    {
                        ;
                    }
                }
      

            }

            return  dictPlane[planeid].PlaneName;

        }
예제 #2
0
 public static void PDTEst()
 {
     SecureDBEntities1 db=new SecureDBEntities1();
     tblPDConfig config= db.tblPDConfig.Where(n => n.PDName == "PD-T78-W-22.0").FirstOrDefault();
     PD.PD pd = new PD.PD("PD-T78-W-22.0", config.IP, 502,config);
     while (true)
     {
         Console.WriteLine(pd.ToString());
         System.Threading.Thread.Sleep(1000);
     }
 }
예제 #3
0
       public PlaneManager()
       {
           SecureDBEntities1 db = new SecureDBEntities1();

           var q =from n in db.tblERPlane select n;

         //  System.Collections.Generic.List<Plane> list = new List<Plane>();

           foreach (tblERPlane tbl in q)
           {

               if(!dictERPlanes.ContainsKey(tbl.PlaneID))
                   dictERPlanes.Add(tbl.PlaneID,new Plane(tbl.ERID,tbl.PlaneID,tbl.PlaneName));

             //  list.Add(new Plane(tbl.PlaneID, tbl.PlaneName));
           }
           //ERPlanes = q.ToArray();
          
          
       }
예제 #4
0
        public void SupressAlarm(int ItemID)
        {
             SecureDBEntities1 db;
            Item item=item_mgr[ItemID];
               item.ItemConfig.Suppress = true;
            using(db=new SecureDBEntities1())
            {
                tblAlarmLog log = new tblAlarmLog() { ControlID = item.ItemConfig.ControlID, ItemID = ItemID, TypeCode = 5, TypeID = 5, Timestamp = DateTime.Now, Value = 0, Memo = "Supress" };
                db.tblAlarmLog.Add(log);
                db.SaveChanges();
            }


            DispatchItemValueChangedEvent(item.ToBindingData());
           
           // throw new NotImplementedException();
        }
예제 #5
0
        //public string Register()
        //{
        //    throw new NotImplementedException();
        //}


        void ProcessNotify()
        {
         
            //foreach (tblCardCommandLog cmdlog in db1.tblCardCommandLog.Where(n => n.Timestamp == null))
            //{
            //    Console.WriteLine(cmdlog.ABA);
            //}
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("=========================start task======================");

            System.Collections.Generic.Dictionary<string, string> abaList = new Dictionary<string, string>();
            SecureDBEntities1 db = new SecureDBEntities1();
            try
            {
                foreach (tblCardCommandLog cmdlog in db.tblCardCommandLog.Where(n => n.Timestamp == null))
                {

                    Console.WriteLine("==========================" + cmdlog.ABA + "," + cmdlog.ControlID + "======================");
                    try
                    {
                        if (cmdlog.ControlID != "*" && !card_mgr[cmdlog.ControlID].IsConnected)
                            continue;
                        if (cmdlog.CommandType == "I")
                        {
                            if (cmdlog.CardType == "C")
                            {
                                Console.WriteLine(cmdlog.ControlID + " Add card!" + cmdlog.ABA);
                                card_mgr[cmdlog.ControlID].AddCard(cmdlog.ABA);

                            }
                            else
                            {
                                Console.WriteLine(cmdlog.ControlID + " Add virtual card!" + cmdlog.ABA);
                                card_mgr[cmdlog.ControlID].AddVirturalCard(cmdlog.ABA);

                            }

                        }
                        else if (cmdlog.CommandType == "D")
                        {
                            Console.WriteLine(cmdlog.ControlID + " delete  card!" + cmdlog.ABA);
                            card_mgr[cmdlog.ControlID].DeleteCard(cmdlog.ABA);
                        }
                        else if (cmdlog.CommandType == "*")
                        {

                            Console.WriteLine("=====================Process CheckCardDue==================");
                            if (!abaList.ContainsKey(cmdlog.ABA))
                            {
                                CheckCardDueTask(cmdlog.ABA);
                                abaList.Add(cmdlog.ABA, cmdlog.ABA);
                                Console.WriteLine("check card " + cmdlog.ABA);


                            }

                        }
                        SecureDBEntities1 db1 = new SecureDBEntities1();
                        tblCardCommandLog log = db1.tblCardCommandLog.Where(n => n.FlowID == cmdlog.FlowID).FirstOrDefault();
                        log.Timestamp = DateTime.Now;
                        log.IsSuccess = true;
                        db1.SaveChanges();
                        db1.Dispose();
                    }
                    catch (Exception ex)
                    {
                        SecureDBEntities1 db1 = new SecureDBEntities1();
                        tblCardCommandLog log = db1.tblCardCommandLog.Where(n => n.FlowID == cmdlog.FlowID).FirstOrDefault();
                        if (log != null)
                        {
                            log.Timestamp = DateTime.Now;
                            Console.WriteLine(ex.Message + "," + ex.StackTrace);
                            log.IsSuccess = false;
                            //throw ex;
                            db1.SaveChanges();
                        }
                    }
                }
            }
            catch (Exception ex1)
            {
                Console.WriteLine(ex1.Message + "," + ex1.StackTrace);
            }
          //  db.SaveChanges();
            Console.ForegroundColor = ConsoleColor.White;
        }
예제 #6
0
        void CheckCardNotReturnTask()
        {
            SecureDBEntities1 db = new SecureDBEntities1();
            int  cnt= (from n in db.tblMagneticCard where n.ReturnDate == null && n.CardEndDate < DateTime.Now select n).Count();
            if (cnt > 0)
            {
                AlarmData adata = new AlarmData() { AlarmType = AlarmType.CARD, TimeStamp = DateTime.Now, Description = "卡片未歸還警報", ColorString = "Orange", IsForkCCTVEvent=false, PlaneID=-1 }
                    ;
                DispatchAlarmEvent(adata);
            }


        }
예제 #7
0
        void CheckCardDueTask() 
        {
            SecureDBEntities1 db = new SecureDBEntities1();
            DateTime dt=System.DateTime.Now.Date;
            DateTime dt1 = dt.AddDays(1);
            var q = from n in db.vwMagneticCardAllowController where n.StartDate >= dt && n.StartDate < dt1 || n.EndDate >= dt.Date && n.EndDate < dt1 select n;
            foreach (vwMagneticCardAllowController vw in q)
            {
                if (card_mgr[vw.ControlID] == null)
                    continue;
                if ((System.DateTime.Now > vw.EndDate || System.DateTime.Now < vw.StartDate) && card_mgr[vw.ControlID].IsConnected)
                {
                    try
                    {
                        card_mgr[vw.ControlID].DeleteCard(vw.ABA);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message + "," + ex.StackTrace);
                    }
                }

                if ((System.DateTime.Now <= vw.EndDate && System.DateTime.Now >= vw.StartDate) && card_mgr[vw.ControlID].IsConnected)
                {
                    try
                    {
                        if (vw.Type == 4)
                            card_mgr[vw.ControlID].AddVirturalCard(vw.ABA);
                        else
                            card_mgr[vw.ControlID].AddCard(vw.ABA);
                    }
                    catch (Exception ex)
                    {

                        ;
                        // Console.WriteLine(ex.Message+","+ex.StackTrace);
                    }



                }
            }

           // NotifyDBChange(DBChangedConstant.AuthorityChanged);
        }
예제 #8
0
 public void LoadItemConfig()
 {
     SecureDBEntities1 client = new SecureDBEntities1();
    tblItemConfig config= client.tblItemConfig.Where(n => n.ItemID == this.ItemID).FirstOrDefault();
     if(config!=null)
           this.ItemConfig = config;
     if (this.ItemValueChanged != null)
         this.ItemValueChanged(this, this.Value);
    
 }