// 使用者巡覽至這個頁面時執行。
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     try
     {
         client = new MyClient("CustomBinding_ISecureService");
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Example #2
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;
        }
        void UpdateItemGroup(int GroupID)
        {
        
            if (IsExit)
                return;
            if (ItemGroupBindingDatas == null)
                return;
            MyClient myclient = new MyClient("CustomBinding_ISecureService", false);
            myclient.SecureService.GetAllItemGroupBindingDataCompleted += (s, a) =>
                {
                    if (a.Error != null)
                    {
                        myclient.Dispose();
                        return;
                    }
                    ItemGroupBindingData[] datas = a.Result.ToArray();

                    ItemGroupBindingData source = datas.Where(n => n.GroupID == GroupID).FirstOrDefault();
                   
                   ItemGroupBindingData  dest = ItemGroupBindingDatas.Where(n=>n.GroupID==GroupID).FirstOrDefault();
                    if(dest!=null && source!=null)
                        dest.ColorString=source.ColorString;
                    myclient.Dispose();
                };
            if (!IsExit)
            myclient.SecureService.GetAllItemGroupBindingDataAsync(this.PlaneID);
        }
        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();
        }
Example #5
0
        // 使用者巡覽至這個頁面時執行。
        protected  async  override void OnNavigatedTo(NavigationEventArgs e)
        {

#if R23
            this.chkIsWindowsAlarm.Visibility = Visibility;
#endif
            SecureDBContext db = new SecureDBContext();// DB.GetDB();
            try
            {
                EntityQuery<tblSysParameter> qry = db.GetTblSysParameterQuery().Where(n => n.VariableName == "TimeoutReturnPage");

                var result = await db.LoadAsync(qry);
                
                tblSysParameter sysparam = result.FirstOrDefault();
                if (sysparam != null)
                {


                    tmr.Interval = TimeSpan.FromMinutes(double.Parse(sysparam.VariableValue));
                    tmr.Tick += tmr_Tick;
                    tmr.Start();

                }

                //  Microsoft.Expression.Interactivity.Layout.FluidMoveBehavior bev = new Microsoft.Expression.Interactivity.Layout.FluidMoveBehavior();



                EntityQuery<vwUserMenuAllow> q = db.GetVwUserMenuAllowQuery().Where(n => n.UserID == Util.GetICommon().GetUserID() && n.IsAllow == true);
                var UserMenus = await db.LoadAsync(q);

                var res = from n in UserMenus group n by n.GroupName into g select new UserGroupMenu() { GroupMenu = g.Key, Menus = g.OrderBy(k => k.MenuOrder).ToList() };
                this.acdMenu.ItemsSource = res;
#if R23
                this.frameMain.Navigate(new Uri("/Forms/R23/Monitor.xaml", UriKind.Relative));
#else
            this.frameMain.Navigate(new Uri("/Forms/R23/Monitor.xaml", UriKind.Relative));
          //  this.frameMain.Navigate(new Uri("/Forms/Monitor.xaml", UriKind.Relative));
#endif

            }
            catch { ;}
           txtTitle.DataContext = new tblMenu() { MenuName = "門禁監控" };
            this.acdMenu.SelectedIndex =1;

             client = new MyClient("CustomBinding_ISecureService",true);
             client.OnRegistEvent +=async  (s) =>
                 {

                     await HookAlarmEvent();
                     client.OnAlarm += client_OnAlarm;


                 };

             this.txtCCTVCnt1.Text = this.NavigationContext.QueryString["username"];
          //   await client.RegistAndGetKey();
        
          
           
             //client.SecureService.HookAlarmEventCompleted += (s, a) =>
             //    {

             //    };



        }