Beispiel #1
0
        public void Execute(SubmitTurnCommandParam parameter)
        {
            this.Result = new SubmitTurnResult();

            if (!CanExecute(parameter))
            {
                return;
            }

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

            GetGamesPlayersCommandResult gameresult;
            Game     foundGame;
            FileInfo file;

            GetObjects(parameter, out foundGame, out gameresult, out file);

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


            this.Result = cmd.UploadGame(file, auth.AuthID, foundGame.CurrentTurn.TurnId).Result;

            IOSSetting setting = this.m_Resolver.GetInstance <IOSSetting>();

            Archive archive = new Archive(setting);

            archive.MoveToArchive(file, foundGame.GameId);
            archive.KeepArchivedFiles(parameter.ArchivedFiles, foundGame.GameId);
        }
        public void Execute(AuthenticateCommandParam parameter)
        {
            IWebCommunitcation        executeWeb = m_Resolver.GetInstance <IWebCommunitcation>();
            AuthenticateCommandResult result     = executeWeb.Authenticate(parameter);

            m_Authenticated(result);

            this.Result = result;
        }
        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);
        }
Beispiel #4
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);
            }
        }