У меня есть требование обновлять корпоративные ресурсы в Project Online на основе условия, а также необходимо обновить настраиваемые пользовательские поля Entity='Resource'
, связанные с ним. Я не могу найти связь между ними.
Что я сделал до сих пор:
Извлеченные корпоративные ресурсы из PWA
.
using (ProjectContext projContext = new ProjectContext(projectUrl))
{
SecureString securePassword = new SecureString();
foreach (char character in password.ToCharArray())
securePassword.AppendChar(character);
projContext.Credentials = new SharePointOnlineCredentials(username, securePassword);
enterpriseResources = projContext.LoadQuery(projContext.EnterpriseResources);
projContext.ExecuteQuery();
if (enterpriseResources.Count() > 0)
{
foreach (EnterpriseResource resource in enterpriseResources)
{
if (!string.IsNullOrEmpty(resource.Email))
{
var enterpriseResource = projContext.EnterpriseResources.GetByGuid(resource.Id);
//var enterpriseResourceCustomFields = enterpriseResource.CustomFields.GetByGuid(resource.Id);
enterpriseResource.Email = "sahil@test.com"; //Email
enterpriseResource.Name = "Sahil Sharma"; //FullName
//enterpriseResource.Id = ""; //EmployeeID [Can't update, readonly]
//These below mentioned items are Enterprise Custom Fields related to Enterprise Resources but I'm not able to get it
//Office
//Level
//SupervisorID
//Division
//Status
//Supervisor
//DepartmentNumber
//LaborCategory
//Function
projContext.EnterpriseResources.Update();
projContext.ExecuteQuery();
}
}
}
}
Что не сделали:
Не удалось получить пользовательские поля Enterprise, связанные с ним:
Я пробовал этот запрос, но не смог получить точные поля, упомянутые выше:
foreach (EnterpriseResource resource in enterpriseResources)
{
if (!string.IsNullOrEmpty(resource.Email))
{
var pId = Guid.Parse("a5c8801f-d505-e811-a745-b0359f8878e9");
var customProject = projContext.LoadQuery(projContext.Projects.Where(p => p.Id == pId).Include(
p => p.Id,
p => p.Name,
p => p.IncludeCustomFields,
p => p.IncludeCustomFields.CustomFields,
P => P.IncludeCustomFields.CustomFields.IncludeWithDefaultProperties(
lu => lu.LookupTable,
lu => lu.LookupEntries
))
);
projContext.ExecuteQuery();
foreach (PublishedProject pubProj in customProject)
{
var projECFs = pubProj.IncludeCustomFields.CustomFields;
Dictionary<string, object> ECFValues = pubProj.IncludeCustomFields.FieldValues;
}
}
}
Любая идея поможет найти связь между ними и получить.