Example #1
0
        // Writes query results to report template. Results are written to tables with name matching query jobId.
        public void WriteToDoc(string fileName, List <QueryClass> queryList, string reportFileName)
        {
            Application wordApp   = new Application();
            Documents   documents = wordApp.Documents;
            Document    document  = documents.Open(fileName);

            Tables tables = document.Tables;

            foreach (QueryClass q in queryList)
            {
                string tableName = "tbl_" + q.JobId;
                Console.WriteLine("table: " + tableName);
                Table table = getTable(tableName, tables);
                if (table != null && q.JobEnabled.Equals("1"))
                {
                    table.Columns[2].Cells[3].Range.Text = q.Result.Replace("\r\n", "\v");
                }
            }

            if (String.IsNullOrEmpty(reportFileName))
            {
                reportFileName = @"C:\developer\c#\kdrs_query\KDRS_Query\doc\testReport.docx";
            }

            document.SaveAs2(reportFileName);

            documents.Close();

            wordApp.Quit();
        }
        public void Documents__Close__Should_Success()
        {
            SetSandboxUrl();
            var docId         = _docs.FindAll()[0].Id;
            var closeDocument = _docs.Close(docId);

            Assert.IsTrue(closeDocument.Success);
        }
Example #3
0
        public int CloseSaleOrder(string pStrRequestId)
        {
            Documents lObjSaleOrder = null;

            try {
                lObjSaleOrder = GetSaleOrderByRequestId(pStrRequestId);
                return(lObjSaleOrder.Close());
            }
            catch (Exception lObjException) {
                throw new DAOException(lObjException.Message, lObjException);
            }
            finally {
                MemoryUtility.ReleaseComObject(lObjSaleOrder);
            }
        }
        public OfficePropertyItem GetProperties()
        {
            DocumentProperties returnValue = null;

            try
            {
                _application         = new Application();
                _application.Visible = false;
                _documents           = _application.Documents;
                _document            = _documents.Open(Path.GetFullPath(FileNameFullPath));
                returnValue          = _document.BuiltInDocumentProperties;
                _document.Close();
                _documents.Close();
                _documents   = null;
                _application = null;
                return(returnValue);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #5
0
 public void LoadnewSalesOrder(Documents.SalesOrder sopenSalesOrder)
 {
     sopenSalesOrder.Close();
     salesOrderToolStripMenuItem_Click(null, null);
 }
Example #6
0
 public void LoadnewSupplDoc(Documents.SupplierDocuments sopenSupplDoc, string sCurrDocType)
 {
     sopenSupplDoc.Close();
     LoadSupplDoc(sCurrDocType);
 }
Example #7
0
 private static void CloseDocuments(Documents documents)
 {
     documents.Close(SaveChanges: WdSaveOptions.wdDoNotSaveChanges);
 }