PSI's IsXyzNull() throwing ArgumentNullException

  • Thread starter Stephan Steiner
  • Start date
S

Stephan Steiner

Hi

I was under the impression that in order to ensure that I'm only using non
empty columns I could use the IsXyzNull() method of the various Row types
defined in PSI. .

for instance, here I'm trying to add a bunch of enterprise resources to a
project plan - so I first check if the resource, identified by its NT
account, is already part of the project, and if not I look it up in the
enterprise pool using the Resource service. Then I create a new line for
ProjectDataSet.ProjectResources and copy all the fields from the
ResourceDataSet.ResourcesRow to the ProjectDataSet.ResourceRow (as long as
they exist in both rows) - in order not to run into any problems I'm using
the IsXyzNull() methods on the ResourcesRow - still, my first line already
fails.. when I'm calling ResourceDataSet.ResourcesRow.IsCREATED_DATENull() I
get an ArgumentException ('column' argument cannot be null. Parameter name:
columm) which seems to indicate that the ADO mapping is messed up - of
course I can go through the table rows the traditional way and check for
DBNull values, but isn't the point of having the PSILib to not having to do
that?

Regards
Stephan
 
S

Stephan Steiner

Actually, it's a bit worse than that.. the underlying table doesn't even
seem to have the colums.

So what I need is an instance of the row, then get the table from that, and
call IndexOf on the Columns collection of the underlying table and using the
appropriate *Column.ColumnName field to identify the column.. if the return
value is -1, the column doesn't exist (weird since the underlying database
table definitely has it) then I know I cannot read the value.. but that
means a lot of manual work - and the question becomes.. why are those
columns not there in the DataTable in the first place?

Regards
Stephan
 
S

Stephan Steiner

Here's a little method I cobbled together to to reproduce the problem on my end (I refreshed the web references just in case):

public void resourceTest(List<string> ntAccounts, string projectName)
{
Guid projectUid = conn.GetProjectUidFromName(projectName);
ProjectWebSvc.ProjectTeamDataSet team = conn.ReadProjectTeam(projectUid);
ResourceWebSvc.ResourceDataSet resources = conn.ReadUserList(ResourceWebSvc.ResourceActiveFilter.Active);
ResourceWebSvc.ResourceDataSet.ResourcesRow enterpriseResource = null;
ProjectWebSvc.ProjectTeamDataSet.ProjectTeamRow projectResource = null;
foreach (string account in ntAccounts)
{
DataView dv = new DataView(resources.Resources);
dv.RowFilter = resources.Resources.WRES_ACCOUNTColumn.ColumnName + " = '" + account + "'";
if (dv.Count == 0)
return;
enterpriseResource = (ResourceWebSvc.ResourceDataSet.ResourcesRow)dv[0].Row;
projectResource = team.ProjectTeam.FindByRES_UIDPROJ_UID(enterpriseResource.RES_UID, projectUid);
if (projectResource != null)
Console.WriteLine("Resource " + account + " is already in the project");
Console.WriteLine("Resource " + account + " is not yet part of the project, adding now, guid:" + enterpriseResource.RES_UID.ToString());
projectResource = team.ProjectTeam.NewProjectTeamRow();
projectResource.PROJ_UID = projectUid;
if (!enterpriseResource.IsRES_BOOKING_TYPENull())
projectResource.RES_BOOKING_TYPE = enterpriseResource.RES_BOOKING_TYPE;
projectResource.RES_HAS_ACTUALS = false;
projectResource.NEW_RES_UID = enterpriseResource.RES_UID;
projectResource.RES_IS_ENTERPRISE_RESOURCE = true;
projectResource.RES_NAME = enterpriseResource.RES_NAME;
projectResource.RES_TYPE = enterpriseResource.RES_TYPE;
projectResource.RES_UID = enterpriseResource.RES_UID;
team.ProjectTeam.AddProjectTeamRow(projectResource);
}
}

The variable conn is a reference to my PSI wrapper class.. it does nothing other than call the actual methods on the appropriate webservice and error handling - since it's huge (contains a bunch of services) I'm not posting it here.

I get the ArgumentNullException when I call enterpriseResource.IsRES_BOOKING_TYPENull() (and probably calling other ISxyzNull methods).

I'm still searching my code for the ugly workaround I developed to find out if a row exists in the underlying dataset.. I seem to recall having written something but I have so many test methods by now that it's not apparent to find them anymore.

Regards
Stephan
"Stephen Sanderlin" <stephen NS-DOT sanderlin A-NS-T msprojectexperts DOT-NS com> wrote in message Hm. Odd. They should be there. Have you tried refreshing your web references? Maybe the proxy class got messed up somehow. If you post your code, I'll try to repro.

--

Stephen Sanderlin

Principal Consultant

MSProjectExperts



For Project Server Consulting: http://www.msprojectexperts.com

For Project Server Training: http://www.projectservertraining.com



Read my blog at: http://www.projectserverhelp.com/

Join the community at: http://forums.epmfaq.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top