예제 #1
0
 /// <summary>
 /// Returns folder names and its scores.
 /// </summary>
 /// <param name="item">Item to be analyzed</param>
 public static Dictionary <string, double> GetScoresForMail(IOutlookItem item)
 {
     try
     {
         if (item != null && _storeModels.Count != 0 && _analyzedStoresIds.Contains(item.GetStoreId()) && _finishedLoading)
         {
             var storeModelOfItem = _storeModels[item.GetStoreId()];
             return(storeModelOfItem.GetScoresForMail(item));
         }
     }
     catch (System.Exception ex)
     {
         MyMessageBox.Show("Error when getting scores for email. Error: " + ex);
     }
     return(new Dictionary <string, double>());
 }
예제 #2
0
 /// <summary>
 /// Files item to folder and run learning if needed.
 /// </summary>
 /// <param name="item">Item to be moved</param>
 /// <param name="folder">Destination folder for item</param>
 /// <param name="learn">Re-learn model if true</param>
 public static void FileEmail(IOutlookItem item, string folder, bool learn)
 {
     try
     {
         var storeModel        = _storeModels[item.GetStoreId()];
         var destinationFolder = OutlookHelpers.GetFolderByName(folder);
         if (destinationFolder == null)
         {
             return;
         }
         item.Move(destinationFolder);
         var keyForResults = new Tuple <int, bool>(1, true);
         if (!_results.ContainsKey(keyForResults))
         {
             _results.Add(keyForResults, new Result()
             {
                 LearnerId = 1, WithBody = true
             });
         }
         if (learn)
         {
             _results[keyForResults].IncrementMistakes();
             if (BwForLearning.IsBusy)
             {
                 _storesWaitingForUpdate.Add(storeModel);
             }
             else
             {
                 object[] parameters = { new HashSet <StoreModel>()
                                         {
                                             storeModel
                                         } };
                 BwForLearning.RunWorkerAsync(parameters);
             }
         }
         else
         {
             _results[keyForResults].IncrementSuccess();
         }
     }
     catch (System.Exception ex)
     {
         MyMessageBox.Show("Error when moving email to folder. Error: " + ex);
     }
 }