Esempio n. 1
0
        /// <summary>
        /// Try to connect to the provided server URL
        /// </summary>
        /// <param name="newserv"></param>
        /// <returns>a structure to represent the results of this action</returns>
        public static AboutResultReport TryChangeServerURL(string newserv)
        {
            string oldserv = BaseWS.Server;

            AboutResultReport res = new AboutResultReport();

            res.newServer = newserv;
            res.oldServer = oldserv;

            if (newserv != oldserv) // we have changed something
            {
                // Ping the new server, if unreacheable display message
                if (WebConnector.Current.PingS2CServer(newserv + WebConnector.PING_URL))
                {
                    // test the login: if not successful, logout the user and display the window
                    BaseWS.Server = newserv;
                    UserWS usRepo   = new UserWS();
                    User   currUser = usRepo.LoginUser(BaseWS.Username, BaseWS.Password);
                    res.currentUser = currUser;
                }
                else
                {
                    // network down / invalid server
                    res.error = "The server inserted is unreacheable now!";
                }
            }

            return(res);
        }
Esempio n. 2
0
        /// <summary>
        /// Try to connect to the provided server URL
        /// </summary>
        /// <param name="newserv"></param>
        /// <returns>a structure to represent the results of this action</returns>
        public static AboutResultReport TryChangeServerURL(string newserv)
        {
            string oldserv = BaseWS.Server;

            AboutResultReport res = new AboutResultReport();
            res.newServer = newserv;
            res.oldServer = oldserv;

            if (newserv != oldserv) // we have changed something
            {
                // Ping the new server, if unreacheable display message
                if (WebConnector.Current.PingS2CServer(newserv + WebConnector.PING_URL))
                {
                    // test the login: if not successful, logout the user and display the window
                    BaseWS.Server = newserv;
                    UserWS usRepo = new UserWS();
                    User currUser = usRepo.LoginUser(BaseWS.Username, BaseWS.Password);
                    res.currentUser = currUser;
                }
                else
                {
                    // network down / invalid server
                    res.error = "The server inserted is unreacheable now!";
                }
            }

            return res;
        }