private void AsyncRetrieveOptions(object state)
        {
            //since we're called from the threadpool we have to catch exceptions or the application will fail.
            try
            {
                object[] args     = (object[])state;
                string   userName = (string)args[0];
                string   password = (string)args[1];

                FBApi fogBugzServer = new FBApi(m_WorkingCommonConfig.Url, userName, password);
                m_ProjectsAndAreas = fogBugzServer.ListProjectsAndAreas();
                m_Priorities       = fogBugzServer.ListPriorities();

                m_ProductsAndApplications = new Dictionary <string, List <string> >();
            }
            catch (Exception ex)
            {
                m_Context.Log.ReportException(ex, RepositoryController.LogCategory, true, false);
            }

            Mapping existingMapping = state as Mapping;

            if (existingMapping == null)
            {
                ThreadSafeAddMapping();
            }
            else
            {
                ThreadSafeEditMapping(existingMapping);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Create a new defect in the defect tracking system with the provided set messages
 /// </summary>
 /// <param name="controller"></param>
 /// <param name="messages"></param>
 private void ActionAddDefect(IUserInterfaceContext controller, IList <ILogMessage> messages)
 {
     using (AddDefectDialog dialog = new AddDefectDialog())
     {
         FBApi api = m_Controller.GetApi();
         dialog.AddDefect(m_Context, messages, m_Controller, api);
     }
 }
 private static void TestServerConnection(string url, string userName, string password)
 {
     try
     {
         //this does an immediate login
         FBApi  testApi = new FBApi(url, userName, password);
         string message = "Successfully authenticated to the server at " + url;
         MessageBox.Show(message, "Connected to Server", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     catch (Exception ex)
     {
         string message = "Unable to log into the server at " + url + ":\r\n\r\n" + ex.Message;
         MessageBox.Show(message, "Unable to Connect to Server", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemplo n.º 4
0
        internal FBApi GetApi()
        {
            string url = m_CommonConfig.Url;
            string userName, password;

            if (m_Context.Environment == LoupeEnvironment.Server)
            {
                m_Context.Configuration.GetServerCredentials(ServerCredentialsKey, out userName, out password);
            }
            else
            {
                m_Context.Configuration.GetUserCredentials(ServerCredentialsKey, out userName, out password);
            }

            if (string.IsNullOrEmpty(url))
            {
                throw new InvalidOperationException("No FogBugz server URL has been configured to connect to.");
            }

            if (string.IsNullOrEmpty(userName))
            {
                throw new InvalidOperationException(string.Format("No account has been provided to connect to FogBugz with.  Please configure a {0} account.",
                                                                  (m_Context.Environment == LoupeEnvironment.Server) ? "server" : "personal"));
            }

            // Throw an exception if we can't connect with FogBugz
            FBApi api;

            try
            {
                m_Context.Log.Verbose(LogCategory, "Connecting to FogBugz Server", "Server URL: {0}\r\nUser Name: {1}", url, userName);
                api = new FBApi(url, userName, password);
            }
            catch (Exception ex)
            {
                m_Context.Log.Error(ex, LogCategory, "Failed to connect to FogBugz Server", "Server URL: {0}\r\nUser Name: {1}\r\nException: {2}", url, userName, ex.Message);
                throw new ApplicationException("Could not contact FogBugz Server", ex);
            }

            return(api);
        }