Login.cs

This is an example on how to use the Bugzproxy.Server.Login call, which can also be used to test if your login works with a given server.

using System;
using Bugzproxy;

class LoginClass {
  static public int Main( string[] args ) {
    ////////////////////////////////////////////////////////////
    // Use common class to get all arguments
    SimpleAppArgs argParser 
      = new SimpleAppArgs( "Login.exe", 
                           "Program to test login to a server" );
    // If parsing fails, bail out
    if ( ! argParser.Parse( args ) ) { 
      return 1; 
    }
    Console.WriteLine( "Using server {0}:{1}/{2}", argParser.Host, argParser.Port, argParser.Path );
    Console.WriteLine( "Using username {0} and password {1}", argParser.User, argParser.Password );
    // Construct server, based on arguments, setup tracer if user set option
    Server server 
      = new Server( argParser.Host, argParser.Port, argParser.Path );
    if ( argParser.Trace ) { 
      server.TraceWriter = System.Console.Out; 
    }
    
    ////////////////////////////////////////////////////////////
    // Real program starts here

    // We try a login
    try {
      server.Login( argParser.User, argParser.Password, true );
    }
    catch (Exception e) {
      Console.WriteLine( "An exception occured. Perhaps your username and password was not legal. Try running with --trace? Exception follows");
      Console.WriteLine( e );
      return 1;
    }
    Console.WriteLine( "Succesfully logged in!" );
    return 0;
  }
}

Generated on Thu Jan 17 07:31:46 2008 for BugzillaProxy by  doxygen 1.5.4