private void btnFile_Click(object sender, EventArgs e) { var selectedNode = treeViewFolders.SelectedNode; if (selectedNode == null) { labelInfoText.Text = Resources.SelectFolderFirst; return; } var folder = OutlookHelpers.GetFolderByName(selectedNode.Text); MainController.FileEmail(_item, folder.Name, true); Close(); }
/// <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); } }
private void btnCreateFolder_Click(object sender, EventArgs e) { var selectedNode = treeViewFolders.SelectedNode; if (selectedNode == null) { labelInfoText.Text = Resources.SelectParentFirst; return; } var parentFolder = OutlookHelpers.GetFolderByName(selectedNode.Text); using (var wCreateFolder = new WindowCreateFolder(parentFolder, _item)) { var result = wCreateFolder.ShowDialog(); if (result == DialogResult.OK) { Close(); } } }