本文整理汇总了C#中EntityReference类的典型用法代码示例。如果您正苦于以下问题:C# EntityReference类的具体用法?C# EntityReference怎么用?C# EntityReference使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EntityReference类属于命名空间,在下文中一共展示了EntityReference类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Program
public Program()
{
m_service = new MockCrmService();
// test data for simple fetch
Entity de = new Entity();
de.LogicalName = "mydynamic";
de["prop1"] = "foo";
Guid deID = m_service.Create( de );
// test data for filters
de = new Entity();
de.LogicalName = "contact";
de[ "address1_name" ] = "Dan";
de[ "address1_city" ] = "Bethesda";
Guid deID2 = m_service.Create( de );
// data for testing links
Guid guid = Guid.NewGuid();
de = new Entity();
de.LogicalName = "subject";
de[ "subjectid" ] = guid;
Guid deID3 = m_service.Create( de );
de = new Entity();
de.LogicalName = "subject";
de[ "subjectid" ] = guid;
de[ "title" ] = "child";
de[ "parentsubject" ] = new EntityReference( "subject", deID3 );
Guid deID4 = m_service.Create( de );
}
示例2: GenerateRandomAccountCollection
private EntityCollection GenerateRandomAccountCollection()
{
var collection = new List<Entity>();
for (var i = 0; i < 10; i++)
{
var rgn = new Random((int)DateTime.Now.Ticks);
var entity = new Entity("account");
entity["accountid"] = entity.Id = Guid.NewGuid();
entity["address1_addressid"] = Guid.NewGuid();
entity["modifiedon"] = DateTime.Now;
entity["lastusedincampaign"] = DateTime.Now;
entity["donotfax"] = rgn.NextBoolean();
entity["new_verybignumber"] = rgn.NextInt64();
entity["exchangerate"] = rgn.NextDecimal();
entity["address1_latitude"] = rgn.NextDouble();
entity["numberofemployees"] = rgn.NextInt32();
entity["primarycontactid"] = new EntityReference("contact", Guid.NewGuid());
entity["revenue"] = new Money(rgn.NextDecimal());
entity["ownerid"] = new EntityReference("systemuser", Guid.NewGuid());
entity["industrycode"] = new OptionSetValue(rgn.NextInt32());
entity["name"] = rgn.NextString(15);
entity["description"] = rgn.NextString(300);
entity["statecode"] = new OptionSetValue(rgn.NextInt32());
entity["statuscode"] = new OptionSetValue(rgn.NextInt32());
collection.Add(entity);
}
return new EntityCollection(collection);
}
示例3: Main
static void Main(string[] args)
{
//IOrganizationService service = XrmConnection.Connect(connectionDetails);
XrmConnection connection = new XrmConnection();
Console.WriteLine("Connected to CRM. Press enter to continue...");
Console.ReadLine();
RoleManager rm = new RoleManager(connection.service, connection.caller);
Console.Write("User (Guid) to test:");
//Guid userToTestGuid = new Guid(Console.ReadLine());
Guid userToTestGuid = new Guid("1065A1BE-6BA3-E611-A161-000C29C78F2E");
EntityReference testUser = new EntityReference("systemuser", userToTestGuid);
Console.Write("User (Guid) to copy from:");
//Guid userToCopyGuid = new Guid(Console.ReadLine());
Guid userToCopyGuid = new Guid("84429B63-C273-E611-A14E-EACD0C285D01");
EntityReference copyFromUser = new EntityReference("systemuser", userToCopyGuid);
EntityCollection teams = rm.RetrieveUserTeams(copyFromUser);
EntityCollection roles = rm.RetrieveUserRoles(copyFromUser);
List <Entity> rolesList = new List<Entity>(roles.Entities);
List<Entity> teamsList = new List<Entity>(teams.Entities);
rm.AssignBusinessUnit(testUser, copyFromUser);
rm.AddRolesToPrincipal(rolesList, testUser, rolesList);
}
示例4: generateRiskFactorsForTemplate
public Boolean generateRiskFactorsForTemplate(EntityReference riskTemplate, Guid fundingCaseRiskAssessmentId)
{
try
{
//
QueryExpression qe = new QueryExpression("gcbase_risktemplateriskfactor");
qe.Criteria.AddCondition("gcbase_risktemplate", ConditionOperator.Equal, riskTemplate.Id);
qe.ColumnSet.AddColumns("gcbase_name", "gcbase_riskfactor", "gcbase_risktemplate");
var riskFactors = _service.RetrieveMultiple(qe).Entities;
foreach (var item in riskFactors)
{
Entity riskFactorValue = new Entity("gcbase_riskfactorvalue");
riskFactorValue["gcbase_name"] = item.GetAttributeValue<EntityReference>("gcbase_riskfactor").Name;
riskFactorValue["gcbase_riskfactor"] = new EntityReference("gcbase_riskfactor", item.GetAttributeValue<EntityReference>("gcbase_riskfactor").Id);
riskFactorValue["gcbase_risktemplateriskfactor"] = new EntityReference("gcbase_risktemplateriskfactor", item.Id);
riskFactorValue["gcbase_fundingcaseriskassessment"] = new EntityReference("gcbase_fundingcaseriskassessment", fundingCaseRiskAssessmentId);
_service.Create(riskFactorValue);
}
return true;
}
catch
{
return false;
}
}
示例5: Post
public HttpResponseMessage Post(Guid taskId)
{
CrmConnection connection = CrmConnection.Parse(Strings.urlCreds);
var ctx = new CrmServiceContext(new OrganizationService(connection));
var taskReference = new EntityReference("task", taskId);
try
{
var req = new SetStateRequest();
req.State = new OptionSetValue(1);
req.Status = new OptionSetValue(5);
req.EntityMoniker = taskReference;
var res = (SetStateResponse)ctx.Execute(req);
}
catch (Exception e)
{
return this.Request.CreateResponse(
HttpStatusCode.InternalServerError, e);
}
return this.Request.CreateResponse(
HttpStatusCode.Created);
}
示例6: When_Executing_Assign_Request_New_Owner_Should_Be_Assigned
public void When_Executing_Assign_Request_New_Owner_Should_Be_Assigned()
{
var oldOwner = new EntityReference("systemuser", Guid.NewGuid());
var newOwner = new EntityReference("systemuser", Guid.NewGuid());
var account = new Account
{
Id = Guid.NewGuid(),
OwnerId = oldOwner
};
var context = new XrmFakedContext();
var service = context.GetFakedOrganizationService();
context.Initialize(new [] { account });
var assignRequest = new AssignRequest
{
Target = account.ToEntityReference(),
Assignee = newOwner
};
service.Execute(assignRequest);
Assert.Equal(newOwner, account.OwnerId);
}
示例7: CreateAccountTask
/// <summary>
/// Code to create account task for new accounts
/// </summary>
/// <param name="service">crm service</param>
/// <param name="accountEntity">entity of the newly created account</param>
public void CreateAccountTask(IOrganizationService service, Entity accountEntity)
{
try
{
//create new task for account set in 2 weeks in the future
Microsoft.Xrm.Sdk.Entity contactAccountTask = new Entity("task");
contactAccountTask["subject"] = "Check new account is happy";
contactAccountTask["description"] =
"Make contact with new customer. See if they are happy with service and resolve any issues.";
contactAccountTask["scheduledstart"] = DateTime.Now.AddDays(14);
contactAccountTask["scheduledend"] = DateTime.Now.AddDays(14);
Microsoft.Xrm.Sdk.EntityReference entRef = new EntityReference("account", accountEntity.Id);
contactAccountTask["regardingobjectid"] = entRef;
// Create the task and this should be linked to the new account record
service.Create(contactAccountTask);
}
catch (FaultException ex)
{
throw new InvalidPluginExecutionException("An error occurred in the plug-in.", ex);
}
}
示例8: GetCuenta
public static bsv_cuentas GetCuenta(
CajaDeAhorro sqlCuenta,
string nroCuenta,
EntityReference modulo,
EntityReference moneda,
EntityReference sucursal,
//EntityReference operacion,
EntityReference tipoOperacion,
EntityReference canalVenta,
EntityReference estadoCuenta)
{
var cuenta = new bsv_cuentas();
MapCuenta(
sqlCuenta,
nroCuenta,
modulo,
moneda,
sucursal,
tipoOperacion,
canalVenta,
estadoCuenta,
cuenta);
return cuenta;
}
示例9: Test_Includes_Mismatch
public void Test_Includes_Mismatch()
{
Guid id1 = Guid.NewGuid();
Guid id2 = Guid.NewGuid();
string propertyName1 = "Property1";
string propertyName2 = "Property2";
string type1 = "Type1";
string type2 = "Type2";
EntityReference reference = new EntityReference();
reference.Entity1ID = id1;
reference.Entity2ID = id2;
reference.Type1Name = type1;
reference.Type2Name = type2;
reference.Property1Name = propertyName1;
reference.Property2Name = propertyName2;
bool includes = reference.Includes(id1, propertyName2);
Assert.IsFalse(includes, "Returned true when it should have returned false");
includes = reference.Includes(id2, propertyName1);
Assert.IsFalse(includes, "Returned true when it should have returned false");
}
示例10: GetAccount
public static Account GetAccount(PersonaJuridica personaJuridica, EntityReference pais, EntityReference sucursal, EntityReference canalVenta, EntityReference segmento, EntityReference domicilioPais, EntityReference localidad, EntityReference provincia, EntityReference banca, EntityReference actividad)
{
var account = new Account();
MapAccount(personaJuridica, account, pais, sucursal, canalVenta, segmento, domicilioPais, localidad, provincia, banca, actividad);
return account;
}
示例11: GetContact
public static Contact GetContact(PersonaFisica personaFisica, EntityReference domicilioPais, EntityReference actividadLaboral, EntityReference banca, EntityReference pais, EntityReference localidad, EntityReference sucursal, EntityReference segmento, EntityReference provincia, EntityReference profesion)
{
var contact = new Contact();
MapContact(personaFisica, domicilioPais, actividadLaboral, banca, pais, localidad, sucursal, segmento, provincia, profesion, contact);
return contact;
}
示例12: IfReferenceTypeIsWrong
public static void IfReferenceTypeIsWrong(EntityReference id, string typeName)
{
if (id.LogicalName != typeName)
{
throw new InvalidPluginExecutionException(
$"EntityReference of type {id.LogicalName} was used in the context where {typeName} is expected.");
}
}
示例13: GetStringFromEntityReference
private static string GetStringFromEntityReference(EntityReference reference)
{
string result = string.Empty;
if (reference != null)
{
result = string.Format("{0}|{1}|{2}", reference.LogicalName, reference.Id, reference.Name);
}
return result;
}
示例14: ToDbType
public static object ToDbType(EntityReference val)
{
if (val == null)
{
return DBNull.Value;
}
return val.Id;
}
示例15: PublishInCRM
public void PublishInCRM(ServiceRequest serviceRequest)
{
//Connects to the database and Logs the User In
var connection = ConnectToDatabase();
var service = new OrganizationService(connection);
var context = new CrmOrganizationServiceContext(connection);
//const int hour = 60;
EventLog.saveMessage("PublishIssue SRID:" + serviceRequest.SRID);
//Creating the new Case
Entity incident = new Entity("incident");
try
{
//Filling the Data for the new case
incident["createdon"] = serviceRequest.RegistrationDate;
incident["description"] = serviceRequest.LongDescription;
incident["statuscode"] = ReturnStatusCode(serviceRequest.ServiceRequestStatus);
incident["subjectid"] = ReturnRequestType(serviceRequest.ServiceRequestType);
incident["new_moduleoptionset"] = ReturnModuleCode("TS");
//incident["ownerid"] = new EntityReference("systemuser", findConsultantID(serviceRequest.AssignedPerson, service));
incident["new_caseasignedto"] = serviceRequest.AssignedPerson;
incident["new_statushistory"] = serviceRequest.CommentsMatricia;
incident["casetypecode"] = returnRequestKind(serviceRequest.ServiceRequestKind);
incident["followupby"] = serviceRequest.DueDate;
incident["new_supportrequestid"] = serviceRequest.SRID;
incident["title"] = serviceRequest.AssignedToClient + " " + serviceRequest.SRID + " " + serviceRequest.companyName;
//incident["customerid"] = new EntityReference("account", findCustomer((string)serviceRequest.companyName, service));
incident["customerid"] = new EntityReference("account", findCustomerID(serviceRequest.companyName));
incident["new_statushistory"] = serviceRequest.ShortDescription;
incident["new_assignedfrom"] = serviceRequest.CreatedBy;
Guid consultantID = findConsultantID(serviceRequest.AssignedPerson, service);
//Adding the created case to CRM;
var incidentGuid = service.Create(incident);
//Assign a case!
EventLog.saveMessage("Start of Assignment! to :" + consultantID);
AssignRequest assignRequest = new AssignRequest();
assignRequest.Assignee = new EntityReference("systemuser", consultantID);
assignRequest.Target = new EntityReference(incident.LogicalName, incidentGuid);
service.Execute(assignRequest);
}
catch (Exception)
{
EventLog.saveMessage("This case was not created in CRM " + serviceRequest.CreatedBy + "'" + serviceRequest.SRID); ;
}
}