Esempio n. 1
0
        public bool CanExecute()
        {
            AuthenticateCommandResult    auth  = m_Resolver.GetInstance <AuthenticateCommandResult>();
            GetGamesPlayersCommandResult games = m_Resolver.GetInstance <GetGamesPlayersCommandResult>();

            return((games.HasResult) && ((null != auth) && (auth.Authenticated)));
        }
Esempio n. 2
0
        public void Execute(AuthenticateCommandParam parameter)
        {
            IWebCommunitcation        executeWeb = m_Resolver.GetInstance <IWebCommunitcation>();
            AuthenticateCommandResult result     = executeWeb.Authenticate(parameter);

            m_Authenticated(result);

            this.Result = result;
        }
        public bool CanExecute()
        {
            AuthenticateCommandResult auth = m_Resolver.GetInstance <AuthenticateCommandResult>();

            if ((null != auth) && (auth.Authenticated))
            {
                return(true);
            }

            return(false);
        }
        public void Execute()
        {
            this.Result = new GetGamesPlayersCommandResult(new YAGMRC.GMR.Core.Models.GetGamesAndPlayers.RootObject());

            if (!this.CanExecute())
            {
                return;
            }

            IWebCommunitcation        executeWeb = m_Resolver.GetInstance <IWebCommunitcation>();
            AuthenticateCommandResult auth       = m_Resolver.GetInstance <AuthenticateCommandResult>();

            this.Result = executeWeb.GetGamesAndPlayers(auth.AuthID);

            this.m_Resolver.Unregister <GetGamesPlayersCommandResult>();
            this.m_Resolver.Register <GetGamesPlayersCommandResult>(() => this.Result);
        }
Esempio n. 5
0
        public void Execute(GetLatestSaveFileBytesCommandParam parameter)
        {
            if (!this.CanExecute())
            {
                return;
            }

            IWebCommunitcation executeWeb = m_Resolver.GetInstance <IWebCommunitcation>();

            int gameid = parameter.GameID;
            {
                GetGamesPlayersCommandResult games = m_Resolver.GetInstance <GetGamesPlayersCommandResult>();
                Game foundGame = (from id in games.Result.Games where id.GameId == gameid select id).FirstOrDefault();
                if (null == foundGame)
                {
                    return;
                }
                AuthenticateCommandResult auth = m_Resolver.GetInstance <AuthenticateCommandResult>();

                byte[] webResult = executeWeb.DownloadSaveGame(auth.AuthID, foundGame.GameId);;

                string path = m_Resolver.GetInstance <IOSSetting>().CIVSaveGamePath.FullName;

                Directory.CreateDirectory(path);

                FileInfo fi = Helper.File(gameid, m_Resolver.GetInstance <IOSSetting>());
                if (fi.Exists)
                {
                    fi.Delete();
                }

                games.SetHashCode(gameid, Helper.GetHashCode(webResult));


                File.WriteAllBytes(fi.FullName, webResult);
            }
        }