This project is read-only.
1
Vote

GetCustomFieldRowValue Fails for Finish Dates

description

I am unable to read FINISH Dates the following is relevant code:
private static object GetCustomFieldRowValue(DataRow row, DataRowVersion version)
    {
      var psDataType =
                (PSDataType)RowDataAdapter.GetRowData<byte>(row, CustomFieldsColumnNames.FIELD_TYPE_ENUM, version);

      switch (psDataType)
      {
        case PSDataType.GUID:
          return RowDataAdapter.GetRowData<Guid>(row, CustomFieldsColumnNames.CODE_VALUE, version);
        case PSDataType.STRING:
          return RowDataAdapter.GetRowData<string>(row, CustomFieldsColumnNames.TEXT_VALUE, version);
        case PSDataType.COST:
          return RowDataAdapter.GetRowData<decimal>(row, CustomFieldsColumnNames.NUM_VALUE, version) / COST_RATE;
        case PSDataType.NUMBER:
          return RowDataAdapter.GetRowData<decimal>(row, CustomFieldsColumnNames.NUM_VALUE, version);
        case PSDataType.DATE:
          return RowDataAdapter.GetRowData<DateTime>(row, CustomFieldsColumnNames.DATE_VALUE, version);
        case PSDataType.YESNO:
          return RowDataAdapter.GetRowData<bool>(row, CustomFieldsColumnNames.FLAG_VALUE, version);
        case PSDataType.DURATION:
          int value = RowDataAdapter.GetRowData<int>(row, CustomFieldsColumnNames.DUR_VALUE, version);
          return TimeSpan.FromSeconds(value * 6);
        default:
          return null;
      }
    }
This is fixed by simply adding:
        case PSDataType.DATE: 
        case PSDataType.FINISHDATE:
          return RowDataAdapter.GetRowData<DateTime>(row, CustomFieldsColumnNames.DATE_VALUE, version);
And using a mapping like:
        [PSCustomField("000039B7-8BBE-4CEB-82C4-FA8C0B40011F")]
        public DateTime Finish8 { get; set; }
But then when I attempt to Update the database I get the following:
System.Exception was unhandled
  IsTransient=false
  Message=<errinfo xmlns=""><general><class name="An unhandled exception occurred in Microsoft.Office.Project.Server.BusinessLayer.Project.QueueUpdateProject."><error id="42" name="GeneralUnhandledException" uid="c288d6d3-8b2b-4eec-be6a-1bcf14f8d2e4" Exception="Microsoft.Office.Project.Server.Errors.InconsistentInternalStateException: Error in the application.
   at Microsoft.Office.Project.Server.Errors.PSError.FailNowTag(UInt32 ulsID, ULSCat catID)
   at Microsoft.Office.Project.Server.BusinessLayer.CustomFields.Validate(DataTable customFieldsTable, String entityPrimaryKeyName, DataTable parentTable, Guid entityTypeUid, Guid projectUid, Boolean deleteCFValuesOnModify, Boolean fromWinProj, ModifiedDeptEntities modifiedDeptEntities)
   at Microsoft.Office.Project.Server.BusinessLayer.ProjectValidate.ValidateCustomFields(ProjectDataSet dataset, Guid projectUid, Boolean validateRequiredFields)
   at Microsoft.Office.Project.Server.BusinessLayer.ProjectValidate.ValidateData(Guid projectUid, ProjectDataSet dataset, Boolean isNew, Boolean validateRequiredFields, Boolean bypassOwnerValidation)
   at Microsoft.Office.Project.Server.BusinessLayer.Project.IsValidData(Guid projectUid, ProjectDataSet dataset, Boolean isNew, Boolean bypassOwnerValidation)
   at Microsoft.Office.Project.Server.BusinessLayer.Project.UpdateProjectCore(Guid jobUid, Guid sessionUid, ProjectDataSet dataset, ProjectDataSet deltaDataset, Boolean validateOnly, Guid projectUid, Boolean validate)
   at Microsoft.Office.Project.Server.BusinessLayer.Project.UpdateProjectInternal(Guid jobUid, Guid sessionUid, ProjectDataSet dataset, Boolean validateOnly, Boolean validate)
   at Microsoft.Office.Project.Server.BusinessLayer.Project.QueueUpdateProject(Guid jobUid, Guid sessionUid, ProjectDataSet dataset, Boolean validateOnly)
   at Microsoft.Office.Project.Server.Wcf.Implementation.ProjectImpl.QueueUpdateProject(Guid jobUid, Guid sessionUid, ProjectDataSet dataset, Boolean validateOnly)"></error></class></general></errinfo>
Any ideas what is causing this, and how to fix it?

comments