private void TestServerConnection() { const string connectionTestCaption = "Test settings"; try { StringBuilder errorMessageBuilder = new StringBuilder(); if (!ValidateCalendarUrl(errorMessageBuilder)) { MessageBox.Show(errorMessageBuilder.ToString(), "The calendar Url is invalid", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } var dataAccess = new CalDavDataAccess( new Uri(_calenderUrlTextBox.Text), new CalDavWebClient( _userNameTextBox.Text, _passwordTextBox.Text, TimeSpan.Parse(ConfigurationManager.AppSettings["calDavConnectTimeout"]), TimeSpan.Parse(ConfigurationManager.AppSettings["calDavReadWriteTimeout"]), Boolean.Parse(ConfigurationManager.AppSettings["disableCertificateValidation"]), Boolean.Parse(ConfigurationManager.AppSettings["enableSsl3"]), Boolean.Parse(ConfigurationManager.AppSettings["enableTls12"])) ); if (!dataAccess.IsCalendarAccessSupported()) { MessageBox.Show("The specified Url does not support calendar access!", connectionTestCaption); } if (!dataAccess.IsResourceCalender()) { MessageBox.Show("The specified Url is not a calendar!", connectionTestCaption); } if (!dataAccess.IsWriteableCalender()) { MessageBox.Show("The specified Url is a read-only calendar!", connectionTestCaption); } if (!dataAccess.DoesSupportCalendarQuery()) { MessageBox.Show("The specified Url does not support Calendar Queries!", connectionTestCaption); } MessageBox.Show("Connection test successful.", connectionTestCaption); } catch (Exception x) { MessageBox.Show(x.Message, connectionTestCaption); } }
public static async Task <TestResult> TestConnection(Uri url, IWebDavClient webDavClient) { var calDavDataAccess = new CalDavDataAccess(url, webDavClient); var cardDavDataAccess = new CardDavDataAccess(url, webDavClient); // Note: CalDav Calendars can contain Events and Todos. Therefore an calender resource is always a calendar and a task list. var ressourceType = (await calDavDataAccess.IsResourceCalender() ? ResourceType.Calendar | ResourceType.TaskList : ResourceType.None) | (await cardDavDataAccess.IsResourceAddressBook() ? ResourceType.AddressBook : ResourceType.None); return(new TestResult( ressourceType, ressourceType.HasFlag(ResourceType.Calendar) ? await GetCalendarProperties(calDavDataAccess) : CalendarProperties.None, ressourceType.HasFlag(ResourceType.AddressBook) ? await GetAddressBookProperties(cardDavDataAccess) : AddressBookProperties.None)); }
public static async Task <TestResult> TestConnection(Uri url, IWebDavClient webDavClient) { var calDavDataAccess = new CalDavDataAccess(url, webDavClient); var cardDavDataAccess = new CardDavDataAccess(url, webDavClient, string.Empty, contentType => true); // Note: CalDav Calendars can contain Events and Todos. Therefore an calender resource is always a calendar and a task list. var ressourceType = (await calDavDataAccess.IsResourceCalender() ? ResourceType.Calendar | ResourceType.TaskList : ResourceType.None) | (await cardDavDataAccess.IsResourceAddressBook() ? ResourceType.AddressBook : ResourceType.None); return(new TestResult( ressourceType, ressourceType.HasFlag(ResourceType.Calendar) ? await GetCalendarProperties(calDavDataAccess) : CalendarProperties.None, ressourceType.HasFlag(ResourceType.AddressBook) ? await GetAddressBookProperties(cardDavDataAccess) : AddressBookProperties.None, await calDavDataAccess.GetPrivileges(), await calDavDataAccess.DoesSupportWebDavCollectionSync(), ressourceType.HasFlag(ResourceType.Calendar) ? await calDavDataAccess.GetCalendarOwnerPropertiesOrNull() : null)); }
public static async Task <TestResult> TestConnection(Uri url, IWebDavClient webDavClient, ResourceType supposedRessourceType) { var calDavDataAccess = new CalDavDataAccess(url, webDavClient); var cardDavDataAccess = new CardDavDataAccess(url, webDavClient); TestResult result; switch (supposedRessourceType) { case ResourceType.None: var ressourceType = (await calDavDataAccess.IsResourceCalender() ? ResourceType.Calendar : ResourceType.None) | (await cardDavDataAccess.IsResourceAddressBook() ? ResourceType.AddressBook : ResourceType.None); result = new TestResult( ressourceType, ressourceType.HasFlag(ResourceType.Calendar) ? await GetCalendarProperties(calDavDataAccess) : CalendarProperties.None, ressourceType.HasFlag(ResourceType.AddressBook) ? await GetAddressBookProperties(cardDavDataAccess) : AddressBookProperties.None); break; case ResourceType.Calendar: result = new TestResult( supposedRessourceType, CalendarProperties.CalendarAccessSupported | (await calDavDataAccess.IsWriteable() ? CalendarProperties.IsWriteable : CalendarProperties.None) | (await calDavDataAccess.DoesSupportCalendarQuery() ? CalendarProperties.SupportsCalendarQuery : CalendarProperties.None), AddressBookProperties.None); break; case ResourceType.AddressBook: result = new TestResult( supposedRessourceType, CalendarProperties.None, AddressBookProperties.AddressBookAccessSupported | (await cardDavDataAccess.IsWriteable() ? AddressBookProperties.IsWriteable : AddressBookProperties.None)); break; default: throw new ArgumentOutOfRangeException("supposedRessourceType"); } return(result); }