Example #1
0
        public static void PrintWordDoc(YellowstonePathology.Business.OrderIdParser orderIdParser)
        {
            Microsoft.Office.Interop.Word.Application oWord;
            Object oMissing = System.Reflection.Missing.Value;
            Object oTrue    = true;
            Object oFalse   = false;
            Object oCopies  = 1;

            oWord = new Microsoft.Office.Interop.Word.Application();
            string currentPrinter = oWord.ActivePrinter;

            oWord.Visible = false;

            Object oFile = CaseDocument.GetCaseFileNameDoc(orderIdParser);

            Microsoft.Office.Interop.Word.Document doc = oWord.Documents.Open(ref oFile, ref oMissing, ref oMissing,
                                                                              ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                                                                              ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);

            doc.PrintOut(ref oFalse, ref oMissing, ref oMissing, ref oMissing,
                         ref oMissing, ref oMissing, ref oMissing, ref oCopies, ref oMissing, ref oMissing, ref oFalse,
                         ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);

            CaseDocument.ReleaseComObject(doc);
            oWord.ActivePrinter = currentPrinter;
            oWord.Quit(ref oFalse, ref oMissing, ref oMissing);
            CaseDocument.ReleaseComObject(oWord);
        }
Example #2
0
 public void CreateFileScript(Document.CaseDocument caseDocument)
 {
     using (StreamWriter streamWriter = new StreamWriter(this.m_BatchFileName))
     {
         streamWriter.WriteLine("put " + caseDocument.FullFileName + " " + caseDocument.FileName);
         streamWriter.WriteLine("quit");
     }
 }
Example #3
0
        public void SaveReport()
        {
            switch (this.m_ReportSaveMode)
            {
            case YellowstonePathology.Business.Document.ReportSaveModeEnum.Normal:
                this.m_ReportXml.Save(this.m_SaveFileName);
                YellowstonePathology.Business.OrderIdParser orderIdParser = new YellowstonePathology.Business.OrderIdParser(this.m_PanelSetOrder.ReportNo);
                CaseDocument.SaveXMLAsDoc(orderIdParser);
                CaseDocument.SaveDocAsXPS(orderIdParser);
                break;

            case YellowstonePathology.Business.Document.ReportSaveModeEnum.Test:
            case YellowstonePathology.Business.Document.ReportSaveModeEnum.Draft:
                this.m_ReportXml.Save(this.m_SaveFileName);
                break;
            }
        }
Example #4
0
        public static int WriteTiffPages(YellowstonePathology.Business.OrderIdParser orderIdParser, long reportDistributionLogId)
        {
            Microsoft.Office.Interop.Word.Application oWord;
            Object oMissing = System.Reflection.Missing.Value;
            Object oTrue    = true;
            Object oFalse   = false;

            oWord         = new Microsoft.Office.Interop.Word.Application();
            oWord.Visible = true;

            string currentPrinter = oWord.ActivePrinter;

            oWord.ActivePrinter = "Microsoft Office Document Image Writer";

            Object docFileName = YellowstonePathology.Document.CaseDocumentPath.GetPath(orderIdParser) + orderIdParser.ReportNo + ".doc";
            Object fileFormat  = "wdFormatDocument";

            Microsoft.Office.Interop.Word.Document doc = oWord.Documents.Open(ref docFileName, ref oMissing, ref oMissing,
                                                                              ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                                                                              ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);

            object oOutputFile;
            object oPages;
            object oRange = Microsoft.Office.Interop.Word.WdPrintOutRange.wdPrintRangeOfPages;

            int pages = doc.ComputeStatistics(Microsoft.Office.Interop.Word.WdStatistic.wdStatisticPages, ref oTrue);

            for (int i = 1; i <= pages; i++)
            {
                oPages      = i.ToString();
                oOutputFile = YellowstonePathology.Document.CaseDocumentPath.GetPath(orderIdParser) + @"Centricity\" + reportDistributionLogId.ToString() + "." + i.ToString().PadLeft(3, '0');
                doc.PrintOut(ref oFalse, ref oFalse, ref oRange, ref oOutputFile, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oPages, ref oMissing,
                             ref oTrue, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
            }

            oWord.ActivePrinter = currentPrinter;

            CaseDocument.ReleaseComObject(oRange);
            CaseDocument.ReleaseComObject(doc);
            oWord.Quit(ref oFalse, ref oMissing, ref oMissing);
            CaseDocument.ReleaseComObject(oWord);

            return(pages);
        }
Example #5
0
        public void OpenTemplate()
        {
            this.m_ReportXml.Load(this.m_TemplateName);
            YellowstonePathology.Business.OrderIdParser orderIdParser = new YellowstonePathology.Business.OrderIdParser(this.m_PanelSetOrder.ReportNo);
            switch (this.m_ReportSaveMode)
            {
            case ReportSaveModeEnum.Draft:
                this.m_SaveFileName = CaseDocument.GetSaveDraftDocumentFilePath(orderIdParser);
                break;

            case ReportSaveModeEnum.Normal:
                this.m_SaveFileName = YellowstonePathology.Document.CaseDocumentPath.GetPath(orderIdParser) + this.m_PanelSetOrder.ReportNo + ".xml";
                break;

            case ReportSaveModeEnum.Test:
                this.m_SaveFileName = @"c:\test.xml";
                break;
            }
        }
Example #6
0
        public static CaseDocument GetCaseDocument(YellowstonePathology.Business.Test.AccessionOrder accessionOrder, string fileName)
        {
            CaseDocument caseDocument = null;

            if (!string.IsNullOrEmpty(fileName))
            {
                string[] slashSplit = fileName.Split('\\');
                string   fileOnly   = slashSplit[slashSplit.Length - 1];
                string[] dotSplit   = fileOnly.Split('.');
                string   extension  = dotSplit[dotSplit.Length - 1];

                switch (extension.ToUpper())
                {
                case "TIF":
                    caseDocument = new TifDocument();
                    break;

                case "JPG":
                case "JPEG":
                    caseDocument = new JpgDocument();
                    break;

                case "DOC":
                    caseDocument = new WordDocDocument();
                    break;

                case "PDF":
                    caseDocument = new PdfDocument();
                    break;

                case "XPS":
                    caseDocument = new XpsCaseDocument();
                    break;

                default:
                    caseDocument = new CaseDocument();
                    break;
                }
            }

            return(caseDocument);
        }
Example #7
0
        public static void SaveDOCXAsDoc(YellowstonePathology.Business.OrderIdParser orderIdParser)
        {
            Microsoft.Office.Interop.Word.Application oWord;
            Object oMissing = System.Reflection.Missing.Value;
            Object oTrue    = true;
            Object oFalse   = false;

            oWord         = new Microsoft.Office.Interop.Word.Application();
            oWord.Visible = false;

            Object xmlFileName = YellowstonePathology.Document.CaseDocumentPath.GetPath(orderIdParser) + orderIdParser.ReportNo + ".docx";
            Object docFileName = YellowstonePathology.Document.CaseDocumentPath.GetPath(orderIdParser) + orderIdParser.ReportNo + ".doc";

            try
            {
                File.Delete(docFileName.ToString());
            }
            catch (Exception)
            {
                //System.Windows.MessageBox.Show("This file is locked and cannot be published at this time: " + reportNo);
                oWord.Quit(ref oFalse, ref oMissing, ref oMissing);
            }

            Object fileFormat = "wdFormatDocument";

            Microsoft.Office.Interop.Word.Document doc = oWord.Documents.Open(ref xmlFileName, ref oMissing, ref oMissing,
                                                                              ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                                                                              ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);

            object oFmt = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatDocument;

            doc.SaveAs(ref docFileName, ref oFmt, ref oMissing, ref oMissing, ref oMissing,
                       ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                       ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);

            CaseDocument.ReleaseComObject(oFmt);
            CaseDocument.ReleaseComObject(doc);
            oWord.Quit(ref oFalse, ref oMissing, ref oMissing);
            CaseDocument.ReleaseComObject(oWord);
        }
Example #8
0
        public static void SaveXMLAsDocFromFileName(string fileName)
        {
            Microsoft.Office.Interop.Word.Application oWord;
            Object oMissing = System.Reflection.Missing.Value;
            Object oTrue    = true;
            Object oFalse   = false;

            oWord         = new Microsoft.Office.Interop.Word.Application();
            oWord.Visible = false;

            Object xmlFileName = fileName;
            Object docFileName = fileName.ToUpper().Replace("XML", "DOC");

            try
            {
                File.Delete(docFileName.ToString());
            }
            catch (Exception)
            {
                //System.Windows.MessageBox.Show("This file is locked and cannot be published at this time: " + reportNo);
                oWord.Quit(ref oFalse, ref oMissing, ref oMissing);
            }

            Object fileFormat = "wdFormatDocument";

            Microsoft.Office.Interop.Word.Document doc = oWord.Documents.Open(ref xmlFileName, ref oMissing, ref oMissing,
                                                                              ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                                                                              ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);

            object oFmt = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatDocument;

            doc.SaveAs(ref docFileName, ref oFmt, ref oMissing, ref oMissing, ref oMissing,
                       ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                       ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);

            CaseDocument.ReleaseComObject(oFmt);
            CaseDocument.ReleaseComObject(doc);
            oWord.Quit(ref oFalse, ref oMissing, ref oMissing);
            CaseDocument.ReleaseComObject(oWord);
        }
Example #9
0
        public static void SaveDocAsXPS(YellowstonePathology.Business.OrderIdParser orderIdParser)
        {
            Microsoft.Office.Interop.Word.Application oWord;
            Object oMissing = System.Reflection.Missing.Value;
            Object oTrue    = true;
            Object oFalse   = false;

            oWord         = new Microsoft.Office.Interop.Word.Application();
            oWord.Visible = false;

            string currentPrinter = oWord.ActivePrinter;

            oWord.ActivePrinter = "Microsoft XPS Document Writer";

            Object docFileName = YellowstonePathology.Document.CaseDocumentPath.GetPath(orderIdParser) + orderIdParser.ReportNo + ".doc";
            Object xpsFileName = YellowstonePathology.Document.CaseDocumentPath.GetPath(orderIdParser) + orderIdParser.ReportNo + ".xps";

            Object fileFormat = "wdFormatDocument";

            if (System.IO.File.Exists(docFileName.ToString()) == true)
            {
                Microsoft.Office.Interop.Word.Document doc = oWord.Documents.Open(ref docFileName, ref oMissing, ref oMissing,
                                                                                  ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                                                                                  ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);

                object oOutputFile = xpsFileName;
                doc.PrintOut(ref oFalse, ref oFalse, ref oMissing, ref oOutputFile, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                             ref oTrue, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);

                CaseDocument.ReleaseComObject(doc);
            }

            oWord.ActivePrinter = currentPrinter;
            oWord.Quit(ref oFalse, ref oMissing, ref oMissing);
            CaseDocument.ReleaseComObject(oWord);
        }
        public static CaseDocument GetCaseDocument(YellowstonePathology.Business.Test.AccessionOrder accessionOrder, string fileName)
        {
            CaseDocument caseDocument = null;
            if(!string.IsNullOrEmpty(fileName))
            {
                string[] slashSplit = fileName.Split('\\');
                string fileOnly = slashSplit[slashSplit.Length - 1];
                string[] dotSplit = fileOnly.Split('.');
                string extension = dotSplit[dotSplit.Length - 1];

                switch (extension.ToUpper())
                {
                    case "TIF":
                        caseDocument = new TifDocument();
                        break;
                    case "JPG":
                    case "JPEG":
                        caseDocument = new JpgDocument();
                        break;
                    case "DOC":
                        caseDocument = new WordDocDocument();
                        break;
                    case "PDF":
                        caseDocument = new PdfDocument();
                        break;
                    case "XPS":
                        caseDocument = new XpsCaseDocument();
                        break;
                    default:
                        caseDocument = new CaseDocument();
                        break;
                }
            }

            return caseDocument;
        }