Beispiel #1
0
    //-------------------------------------------------------------------------

    private void LoadFromDb()
    {
      // Compile a list of user IDs.
      List<int> userIDs = new List<int>();

      SqlCommand cmd = Program.DbConnection.Critr.CreateCommand();
      cmd.CommandText =
        "SELECT id " +
        "FROM [User] " +
        "ORDER BY sourceControlUsername";

      using( SqlDataReader reader = cmd.ExecuteReader() )
      {
        while( reader.Read() )
        {
          userIDs.Add( reader.GetInt32( 0 ) );
        }
      }

      // Create each user.
      foreach( int id in userIDs )
      {
        User user = new User( id );
        Users.Add( user );

        //Program.Log.AddEntry(
        //  Log.EntryType.INFO,
        //  "Added user '" + user.Username + "' from DB." );
      }
    }
Beispiel #2
0
    //-------------------------------------------------------------------------

    public Changelist( int id,
                       string description,
                       User submitter,
                       DateTime date )
    {
      Id = id;
      Description = description;
      Submitter = submitter;
      SubmittedDate = date;
    }
Beispiel #3
0
    //-------------------------------------------------------------------------

    private void uiOK_Click( object sender, EventArgs e )
    {
      // Nothing selected? Do nothing.
      if( uiP4Username.SelectedItem == null )
      {
        return;
      }

      SelectedUser = uiP4Username.SelectedItem as User;

      Hide();
    }
Beispiel #4
0
    //-------------------------------------------------------------------------

    private void uiCancel_Click( object sender, EventArgs e )
    {
      SelectedUser = null;

      Hide();
    }
Beispiel #5
0
    //-------------------------------------------------------------------------

    private void LoadFromP4()
    {
      // Get users from P4.
      string output = Perforce.RunCommand( "users" );

      // Split the output into individual lines.
      string[] lines = output.Split( new string[] { Environment.NewLine }, StringSplitOptions.None );

      // The username is the first thing on each line followed by a space char.
      foreach( string line in lines )
      {
        if( line.IndexOf( ' ' ) < 0 )
        {
          continue;
        }

        string username = line.Substring( 0, line.IndexOf( ' ' ) );

        //Program.Log.AddEntry(
        //  Log.EntryType.INFO,
        //  "Found user '" + username + "' in P4." );

        try
        {
          if( GetUser( username ) != null )
          {
            continue;
          }

          User user =
            new User(
              false,
              username,
              "Unknown",
              "Unknown",
              "123454321",
              "Unknown",
              false,
              false,
              false );

          Users.Add( user );

          //Program.Log.AddEntry(
          //  Log.EntryType.INFO,
          //  "Added user '" + user.Username + "' to DB." );
        }
        catch( Exception ex )
        {
          Program.Log.AddEntry(
            Log.EntryType.ERROR,
            "Error while creating a user: " + ex.Message );
        }
      }
    }