async Task AddMagneticCardNormalGroup()
        {
            db = slSecure.DB.GetDB();

            //非同步模擬成同步
            var q = await db.LoadAsync<tblMagneticCardNormalGroup>(from b in db.GetTblMagneticCardNormalGroupQuery() select b);
            tblMagneticCardNormalGroup bc = q.Last();

            db.tblMagneticCardNormalGroups.Add(

               new tblMagneticCardNormalGroup()
               {
                   //NormalID = bc.NormalID + 1,
                   NormalName = txt_NormalName.Text,
                   UpdateDate = DateTime.Now,
                   Memo = tb_Memo.Text
               }
               );
            try
            {
                bool res = await db.SubmitChangesAsync();
                MessageBox.Show("新增定期卡群組成功!");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Adding Data failed due to " + ex.Message);
            }
        }
Ejemplo n.º 2
0
        async void treeView_New()
        {
            slSecure.Web.SecureDBContext db;
            db = slSecure.DB.GetDB();
            TreeViewItem tvItem;

            var ERNameData = await db.LoadAsync<tblEngineRoomConfig>(db.GetTblEngineRoomConfigQuery());
            string sERName, sReadCardName, sControlID;
            foreach (var tempERNameData in ERNameData)
            {
                sERName = tempERNameData.ERName;
                tvItem = new TreeViewItem();
                tvItem.Header = sERName;

                foreach (var tempEntranceGuardData in tempERNameData.tblEntranceGuardConfig)
                {
                    foreach (var tempControllerConfigData in tempERNameData.tblControllerConfig)
                    {
                        if (tempControllerConfigData.EntranceCode == tempEntranceGuardData.EntranceCode && (tempControllerConfigData.ControlType == 1 || tempControllerConfigData.ControlType == 2))
                        {
                            sControlID = tempControllerConfigData.ControlID;
                            sReadCardName = tempEntranceGuardData.Memo;

                            RadioButton ck1 = new RadioButton() { Content = sReadCardName, Tag = sControlID, GroupName = "Door" };
                            tvItem.Items.Add(ck1);
                            tvItem.Tag = sControlID;
                        }
                    }
                }
                tv_TreeView_New.Items.Add(tvItem);
            }
        }
        async void QueryMagneticCardNormalGroup()
        {
            db = slSecure.DB.GetDB();
            //非同步模擬成同步
            var q = await db.LoadAsync<tblMagneticCardNormalGroup>(db.GetTblMagneticCardNormalGroupQuery());
            dataGrid.ItemsSource = q;

            NewMagneticCardNormalGroup();
        }
        async Task ModifyMagneticCardNormalGroup()
        {
            db = slSecure.DB.GetDB();
            var normalID = int.Parse(txt_NormalID.Text);
            //非同步模擬成同步
            var q = await db.LoadAsync<tblMagneticCardNormalGroup>(from b in db.GetTblMagneticCardNormalGroupQuery() where b.NormalID == normalID select b);
            tblMagneticCardNormalGroup bc = q.First();
            bc.NormalName = txt_NormalName.Text;
            bc.UpdateDate = DateTime.Now;
            bc.Memo = tb_Memo.Text;

            try
            {
                bool res = await db.SubmitChangesAsync();
                MessageBox.Show("修改定期卡群組成功!");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Data updation failed due to " + ex.Message);
            }

        }
        async Task DeleteMagneticCardNormalGroup()
        {
            db = slSecure.DB.GetDB();
            var normalID = int.Parse(txt_NormalID.Text);
            //非同步模擬成同步
            var q = await db.LoadAsync<tblMagneticCardNormalGroup>(from b in db.GetTblMagneticCardNormalGroupQuery() where b.NormalID == normalID select b);
            tblMagneticCardNormalGroup bc = q.First();

            db.tblMagneticCardNormalGroups.Remove(bc);
            try
            {
                bool res = await db.SubmitChangesAsync();
                MessageBox.Show("刪除定期卡群組成功!");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Data deletion failed due to " + ex.Message);
            }
        }
Ejemplo n.º 6
0
        // 使用者巡覽至這個頁面時執行。
        protected  async override void OnNavigatedTo(NavigationEventArgs e)
        {

            db = new slSecure.Web.SecureDBContext();
            var q = from n in db.GetTblEngineRoomConfigQuery() select n;
                   
           
                     

            var res=await  db.LoadAsync<slSecure.Web.tblEngineRoomConfig>(q );
             roomInfos = (from n in res
                            select new ControlRoomInfo()
                            {
                                 ERID=n.ERID,
                                Type = "C",
                                AlarmStatus = 0,
                                Name = n.ERName,
                                X = n.GPSX,
                                Y = n.GPSY
                            }).ToArray();

            foreach (ControlRoomInfo info in roomInfos)
            {
                mapctl.AddControllRoomPin(info);
              
            }

            //var q1 = from n in db.GetTblERPlaneQuery() select n;
            //var res1= await db.LoadAsync<tblERPlane>(q1);

            //planeInfos = (from n in res1
            //             select new PlaneInfo()
            //             {
            //                  ERID=n.ERID,
            //                   AlarmStatus=0,
            //                    Name=n.PlaneName,
            //                    PlaneID=n.PlaneID,
            //                     Type="EP"
                                  
            //             }).ToArray();

            
                client = new MyClient("CustomBinding_ISecureService", false);
          
            client.SecureService.GetAllPlaneInfoCompleted += (s, a) =>
                {
                    if (a.Error != null)
                        return;
                  lstMenu.ItemsSource =   PlaneDegreeInfos=a.Result;

                  if (roomInfos != null)
                      foreach (ControlRoomInfo info in roomInfos)
                      {
                          try
                          {
                              info.AlarmStatus = PlaneDegreeInfos.Where(n => n.ERID == info.ERID).Max(n => n.AlarmStatus);

                          }
                          catch { ;}
                      }

                };
            if (!IsExit)
            {
                client.SecureService.GetAllPlaneInfoAsync();


                tmr.Interval = TimeSpan.FromSeconds(10);
                tmr.Tick += tmr_Tick;

                tmr.Start();
            }
          //  client.OnItemValueChangedEvent += client_OnItemValueChangedEvent;
        }
Ejemplo n.º 7
0
        protected async  override void OnNavigatedTo(NavigationEventArgs e)
        {
            client = new MyClient("CustomBinding_ISecureService", false);
         
            db = new SecureDBContext();
            this.PlaneID = int.Parse(this.NavigationContext.QueryString["PlaneID"]);

           


            this.image.Source = new BitmapImage(new Uri("/Diagrams/" + PlaneID + ".png", UriKind.Relative));
#if !R23
          
#endif
            if (!IsExit)
            await GetALLDoorBindingData(PlaneID);
            if (!IsExit)
            await GetALLCCTVBindingData(PlaneID);
            if (!IsExit)
            await GetAllItemBindingData(PlaneID);
            if (!IsExit)
            await GetAllItemGroupBindingData(PlaneID);
#if !R23

#endif
            PlaceDoor();
            PlaceCCTV();
            PlaceItem();
            PlaceItemGroup();
            var erplanes= await  db.LoadAsync<tblERPlane>(db.GetTblERPlaneQuery().Where(n=>n.PlaneID==this.PlaneID));
           this.tblPlane= erplanes.FirstOrDefault();
           this.DataContext = tblPlane;
           // tblPlane.PlaneName


      

           client.OnRegistEvent += async (s) =>
           {

               if (!IsExit)
                   await HookDoorEvent(PlaneID);
               if (!IsExit)
                   await HookItemValueChangeEvent(PlaneID);

           };
           client.OnDoorEvent += client_OnDoorEvent;
           client.OnItemValueChangedEvent += client_OnItemValueChangedEvent;
           if (!IsExit)
               await client.RegistAndGetKey();
        }