Archive Documents |
Scroll |
Archiving is the process of adding new documents to the Thereforeā¢ system. The Step By Step guide below explains how to create a new document, add streams, edit index data values and store the document on the server.
1 |
Connect to the Thereforeā¢ server (see "Server - Connect and Disconnect" for Details) |
2 |
Declare and initialize a new TheDocument instance. |
3 |
Create a temporary file. |
4 |
Set the Thereforeā¢ category for the document's IndexData. 4A. Set the category by number or 4B. Set the category by name |
5 |
Add one or more file streams to the document. |
6 |
Set some values in the document's IndexData. |
7 |
Archive the document on the server. |
8 |
Close the TheDocument and delete the temporary file. |
9 |
Optional. Print a success message on the console. |
Requirements and Assumptions: Category number 5 named "Invoice - Supplier" with the string fields "Filename", "FileType" and "InvoiceNo" and the money (decimal) fields "AmountNet" and "AmountVAT". Files "D:\\TestAll\\TestDocs\\Scsi.doc" and "D:\\TestAll\\TestDocs\\TEST.xls" on your local hard drive. If these assumptions do not apply to your system or configuration please replace them with appropriate values when copying the code samples below. Visual Basic Imports Therefore.API '...
' 1. Connect to the Thereforeā¢ Server Dim server As New TheServer server.Connect(TheClientType.CustomApplication)
' 2. Create a new Thereforeā¢ Document Dim doc As New TheDocument
' 3. Create temporary File Dim filename As String = "" doc.Create(filename)
' 4A. Set Thereforeā¢ Category by Number doc.IndexData.SetCategory(5, server)
' or 4B. Set Thereforeā¢ Category by Name ' doc.IndexData.SetCategory("Invoice - Supplier", server)
' 5. Add streams doc.AddStream("D:\\TestAll\\TestDocs\\Scsi.doc", "", 0) doc.AddStream("D:\\TestAll\\TestDocs\\TEST.xls", "", 0)
' 6. Set index data Dim indexData As TheIndexData = doc.IndexData indexData("Filename") = "Scsi.doc" indexData("FileType") = "MS Word" indexData("InvoiceNo") = "17" indexData("AmountNet") = 500.00 indexData("AmountVAT") = 550.00
' 7. Archive the document Dim docNo As Integer = doc.Archive(server,0)
' 8. Close Thereforeā¢ document object doc.Close()
' 9. Delete the temporary file System.IO.File.Delete(filename)
' 10. Optional: Print a success message on the console Console.WriteLine("Document successfully archived as " _ + docNo.ToString() + ".") C# using Therefore.API; //...
// 1. Connect to the Thereforeā¢ Server TheServer server = new TheServer(); server.Connect(TheClientType.CustomApplication);
// 2. Create a new Thereforeā¢ Document TheDocument doc = new TheDocument();
// 3. Create temporary File string filename = ""; doc.Create(ref filename);
// 4A. Set Thereforeā¢ Category by Number doc.IndexData.SetCategory(5, server);
// or 4B. Set Thereforeā¢ Category by Name // doc.IndexData.SetCategory("Invoice - Supplier", server);
// 5. Add streams doc.AddStream("D:\\TestAll\\TestDocs\\Scsi.doc", "", 0); doc.AddStream("D:\\TestAll\\TestDocs\\TEST.xls", "", 0);
// 6. Set index data TheIndexData indexData = doc.IndexData; indexData["Filename"] = "Scsi.doc"; indexData["FileType"] = "MS Word"; indexData["InvoiceNo"] = "17"; indexData["AmountNet"] = 500.00; indexData["AmountVAT"] = 550.00;
// 7. Archive the document int nDocNo = doc.Archive(server, 0);
// 8. Close Thereforeā¢ document object and delete the temporary file doc.Dispose();
// 9. Optional: Print a success message on the console Console.WriteLine("Document successfully archived as " + docNo.ToString() + "."); |