本文整理汇总了C#中Team.ToEntityReference方法的典型用法代码示例。如果您正苦于以下问题:C# Team.ToEntityReference方法的具体用法?C# Team.ToEntityReference怎么用?C# Team.ToEntityReference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Team
的用法示例。
在下文中一共展示了Team.ToEntityReference方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateRequiredRecords
/// <summary>
/// Creates any entity records that this sample requires.
/// </summary>
public void CreateRequiredRecords()
{
#region create users
Console.WriteLine(" Creating users");
var ldapPath = "";
_users =
SystemUserProvider.RetrieveSalespersons(_serviceProxy, ref ldapPath);
_users.Add(SystemUserProvider.RetrieveSystemUser(
"dparker", "Darren", "Parker", "Salesperson",
_serviceProxy, ref ldapPath));
#endregion
#region fetch root business unit
// Retrieve the root business unit to use for creating the team for the
// sample.
var businessUnitQuery = new QueryExpression
{
EntityName = BusinessUnit.EntityLogicalName,
ColumnSet = new ColumnSet("businessunitid"),
Criteria = new FilterExpression()
};
businessUnitQuery.Criteria.AddCondition("parentbusinessunitid",
ConditionOperator.Null);
var businessUnitResult = _serviceProxy.RetrieveMultiple(businessUnitQuery);
_rootBusinessUnit = businessUnitResult.Entities[0].ToEntity<BusinessUnit>();
#endregion
#region create new business unit
Console.WriteLine(" Creating new business unit");
_buisnessUnit = new BusinessUnit()
{
Name = "A Sample Business Unit",
ParentBusinessUnitId = _rootBusinessUnit.ToEntityReference()
};
_buisnessUnit.Id = _serviceProxy.Create(_buisnessUnit);
#endregion
#region create team
Console.WriteLine(" Creating a user team");
_team = new Team
{
AdministratorId =
new EntityReference(SystemUser.EntityLogicalName, _users[0]),
Name = "Sample team",
BusinessUnitId = _rootBusinessUnit.ToEntityReference()
};
_team.Id = _serviceProxy.Create(_team);
var salespersonRole = (from role in _context.RoleSet
where role.Name == "Salesperson"
&& role.BusinessUnitId.Id == _rootBusinessUnit.Id
select role).First();
// assign role to the team
_serviceProxy.Associate(
Team.EntityLogicalName,
_team.Id,
new Relationship("teamroles_association"),
new EntityReferenceCollection() {
salespersonRole.ToEntityReference()
}
);
// wait for the async job to finish
for (int i = 1; i <= 30; i++)
{
Console.WriteLine(" Checking to see if the async job has finished {0}/30", i);
var teamPrivileges = (RetrieveTeamPrivilegesResponse)
_serviceProxy.Execute(new RetrieveTeamPrivilegesRequest
{
TeamId = _team.Id
});
if (teamPrivileges.RolePrivileges.Any((rp) =>
rp.PrivilegeId ==
new Guid("A8ECAC53-09E8-4A13-B598-8D8C87BC3D33"))) // prvReadLead
{
break;
}
System.Threading.Thread.Sleep(1000);
}
#endregion
#region add users to team
Console.WriteLine(" Adding users to the team");
AddMembersTeamRequest addMembers = new AddMembersTeamRequest()
{
TeamId = _team.Id,
MemberIds = new Guid[] { _users[0], _users[1] }
//.........这里部分代码省略.........