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); } }
// 使用者巡覽至這個頁面時執行。 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; }