예제 #1
0
        public override void Execute(WorkItem workItem)
        {
            try
            {
                m_workItem = workItem;
                DocumentText dtCheck;
                switch (workItem.Extension)
                {
                    case "doc":
                        WordDocumentReader wrdRdr = new WordDocumentReader(workItem.BaseFileName);
                        try
                        {
                            dtCheck = wrdRdr.Read();
                        }
                        catch (Exception)
                        {
                            return; // failed to discover source document
                        }
                        CompareDiscoveryForDoc(workItem.BaseFileName, workItem.DiscoveredText, dtCheck);
                        break;

                    case "ppt":
                        PptDocumentReader pptRdr = new PptDocumentReader(workItem.BaseFileName);
                        try
                        {
                            dtCheck = pptRdr.Read();
                        }
                        catch (Exception)
                        {
                            return; // failed to discover source document
                        }
                        CompareDiscoveryForPpt(workItem.BaseFileName, workItem.DiscoveredText, dtCheck);
                        break;

                    case "xls":
                        ExcelDocumentReader xlsRdr = new ExcelDocumentReader(workItem.BaseFileName);
                        try
                        {
                            dtCheck = xlsRdr.Read();
                        }
                        catch (Exception)
                        {
                            return; // failed to discover source document
                        }
                        CompareDiscoveryForXls(workItem.BaseFileName, workItem.DiscoveredText, dtCheck);
                        break;

                    default:
                        throw new Exception("File extension not expected : " + workItem.Extension);
                }
            }
            catch (Exception e)
            {
                workItem.FailureMode = FailureMode.DiscoveryMismatch;
                throw e;
            }
        }
        public override bool VerifyFile(TempFileForActions tempFile)
        {
            try
            {
                using (PptDocumentReader reader = new PptDocumentReader(tempFile.TempFile, true))
                {
                    reader.Read();
                    return true;
                }
            }
            catch (System.Exception ex)
            {
                Logger.LogError("PowerPoint Verification failed");
				Logger.LogError(ex);
            }
            return false;
        }
		DocumentText DiscoverDocument(string sFilename)
		{
			switch (m_ft)
			{
				case Workshare.Policy.FileType.WordDocument:
					using (WordDocumentReader Word2003Reader1 = new WordDocumentReader(sFilename, false))
					{
						return Word2003Reader1.Read();
					}

				case Workshare.Policy.FileType.ExcelSheet:
					using (ExcelDocumentReader Excel2003Reader1 = new ExcelDocumentReader(sFilename, false))
					{
						return Excel2003Reader1.Read();
					}

				case Workshare.Policy.FileType.PowerPoint:
					using (Workshare.FCS.Lite.PptDocumentReader Ppt2003Reader1 = new PptDocumentReader(sFilename, false))
					{
						return Ppt2003Reader1.Read();
					}

				case Workshare.Policy.FileType.WordDocumentX:
				case Workshare.Policy.FileType.WordDocumentMacroX:
				case Workshare.Policy.FileType.WordDocumentTemplateX:
				case Workshare.Policy.FileType.WordDocumentMacroTemplateX:
					using (DocxDocumentReader Word2007Reader1 = new DocxDocumentReader(sFilename))
					{
						return Word2007Reader1.Read();
					}

				case Workshare.Policy.FileType.ExcelSheetX:
				case Workshare.Policy.FileType.ExcelSheetMacroX:
				case Workshare.Policy.FileType.ExcelSheetTemplateX:
				case Workshare.Policy.FileType.ExcelSheetMacroTemplateX:
					using (XlsxDocumentReader Excel2007Reader1 = new XlsxDocumentReader(sFilename))
					{
						return Excel2007Reader1.Read();
					}

				case Workshare.Policy.FileType.PowerPointX:
				case Workshare.Policy.FileType.PowerPointMacroX:
				case Workshare.Policy.FileType.PowerPointTemplateX:
				case Workshare.Policy.FileType.PowerPointMacroTemplateX:
				case Workshare.Policy.FileType.PowerPointShowX:
				case Workshare.Policy.FileType.PowerPointMacroShowX:
					using (PptxDocumentReader Ppt2007Reader1 = new PptxDocumentReader(sFilename))
					{
						return Ppt2007Reader1.Read();
					}
				default:
					break;
			}
			return null;
		}
예제 #4
0
        public DocumentText DiscoverDocument(string sFilename)
        {
            switch (m_ft)
            {
                case Workshare.Policy.FileType.WordDocument:
                    using (WordDocumentReader Word2003Reader1 = new WordDocumentReader(sFilename, false))
                    {
                        return Word2003Reader1.Read();
                    }

                case Workshare.Policy.FileType.ExcelSheet:
                    using (ExcelDocumentReader Excel2003Reader1 = new ExcelDocumentReader(sFilename, false))
                    {
                        return Excel2003Reader1.Read();
                    }

                case Workshare.Policy.FileType.PowerPoint:
                    using (Workshare.FCS.Lite.PptDocumentReader Ppt2003Reader1 = new PptDocumentReader(sFilename, false))
                    {
                        return Ppt2003Reader1.Read();
                    }

                default:
                    break;
            }
            return null;
        }