Beispiel #1
0
 public void InitializeSyncTimesAccounts(DateTime time,
     IMailHandler mailHandler)
 {
     SyncTimes.Clear();
     //Outlook.NameSpace nameSpace = null;
     //Outlook.Folders profileFolders = null;
     var profileFolders = mailHandler.GetWatchFolders();
     try
     {
         //if (mailHandler.OutlookApp == null) return;
         //nameSpace = OutlookApp.GetNamespace("MAPI");
         //if (nameSpace != null)
         //{
         //    profileFolders = nameSpace.Folders;
         //    int numberOfProfiles = profileFolders.Count;
         for (int i = 0; i < profileFolders.Count; i++)
             {
                 var currProfile = profileFolders[i];
                 if (currProfile != null)
                 {
                     SyncTime NewTime = new SyncTime();
                     NewTime.AccountID = currProfile.EntryID;
                     NewTime.LatestTime = time;
                     SyncTimes.Add(NewTime);
                     //Marshal.ReleaseComObject(currProfile);
                 }
             }
         //}
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         //if (nameSpace != null)
             //Marshal.ReleaseComObject(nameSpace);
         if (profileFolders != null)
         {
             profileFolders.ToList().ForEach(m => Marshal.ReleaseComObject(m));
         }
             //Marshal.ReleaseComObject(profileFolders);
     }
 }
Beispiel #2
0
        public void Load()
        {
            Items.Clear();
            if (CheckFile())
            {
                XmlDocument xmlDoc = new XmlDocument();
                if (xmlDoc != null)
                {
                    xmlDoc.Load(FileName);
                    XmlNode rootNode = xmlDoc.DocumentElement;

                    foreach (XmlNode node in rootNode)
                    {
                        if (node.Name == "synctimes")
                        {
                            foreach (XmlNode ItemNode in node)
                            {
                                SyncTime NewItem = new SyncTime();
                                if ((ItemNode.InnerText != null) &&
                                    (ItemNode.InnerText != string.Empty))
                                {
                                    NewItem.LatestTime =
                                        Convert.ToDateTime(ItemNode.InnerText);
                                }
                                if (ItemNode.Attributes["accountid"] != null)
                                {
                                    NewItem.AccountID =
                                        ItemNode.Attributes["accountid"].Value;
                                }
                                SyncTimes.Add(NewItem);
                                NewItem = null;
                            }
                        }
                        else if (node.Name == "syncitems")
                        {
                            foreach (XmlNode ItemNode in node)
                            {
                                SyncItem NewItem = new SyncItem();
                                NewItem.EntryID = ItemNode.InnerText.Trim();
                                if (ItemNode.Attributes["receivedtime"] != null)
                                {
                                    NewItem.ReceivedTime = Convert.ToDateTime(
                                        ItemNode.Attributes["receivedtime"].Value);
                                }
                                if (ItemNode.Attributes["sendersubj"] != null)
                                {
                                    NewItem.SenderSubject =
                                        ItemNode.Attributes["sendersubj"].Value;
                                }
                                if (ItemNode.Attributes["accountid"] != null)
                                {
                                    NewItem.AccountID =
                                        ItemNode.Attributes["accountid"].Value;
                                }
                                Items.Add(NewItem);
                                NewItem = null;
                            }
                        }
                    }
                    rootNode = null;
                    xmlDoc = null;
                }
            }
        }