예제 #1
0
        public MR_users_findMyStation Users_findMyStation()
        {
            if (!IsNetworkAvailable)
            {
                return(null);
            }

            MR_users_findMyStation _ret = null;

            try
            {
                _ret = m_service.users_findMyStation(SessionToken);
            }
            catch (Station401Exception _e)
            {
                Main.Current.Station401ExceptionHandler(_e.Message);
            }

            if (_ret != null)
            {
                if (_ret.status == "200")
                {
                    return(_ret);
                }
            }

            return(null);
        }
예제 #2
0
        private void ThreadMethod(object state)
        {
            while (true)
            {
                try
                {
                    if (Main.Current.RT.Login == null)
                    {
                        NotifyState(ConnectServiceStateType.NetworkDisconnected);

                        Delay(2);
                        continue;
                    }

                    if (Main.Current.RT.StationMode)
                    {
                        if (Main.Current.RT.REST.CheckStationAlive(WService.StationIP, m_lastTimeout))
                        {
                            Delay(10);
                            continue;
                        }
                        else
                        {
                            WService.StationIP          = string.Empty;
                            Main.Current.RT.StationMode = false;

                            NotifyState(ConnectServiceStateType.Cloud);

                            //RefreshDownloadPhotosCache();

                            s_logger.Info("Station Disappear");
                        }
                    }
                    else
                    {
                        NotifyState(ConnectServiceStateType.Cloud);

                        MR_users_findMyStation _findMyStation = Main.Current.RT.REST.Users_findMyStation();

                        s_logger.Trace("Call FindMyStation");

                        if (_findMyStation != null)
                        {
                            if (_findMyStation.stations != null)
                            {
                                //Test Local IP
                                string _ip = GetStationIP(_findMyStation.stations, false);

                                if (!string.IsNullOrEmpty(_ip))
                                {
                                    m_lastTimeout = 3000;

                                    if (Main.Current.RT.REST.CheckStationAlive(_ip, m_lastTimeout))
                                    {
                                        WService.StationIP          = _ip;
                                        Main.Current.RT.StationMode = true;

                                        NotifyState(ConnectServiceStateType.Station_LocalIP);

                                        //RefreshDownloadPhotosCache();

                                        s_logger.Info("Station IP:" + _ip);

                                        Delay(5);
                                        continue;
                                    }
                                }

                                //Test UPnP
                                _ip = GetStationIP(_findMyStation.stations, true);

                                m_lastTimeout = 6000;

                                if (!string.IsNullOrEmpty(_ip))
                                {
                                    if (Main.Current.RT.REST.CheckStationAlive(_ip, m_lastTimeout))
                                    {
                                        WService.StationIP          = _ip;
                                        Main.Current.RT.StationMode = true;

                                        NotifyState(ConnectServiceStateType.Station_UPnP);

                                        //RefreshDownloadPhotosCache();

                                        s_logger.Info("Station IP(UPnP):" + _ip);

                                        Delay(10);
                                        continue;
                                    }
                                }
                            }
                        }
                    }

                    Delay(60);
                }
                catch (Exception _e)
                {
                    NLogUtility.Exception_Warn(s_logger, _e, "ThreadMethod", "");
                }
            }
        }