ListProducts.cs

This is an example on how to use the Bugzproxy.Server.GetProducts call

using System;
using Bugzproxy;

class ListProductClass {
  static public int Main( string[] args ) {
    ////////////////////////////////////////////////////////////
    // Use common class to get all arguments
    SimpleAppArgs argParser 
      = new SimpleAppArgs( "ListProducts.exe", 
                           "Program to list products" );
    // 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
    Console.WriteLine( "Id\tName\tDescription" );
    // We may need a login to list our products, but we try without
    try {
      foreach ( Product p
                in server.GetProducts( server.GetAccessibleProductIds() ) ) {
        Console.WriteLine( p.Id + "\t" + p.Name + "\t" + p.Description );
      }
    }
    catch (Exception e) {
      Console.WriteLine( "An exception occured. Try running with --trace? Exception follows");
      Console.WriteLine( e );
      return 1;
    }
    return 0;
  }
}


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