コード例 #1
0
        public void TestDocumentTracking()
        {
            var filenames = new List<string>()
                { 
                    "SupportsCleaning.doc",
                    "5DocStats2BuiltInProps.docx",
                    "హాయ్ .docx",
                    "SmallTextComplexDocument.doc",
                    "small.doc",
                    "final.docx",
                    "15Footnotes1Field5DocStats2BuiltInProps.docx"
                };

            filenames.ForEach(delegate(string x)
                {
                    var id = String.Empty;
                    try
                    {
                        var lcfm = new LocalCopyOfFileManager();
                        var sourceFile = Path.Combine(TestRoot, x);
                        Assert.IsTrue(File.Exists(sourceFile), String.Format("File does not exist [{0}]", sourceFile));

                        var testFile = lcfm.GetLocalCopyOfFileTarget(x);
                        File.Copy(sourceFile, testFile, true);
                        Assert.IsTrue(File.Exists(testFile), String.Format("File does not exist [{0}]", testFile));

                        var attachment = new ProtectAttachment(FcsFileFactory.Create(testFile, x));

                        var readyRedlineTask = new TaskReadyRedline(attachment);
                        readyRedlineTask.Execute(new CancellationToken());

                        var intelligentDocument = new IntelligentDocument();
                        intelligentDocument.SetFileName(attachment.FileName);
                        Assert.IsTrue(intelligentDocument.IsDocumentBeingTracked(), String.Format("Failed to add tracking id to test file [{0}]", x));
                        
                        id = intelligentDocument.GetDocumentTrackingId();
                        Assert.IsFalse(String.IsNullOrEmpty(id), String.Format("Failed to get tracking id for test file [{0}]", x));
                        Assert.IsFalse(String.IsNullOrEmpty(GetDocumentChecksum(id)), String.Format("Failed to get checksum for test file [{0}]", x));
                    }
                    finally
                    {
                        DeleteEntry(id);
                    }
                });
        }
コード例 #2
0
ファイル: MailAttachment.cs プロジェクト: killbug2004/WSProf
		private void LoadDocumentProperties(Redemption.Attachment _attachment)
        {
            try
            {
                if (_size > 0) // This is needed as 0 byte .doc files have no custom property storage.
                {
					Logger.LogInfo(string.Format("Loading .... {0}", _displayName));
                    string tempfile = Utils.GetTempFile(System.IO.Path.GetExtension(_fileName));
                    _attachment.SaveAsFile(tempfile);
                    var idoc = new IntelligentDocument();
                    idoc.SetFileName(tempfile);
                    if (idoc.IsDocumentBeingTracked())
                    {
						_checkSum = idoc.CalculateDocumentChecksum();
                        _trackingId = idoc.GetDocumentTrackingId();
                        _isModified = idoc.IsDocumentModified();
                    }
                    else
                    {
                        // set the tracking id to an unique value to ensure that it isn't discovered during the 
                        // comparison stage
                        _trackingId = Guid.NewGuid().ToString();
                    }
                    
                    Utils.SafeDeleteFile(tempfile);
                }
            }
            catch (System.Exception e)
            {
                Logger.LogError(e);
            }
        }
コード例 #3
0
		private void AddTrackingInfo(string tempfile)
		{
			var intelligentDocument = new IntelligentDocument();
            intelligentDocument.SetFileName(tempfile);
			intelligentDocument.AddDocumentTrackingId();
			intelligentDocument.UpdateDocumentChecksum();

            if (String.IsNullOrEmpty(intelligentDocument.GetDocumentTrackingId()))
            {
                Logger.LogError("Attachments(s) Alert & Compare: Failed to add document tracking.");
            }
		}