using System;
using System.Text;
namespace P4API
{
public class P4PendingChangelist
{
private P4Connection _p4 = null;
internal P4Form baseForm;
internal P4PendingChangelist(string Description, P4Connection p4)
{
_p4 = p4;
baseForm = _p4.Fetch_Form("change");
// clear the Jobs list
string [] NullList = {};
baseForm.ArrayFields["Jobs"] = NullList;
// clear the Files list
baseForm.ArrayFields["Files"] = NullList;
// save the description
baseForm.Fields["Description"] = Description;
P4UnParsedRecordSet r = _p4.Save_Form(baseForm);
if (!r.HasErrors())
{
// convert to int to verify we're parsing correctly
int changeNumber = int.Parse(r.Messages[0].Split(' ')[1]);
baseForm.Fields["Change"] = changeNumber.ToString();
}
}
///
/// Gets the pending changelist's number.
///
/// The number.
public int Number
{
get
{
return int.Parse(baseForm.Fields["Change"]);
}
}
///
/// Gets the pending changelist's description.
///
/// The description.
public string Description
{
get
{
return baseForm.Fields["Description"];
}
}
public P4UnParsedRecordSet Submit()
{
return _p4.RunUnParsed("submit", "-c", Number.ToString());
}
}
}