protected override void Dispose(bool disposing) { if (CloseHandle) { FsClient.CloseFile(Handle); } }
private Result WriteFile(ReadOnlySpan <byte> data) { Debug.Assert(FsClient != null); Debug.Assert(!string.IsNullOrWhiteSpace(FileName)); FsClient.DeleteFile(FileName); Result rc = FsClient.CreateFile(FileName, data.Length); if (rc.IsFailure()) { return(rc); } rc = FsClient.OpenFile(out FileHandle handle, FileName, OpenMode.Write); if (rc.IsFailure()) { return(rc); } rc = FsClient.WriteFile(handle, 0, data, WriteOption.Flush); FsClient.CloseFile(handle); return(rc); }
public void FSBeginTransaction() { FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Green, "\n :: Starting New Transaction ::\n"); if (TransactionId != null) { FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Yellow, "Transaction in play, returning!\n"); return; } var options = new TransactionOptions(); var beginTransactionRequest = new BeginTransactionRequest(); beginTransactionRequest.Database = Parent; beginTransactionRequest.Options = options; var beginTransactionResponse = new BeginTransactionResponse(); try { beginTransactionResponse = FsClient.BeginTransaction(beginTransactionRequest); } catch (Exception e) { FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Red, "Exception caught\n" + e.Message); return; } TransactionId = beginTransactionResponse.Transaction; FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Green, "\n Successfully began new transaction '"); FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.White, TransactionId.ToBase64().ToString()); FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Green, "'!"); }
public Document GetDocument(String documentName, String collectionID = "GrpcTestData") { var getDocumentRequest = new GetDocumentRequest(); getDocumentRequest.Name = Parent + "/documents/" + collectionID + "/" + documentName; Document retDoc; try { retDoc = FsClient.GetDocument(getDocumentRequest); } catch (Grpc.Core.RpcException e) { if (e.Status.StatusCode == Grpc.Core.StatusCode.NotFound) { // FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Red, "ERROR: Document " + documentName + " not found!"); throw e; } else { Console.WriteLine("{0} Exception caught.", e); } throw e; } catch (Exception e) { Console.WriteLine("{0} Exception caught.", e); throw e; } return(retDoc); }
public void Dispose() { if (IsMounted) { FsClient.Unmount(MountName); } }
public void FSRollback() { FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Green, "\n :: Starting Rollback ::\n"); if (TransactionId == null) { FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Yellow, "\nNo transaction to rollback, returning!"); return; } var rollbackRequest = new RollbackRequest(); rollbackRequest.Database = Parent; rollbackRequest.Transaction = TransactionId; try { FsClient.Rollback(rollbackRequest); } catch (Exception e) { FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Red, "Exception caught\n" + e.Message); return; } FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Green, "\nSuccessfully rollback!"); // clear transactionId! ClearTransactionId(); }
private Result ReadFile(out byte[] data) { Debug.Assert(FsClient != null); Debug.Assert(!string.IsNullOrWhiteSpace(FileName)); data = default; Result rc = FsClient.OpenFile(out FileHandle handle, FileName, OpenMode.Read); if (rc.IsFailure()) { return(rc); } rc = FsClient.GetFileSize(out long fileSize, handle); if (rc.IsSuccess()) { data = new byte[fileSize]; rc = FsClient.ReadFile(handle, 0, data); } FsClient.CloseFile(handle); return(rc); }
public void ListDocuments() { var listDocumentsRequest = new ListDocumentsRequest(); listDocumentsRequest.Parent = Parent; var listDocumentsResponse = FsClient.ListDocuments(listDocumentsRequest); var documents = listDocumentsResponse.Documents; int i = 0; foreach (var document in documents) { i++; FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.White, "\nDocument " + i + ": " + document.Name + ""); } }
public Result Reset() { lock (Locker) { IsKvdbLoaded = false; Result rc = FsClient.DeleteSaveData(SaveDataId); if (rc.IsSuccess() || ResultFs.TargetNotFound.Includes(rc)) { Version++; } return(rc); } }
public void FSListCollectionIds() { FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Green, "\n:: Listing all Collection Ids from Document or Database... ::\n"); var listCollectionIdsRequest = new ListCollectionIdsRequest(); listCollectionIdsRequest.Parent = Parent; var listCollectionIdsResponse = FsClient.ListCollectionIds(listCollectionIdsRequest); var cids = listCollectionIdsResponse.CollectionIds; int i = 0; foreach (var cid in cids) { i++; FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.White, "\n:: Collection Id " + i + ": " + cid.ToString()); } FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Green, "\nFinished listing Collection Ids from Document or Database."); }
public void FSDeleteDocument() { FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Green, "\n:: Deleting a Document ::\n"); FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Yellow, "\nEnter Collection [cities]: "); string collectionId = Console.ReadLine(); if (collectionId == "") { collectionId = "cities"; } FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Yellow, "\nEnter Document ID: "); var docId = Console.ReadLine(); var deleteDocumentRequest = new DeleteDocumentRequest(); deleteDocumentRequest.Name = Parent + "/documents/" + collectionId + "/" + docId; try { FsClient.DeleteDocument(deleteDocumentRequest); } catch (Grpc.Core.RpcException e) { if (e.Status.StatusCode == Grpc.Core.StatusCode.NotFound) { FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Yellow, "\nDocument does not exists."); } FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Red, "\n" + e.Status.Detail); return; } catch (Exception e) { Console.WriteLine("{0} Exception caught.", e); return; } FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Green, "\nSuccessfully deleted document!"); }
protected override Result DoWrite(long offset, ReadOnlySpan <byte> source) { lock (_locker) { if (source.Length == 0) { return(Result.Success); } Result rc = UpdateSize(); if (rc.IsFailure()) { return(rc); } if (!IsRangeValid(offset, source.Length, FileSize)) { return(ResultFs.OutOfRange.Log()); } return(FsClient.WriteFile(Handle, offset, source)); } }
protected override Result DoRead(long offset, Span <byte> destination) { lock (_locker) { if (destination.Length == 0) { return(Result.Success); } Result rc = UpdateSize(); if (rc.IsFailure()) { return(rc); } if (!IsRangeValid(offset, destination.Length, FileSize)) { return(ResultFs.OutOfRange.Log()); } return(FsClient.ReadFile(Handle, offset, destination)); } }
public void FSCommit() { FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Green, "\n :: Starting Commit ::\n"); if (TransactionId == null) { FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Yellow, "No transaction to commit, returning!\n"); return; } var commitRequest = new CommitRequest(); commitRequest.Database = Parent; commitRequest.Transaction = TransactionId; var commitResponse = new CommitResponse(); try { commitResponse = FsClient.Commit(commitRequest); } catch (Exception e) { FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Red, "Exception caught\n" + e.Message); return; } var timestamp = commitResponse.CommitTime; if (timestamp == null) { timestamp = new Google.Protobuf.WellKnownTypes.Timestamp(); // fix } FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Green, "\n Successfully commit at "); FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.White, timestamp.ToDateTime().ToString()); FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Green, "!"); // clear transactionId! ClearTransactionId(); }
public Result Commit() { lock (Locker) { Result rc = Initialize(); if (rc.IsFailure()) { return(rc); } rc = EnsureKvDatabaseLoaded(false); if (rc.IsFailure()) { return(rc); } var mount = new Mounter(); try { rc = mount.Initialize(FsClient, MountName, SpaceId, SaveDataId); if (rc.IsFailure()) { return(rc); } rc = KvDatabase.WriteDatabaseToFile(); if (rc.IsFailure()) { return(rc); } string idFilePath = $"{MountName}:/{LastIdFileName}"; rc = FsClient.OpenFile(out FileHandle handle, idFilePath, OpenMode.Write); if (rc.IsFailure()) { return(rc); } bool fileAlreadyClosed = false; try { ulong lastId = LastPublishedId; rc = FsClient.WriteFile(handle, 0, SpanHelpers.AsByteSpan(ref lastId), WriteOption.None); if (rc.IsFailure()) { return(rc); } rc = FsClient.FlushFile(handle); if (rc.IsFailure()) { return(rc); } FsClient.CloseFile(handle); fileAlreadyClosed = true; return(FsClient.Commit(MountName)); } finally { if (!fileAlreadyClosed) { FsClient.CloseFile(handle); } } } finally { mount.Dispose(); } } }
public void FSUpdateDocument() { FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Green, "\n:: Update/Create a Document ::\n"); FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Yellow, "\nEnter Collection [cities]: "); string collectionId = Console.ReadLine(); if (collectionId == "") { collectionId = "cities"; } FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Yellow, "\nEnter Document Id: "); String docId = Console.ReadLine(); Document updatedDoc = GetDocument(docId, collectionId); MapField <string, Value> fields; if (updatedDoc == null) { FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Yellow, "\nDocument within " + collectionId + " does not exist, create it (y/n): "); String ynValue = Console.ReadLine(); if ((ynValue.ToLower() != "y") && (ynValue.ToLower() != "yes")) { FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Red, "\nDocument update aborted, returning"); return; } updatedDoc = new Document(); updatedDoc.Name = Parent + "/documents/" + collectionId + "/" + docId; fields = new MapField <string, Value>(); } else { FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.White, "\nAvailable fields in this document to update:\n"); Utils.ProcessFields(updatedDoc); fields = updatedDoc.Fields; } // update/create fields while (true) { FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Yellow, "\nEnter Field Name (blank when finished): "); string fieldName = Console.ReadLine(); if (fieldName != "") { FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Yellow, "\nEnter Field Value: "); string fieldInValue = Console.ReadLine(); // TODO must query for type and handle!!!! // TODO only handling string!!!! Value fieldValue = new Value(); fieldValue.StringValue = fieldInValue; if (fields.ContainsKey(fieldName)) { fields[fieldName].StringValue = fieldInValue; } else { fields.Add(fieldName, fieldValue); } } else { break; } } var updateDocumentRequest = new UpdateDocumentRequest(); updateDocumentRequest.Document = updatedDoc; Document returnDocument; try { returnDocument = FsClient.UpdateDocument(updateDocumentRequest); } catch (Exception e) { Console.WriteLine("{0} Exception caught.", e); } FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Green, "\nSuccessfully updated document!\n"); }
protected override Result DoSetSize(long size) { FileSize = InvalidSize; return(FsClient.SetFileSize(Handle, size)); }
protected override Result DoFlush() { return(FsClient.FlushFile(Handle)); }
public async Task FSWrite() { try { FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Green, "\n:: Streaming Writes to a Document ::\n"); FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.White, "\nEnter Document Id: "); String docId = Console.ReadLine(); FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Green, "\nStreaming writes to "); FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.White, docId); FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Green, "...\n"); Document updatedDoc = GetDocument(docId); MapField <string, Value> fields; if (updatedDoc == null) { updatedDoc = new Document(); updatedDoc.Name = Parent + "/documents/GrpcTestData/" + docId; fields = new MapField <string, Value>(); } else { FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.White, "\nAvailable fields in this document to update:\n"); Utils.ProcessFields(updatedDoc); fields = updatedDoc.Fields; } String streamId = ""; Google.Protobuf.ByteString streamToken = null; using (var writeCall = FsClient.Write()) { var writeRequest = new WriteRequest(); writeRequest.Database = Parent; await writeCall.RequestStream.WriteAsync(writeRequest); await writeCall.ResponseStream.MoveNext(); var responseStr = writeCall.ResponseStream.Current; streamId = responseStr.StreamId; streamToken = responseStr.StreamToken; var responseReaderTask = Task.Run(async() => { while (await writeCall.ResponseStream.MoveNext()) { var response = writeCall.ResponseStream.Current; var writeResults = response.WriteResults; foreach (var writeResult in writeResults) { FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.White, "\nWrite result:" + writeResult.ToString()); } } }); var currentWrite = new Write(); var docMask = new DocumentMask(); // update/create fields while (true) { FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.White, "\nEnter Field Name (blank when finished): "); string fieldName = Console.ReadLine(); if (fieldName == "") { break; } else { FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.White, "\nEnter Field Value: "); var fieldInValue = Console.ReadLine(); Utils.AddField(fields, fieldName, fieldInValue); docMask.FieldPaths.Add(fieldName); } } writeRequest.Database = Parent; currentWrite.Update = updatedDoc; currentWrite.UpdateMask = docMask; writeRequest.StreamId = streamId; writeRequest.StreamToken = streamToken; writeRequest.Writes.Add(currentWrite); await writeCall.RequestStream.WriteAsync(writeRequest); await writeCall.RequestStream.CompleteAsync(); await responseReaderTask; } } catch (Grpc.Core.RpcException e) { Console.WriteLine("RPC failed", e); throw; } FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Green, "\nSuccessfully streamed updates to the document!\n"); }
public async System.Threading.Tasks.Task FSRunQuery() { FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Green, "\n:: Running a query from Firestore... ::\n"); FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Yellow, "\nUSA Cities with populations larger than 1 millon\n"); var runQueryRequest = new RunQueryRequest(); runQueryRequest.Parent = "projects/mch-test-49bba/databases/(default)" + "/documents"; StructuredQuery sq = new StructuredQuery(); // just look at cities! var colSel = new StructuredQuery.Types.CollectionSelector(); colSel.CollectionId = "cities"; sq.From.Add(colSel); // only get USA cities with more than 1 million people // define USA filter StructuredQuery.Types.Filter countryFilter = new StructuredQuery.Types.Filter(); StructuredQuery.Types.FieldFilter fieldFilter = new StructuredQuery.Types.FieldFilter(); StructuredQuery.Types.FieldReference field = new StructuredQuery.Types.FieldReference { FieldPath = "country" }; fieldFilter.Field = field; fieldFilter.Op = StructuredQuery.Types.FieldFilter.Types.Operator.Equal; Value filterValue = new Value { StringValue = "USA" }; fieldFilter.Value = filterValue; countryFilter.FieldFilter = fieldFilter; // define 1 Million filer StructuredQuery.Types.Filter populationFilter = new StructuredQuery.Types.Filter(); fieldFilter = new StructuredQuery.Types.FieldFilter(); field = new StructuredQuery.Types.FieldReference { FieldPath = "population" }; fieldFilter.Field = field; fieldFilter.Op = StructuredQuery.Types.FieldFilter.Types.Operator.GreaterThanOrEqual; filterValue = new Value { IntegerValue = 1000000 }; fieldFilter.Value = filterValue; populationFilter.FieldFilter = fieldFilter; StructuredQuery.Types.CompositeFilter compositeFilter = new StructuredQuery.Types.CompositeFilter(); compositeFilter.Filters.Add(countryFilter); compositeFilter.Filters.Add(populationFilter); compositeFilter.Op = StructuredQuery.Types.CompositeFilter.Types.Operator.And; var where = new StructuredQuery.Types.Filter(); where.CompositeFilter = compositeFilter; sq.Where = where; runQueryRequest.StructuredQuery = sq; var select = new StructuredQuery.Types.Projection(); var fields = select.Fields; var fieldRef = new StructuredQuery.Types.FieldReference { FieldPath = "name" }; fields.Add(fieldRef); fieldRef = new StructuredQuery.Types.FieldReference { FieldPath = "population" }; fields.Add(fieldRef); sq.Select = select; var runQueryResponse = new RunQueryResponse(); try { var ret = FsClient.RunQuery(runQueryRequest); var responseStream = ret.ResponseStream; var cancellationToken = new System.Threading.CancellationToken(); while (await responseStream.MoveNext(cancellationToken)) { runQueryResponse = responseStream.Current; Utils.ReadDocument(runQueryResponse.Document); } } catch (Exception e) { Console.WriteLine("{0} Exception caught.", e); return; } FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Green, "\nFinished running query!\n"); }
public async System.Threading.Tasks.Task FSBatchGetDocuments() { FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Green, "\n:: Batch Retrieve Documents ::\n"); FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.White, "\nAvailable Docments:\n"); ListDocuments(); var batchGetDocumentsRequest = new BatchGetDocumentsRequest(); batchGetDocumentsRequest.Database = Parent; while (true) { FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Yellow, "\n\nEnter Collection [cities]: "); string collectionId = Console.ReadLine(); if (collectionId == "") { collectionId = "cities"; } FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Yellow, "\nEnter Document Name (blank when finished): "); string documentName = Console.ReadLine(); if (documentName != "") { Document doc = null; try { doc = GetDocument(documentName, collectionId); } catch (Grpc.Core.RpcException e) { if (e.Status.StatusCode == Grpc.Core.StatusCode.NotFound) { FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Red, "ERROR: Document " + documentName + " not found, ignoring ..."); } continue; } batchGetDocumentsRequest.Documents.Add(doc.Name); } else { break; } } var batchGetDocumentsResponse = new BatchGetDocumentsResponse(); try { var ret = FsClient.BatchGetDocuments(batchGetDocumentsRequest); var responseStream = ret.ResponseStream; var cancellationToken = new System.Threading.CancellationToken(); while (await responseStream.MoveNext(cancellationToken)) { batchGetDocumentsResponse = responseStream.Current; Utils.ReadDocument(batchGetDocumentsResponse.Found); } } catch (Exception e) { Console.WriteLine("{0} Exception caught.", e); return; } FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Green, "\nSuccessfully batch retrieved documents!\n"); }
public void Process() { if (Context.Options.OutDir == null) { Context.Logger.LogMessage("Output directory must be specified."); return; } var localFs = new LocalFileSystem(Context.Options.InFile); var outFs = new LocalFileSystem(Context.Options.OutDir); FsClient.Register("search".ToU8Span(), localFs); FsClient.Register("out".ToU8Span(), outFs); IEnumerable <DirectoryEntryEx> entries = FsClient.EnumerateEntries("search:/", "*.xci", SearchOptions.CaseInsensitive | SearchOptions.RecurseSubdirectories) .Concat(FsClient.EnumerateEntries("search:/", "*.nsp", SearchOptions.CaseInsensitive | SearchOptions.RecurseSubdirectories)) .Concat(FsClient.EnumerateEntries("search:/", "*.nca", SearchOptions.CaseInsensitive | SearchOptions.RecurseSubdirectories)) .Concat(FsClient.EnumerateEntries("search:/", "*.nso", SearchOptions.CaseInsensitive | SearchOptions.RecurseSubdirectories)); { foreach (DirectoryEntryEx entry in entries) { try { Context.Logger.LogMessage(entry.FullPath); string extension = Path.GetExtension(entry.Name); if (extension.ToLower() == ".xci") { ProcessXci(entry.FullPath); } else if (extension.ToLower() == ".nsp") { ProcessNsp(entry.FullPath); } else if (extension.ToLower() == ".nca") { ProcessNcaFile(entry.FullPath); } else if (extension.ToLower() == ".nso") { string parentDirectory = PathTools.GetParentDirectory(entry.FullPath); // Don't process sets multiple times if (LooseNsoSetsProcessed.Contains(parentDirectory)) { continue; } if (IsNsoSetDirectory(parentDirectory)) { ProcessNsoSetDirectory(parentDirectory); LooseNsoSetsProcessed.Add(parentDirectory); } else { ProcessNso(entry.FullPath); } } } catch (Exception ex) { Console.WriteLine($"Error processing {entry.FullPath}"); Console.WriteLine(ex); } } } CalculateVersions(); RenameOutput(); FsClient.Unmount("search"); FsClient.Unmount("out"); }
public void FSCreateDocument() { FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Green, "\n:: Creating a new Document ::\n"); FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Yellow, "\nEnter Collection [cities]: "); string collectionId = Console.ReadLine(); if (collectionId == "") { collectionId = "cities"; } FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Yellow, "\nEnter Document: "); var docId = Console.ReadLine(); var createDocRequest = new CreateDocumentRequest(); createDocRequest.Parent = Parent; createDocRequest.DocumentId = docId; createDocRequest.CollectionId = collectionId; var fsDocument = new Document(); createDocRequest.Document = fsDocument; try { fsDocument = FsClient.CreateDocument(createDocRequest); } catch (Grpc.Core.RpcException e) { Grpc.Core.Status stat = e.Status; if (stat.StatusCode == Grpc.Core.StatusCode.AlreadyExists) { FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Red, "\nDocument already exists."); } FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Yellow, "\n" + stat.Detail); } catch (Exception e) { Console.WriteLine("{0} Exception caught.", e); } // get the document to ensure it was created Document retDoc; try { retDoc = GetDocument(docId, collectionId); } catch (Grpc.Core.RpcException e) { if (e.Status.StatusCode == Grpc.Core.StatusCode.NotFound) { FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Red, "\nDocument was not added."); } FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Red, "\n" + e.Status.Detail); return; } catch (Exception e) { Console.WriteLine("{0} Exception caught.", e); return; } FirestoreTestUtils.ColoredConsoleWrite(ConsoleColor.Green, "\nSuccessfully created new document!\nName:" + retDoc.Name + "\n"); }