/// <summary> /// Uploads player turn (commands) for this game. /// </summary> public void UploadTurn() { // get list of files var path = GetSavePath(); var files = GetFiles(path, GenerateArgumentsOrFilter(Engine.PlayerTurnUploadFilter)); // send to PBW var url = "http://pbw.spaceempires.net/games/{0}/player-turn/upload".F(Code); if (files.Count() != 1) { throw new InvalidOperationException("Can only upload one PLR file at a time. " + files.Count() + " files were submitted."); } PBW.Log.Write($"Uploading player commands {path} for {this}."); PBW.Upload(files.Single(), url, "plr_file"); Status = PlayerStatus.Uploaded; }
protected void ArchiveUploadAndDeleteArchive(IEnumerable <string> files, string url, string uploadFormParam, HttpStatusCode expectedStatus = HttpStatusCode.OK) { // generate a temp file name var tempfile = MakeTempFile("7z"); PBW.Log.Write("Archiving files into {0}:".F(tempfile)); // archive the files var c = new SevenZipCompressor(); var files2 = files.ToArray(); foreach (var f in files2) { PBW.Log.Write("\t" + f); } c.CompressFiles(tempfile, files2); // upload the archive PBW.Upload(tempfile, url, uploadFormParam, expectedStatus); // delete the archive File.Delete(tempfile); }