/// <summary> /// Provides a record-by-record processing functionality for the cmdlet. /// </summary> protected override void ProcessRecord() { // Create the Exchange Service Object and auth with bearer token ExchangeService exchangeService = new ExchangeService(new AuthenticationProvider(), this.SmtpAddress, RestEnvironment.OutlookBeta); FolderView folderView = new FolderView(10); FindFoldersResults findFoldersResults = null; do { SearchFilter searchFilter = new SearchFilter.IsEqualTo(MailFolderObjectSchema.DisplayName, this.FolderName); findFoldersResults = exchangeService.FindFolders(this.FolderRoot, searchFilter, folderView); folderView.Offset += folderView.PageSize; foreach (MailFolder folder in findFoldersResults) { if (!this.Force && !this.ShouldContinue(string.Format("This is a hard delete operation. Are you sure you want to delete mail folder {0}?", this.FolderName), "Hard Delete Folder", true, ref this.yesToAll, ref this.noToAll)) { return; } // Hard delete the folder folder.Delete(); } }while (findFoldersResults.MoreAvailable); }
public FolderId GetOutlookProjectPath(Entity.Store store) { //find the program folder first then search it for the project folder var parentView = new FolderView(int.MaxValue); parentView.PropertySet = new PropertySet(BasePropertySet.IdOnly, FolderSchema.DisplayName); var programNumber = Configuration.ConfigHandler.InstanceOf.ProgramMappings.Where( x => x.Value.Equals(store.Program)) .Select(y => y.Key).Distinct(); var taskResult = new System.Collections.Generic.List <System.Threading.Tasks.Task <FolderId> >(); foreach (var element in programNumber) { var filter = new SearchFilter.ContainsSubstring(FolderSchema.DisplayName, element.ToString("D2") + " "); var result = this.GetEmailService.FindFolders(WellKnownFolderName.PublicFoldersRoot, filter, parentView); var programFolder = result.Where(y => typeof(Microsoft.Exchange.WebServices.Data.ContactsFolder) != y.GetType()); taskResult.Add(this.FindProjectPath(programFolder.First(), 0, 255, "(" + store.ProjectNumber.ToString("D7") + ")", 0)); } var asyncResults = System.Threading.Tasks.Task.WhenAll(taskResult); var folders = asyncResults.Result; return(folders.Single(x => x != null)); }
public Folder GetFolderByPath(string path, string username, string password, string email) { path = path.Replace('/', '\\').Replace("\\\\", ""); var ar = path.Split('\\'); var service = GetEWSService(username, password, email); var fv = new FolderView(1000); fv.PropertySet = GetPropertySet(); fv.PropertySet.Add(EWSProperties.PR_PF_Proxy); var folders = service.FindFolders(WellKnownFolderName.PublicFoldersRoot, fv).Folders.FirstOrDefault(e => { e.TryGetProperty(EWSProperties.PR_Display_name, out string displayName); return(displayName == ar[0]); }); var i = 0; foreach (var p in ar) { if (i > 0) { folders = folders.FindFolders(fv).FirstOrDefault(e => { e.TryGetProperty(EWSProperties.PR_Display_name, out string displayName); return(displayName == p); }); } i++; } return(folders); }
private IEnumerable <PublicFolderModel> GetFolder(Folder baseFolder, FolderView fv, IEnumerable <KeyValuePair <string, string> > toDelete = null) { var fList = new List <PublicFolderModel>(); baseFolder.TryGetProperty(EWSProperties.Pr_Folder_Path, out string path); //if (path.ToLower().Contains("weather forecasts")) //{ // System.Diagnostics.Debugger.Break(); //} if (baseFolder.ChildFolderCount == 0) { fList.Add(ParseFolder(baseFolder, toDelete)); return(fList); } var q = baseFolder.FindFolders(fv); loopthroughFolders(fv, fList, q); var moreAvailable = q.MoreAvailable; while (moreAvailable) { //loopthroughFolders(fv, fList, q); var folderV = new FolderView(1000); folderV.PropertySet = GetPropertySet(); folderV.Offset = q.NextPageOffset.GetValueOrDefault(); q = baseFolder.FindFolders(folderV); moreAvailable = q.MoreAvailable; loopthroughFolders(folderV, fList, q, toDelete); } return(fList); }
public static FolderId FindFolder(Microsoft.Exchange.WebServices.Data.ExchangeService service) { var resultid = new FolderId("0"); var responseview = new FolderView(1); var filter = new SearchFilter.IsEqualTo(FolderSchema.DisplayName, "sync-adressen"); var folderresponse = service.FindFolders(WellKnownFolderName.PublicFoldersRoot, filter, responseview); if (folderresponse.Count() == 1) { var responseview2 = new FolderView(1); var filter2 = new SearchFilter.IsEqualTo(FolderSchema.DisplayName, "sync-contacten"); var folderresponse2 = service.FindFolders(folderresponse.First().Id, filter2, responseview2); if (folderresponse2.Count() == 1) { var responseview3 = new FolderView(1); var filter3 = new SearchFilter.IsEqualTo(FolderSchema.DisplayName, "syncContacts"); var folderresponse3 = service.FindFolders(folderresponse2.First().Id, filter3, responseview3); if (folderresponse3.Count() == 1) { resultid = folderresponse3.First().Id; } } } return(resultid); }
//---------------------------------------------------------------------------------------------------------------------- void playerAction_FolderDialogQuery(object obj) { FolderView folderView = new FolderView(); folderView.DataContext = obj; folderView.ShowDialog(); }
private Folder FindImHistoryFolder() { FolderView folderView = new FolderView(_pageSize, 0); folderView.PropertySet = new PropertySet(BasePropertySet.IdOnly); folderView.PropertySet.Add(FolderSchema.DisplayName); folderView.PropertySet.Add(FolderSchema.ChildFolderCount); folderView.Traversal = FolderTraversal.Shallow; Folder imHistoryFolder = null; FindFoldersResults findFolderResults; bool foundImHistoryFolder = false; do { findFolderResults = _exchangeService.FindFolders(WellKnownFolderName.MsgFolderRoot, folderView); foreach (Folder folder in findFolderResults) { if (folder.DisplayName.ToLower() == "conversation history") { imHistoryFolder = folder; foundImHistoryFolder = true; } } folderView.Offset += _pageSize; } while (findFolderResults.MoreAvailable && !foundImHistoryFolder); return(imHistoryFolder); }
public override void ViewDidLoad() { base.ViewDidLoad(); var folderControl = new FolderControl(); AddChildViewController(folderControl); FolderView.AddSubview(folderControl.View); var mailControl = new MailControl(); AddChildViewController(mailControl); MailView.AddSubview(mailControl.View); var source = new MvxSimpleTableViewSource(FoldersTable, FolderCellTemplate.Key, FolderCellTemplate.Key); FoldersTable.Source = source; var set = this.CreateBindingSet <FoldersView, FoldersViewModel>(); set.Bind(source).To(vm => vm.Folders); set.Bind(source).For(s => s.SelectedItem).To(vm => vm.SelectedFolder); set.Apply(); this.Title = "MailApp"; //As the folder is also showed on this view, we don't wait for the user to select one ((FoldersViewModel)ViewModel).SelectedFolder = ((FoldersViewModel)ViewModel).Folders.FirstOrDefault(); }
public async Task <IActionResult> Rename(string Id, string titleNew) { if (string.IsNullOrEmpty(titleNew)) { return(BadRequest("Title length is less than 1")); } var userId = userManager.GetUserId(User); var folder = await db.Folders.GetAsync(userId, Id); if (folder == null) { return(NotFound(Id)); } folder.Title = titleNew; db.Folders.Update(folder); await db.SaveAsync(); FolderView view = new FolderView() { Id = folder.Id, Title = folder.Title, ParentId = folder.ParentId, Breadcrumbs = await GetBreadcrumbsAsync(userId, folder.Id), Items = await GetItemsAsync(userId, folder.Id) }; return(Ok(view)); }
public Folder GetFolder(string displayName) { FolderView folderView = new FolderView(int.MaxValue) { Traversal = FolderTraversal.Shallow }; if (displayName == "Inbox") { this.txtLog.Text += "EWS API: Folder.Bind\r\nLocation:..\\EWS\\EWS\\Form1.cs(60)\r\n\r\n"; return(Folder.Bind(service, WellKnownFolderName.Inbox)); } else { SearchFilter.ContainsSubstring filter = new SearchFilter.ContainsSubstring(FolderSchema.DisplayName, displayName, ContainmentMode.FullString, ComparisonMode.IgnoreCase); FindFoldersResults findFoldersResults = service.FindFolders(WellKnownFolderName.Inbox, filter, new FolderView(int.MaxValue) { Traversal = FolderTraversal.Deep }); this.txtLog.Text += "EWS API: FindFolders\r\nLocation:..\\EWS\\EWS\\Form1.cs(64)\r\n\r\n"; if (findFoldersResults.Count() > 0) { return(findFoldersResults.First()); } else { return(null); } } }
public List <EWSCalendar> GetCalendarsAsync(int maxFoldersToRetrive) { var service = GetExchangeService(null); // Create a new folder view, and pass in the maximum number of folders to return. var view = new FolderView(1000); // Create an extended property definition for the PR_ATTR_HIDDEN property, // so that your results will indicate whether the folder is a hidden folder. var isHiddenProp = new ExtendedPropertyDefinition(0x10f4, MapiPropertyType.Boolean); // As a best practice, limit the properties returned to only those required. // In this case, return the folder ID, DisplayName, and the value of the isHiddenProp // extended property. view.PropertySet = new PropertySet(BasePropertySet.FirstClassProperties, FolderSchema.DisplayName, isHiddenProp); // Indicate a Traversal value of Deep, so that all subfolders are retrieved. view.Traversal = FolderTraversal.Deep; // Call FindFolders to retrieve the folder hierarchy, starting with the MsgFolderRoot folder. // This method call results in a FindFolder call to EWS. var findFolderResults = service.FindFolders(WellKnownFolderName.MsgFolderRoot, view); var ewsCalendars = new List <EWSCalendar>(); foreach (var searchFolder in findFolderResults.Folders) { GetCalendars(searchFolder, ewsCalendars, view); } return(ewsCalendars); }
public ascx_FolderView buildGui() { var topPanel = this.clear().add_Panel(); CodeViewer = topPanel.title(Title_CodeEditor).add_SourceCodeViewer(); FolderView = topPanel.insert_Left(SplitterDistance, Title_FolderView).add_TreeView(); FolderView.afterSelect <string>( (fileOrFolder) => { if (fileOrFolder.fileExists()) { CodeViewer.open(fileOrFolder); } }); FolderView.beforeExpand <string>((treeNode, path) => loadFolder(treeNode, path)); FolderView.onDrop((fileOrfolder) => { FolderView.clear(); if (fileOrfolder.dirExists()) { loadFolder(FolderView.rootNode(), fileOrfolder); } }); FolderView.add_ContextMenu() .add_MenuItem("Refresh", true, () => refresh()) .add_MenuItem("Open in Windows Explorer", () => FolderView.selected().get_Tag().str().startProcess()); CodeViewer.set_Text("....select file on the left to view its contents here..."); return(this); }
static void ListTopLevelFolders(ExchangeService service, int moffset) { int mPageSize = 5; // Create a view with a page size of 5. FolderView view = new FolderView(mPageSize, moffset, OffsetBasePoint.Beginning); // Identify the properties to return in the results set. view.PropertySet = new PropertySet(BasePropertySet.IdOnly); view.PropertySet.Add(FolderSchema.DisplayName); view.PropertySet.Add(FolderSchema.ChildFolderCount); // Unlike FindItem searches, folder searches can be deep traversals. view.Traversal = FolderTraversal.Shallow; // Send the request to search the mailbox and get the results. FindFoldersResults findFolderResults = service.FindFolders(WellKnownFolderName.MsgFolderRoot, view); //FindFoldersResults findFolderResults = service.FindFolders(WellKnownFolderName.Calendar, view); // Process each item. foreach (Folder myFolder in findFolderResults.Folders) { if (myFolder is SearchFolder) { Console.WriteLine("Search folder: " + (myFolder as SearchFolder).DisplayName); } else if (myFolder is ContactsFolder) { Console.WriteLine("Contacts folder: " + (myFolder as ContactsFolder).DisplayName); } else if (myFolder is TasksFolder) { Console.WriteLine("Tasks folder: " + (myFolder as TasksFolder).DisplayName); } else if (myFolder is CalendarFolder) { Console.WriteLine("Calendar folder: " + (myFolder as CalendarFolder).DisplayName); } else { // Handle a generic folder. Console.WriteLine("Folder: " + myFolder.DisplayName); } } // Determine whether there are more folders to return. if (findFolderResults.MoreAvailable) { // Make recursive calls with offsets set for the FolderView to get the remaining folders in the result set. moffset = moffset + mPageSize; ListTopLevelFolders(service, moffset); } else { Console.WriteLine("More Available: " + findFolderResults.MoreAvailable); } }
// Resolve folder name to Folder object - the folder is expected to be immediately under the mailbox root public static Folder FindFolderByName(string folderName, ExchangeService service) { Logger.DebugFormat("Looking for folder named '{0}'", folderName); // Look for the folder under the mailbox root var rootFolder = Folder.Bind(service, WellKnownFolderName.MsgFolderRoot); // Folder name should be equal to 'folderName' var folderFilter = new SearchFilter.IsEqualTo(FolderSchema.DisplayName, folderName); // No need to look for more than one folder (can't have more than one folder with the exact same name) var view = new FolderView(1); view.Traversal = FolderTraversal.Deep; var findFoldersResults = rootFolder.FindFolders(folderFilter, view); if (!findFoldersResults.Any()) { Logger.InfoFormat("Couldn't find folder {0}", folderName); return(null); } Logger.DebugFormat("Found folder {0} ({1} matching folder items)", folderName, findFoldersResults.Count()); var folder = findFoldersResults.First(); return(folder); }
private Folder GetOrCreateFolderCore(string folderName, FolderId parentFolder, Func <Folder> creator) { SearchFilter filter = new SearchFilter.IsEqualTo(FolderSchema.DisplayName, folderName); FolderView view = new FolderView(1); FindFoldersResults findFoldersResults = this.InvokeServiceCall <FindFoldersResults>(() => this.Service.FindFolders(parentFolder, filter, view)); if (findFoldersResults.Folders.Count == 0) { Folder folder = creator(); folder.DisplayName = folderName; try { this.InvokeServiceCall(delegate() { folder.Save(parentFolder); }); } catch (DataSourceOperationException ex) { ServiceResponseException ex2 = ex.InnerException as ServiceResponseException; if (ex2 == null || ex2.ErrorCode != 107) { throw; } } findFoldersResults = this.InvokeServiceCall <FindFoldersResults>(() => this.Service.FindFolders(parentFolder, filter, view)); } return(findFoldersResults.Folders[0]); }
/// <summary> /// Provides a record-by-record processing functionality for the cmdlet. /// </summary> protected override void ProcessRecord() { // Create the Exchange Service Object and auth with bearer token ExchangeService exchangeService = new ExchangeService(new AuthenticationProvider(), this.SmtpAddress, RestEnvironment.OutlookBeta); MailFolder mailFolder = new MailFolder(exchangeService) { DisplayName = this.FolderName }; mailFolder.Save(this.FolderRoot); FolderView folderView = new FolderView(10); FindFoldersResults findFoldersResults = null; do { // Find the new folder and output the result SearchFilter searchFilter = new SearchFilter.IsEqualTo(MailFolderObjectSchema.DisplayName, mailFolder.DisplayName); findFoldersResults = exchangeService.FindFolders(this.FolderRoot, searchFilter, folderView); folderView.Offset += folderView.PageSize; foreach (MailFolder folder in findFoldersResults) { this.WriteObject(new PSObject(folder)); } }while (findFoldersResults.MoreAvailable); }
private FindFoldersResults TimedFindFolders(Folder folder, FolderView folderView) { if (folder == null) { return(null); } SleepIfThrottled(); FindFoldersResults results = null; long startTicks = DateTime.Now.Ticks; try { results = folder.FindFolders(folderView); } catch (Exception ex) { Throttled(ex); } finally { long endTicks = DateTime.Now.Ticks; _stats.AddStat("FindFolders", endTicks - startTicks); } return(results); }
/// <summary> /// Fecthing mails from a folder of mailbox. /// It will fetch without any filter /// </summary> /// <param name="service"></param> /// <param name="FolderName"></param> /// <param name="numberOfMails"></param> /// <param name="mailboxName"></param> /// <param name="onlyUnreadMails"></param> /// <returns></returns> static System.Collections.ObjectModel.Collection <Item> ReadMailFromFolder(ExchangeService service, String FolderName, Int32 numberOfMails, String mailboxName, bool onlyUnreadMails) { FolderView view = new FolderView(10000); view.PropertySet = new PropertySet(BasePropertySet.IdOnly); view.PropertySet.Add(FolderSchema.DisplayName); view.Traversal = FolderTraversal.Deep; Mailbox mailbox = new Mailbox(mailboxName); FindFoldersResults findFolderResults = service.FindFolders(new FolderId(WellKnownFolderName.MsgFolderRoot, mailbox), view); foreach (Folder folder in findFolderResults) { //For Folder filter if (folder.DisplayName == FolderName) { ItemView itemView = new ItemView(numberOfMails); if (onlyUnreadMails) { SearchFilter searchFilter = new SearchFilter.SearchFilterCollection(LogicalOperator.And, new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, false)); return((service.FindItems(folder.Id, searchFilter, itemView)).Items); } else { return((service.FindItems(folder.Id, itemView)).Items); } } } throw new Exception("Folder is not found"); }
/// <summary> /// Class constructor /// </summary> public ApplicationViewModel() { // Create and initialize list and combobox viemodel FolderView = ExplorerFactory.CreateList(); FolderView.AddRecentFolder(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)); FolderView.AddRecentFolder(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), true); FolderView.AddFilter("Executeable files", "*.exe;*.bat"); FolderView.AddFilter("Image files", "*.png;*.jpg;*.jpeg"); FolderView.AddFilter("LaTex files", "*.tex"); FolderView.AddFilter("Text files", "*.txt"); FolderView.AddFilter("All Files", "*.*"); // Create and initialize tree, list, and combobox viemodel FolderTreeView = ExplorerFactory.CreateTreeList(); FolderTreeView.AddRecentFolder(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)); FolderTreeView.AddRecentFolder(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), true); FolderTreeView.AddFilter("Executeable files", "*.exe;*.bat"); FolderTreeView.AddFilter("Image files", "*.png;*.jpg;*.jpeg"); FolderTreeView.AddFilter("LaTex files", "*.tex"); FolderTreeView.AddFilter("Text files", "*.txt"); FolderTreeView.AddFilter("All Files", "*.*"); _SelectedControllerTestViewModel = new object[2]; _SelectedControllerTestViewModel[0] = FolderView; _SelectedControllerTestViewModel[1] = FolderTreeView; // Set this as selected test by default ... SelectedTestviewModelIndex = 1; }
public List <Item> GetIndoxFormItem(SearchFilter searchFilter, ItemView options = null) { List <Item> items = new List <Item>(); List <Folder> folderIds = new List <Folder>(); FolderView folderView = new FolderView(int.MaxValue); FindFoldersResults findFolderResults = _exchangeService.FindFolders(WellKnownFolderName.Inbox, folderView); if (findFolderResults != null && findFolderResults.TotalCount > 0) { FindItemsResults <Item> parents = Find(searchFilter, options); foreach (Item item in parents) { items.Add(item); } Folder folder = findFolderResults.Folders[0]; FindItemsResults <Item> childrends = _exchangeService.FindItems(folder.Id, searchFilter, options); foreach (Item item in childrends) { items.Add(item); } } return(items); }
static void Main(string[] args) { Task <Folder> rootFolder = Folder.Bind(service, WellKnownFolderName.MsgFolderRoot); Task <FindFoldersResults> childFolders = rootFolder.Result.FindFolders(new FolderView(rootFolder.Result.ChildFolderCount)); List <MessageIndexObject> messageIndexObjects = new List <MessageIndexObject>(); List <Folder> allFolders = new List <Folder>(); //Build the allFolders list foreach (Folder f in childFolders.Result) { if ((String.Equals(f.DisplayName, "Inbox")) || (String.Equals(f.DisplayName, "Conversation History")) || (String.Equals(f.DisplayName, "Save")) || (String.Equals(f.DisplayName, "Trips")) || (String.Equals(f.DisplayName, "Sent Items"))) { allFolders.Add(f); if (f.ChildFolderCount > 0) { FolderView folderView = new FolderView(f.ChildFolderCount); GetSubFolders(f, folderView, allFolders); } } } foreach (Folder f in allFolders) { GetMessages(f); } }
private FindFoldersResults FindSubFolder(Queue <string> folderNames, FolderId folder = null) { string folderName = folderNames.Dequeue(); FolderView folderView = new FolderView(int.MaxValue); SearchFilter searchFilter = new SearchFilter.ContainsSubstring(FolderSchema.DisplayName, folderName); FindFoldersResults folderResults; if (folder == null) { folderResults = Service.FindFolders(WellKnownFolderName.PublicFoldersRoot , searchFilter, folderView); } else { folderResults = Service.FindFolders(folder , searchFilter, folderView); } if (!folderResults.Any()) { throw new ApplicationException("Non trovata la cartella " + folderName); } if (folderNames.Any()) { return(FindSubFolder(folderNames, folderResults.Folders.First().Id)); } else { return(folderResults); } }
private static Collection <Folder> GetAllContactsFolders(ExchangeService service) { // The collection will contain all contact folders. Collection <Folder> folders = new Collection <Folder>(); // Get the root Contacts folder and load all properties. This results in a GetFolder call to EWS. ContactsFolder rootContactFolder = ContactsFolder.Bind(service, WellKnownFolderName.Contacts); folders.Add(rootContactFolder); Console.WriteLine("Added the default Contacts folder to the collection of contact folders."); // Find all child folders of the root Contacts folder. int initialFolderSearchOffset = 0; const int folderSearchPageSize = 100; bool AreMoreFolders = true; FolderView folderView = new FolderView(folderSearchPageSize, initialFolderSearchOffset); folderView.Traversal = FolderTraversal.Deep; folderView.PropertySet = new PropertySet(BasePropertySet.IdOnly); while (AreMoreFolders) { try { // Find all the child folders of the default Contacts folder. This results in a FindFolder // operation call to EWS. FindFoldersResults childrenOfContactsFolderResults = rootContactFolder.FindFolders(folderView); if (folderView.Offset == 0) { Console.WriteLine("Found {0} child folders of the default Contacts folder.", childrenOfContactsFolderResults.TotalCount); } foreach (Folder f in childrenOfContactsFolderResults.Folders) { ContactsFolder contactFolder = (ContactsFolder)f; // Loads all the properties for the folder. This results in a GetFolder operation call to EWS. contactFolder.Load(); Console.WriteLine("Loaded a folder named {0} and added it to the collection of contact folders.", contactFolder.DisplayName); // Add the folder to the collection of contact folders. folders.Add(contactFolder); } // Turn off paged searches if there are no more folders to return. if (childrenOfContactsFolderResults.MoreAvailable == false) { AreMoreFolders = false; } else // Increment the paging offset. { folderView.Offset = folderView.Offset + folderSearchPageSize; } } catch (Exception ex) { Console.WriteLine("Error: {0}", ex.Message); } } return(folders); }
public IEnumerable <PublicFolderModel> GetAllFolders(string username, string password, string email, IEnumerable <KeyValuePair <string, string> > toDelete = null) { ExchangeService service = GetEWSService(username, password, email); var fv = new FolderView(2500); fv.PropertySet = GetPropertySet(); //fv.Traversal = FolderTraversal.Deep; var w = new MAPI(); //fv.Traversal = FolderTraversal.Shallow; //new FolderId("AQEuAAADGkRzkKpmEc2byACqAC/EWgMAbN4R9X4ytEC8CYU/2LnSxQACFO0hvgAAAA==") //WellKnownFolderName.PublicFoldersRoot var fList = new List <PublicFolderModel>(); var folders = service.FindFolders(WellKnownFolderName.PublicFoldersRoot, fv); foreach (var item in folders.Folders) { fList.Add(ParseFolder(item, toDelete)); //item.TryGetProperty(EWSProperties.Pr_Folder_Path, out string path); fList.AddRange(GetFolder(item, fv, toDelete).ToList()); } // e.TryGetProperty(EWSProperties.PR_Display_name, out string displayName); var t = fList.Count(e => e.NumberOfRules > 0); return(fList); }
public Folder GetVpnFolder(ExchangeService client, string inboxSubFolderNameWithVpnEmails = null) { var defaultFolder = Folder.Bind(client, WellKnownFolderName.Inbox); if (string.IsNullOrEmpty(inboxSubFolderNameWithVpnEmails)) { return(defaultFolder); } // https://stackoverflow.com/questions/7912584/exchange-web-service-folderid-for-a-not-well-known-folder-name // var folderIdVpn = new FolderId(InboxSubFolderNameWithVpnEmails); var folderView = new FolderView(pageSize: 5); folderView.Traversal = FolderTraversal.Deep; // Allows search in nested folders. var searchFilterVpnFolder = new SearchFilter.IsEqualTo(FolderSchema.DisplayName, inboxSubFolderNameWithVpnEmails); var vpnFolders = client.FindFolders(WellKnownFolderName.Inbox, searchFilterVpnFolder, folderView); Folder vpnFolder = null; if (vpnFolders.TotalCount > 0) { //var vpnFolderId = vpnFolders.Folders.Single().Id; var vpnFolderId = vpnFolders.Folders.FirstOrDefault()?.Id; vpnFolder = Folder.Bind(client, vpnFolderId); } else { vpnFolder = defaultFolder; } return(vpnFolder); }
static FolderId FindPublicFolder(ExchangeService myService, FolderId baseFolderId, string folderName) { // We will search using paging. We will use page size 10 FolderView folderView = new FolderView(10, 0); folderView.OffsetBasePoint = OffsetBasePoint.Beginning; // we will need only DisplayName and Id of every folder // se we'll reduce the property set to the properties folderView.PropertySet = new PropertySet(FolderSchema.DisplayName, FolderSchema.Id); FindFoldersResults folderResults; do { folderResults = myService.FindFolders(baseFolderId, folderView); foreach (Folder folder in folderResults) { if (String.Compare(folder.DisplayName, folderName, StringComparison.OrdinalIgnoreCase) == 0) { return(folder.Id); } } if (folderResults.NextPageOffset.HasValue) { // go to the next page folderView.Offset = folderResults.NextPageOffset.Value; } }while (folderResults.MoreAvailable); return(null); }
protected override void ProcessRecord() { FindFoldersResults results; if (!FolderName.ToLower().Equals("inbox")) { SearchFilter folderFilter = new SearchFilter.IsEqualTo(FolderSchema.DisplayName, FolderName); FolderView view = new FolderView(int.MaxValue); view.PropertySet = new PropertySet(BasePropertySet.IdOnly); view.PropertySet.Add(FolderSchema.DisplayName); view.Traversal = FolderTraversal.Deep; results = mailboxConnection.FindFolders(WellKnownFolderName.MsgFolderRoot, folderFilter, view); } else { FolderId folderID = new FolderId(WellKnownFolderName.Inbox); SearchFilter folderFilter = new SearchFilter.IsEqualTo(FolderSchema.Id, folderID); FolderView view = new FolderView(int.MaxValue); view.PropertySet = new PropertySet(BasePropertySet.IdOnly); view.PropertySet.Add(FolderSchema.DisplayName); view.Traversal = FolderTraversal.Deep; results = mailboxConnection.FindFolders(WellKnownFolderName.MsgFolderRoot, folderFilter, view); } foreach (Folder folder in results) { WriteObject(folder); } }
private void MenuItem_ClickDelete(object sender, RoutedEventArgs e) { var menuItem = sender as MenuItem; // Find the item from OS TreeItem itemToDelete = FakeOS.Volume.GetTreeItem(menuItem.Tag.ToString()); // Find its parant from OS TreeItem parant = FakeOS.Volume.GetParantOf(itemToDelete.Id); // Let's be sure that user really wants to delete the item MessageBoxResult result = MessageBox.Show($"Are you sure you want to delete {itemToDelete.Name}?", "Artemiy OS", MessageBoxButton.OKCancel); switch (result) { case MessageBoxResult.OK: // Remove item from OS FakeOS.Volume.RemoveTreeItem(itemToDelete.Id); // Find parant of item user want to delete in the Tree TreeViewItem parantTVI = (TreeViewItem)LogicalTreeHelper.FindLogicalNode(FolderView, "Id" + parant.Id); //FolderView.Items.GetItemAt(0); // Find item from the Tree by itself TreeViewItem childTVI = (TreeViewItem)LogicalTreeHelper.FindLogicalNode(FolderView, "Id" + itemToDelete.Id); //FolderView.Items.GetItemAt(0); // Remove child from children of parant parantTVI.Items.Remove(childTVI); // Update the Tree so deleted item will be finaly removed from the UI DrawGrid(); FolderView.UpdateLayout(); break; case MessageBoxResult.Cancel: break; } }
void Awake() { folderFacade.Register(); settingsFacade.Register(); workBenchFacade.Register(); this.initialize(); folderModel = new FolderModel(); this.framework.modelCenter.Register(FolderModel.NAME, folderModel); folderView = new FolderView(); this.framework.viewCenter.Register(FolderView.NAME, folderView); folderController = new FolderController(); this.framework.controllerCenter.Register(FolderController.NAME, folderController); mouseController = new MouseController(); this.framework.controllerCenter.Register(MouseController.NAME, mouseController); SettingsView viewSettings = new SettingsView(); this.framework.viewCenter.Register(SettingsView.NAME, viewSettings); WorkBenchView viewWorkBench = new WorkBenchView(); this.framework.viewCenter.Register(WorkBenchView.NAME, viewWorkBench); WorkBenchController controllerWorkBench = new WorkBenchController(); this.framework.controllerCenter.Register(WorkBenchController.NAME, controllerWorkBench); workBenchModel = new WorkBenchModel(); this.framework.modelCenter.Register(WorkBenchModel.NAME, workBenchModel); }
private async System.Threading.Tasks.Task <FolderId> FindProjectPath(Folder parentFolder, int start, int offset, string projectNumber, int recursionCount) { var view = new FolderView(int.MaxValue); view.PropertySet = new PropertySet(BasePropertySet.IdOnly, FolderSchema.DisplayName); var filter = new SearchFilter.ContainsSubstring(FolderSchema.DisplayName, projectNumber); var results = await System.Threading.Tasks.Task.Run(() => { return(this.GetEmailService.FindFolders(parentFolder.Id, filter, view)); }); //var folders = parentFolder.FindFolders(filter, view); if (results.Folders.Count <= 0) { //return await this.FindProjectPath(parentFolder, offset, offset + 255, projectNumber, recursionCount ++); Logger.LoggerAsync.InstanceOf.GeneralLogger.Info("FindProjectPath for {0} returned null after searching in {1}", projectNumber, parentFolder.DisplayName); return(null); } else if (recursionCount > 5) { throw new TimeoutException("recursion too deep"); } else { var projectFolder = results.Folders[0].Id; Logger.LoggerAsync.InstanceOf.GeneralLogger.Info("FindProjectPath returned a project folder {0} after searching in {1}", projectFolder.FolderName, parentFolder.DisplayName); return(projectFolder); } }
public MailFolderDialog (Gtk.Window parent) { this.parent = parent; Glade.XML glade = new Glade.XML (null, "settings.glade", "mail_folder_dialog", "beagle"); glade.Autoconnect (this); folder_view = new FolderView (); folder_view.Show (); folder_sw.Child = folder_view; }