private bool TestConnection(out string errorMsg) { try { errorMsg = ""; using (ProgressDialog dlg = new ProgressDialog(3, 1)) { dlg.Show(); dlg.Step("Contacting Workshare Navigtator Web-Service"); Proxy.NavigatorRef.Navigator navigator = navigator = Proxy.WebServiceController.GetNavigator(this.DocumentLibrary); if (navigator == null) { errorMsg = "Invalid web address. Please check that the Workshare server component is installed."; return false; } try { dlg.Step("Attemping handshake"); string s = navigator.Handshake(); if (s != "Hello") { errorMsg = "Handshake with server returned incorrect string: " + s + "."; return false; } } catch (Exception ex) { errorMsg = "Handshake with server threw an exception: " + ex.Message + "."; return false; } dlg.Step("Retrieving data from server"); Proxy.NavigatorRef.Item item = null; try { item = navigator.GetItem(this.DocumentLibrary); } catch (Exception ex) { Logger.LogError(ex); item = navigator.GetItem(this.DocumentLibrary); } if (item == null) { errorMsg = "Unable to retrieve data from server."; return false; } } } catch (Exception ex) { errorMsg = "Invalid settings: " + ex.Message + "."; return false; } return true; }
public bool TestConnection(string libUrl) { try { using (ProgressDialog dlg = new ProgressDialog(3, 1)) { dlg.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; dlg.Show(); dlg.Step("Contacting Workshare Navigtator Web-Service"); Proxy.NavigatorRef.Navigator navigator = navigator = Proxy.WebServiceController.GetNavigator(libUrl); if (navigator == null) { Logger.LogInfo("Invalid web address. Please check that the Workshare server component is installed."); return false; } try { dlg.Step("Attemping handshake"); string s = navigator.Handshake(); if (s != "Hello") { Logger.LogInfo("Handshake with server returned incorrect string: " + s + "."); return false; } } catch (Exception ex) { Logger.LogError("Handshake with server threw an exception: " + ex.Message + "."); return false; } dlg.Step("Retrieving data from server"); Proxy.NavigatorRef.Item item = null; try { item = navigator.GetItem(libUrl); } catch (Exception ex) { Logger.LogError(ex); item = navigator.GetItem(libUrl); } if (item == null) { Logger.LogInfo("Unable to retrieve data from server."); return false; } } } catch(Exception ex) { Logger.LogError("Invalid settings: " + ex.Message + "."); return false; } return true; }