protected void Page_Load(object sender, EventArgs e) { NetworkCredential credential = new NetworkCredential("username", "password"); Service service = new Service("https://myserver/ews/Exchange.asmx", credential); try { IsGreaterThanOrEqualTo restriction1 = new IsGreaterThanOrEqualTo(AppointmentPropertyPath.StartTime, DateTime.Today); IsLessThanOrEqualTo restriction2 = new IsLessThanOrEqualTo(AppointmentPropertyPath.EndTime, DateTime.Today.AddDays(1)); And restriction3 = new And(restriction1, restriction2); FindItemResponse response = service.FindItem(StandardFolder.Calendar, AppointmentPropertyPath.AllPropertyPaths, restriction3); for (int i = 0; i < response.Items.Count; i++) { if (response.Items[i] is Appointment) { Appointment appointment = (Appointment)response.Items[i]; lblSubject.Text = "Subject = " + appointment.Subject; lblStartTime.Text = "StartTime = " + appointment.StartTime; lblEndTime.Text = "EndTime = " + appointment.EndTime; lblBodyPreview.Text = "Body Preview = " + appointment.BodyPlainText; } } } catch (ServiceRequestException ex) { lblError.Text= "Error: " + ex.Message; lblXmlError.Text = "Error: " + ex.XmlMessage; Console.Read(); } catch (WebException ex) { lblWebError.Text = "Error: " + ex.Message; } }
/// <summary> /// Gets the search filter instance. /// </summary> /// <param name="localName">Name of the local.</param> /// <returns></returns> private static SearchFilter GetSearchFilterInstance(string localName) { SearchFilter searchFilter; switch (localName) { case XmlElementNames.Exists: searchFilter = new Exists(); break; case XmlElementNames.Contains: searchFilter = new ContainsSubstring(); break; case XmlElementNames.Excludes: searchFilter = new ExcludesBitmask(); break; case XmlElementNames.Not: searchFilter = new Not(); break; case XmlElementNames.And: searchFilter = new SearchFilterCollection(LogicalOperator.And); break; case XmlElementNames.Or: searchFilter = new SearchFilterCollection(LogicalOperator.Or); break; case XmlElementNames.IsEqualTo: searchFilter = new IsEqualTo(); break; case XmlElementNames.IsNotEqualTo: searchFilter = new IsNotEqualTo(); break; case XmlElementNames.IsGreaterThan: searchFilter = new IsGreaterThan(); break; case XmlElementNames.IsGreaterThanOrEqualTo: searchFilter = new IsGreaterThanOrEqualTo(); break; case XmlElementNames.IsLessThan: searchFilter = new IsLessThan(); break; case XmlElementNames.IsLessThanOrEqualTo: searchFilter = new IsLessThanOrEqualTo(); break; default: searchFilter = null; break; } return(searchFilter); }
public void No_match_if_less() { var isGreaterThanOrEqualToOne = new IsGreaterThanOrEqualTo<int>(1); var matches = isGreaterThanOrEqualToOne.Matches(0); Assert.IsFalse(matches); }
public void Match_if_equal() { var isGreaterThanOrEqualToOne = new IsGreaterThanOrEqualTo<int>(1); var matches = isGreaterThanOrEqualToOne.Matches(1); Assert.IsTrue(matches); }
public void Match_if_equal() { var isGreaterThanOrEqualToOne = new IsGreaterThanOrEqualTo <int>(1); var matches = isGreaterThanOrEqualToOne.Matches(1); Assert.True(matches); }
public void No_match_if_less() { var isGreaterThanOrEqualToOne = new IsGreaterThanOrEqualTo <int>(1); var matches = isGreaterThanOrEqualToOne.Matches(0); Assert.False(matches); }
/// <summary> /// Das ist der Kern der Routine, hier wird alles aufgerollt und dann /// geht es los. /// </summary> public IList <WorkReportItemDTO> RetrieveAppointments() { //Aufruf nur sinnvoll, wenn Objekt konfiguriert if (String.IsNullOrEmpty(_username) || String.IsNullOrEmpty(_password)) { throw new ArgumentException("Username / Password not set!"); } if (String.IsNullOrEmpty(_exchangeServerURI)) { throw new ArgumentException("Exchange Server URI not set!"); } List <WorkReportItemDTO> workReportItems = new List <WorkReportItemDTO>(); NetworkCredential credential = new NetworkCredential(_username, _password); Service service = new Service(_exchangeServerURI, credential); try { FindFolderResponse allCalendarFolders = service.FindFolder(StandardFolder.Calendar, FolderQueryTraversal.Deep); Folder rootCalendarFolder = service.GetFolder(StandardFolder.Calendar); allCalendarFolders.Folders.Add(rootCalendarFolder); IList <Independentsoft.Exchange.FolderId> calenderFoldersToBeSearched = new List <Independentsoft.Exchange.FolderId>(); string[] defaultCalendarSearchList = (System.Windows.Application.Current as App)._currentConfiguration.CalendarList; for (int i = 0; i < allCalendarFolders.Folders.Count; i++) { string folderName = allCalendarFolders.Folders[i].DisplayName; if (defaultCalendarSearchList == null || defaultCalendarSearchList.Contains(folderName)) { Trace.WriteLine($"Accepted FolderName: {allCalendarFolders.Folders[i].DisplayName}"); FolderId f = allCalendarFolders.Folders[i].FolderId; calenderFoldersToBeSearched.Add(f); } else { Trace.WriteLine($"Ignored FolderName: {allCalendarFolders.Folders[i].DisplayName}"); } } //wenn ich keine calendar folders habe, brauche ich gar nicht suchen. das ist sinnlos und würde //nur das web service mit einem Fehler aussteigen lassen if (calenderFoldersToBeSearched.Count == 0) { return(workReportItems); } IsGreaterThanOrEqualTo restrictionStartInterval = new IsGreaterThanOrEqualTo(AppointmentPropertyPath.StartTime, _startInterval); IsLessThan restrictionEndInterval = new IsLessThan(AppointmentPropertyPath.StartTime, _endInterval); And restrictionInterval = new And(restrictionStartInterval, restrictionEndInterval); IList <FindItemResponse> responses = service.FindItem(calenderFoldersToBeSearched, AppointmentPropertyPath.AllPropertyPaths, restrictionInterval); foreach (FindItemResponse response in responses) { for (int i = 0; i < response.Items.Count; i++) { if (response.Items[i] is Appointment) { if (_appointmentSelectPredicate(response.Items[i] as Appointment) == true) { WorkReportItemDTO wre = new WorkReportItemDTO(); Appointment appointment = (Appointment)response.Items[i]; wre.CustomerName = appointment.Subject; wre.StartTime = appointment.StartTime; wre.EndTime = appointment.EndTime; wre.WorkDescription = appointment.BodyPlainText; string s = appointment.BodyHtmlText; workReportItems.Add(wre); } } } } workReportItems.Sort(); } catch (Exception ex) { Trace.WriteLine(ex.Message); throw; } return(workReportItems); }
/// <summary> /// Gets the search filter instance. /// </summary> /// <param name="localName">Name of the local.</param> /// <returns></returns> private static SearchFilter GetSearchFilterInstance(string localName) { SearchFilter searchFilter; switch (localName) { case XmlElementNames.Exists: searchFilter = new Exists(); break; case XmlElementNames.Contains: searchFilter = new ContainsSubstring(); break; case XmlElementNames.Excludes: searchFilter = new ExcludesBitmask(); break; case XmlElementNames.Not: searchFilter = new Not(); break; case XmlElementNames.And: searchFilter = new SearchFilterCollection(LogicalOperator.And); break; case XmlElementNames.Or: searchFilter = new SearchFilterCollection(LogicalOperator.Or); break; case XmlElementNames.IsEqualTo: searchFilter = new IsEqualTo(); break; case XmlElementNames.IsNotEqualTo: searchFilter = new IsNotEqualTo(); break; case XmlElementNames.IsGreaterThan: searchFilter = new IsGreaterThan(); break; case XmlElementNames.IsGreaterThanOrEqualTo: searchFilter = new IsGreaterThanOrEqualTo(); break; case XmlElementNames.IsLessThan: searchFilter = new IsLessThan(); break; case XmlElementNames.IsLessThanOrEqualTo: searchFilter = new IsLessThanOrEqualTo(); break; default: searchFilter = null; break; } return searchFilter; }
private static ConditionResult VerifyCondition(List <object> objects, IsGreaterThanOrEqualTo cond) { return(ConvertToValueConditionAndVerify(objects, cond)); }