public void GetTemplateThumbnailsTest()
        {
            try
            {
                ReportingCloud rc = new ReportingCloud(sUsername, sPassword, uriBasePath);

                // upload 1 more document with unique file name
                byte[] bDocument     = File.ReadAllBytes("documents/invoice.tx");
                string sTempFilename = "test" + Guid.NewGuid().ToString() + ".tx";
                rc.UploadTemplate(sTempFilename, bDocument);

                // create thumbnails
                List <string> images = rc.GetTemplateThumbnails(sTempFilename, 20, 1, 1, ImageFormat.PNG);

                // check, if images are created
                Assert.IsFalse((images.Count == 0));

                // delete temp file
                rc.DeleteTemplate(sTempFilename);
            }
            catch (Exception exc)
            {
                Assert.Fail(exc.Message);
            }
        }
        public void GetTemplateCountTest()
        {
            try
            {
                ReportingCloud rc = new ReportingCloud(sUsername, sPassword, uriBasePath);

                // store current template number
                int iTemplateCount = rc.GetTemplateCount();

                // upload 1 more document with unique file name
                byte[] bDocument     = File.ReadAllBytes("documents/invoice.tx");
                string sTempFilename = "test" + Guid.NewGuid().ToString() + ".tx";
                rc.UploadTemplate(sTempFilename, bDocument);

                // check, if the count went up
                Assert.AreEqual(iTemplateCount + 1, rc.GetTemplateCount());

                // delete temp document
                rc.DeleteTemplate(sTempFilename);
            }
            catch (Exception exc)
            {
                Assert.Fail(exc.Message);
            }
        }
        public void GetTemplateInfoTest()
        {
            try
            {
                ReportingCloud rc = new ReportingCloud(sUsername, sPassword, uriBasePath);

                // upload 1 more document with unique file name
                byte[] bDocument     = File.ReadAllBytes("documents/test.doc");
                string sTempFilename = "test" + Guid.NewGuid().ToString() + ".doc";
                rc.UploadTemplate(sTempFilename, bDocument);

                // get template information
                TemplateInfo templateInfo = rc.GetTemplateInfo(sTempFilename);

                // check, if images are created
                Assert.IsFalse(templateInfo.TemplateName == "");

                // delete temp file
                rc.DeleteTemplate(sTempFilename);
            }
            catch (Exception exc)
            {
                Assert.Fail(exc.Message);
            }
        }
        public void FindAndReplaceDocumentTest()
        {
            try
            {
                ReportingCloud rc = new ReportingCloud(sUsername, sPassword, uriBasePath);

                // upload 1 more document with unique file name
                byte[] bDocument     = File.ReadAllBytes("documents/replace_template.tx");
                string sTempFilename = "test" + Guid.NewGuid().ToString() + ".tx";
                rc.UploadTemplate(sTempFilename, bDocument);

                // create a new FindAndReplaceBody object
                FindAndReplaceBody body = new FindAndReplaceBody();
                body.FindAndReplaceData = new List <string[]>()
                {
                    new string[] { "%%TextToReplace%%", "ReplacedString" },
                    new string[] { "%%SecondTextToReplace%%", "ReplacedString2" }
                };

                // merge the document
                byte[] results = rc.FindAndReplaceDocument(body, sTempFilename, ReturnFormat.HTML);

                string bHtmlDocument = System.Text.Encoding.UTF8.GetString(results);

                // check whether the created HTML contains the test string
                Assert.IsTrue(bHtmlDocument.Contains("ReplacedString"));

                // delete the template
                rc.DeleteTemplate(sTempFilename);
            }
            catch (Exception exc)
            {
                Assert.Fail(exc.Message);
            }
        }
        public void DeleteTemplateTest()
        {
            try
            {
                ReportingCloud rc = new ReportingCloud(sUsername, sPassword, uriBasePath);

                // upload test document
                byte[] bDocument     = File.ReadAllBytes("documents/invoice.tx");
                string sTempFilename = "test" + Guid.NewGuid().ToString() + ".tx";
                rc.UploadTemplate(sTempFilename, bDocument);

                if (rc.TemplateExists(sTempFilename) == true)
                {
                    // delete template
                    rc.DeleteTemplate(sTempFilename);

                    // check, if template has been deleted
                    Assert.IsFalse(rc.TemplateExists(sTempFilename), "Template is not deleted.");
                }
            }
            catch (Exception exc)
            {
                Assert.Fail(exc.Message);
            }
        }
        public void MergeDocumentTest()
        {
            try
            {
                ReportingCloud rc = new ReportingCloud(sUsername, sPassword, uriBasePath);

                // upload 1 more document with unique file name
                byte[] bDocument     = File.ReadAllBytes("documents/invoice.tx");
                string sTempFilename = "test" + Guid.NewGuid().ToString() + ".tx";
                rc.UploadTemplate(sTempFilename, bDocument);

                List <Invoice> invoices = new List <Invoice>();

                // create dummy data
                Invoice invoice = new Invoice();
                invoice.yourcompany_companyname = "Text Control, LLC";
                invoice.invoice_no  = "Test_R667663";
                invoice.billto_name = "<html><strong>Test</strong> <em>Company</em></html>";

                Invoice invoice2 = new Invoice();
                invoice2.yourcompany_companyname = "Text Control 2, LLC";
                invoice2.invoice_no  = "Test_R667663";
                invoice2.billto_name = "<html><strong>Test</strong> <em>Company</em></html>";

                invoices.Add(invoice);
                invoices.Add(invoice2);

                // create a new MergeBody object
                MergeBody body = new MergeBody();
                body.MergeData = invoices;

                MergeSettings settings = new MergeSettings();
                settings.Author    = "Text Control GmbH";
                settings.MergeHtml = true;
                settings.Culture   = "de-DE";

                body.MergeSettings = settings;

                // merge the document
                List <byte[]> results = rc.MergeDocument(body, sTempFilename, ReturnFormat.HTML, false, false);

                string bHtmlDocument = System.Text.Encoding.UTF8.GetString(results[0]);

                // check whether the created HTML contains the test string
                Assert.IsTrue(bHtmlDocument.Contains("Test_R667663"));

                // delete the template
                rc.DeleteTemplate(sTempFilename);
            }
            catch (Exception exc)
            {
                Assert.Fail(exc.Message);
            }
        }
        public void UploadTemplateTest()
        {
            try
            {
                ReportingCloud rc = new ReportingCloud(sUsername, sPassword, uriBasePath);

                // upload 1 more document with unique file name
                byte[] bDocument     = File.ReadAllBytes("documents/invoice.tx");
                string sTempFilename = "test" + Guid.NewGuid().ToString() + ".tx";
                rc.UploadTemplate(sTempFilename, bDocument);

                // template exists?
                Assert.IsTrue(rc.TemplateExists(sTempFilename), "Template doesn't exist");

                rc.DeleteTemplate(sTempFilename);
            }
            catch (Exception exc)
            {
                Assert.Fail(exc.Message);
            }
        }
        public void DownloadTemplateTest()
        {
            try
            {
                ReportingCloud rc = new ReportingCloud(sUsername, sPassword, uriBasePath);

                // upload local test document
                byte[] bDocument     = File.ReadAllBytes("documents/invoice.tx");
                string sTempFilename = "test" + Guid.NewGuid().ToString() + ".tx";
                rc.UploadTemplate(sTempFilename, bDocument);

                // download document
                byte[] bTemplate = rc.DownloadTemplate(sTempFilename);

                // compare documents
                Assert.IsNotNull(bTemplate);

                rc.DeleteTemplate(sTempFilename);
            }
            catch (Exception exc)
            {
                Assert.Fail(exc.Message);
            }
        }