Exemple #1
0
        static int Main(string[] args)
        {
            if (args.Length != 1)
            {
                printUsage(Environment.GetCommandLineArgs()[0]);
                return(-1);
            }

            string pstFile = args[0];

            // Check if the file exists

            if (!File.Exists(pstFile))
            {
                Console.WriteLine(
                    "The specified PST file argument is incorrect. " +
                    "Either it is not a file or the file does not exist");
                return(-1);
            }

            IPst myFile = new Pst(pstFile);

            traverseAllMessages(myFile);

            return(0);
        }
Exemple #2
0
        public void Folder_Enumerator_Get_Name_Prop()
        {
            int countFolders = 0;

            foreach (var testFile in testData)
            {
                Assert.IsTrue(testFile.Exists, "Test file " + testFile.Name + " cannot be found, so test cannot succeed.");
                Console.WriteLine("File: {0}", testFile.Name);
                using (var pst = new Pst(testFile.FullName))
                {
                    //var name = pst.Name;
                    Assert.IsNotNull(pst);

                    foreach (var folder in pst.Folders)
                    {
                        Assert.IsNotNull(folder);
                        var name = folder.Name;

                        //Assert.IsTrue(!string.IsNullOrEmpty(name), "Folder.Name returned an empty value.");
                        Console.WriteLine("  Node: {0}, Name: {1}", folder.Node.Value, name);
                        countFolders++;
                    }
                }
            }

            Assert.AreEqual(25, countFolders, "Expected 25 folders, but actually iterated over " + countFolders + " folders.");
        }
Exemple #3
0
        public void PstConstructorTest()
        {
            string path   = string.Empty; // TODO: Initialize to an appropriate value
            Pst    target = new Pst(path);

            Assert.Inconclusive("TODO: Implement code to verify target");
        }
Exemple #4
0
        public void Messages_Enumerator_Get_Subject_Prop()
        {
            int countMessages = 0;

            foreach (var testFile in testData)
            {
                Assert.IsTrue(testFile.Exists, "Test file " + testFile.Name + " cannot be found, so test cannot succeed.");
                Console.WriteLine("File: {0}", testFile.Name);

                using (var pst = new Pst(testFile.FullName))
                {
                    //var name = pst.Name;
                    Assert.IsNotNull(pst);

                    foreach (var message in pst.Messages)
                    {
                        Assert.IsNotNull(message);
                        var subject = message.Subject;

                        //Assert.IsTrue(!string.IsNullOrEmpty(subject), "Message.Subject returned an empty value.");
                        Console.WriteLine("  Node: {0}, Subject: {1}", message.Node.Value, subject);
                        countMessages++;
                    }
                }
            }

            Assert.AreEqual(6, countMessages, "Expected 6 messages, but only iterated over " + countMessages + " messages.");
        }
Exemple #5
0
 public void GetAdditionalEntries()
 {
     using (IPst pstFile = new Pst(@"C:\\Users\\Antonio\\Documents\\Outlook Files\\[email protected]"))
     {
         var addEntries = pstFile.OpenRootFolder().GetAdditionalEntryIds();
     }
 }
        protected override PSTProcessingResult ProcessQueueObjectImplementation()
        {
            IPst rdopststore = null;

            try
            {
                Logger.NLogger.Info("PSTFile: {0}  EntryID: {1}", this.PSTFile, this.EntryID);
#if USE_PSTSTORE
                rdopststore = this.PstStore;
#else
                rdopststore = new Pst(this.PSTFile);
#endif
                Message rdomail = null;
                try
                {
                    rdomail     = (Message)rdopststore.OpenMessage(this.EntryID);
                    rdomail.Pst = (Pst)rdopststore;
                    Logger.NLogger.Info("EntryID: {0}", rdomail.EntryID.ToString());
                }
                catch (Exception ex)
                {
                    Logger.NLogger.ErrorException("ERROR: ProcessQueueObjectImplementation", ex);
                }
                if (rdomail != null)
                {
                    try
                    {
                    }
                    catch (Exception ex)
                    {
                        Logger.NLogger.ErrorException("ERROR: HandleMessage", ex);
                    }
                    rdomail.Dispose();
                    rdomail = null;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
            }
            finally
            {
#if !USE_PSTSTORE
                if (rdopststore != null)
                {
                    rdopststore.Dispose();
                    rdopststore = null;
                }
#endif
            }

            PSTProcessingResult result = new PSTProcessingResult()
            {
                IsSuccessful = true, Filename = string.Empty
            };
            result.SetProcessingObject <PSTFolderParser>(this);
            return(result);
        }
        //List<InputOutputThreadObjectHandler<PSTMsgParser>> outputobjects, InputOutputMessageQueue<PSTMsgParser> inqueue, InputOutputMessageQueue<PSTMsgParser> outqueue)
        protected override PSTProcessingResult ProcessQueueObjectImplementation()
        {
            IPst rdopststore = null;
            try
            {
                Logger.NLogger.Info("PSTFile: {0}  EntryID: {1}", this.PSTFile, this.EntryID);
            #if USE_PSTSTORE
                rdopststore = this.PstStore;
            #else
                rdopststore = new Pst(this.PSTFile);
            #endif
                Message rdomail = null;
                try
                {
                    rdomail = (Message)rdopststore.OpenMessage(this.EntryID);
                    rdomail.Pst = (Pst)rdopststore;
                    Logger.NLogger.Info("EntryID: {0}", rdomail.EntryID.ToString());
                }
                catch (Exception ex)
                {
                    Logger.NLogger.ErrorException("ERROR: ProcessQueueObjectImplementation", ex);
                }
                if (rdomail != null)
                {
                    try
                    {
                        HandleMessage(rdomail, this.ExportDirectory); //, outputobjects, inqueue, outqueue);
                    }
                    catch (Exception ex)
                    {
                        Logger.NLogger.ErrorException("ERROR: HandleMessage", ex);
                    }
                    rdomail.Dispose();
                    rdomail = null;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
            }
            finally
            {
            #if !USE_PSTSTORE
                if (rdopststore != null)
                {
                    rdopststore.Dispose();
                    rdopststore = null;
                }
            #endif
            }

            foreach (string file in this.OutputFiles)
                Console.WriteLine(file);

            PSTProcessingResult result = new PSTProcessingResult() { IsSuccessful = true, Filename = string.Empty};
            result.SetProcessingObject<PSTMsgParser>(this);
            return result;
        }
Exemple #8
0
        public void DisposeTest()
        {
            string path   = string.Empty;  // TODO: Initialize to an appropriate value
            Pst    target = new Pst(path); // TODO: Initialize to an appropriate value

            target.Dispose();
            Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }
Exemple #9
0
        public void PropertiesTest()
        {
            string path   = string.Empty;  // TODO: Initialize to an appropriate value
            Pst    target = new Pst(path); // TODO: Initialize to an appropriate value
            IEnumerable <PropId> actual;

            actual = target.Properties;
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Exemple #10
0
        public void DatabaseAccessorTest()
        {
            string      path   = string.Empty;  // TODO: Initialize to an appropriate value
            Pst         target = new Pst(path); // TODO: Initialize to an appropriate value
            IDBAccessor actual;

            actual = target.DatabaseAccessor;
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Exemple #11
0
        public void NodeTest()
        {
            string path   = string.Empty;  // TODO: Initialize to an appropriate value
            Pst    target = new Pst(path); // TODO: Initialize to an appropriate value
            NodeID actual;

            actual = target.Node;
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Exemple #12
0
        public void OpenRootFolderTest()
        {
            string  path     = string.Empty;  // TODO: Initialize to an appropriate value
            Pst     target   = new Pst(path); // TODO: Initialize to an appropriate value
            IFolder expected = null;          // TODO: Initialize to an appropriate value
            IFolder actual;

            actual = target.OpenRootFolder();
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Exemple #13
0
        public void Folder_Enumerator_Recursive_Get_Name_Prop_And_Associated_Messages_With_Subject_Prop()
        {
            // note: this test is kind of pointless at the moment, because our test data doesn't have any associated content in it.

            int countFolders  = 0;
            int countMessages = 0;

            foreach (var testFile in testData)
            {
                Assert.IsTrue(testFile.Exists, "Test file " + testFile.Name + " cannot be found, so test cannot succeed.");

                Console.WriteLine("File: {0}", testFile.Name);

                using (var pst = new Pst(testFile.FullName))
                {
                    //var name = pst.Name;
                    Assert.IsNotNull(pst);

                    Queue <IFolder> folders = new Queue <IFolder>();
                    foreach (var folder in pst.Folders)
                    {
                        folders.Enqueue(folder);
                    }

                    while (folders.Count > 0)
                    {
                        var folder = folders.Dequeue();

                        Assert.IsNotNull(folder);
                        var name           = folder.Name;
                        var subFolderCount = folder.SubFolderCount;

                        Console.WriteLine("  Node: {0}, Name: {1}, Count: {2}", folder.Node.Value, name, subFolderCount);
                        countFolders++;

                        if (folder.AssociatedMessageCount > 0)
                        {
                            foreach (var message in folder.AssociatedMessages)
                            {
                                Assert.IsNotNull(message);
                                var subject = message.Subject;

                                //Assert.IsTrue(!string.IsNullOrEmpty(subject), "Message.Subject returned an empty value.");
                                Console.WriteLine("    Node: {0}, Subject: {1}", message.Node.Value, subject);
                                countMessages++;
                            }
                        }
                    }
                }
            }

            Assert.AreEqual(25, countFolders, "Expected 25 folders, but actually iterated over " + countFolders + " folders.");
            Assert.AreEqual(0, countMessages, "Expected 0 messages, but actually iterated over " + countMessages + " messages.");
        }
Exemple #14
0
        public void PropertyExistsTest()
        {
            string path     = string.Empty;  // TODO: Initialize to an appropriate value
            Pst    target   = new Pst(path); // TODO: Initialize to an appropriate value
            PropId id       = new PropId();  // TODO: Initialize to an appropriate value
            bool   expected = false;         // TODO: Initialize to an appropriate value
            bool   actual;

            actual = target.PropertyExists(id);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Exemple #15
0
        public void OpenMessageTest()
        {
            string   path     = string.Empty;  // TODO: Initialize to an appropriate value
            Pst      target   = new Pst(path); // TODO: Initialize to an appropriate value
            NodeID   nodeID   = new NodeID();  // TODO: Initialize to an appropriate value
            IMessage expected = null;          // TODO: Initialize to an appropriate value
            IMessage actual;

            actual = target.OpenMessage(nodeID);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Exemple #16
0
        public void OpenPropertyStreamTest()
        {
            string path     = string.Empty;  // TODO: Initialize to an appropriate value
            Pst    target   = new Pst(path); // TODO: Initialize to an appropriate value
            PropId id       = new PropId();  // TODO: Initialize to an appropriate value
            Stream expected = null;          // TODO: Initialize to an appropriate value
            Stream actual;

            actual = target.OpenPropertyStream(id);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Exemple #17
0
        public void GetTopIMFFolder()
        {
            using (IPst pstFile = new Pst(@"Resources\small_test.pst"))
            {
                var topId = pstFile.GetTopIPMFolderId();
                Assert.AreNotEqual(0, topId);

                var topFolder = pstFile.OpenFolder(topId);

                Assert.IsNotNull(topFolder);
            }
        }
Exemple #18
0
        public void Pst_Ctor()
        {
            foreach (var testFile in testData)
            {
                Assert.IsTrue(testFile.Exists, "Test file " + testFile.Name + " cannot be found, so test cannot succeed.");

                using (var pst = new Pst(testFile.FullName))
                {
                    Assert.IsNotNull(pst);
                }
            }
        }
Exemple #19
0
        public void Pst_Name()
        {
            foreach (var testFile in testData)
            {
                Assert.IsTrue(testFile.Exists, "Test file " + testFile.Name + " cannot be found, so test cannot succeed.");
                Console.WriteLine("File: {0}", testFile.Name);

                using (var pst = new Pst(testFile.FullName))
                {
                    var name = pst.Name;
                    Assert.IsNotNull(pst);
                    Assert.IsTrue(!string.IsNullOrEmpty(name), "Pst.Name returned an empty value.");
                    Console.WriteLine("  Name: {0}", name);
                }
            }
        }
Exemple #20
0
        static int Main(string[] args)
        {
            if (args.Length != 1)
            {
                Console.WriteLine(Environment.GetCommandLineArgs()[0] + " <pst-filename>");
                return(-1);
            }
            string path = args[0];

            IPst     store = new Pst(path);
            DateTime lolz  = DateTime.Now;

            process_folder(0, store.OpenRootFolder());
            Console.WriteLine("Total Time Elapsed: " + DateTime.Now.Subtract(lolz));

            Console.ReadKey();

            return(0);
        }
 public override void Process(PSTFileParserData data)
 {
     data.WFState.Value = WFState.WFStateFail;
     try
     {
         IPst rdopststore = new Pst(data.DocumentToProcess);
         foreach (IMessage msg in rdopststore.Messages)
         {
             data.OutputDocuments.Add(msg.Node.Value.ToString());
         }
         rdopststore.Dispose();
         data.PSTFile = data.DocumentToProcess;
     }
     catch (Exception ex)
     {
         WFLogger.NLogger.ErrorException(String.Format("Message extraction for PST file: {0} failed.", data.DocumentToProcess), ex);
     }
     data.WFState.Value = WFState.WFStateSuccess;
 }
Exemple #22
0
        public void Folder_Enumerator_Recursive_Get_Name_Prop()
        {
            int countFolders = 0;

            foreach (var testFile in testData)
            {
                Assert.IsTrue(testFile.Exists, "Test file " + testFile.Name + " cannot be found, so test cannot succeed.");

                Console.WriteLine("File: {0}", testFile.Name);

                using (var pst = new Pst(testFile.FullName))
                {
                    //var name = pst.Name;
                    Assert.IsNotNull(pst);

                    Queue <IFolder> folders = new Queue <IFolder>();
                    foreach (var folder in pst.Folders)
                    {
                        folders.Enqueue(folder);
                    }

                    while (folders.Count > 0)
                    {
                        var folder = folders.Dequeue();

                        Assert.IsNotNull(folder);
                        var name           = folder.Name;
                        var subFolderCount = folder.SubFolderCount;

                        Console.WriteLine("  Node: {0}, Name: {1}, Count: {2}", folder.Node.Value, name, subFolderCount);
                        countFolders++;
                    }
                }
            }

            Assert.AreEqual(25, countFolders, "Expected 55 folders, but actually iterated over " + countFolders + " folders.");
        }
Exemple #23
0
        protected override PSTProcessingResult ProcessQueueObjectImplementation()         //List<InputOutputThreadObjectHandler<PSTMsgParser>> outputobjects, InputOutputMessageQueue<PSTMsgParser> inqueue, InputOutputMessageQueue<PSTMsgParser> outqueue)
        {
            IPst rdopststore = null;

            try
            {
                Logger.NLogger.Info("PSTFile: {0}  EntryID: {1}", this.PSTFile, this.EntryID);
#if USE_PSTSTORE
                rdopststore = this.PstStore;
#else
                rdopststore = new Pst(this.PSTFile);
#endif
                Message rdomail = null;
                try
                {
                    rdomail     = (Message)rdopststore.OpenMessage(this.EntryID);
                    rdomail.Pst = (Pst)rdopststore;
                    Logger.NLogger.Info("EntryID: {0}", rdomail.EntryID.ToString());
                }
                catch (Exception ex)
                {
                    Logger.NLogger.ErrorException("ERROR: ProcessQueueObjectImplementation", ex);
                }
                if (rdomail != null)
                {
                    try
                    {
                        HandleMessage(rdomail, this.ExportDirectory);                         //, outputobjects, inqueue, outqueue);
                    }
                    catch (Exception ex)
                    {
                        Logger.NLogger.ErrorException("ERROR: HandleMessage", ex);
                    }
                    rdomail.Dispose();
                    rdomail = null;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
            }
            finally
            {
#if !USE_PSTSTORE
                if (rdopststore != null)
                {
                    rdopststore.Dispose();
                    rdopststore = null;
                }
#endif
            }

            foreach (string file in this.OutputFiles)
            {
                Console.WriteLine(file);
            }

            PSTProcessingResult result = new PSTProcessingResult()
            {
                IsSuccessful = true, Filename = string.Empty
            };
            result.SetProcessingObject <PSTMsgParser>(this);
            return(result);
        }
Exemple #24
0
        public void Folder_Messages_Attachments()
        {
            int countFolders     = 0;
            int countMessages    = 0;
            int countAttachments = 0;

            foreach (var testFile in testData)
            {
                Assert.IsTrue(testFile.Exists, "Test file " + testFile.Name + " cannot be found, so test cannot succeed.");

                Console.WriteLine("File: {0}", testFile.Name);

                using (var pst = new Pst(testFile.FullName))
                {
                    //var name = pst.Name;
                    Assert.IsNotNull(pst);

                    Queue <IFolder> folders = new Queue <IFolder>();
                    foreach (var folder in pst.Folders)
                    {
                        folders.Enqueue(folder);
                    }

                    while (folders.Count > 0)
                    {
                        var folder = folders.Dequeue();

                        Assert.IsNotNull(folder);
                        var name           = folder.Name;
                        var subFolderCount = folder.SubFolderCount;

                        Console.WriteLine("  Node: {0}, Name: {1}, Count: {2}", folder.Node.Value, name, subFolderCount);
                        countFolders++;

                        if (folder.MessageCount > 0)
                        {
                            Queue <IMessage> messages = new Queue <IMessage>();
                            foreach (var message in folder.Messages)
                            {
                                messages.Enqueue(message);
                            }

                            countMessages += messages.Count;

                            while (messages.Count > 0)
                            {
                                var message = messages.Dequeue();

                                Assert.IsNotNull(message);
                                var subject = message.Subject;

                                //Assert.IsTrue(!string.IsNullOrEmpty(subject), "Message.Subject returned an empty value.");
                                Console.WriteLine("    Node: {0}, Subject: {1}", message.Node.Value, subject);
                                //countMessages++;

                                if (message.AttachmentCount > 0)
                                {
                                    foreach (var attachment in message.Attachments)
                                    {
                                        var contentSize = attachment.ContentSize;

                                        if (attachment.IsMessage)
                                        {
                                            var embeddedMessage = attachment.OpenAsMessage();
                                            messages.Enqueue(embeddedMessage);
                                            Console.WriteLine(
                                                "      Node: {0}, ContentSize: {1}, <Embedded-Message> '{2}'", attachment.Node.Value, contentSize, embeddedMessage.Subject);
                                        }
                                        else
                                        {
                                            var filename = attachment.Filename;
                                            Console.WriteLine(
                                                "      Node: {0}, ContentSize: {1}, Filename: {2}", attachment.Node.Value, contentSize, filename);
                                        }
                                        countAttachments++;
                                    }
                                }
                            }
                        }
                    }
                }
            }

            Assert.AreEqual(25, countFolders, "Expected 25 folders, but actually iterated over " + countFolders + " folders.");
            Assert.AreEqual(6, countMessages, "Expected 6 messages, but actually iterated over " + countMessages + " messages.");
            Assert.AreEqual(3, countAttachments, "Expected 3 attachments, but actually iterated over " + countAttachments + " attachments.");
        }
        public override void Process(PSTMsgParserData data)
        {
            this.PSTFile = data.PSTFile;             // GetProperty<string>("PSTFile", "PSTFileParserData");
            this.PSTFile = data.PSTFile;             // GetProperty<string>("PSTFile", "PSTFileParserData");
            this.ProcessedMsgs.Clear();
            this.ParentMsg         = "0";
            this.SaveAsTypes       = data.SaveAsTypes;
            this.SaveAttachments   = data.SaveAttachments;
            this.SaveEmbeddedMsgs  = data.SaveEmbeddedMsgs;
            this.Pst2MsgCompatible = data.Pst2MsgCompatible;
            this.OutputFiles       = data.OutputDocuments;
            this.FileToProcess     = data.DocumentToProcess;

            data.WFState.Value = "Fail";

            IPst rdopststore = null;

            try
            {
                WFLogger.NLogger.Info("PSTFile={0}  NodeID={1}", PSTFile, this.FileToProcess);

                rdopststore = new Pst(PSTFile);

                Message rdomail = null;
                try
                {
                    NodeID msgid = Convert.ToUInt32(this.FileToProcess);
                    if (this.ParentMsg != "0")
                    {
                        msgid = Convert.ToUInt32(this.ParentMsg);
                    }

                    rdomail            = (Message)rdopststore.OpenMessage(msgid);          //this.EntryID);
                    rdomail.Pst        = (Pst)rdopststore;
                    rdomail.FolderPath = data.FolderPath;
                    WFLogger.NLogger.Info("EntryID={0}", rdomail.EntryID.ToString());
                }
                catch (Exception ex)
                {
                    WFLogger.NLogger.ErrorException("ERROR: ProcessQueueObjectImplementation", ex);
                }
                if (rdomail != null)
                {
                    try
                    {
                        HandleMessage(rdomail, data.ExportDirectory);
                        data.ExportDirectory = data.ExportDirectory + @"\" + this.FileToProcess;
                    }
                    catch (Exception ex)
                    {
                        WFLogger.NLogger.ErrorException("ERROR: HandleMessage", ex);
                    }
                    rdomail.Dispose();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
            }
            finally
            {
                if (rdopststore != null)
                {
                    rdopststore.Dispose();
                }
            }
            data.WFState.Value = "Succcess";
        }
Exemple #26
0
        static int Main(string[] args)
        {
            if (args.Length != 1)
            {
                printUsage(Environment.GetCommandLineArgs()[0]);
                return(-1);
            }

            string pstFile = args[0];

            // Check if the file exists

            if (!File.Exists(pstFile))
            {
                Console.WriteLine(
                    "The specified PST file argument is incorrect. " +
                    "Either it is not a file or the file does not exist");
                return(-1);
            }

            IPst pst             = new Pst(pstFile);
            var  nameIdMap       = pst.NameIDMap;
            var  nameIdMapObject = nameIdMap.PropertyBag;

            Console.WriteLine("Bucket Count: {0}", nameIdMap.BucketCount);
            Console.WriteLine(Environment.NewLine);

            //Dump out all the Guids
            using (var guids =
                       new GuidStreamReader(nameIdMapObject.OpenPropertyStream(PropId.KnownValue.PidTagNameidStreamGuid)))
            {
                Console.WriteLine("GUID Stream: (* indicates predefined guid)");
                Console.WriteLine("\t [000] {0}*", Guid.Empty);
                Console.WriteLine("\t [001] {0}*", GuidStreamReader.MapiGuid);
                Console.WriteLine("\t [002] {0}*", GuidStreamReader.PublicStringsGuid);

                for (int i = 3; i < nameIdMap.PropertyCount; i++)
                {
                    Console.WriteLine("\t [{0:D3}] {1}", i, guids.ReadGuid(i));
                }
            }

            Console.WriteLine(Environment.NewLine);

            //Dump out the Entry Stream);
            using (var entries =
                       new EntryStreamReader(nameIdMapObject.OpenPropertyStream(PropId.KnownValue.PidTagNameidStreamEntry)))
            {
                Console.WriteLine("Entry Stream: ");
                for (int i = 0; i < nameIdMap.PropertyCount; i++)
                {
                    Console.WriteLine("\t [{0:D3}] {1}", i, entries.ReadEntry(i));
                }
            }

            Console.WriteLine(Environment.NewLine);

            using (var strings = new BinaryReader(nameIdMapObject.OpenPropertyStream(PropId.KnownValue.PidTagNameidStreamString)))
            {
                Console.WriteLine("String Stream: ");
                var streamLength = strings.BaseStream.Length;

                while (strings.BaseStream.Position < streamLength)
                {
                    var stringLength = strings.ReadInt32();
                    var stringBytes  = strings.ReadBytes(stringLength);

                    Console.WriteLine(Encoding.Unicode.GetString(stringBytes));

                    //seek to nearest 4-byte boundary
                    var offset = stringLength % 4;

                    if (offset != 0)
                    {
                        strings.BaseStream.Seek((4 - offset), SeekOrigin.Current);
                    }
                }
            }

            Console.WriteLine("Hash Buckets:");
            for (int i = 0; i < nameIdMap.BucketCount; i++)
            {
                var bucketProperty = i + 0x1000;

                if (nameIdMapObject.PropertyExists((PropId)bucketProperty))
                {
                    var bytes       = nameIdMapObject.ReadProperty((PropId)bucketProperty);
                    var nameIdbytes = new byte[8];

                    for (int x = 0; x < bytes.Length; x += 8)
                    {
                        Array.Copy(bytes, x, nameIdbytes, 0, 8);

                        var nameId = new NameId(nameIdbytes);
                        Console.WriteLine("[{0:D3}] Hash: 0x{1:X8}, Guid Index: {2}, \r\n\tProperty Index: 0x{3:X4}, Is String? {4}",
                                          i, nameId.Id, nameId.GuidIndex, (nameId.PropertyIndex + 0x8000), nameId.IsString);
                        Console.WriteLine();
                    }
                }
            }


            foreach (var np in nameIdMap.NamedProperties)
            {
                Console.WriteLine();
                Console.WriteLine(np.ToString());
                Console.WriteLine();
            }

            Console.ReadKey(true);

            return(0);
        }
Exemple #27
0
        public override WFState Run()
        {
            WFState retval = new WFState();

            IPst rdopststore = null;

            try
            {
                retval.Value = WFState.WFStateFail;
                WFLogger.NLogger.Info("PSTFile={0}  NodeID={1}", this.PSTFile, this.FileToProcess);

                rdopststore = new Pst(this.PSTFile);

                Message rdomail = null;
                try
                {
                    NodeID msgid = Convert.ToUInt32(this.FileToProcess);
                    if (this.ParentMsg != "0")
                    {
                        msgid = Convert.ToUInt32(this.ParentMsg);
                    }

                    rdomail            = (Message)rdopststore.OpenMessage(msgid);          //this.EntryID);
                    rdomail.Pst        = (Pst)rdopststore;
                    rdomail.FolderPath = this.FolderPath;
                    WFLogger.NLogger.Info("EntryID={0}", rdomail.EntryID.ToString());
                }
                catch (Exception ex)
                {
                    WFLogger.NLogger.ErrorException("ERROR: ProcessQueueObjectImplementation", ex);
                }
                if (rdomail != null)
                {
                    try
                    {
                        HandleMessage(rdomail, this.ExportDirectory);
                        this.ExportDirectory = this.ExportDirectory + @"\" + this.FileToProcess;
                        retval.Value         = WFState.WFStateSuccess;
                    }
                    catch (Exception ex)
                    {
                        WFLogger.NLogger.ErrorException("ERROR: HandleMessage", ex);
                    }
                    rdomail.Dispose();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
            }
            finally
            {
                if (rdopststore != null)
                {
                    rdopststore.Dispose();
                }
            }

            return(retval);
        }
        public override WFState Run()
        {
            WFState retval = new WFState();

            IPst rdopststore = null;
            try
            {
                retval.Value = WFState.WFStateFail;
                WFLogger.NLogger.Info("PSTFile={0}  NodeID={1}", this.PSTFile, this.FileToProcess);

                rdopststore = new Pst(this.PSTFile);

                Message rdomail = null;
                try
                {
                    NodeID msgid = Convert.ToUInt32(this.FileToProcess);
                    if (this.ParentMsg != "0")
                        msgid = Convert.ToUInt32(this.ParentMsg);

                    rdomail = (Message)rdopststore.OpenMessage(msgid); //this.EntryID);
                    rdomail.Pst = (Pst)rdopststore;
                    rdomail.FolderPath = this.FolderPath;
                    WFLogger.NLogger.Info("EntryID={0}", rdomail.EntryID.ToString());
                }
                catch (Exception ex)
                {
                    WFLogger.NLogger.ErrorException("ERROR: ProcessQueueObjectImplementation", ex);
                }
                if (rdomail != null)
                {
                    try
                    {
                        HandleMessage(rdomail, this.ExportDirectory);
                        this.ExportDirectory = this.ExportDirectory + @"\" + this.FileToProcess;
                        retval.Value = WFState.WFStateSuccess;
                    }
                    catch (Exception ex)
                    {
                        WFLogger.NLogger.ErrorException("ERROR: HandleMessage", ex);
                    }
                    rdomail.Dispose();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
            }
            finally
            {
                if (rdopststore != null)
                    rdopststore.Dispose();
            }

            return retval;
        }