예제 #1
0
        /// <summary>
        /// Analyzes selected item and create folders scores for it.
        /// </summary>
        /// <param name="item">Selected item</param>
        public static async void SelectionChanged(IOutlookItem item)
        {
            try
            {
                SelectedItem = item;
                var r = item.GetText();
                var s = item.GetSubject();
                SelectedMailScores = await Task.Run(() => GetScoresForMail(item));

                var myRibbon = Globals.Ribbons.MainRibbon;
                myRibbon.menuChoose.Enabled   = SelectedMailScores.Count > 0;
                myRibbon.btnFileEmail.Enabled = SelectedMailScores.Count > 0;
                myRibbon.btnChoose1.Visible   = SelectedMailScores.Count > 0;
                myRibbon.btnNdOpt.Enabled     = SelectedMailScores.Count > 1;
                myRibbon.btnChoose2.Visible   = SelectedMailScores.Count > 1;
                myRibbon.btnRdOpt.Enabled     = SelectedMailScores.Count > 2;
                myRibbon.btnChoose3.Visible   = SelectedMailScores.Count > 2;
                myRibbon.btnChoose4.Visible   = SelectedMailScores.Count > 3;
                myRibbon.btnChoose5.Visible   = SelectedMailScores.Count > 4;

                myRibbon.btnFileEmail.Label = SelectedMailScores.Count > 0 ? SelectedMailScores.First().Key : "";
                myRibbon.btnNdOpt.Label     = SelectedMailScores.Count > 1 ? OutlookHelpers.AdjustLabelLength(SelectedMailScores.ElementAt(1).Key) : "";
                myRibbon.btnRdOpt.Label     = SelectedMailScores.Count > 2 ? OutlookHelpers.AdjustLabelLength(SelectedMailScores.ElementAt(2).Key) : "";
                myRibbon.btnChoose1.Label   = SelectedMailScores.Count > 0 ? OutlookHelpers.AdjustLabelLength(SelectedMailScores.First().Key) : "";
                myRibbon.btnChoose2.Label   = SelectedMailScores.Count > 1 ? OutlookHelpers.AdjustLabelLength(SelectedMailScores.ElementAt(1).Key) : "";
                myRibbon.btnChoose3.Label   = SelectedMailScores.Count > 2 ? OutlookHelpers.AdjustLabelLength(SelectedMailScores.ElementAt(2).Key) : "";
                myRibbon.btnChoose4.Label   = SelectedMailScores.Count > 3 ? OutlookHelpers.AdjustLabelLength(SelectedMailScores.ElementAt(3).Key) : "";
                myRibbon.btnChoose5.Label   = SelectedMailScores.Count > 4 ? OutlookHelpers.AdjustLabelLength(SelectedMailScores.ElementAt(4).Key) : "";
            }
            catch (System.Exception ex)
            {
                MyMessageBox.Show("Error occured when selection changed. Error: " + ex);
            }
        }
예제 #2
0
 public WindowCreateFolder(Folder parentFolder, IOutlookItem item)
 {
     InitializeComponent();
     _parentFolder          = parentFolder;
     textBoxFolderPath.Text = _parentFolder.FolderPath;
     _item = item;
 }
예제 #3
0
파일: StoreModel.cs 프로젝트: kremda/Fodler
        /// <summary>
        /// Return scores for item.
        /// </summary>
        /// <param name="item">Item to be analyzed</param>
        public Dictionary <string, double> GetScoresForMail(IOutlookItem item)
        {
            if (item != null && Accord.IsReady())
            {
                var input   = item.GetInput();
                var subject = item.GetSubject();
                var text    = item.GetText();
                var results = Accord.DecideFolder(input, subject, text);
                return(results);
            }

            return(new Dictionary <string, double>());
        }
예제 #4
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>());
 }
예제 #5
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);
     }
 }
예제 #6
0
        private async void EmailInspectorRibbon_Load(object sender, RibbonUIEventArgs e)
        {
            var    inspector = Context as Outlook.Inspector;
            object item      = inspector?.CurrentItem;

            if (item != null && (item is Outlook.MailItem || item is Outlook.MeetingItem))
            {
                _item = OutlookItemHelpers.GetItemClass(item);

                _results = await Task.Run(() => MainController.GetScoresForMail(_item));

                EnableButtons(_results.Count);
                btnFileEmailInspector.Label = _results.Count > 0 ? _results.First().Key : "";
                btnNdOptInspector.Label     = _results.Count > 1 ? _results.ElementAt(1).Key : "";
                btnRdOptInspector.Label     = _results.Count > 2 ? _results.ElementAt(2).Key : "";
                btnChoose1.Label            = _results.Count > 0 ? _results.First().Key : "";
                btnChoose2.Label            = _results.Count > 1 ? _results.ElementAt(1).Key : "";
                btnChoose3.Label            = _results.Count > 2 ? _results.ElementAt(2).Key : "";
                btnChoose4.Label            = _results.Count > 3 ? _results.ElementAt(3).Key : "";
                btnChoose5.Label            = _results.Count > 4 ? _results.ElementAt(4).Key : "";
            }
        }
예제 #7
0
 public WindowChooseFolder(Dictionary <string, double> results, IOutlookItem item)
 {
     InitializeComponent();
     _item = item;
     PopulateTree(OutlookHelpers.GetListStores());
 }