本文整理汇总了C#中OrganizationService类的典型用法代码示例。如果您正苦于以下问题:C# OrganizationService类的具体用法?C# OrganizationService怎么用?C# OrganizationService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OrganizationService类属于命名空间,在下文中一共展示了OrganizationService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindPluginAssembly
private static Guid FindPluginAssembly(OrganizationService service, string assemblyName)
{
var query = new QueryExpression
{
EntityName = "pluginassembly",
ColumnSet = null,
Criteria = new FilterExpression()
};
query.Criteria.AddCondition("name", ConditionOperator.Equal, assemblyName);
var request = new RetrieveMultipleRequest
{
Query = query
};
var response = (RetrieveMultipleResponse)service.Execute(request);
if (response.EntityCollection.Entities.Count == 1)
{
var id = response.EntityCollection[0].GetAttributeValue<Guid>("pluginassemblyid");
_logger.Log(LogLevel.Debug, () => string.Format("Found id {0} for assembly", id));
return id;
}
return Guid.Empty;
}
示例2: Validate
public override DTSExecResult Validate(IDTSInfoEvents infoEvents)
{
// プロパティが一つでも空だったらエラーとする
if (!PropertiesValidate(infoEvents, URL, Domain, UserName, Password))
{
return DTSExecResult.Failure;
}
// 接続テスト
try
{
var con = CrmConnection.Parse(ConnectionString);
con.Timeout = TimeSpan.FromSeconds(30);
using (var service = new OrganizationService(con))
{
service.Execute<WhoAmIResponse>(new WhoAmIRequest());
}
}
catch (Exception e)
{
infoEvents.FireError(0, "Dynamics CRM 2011 接続マネージャー", e.Message, string.Empty, 0);
return DTSExecResult.Failure;
}
return DTSExecResult.Success;
}
示例3: Export
private static void Export()
{
var service = new OrganizationService(CrmConnection.Parse("Url=http://dev-crm/SCAMPROD;"));
//var doc = new WordDocumentDocX();
//doc.Settings = new GenerationSettings
//{
// FilePath = @"c:\temp\doc.docx",
// AddAuditInformation = true,
// AddEntitiesSummary = true,
// AddFieldSecureInformation = true,
// AddFormLocation = true,
// AddRequiredLevelInformation = true,
// AddValidForAdvancedFind = true,
// AttributesSelection = AttributeSelectionOption.AllAttributes,
// DisplayNamesLangugageCode = 1033,
// EntitiesToProceed = new List<EntityItem>{new EntityItem
// {
// Name = "scam_repartition"
// }},
// IncludeOnlyAttributesOnForms = false,
// OutputDocumentType = Output.Word,
//};
//doc.Generate(service);
}
示例4: btnTest_Click
/// <summary>
/// 接続テスト
/// </summary>
/// <param name="sender"></param>
/// <param name="ev"></param>
private void btnTest_Click(object sender, EventArgs ev)
{
var connectionString = CreateConnectionString
(
Url => txbURL.Text,
Domain => txbDomain.Text,
Username => txbUserName.Text,
Password => txbPassword.Text
);
// connection test
try
{
var con = CrmConnection.Parse(connectionString);
con.Timeout = TimeSpan.FromSeconds(30);
using (var service = new OrganizationService(con))
{
service.Execute<WhoAmIResponse>(new WhoAmIRequest());
}
}
catch (Exception e)
{
MessageBox.Show(e.Message, "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
MessageBox.Show("OK", "確認", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
示例5: Connect
public virtual void Connect()
{
string CrmConnectionString = string.Format("Url={0}; Username={1}; Password={2};",
Url, Username, Password);
crmConnection = CrmConnection.Parse(CrmConnectionString);
service = new OrganizationService(crmConnection);
}
示例6: GetUserRoles
/// <summary>
/// retrieves a list of CRM roles assigned to a specific user
/// </summary>
/// <param name="userid"></param>
/// <param name="service"></param>
/// <returns></returns>
private List<string> GetUserRoles(Guid userid, OrganizationService service)
{
List<string> roles = new List<string>();
string fetchXml = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true'>
<entity name='role'>
<attribute name='name' />
<attribute name='businessunitid' />
<attribute name='roleid' />
<order attribute='name' descending='false' />
<link-entity name='systemuserroles' from='roleid' to='roleid' visible='false' intersect='true'>
<link-entity name='systemuser' from='systemuserid' to='systemuserid' alias='af'>
<filter type='and'>
<condition attribute='systemuserid' operator='eq' uitype='systemuser' value='{$USERID}' />
</filter>
</link-entity>
</link-entity>
</entity>
</fetch>";
fetchXml = fetchXml.Replace("$USERID", userid.ToString());
EntityCollection results = service.RetrieveMultiple(new FetchExpression(fetchXml));
foreach (Entity entity in results.Entities)
{
roles.Add((string)entity["name"]);
}
return roles;
}
示例7: IsAuthenticated
public async Task<bool> IsAuthenticated(PortalUser user)
{
string Url = ConfigurationManager.AppSettings["URL"].ToString();
string CrmConnectionString = string.Format("Url={0}; Username={1}; Password={2}",
Url, user.Username, user.Password);
ClientCredentials credential = new ClientCredentials();
credential.UserName.UserName = user.Username;
credential.UserName.Password = user.Password;
CrmConnection crmConnection = CrmConnection.Parse(CrmConnectionString);
crmConnection.ClientCredentials = credential;
OrganizationService service = new OrganizationService(crmConnection);
QueryExpression qe = new QueryExpression("systemuser");
qe.ColumnSet = new ColumnSet();
qe.ColumnSet.AddColumn("systemuserid");
qe.ColumnSet.AddColumn("fullname");
qe.Criteria = new FilterExpression();
qe.Criteria.AddCondition("domainname", ConditionOperator.Equal, user.Username);
EntityCollection collection = service.RetrieveMultiple(qe);
if (collection.Entities.Count == 0)
{
return false;
}
return true;
}
示例8: GetYelpAccounts
private EntityCollection GetYelpAccounts()
{
CrmConnection connection = CrmConnection.Parse(_connection);
using (_orgService = new OrganizationService(connection))
{
var query = new QueryExpression
{
EntityName = "account",
ColumnSet = new ColumnSet("test9_yelpid"),
Criteria = new FilterExpression
{
Conditions =
{
new ConditionExpression
{
AttributeName = "test9_yelpid",
Operator = ConditionOperator.NotNull
}
}
}
};
return _orgService.RetrieveMultiple(query);
}
}
示例9: 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); ;
}
}
示例10: Main
static void Main(string[] args)
{
CrmConnection connection = CrmConnection.Parse(
ConfigurationManager.ConnectionStrings["CRMConnectionString"].ConnectionString);
using (_orgService = new OrganizationService(connection))
{
//Do stuff
}
}
示例11: TestSiteMapCacheRequest
public void TestSiteMapCacheRequest()
{
IOrganizationService service = new OrganizationService(new CrmConnection("CRM"));
StringWriter mapJson = new StringWriter();
SiteMapLoader loader = new SiteMapLoader(1033);
ITracingService tace = new debugTrace();
loader.ParseSiteMapToJson(service,tace, mapJson);
Console.WriteLine(mapJson.ToString());
}
示例12: TestMethod1
public void TestMethod1()
{
IOrganizationService service = new OrganizationService(new CrmConnection("CRM"));
RetrieveFormXmlRequest request = new RetrieveFormXmlRequest();
request.EntityName = "contact";
var response = service.Execute<RetrieveFormXmlResponse>(request);
Console.WriteLine(response.FormXml);
}
示例13: DynamicsCls
/// <summary>
/// コンストラクタ。dynamicsとの接続を確立する。
/// </summary>
/// <param name="user"></param>
/// <param name="pass"></param>
/// <param name="url"></param>
public DynamicsCls(string user, string pass, string url)
{
string connetString = String.Format("Url={0}; Username={1}; Password={2};",
url,
user,
pass);
CrmConnection connection = CrmConnection.Parse(connetString);
_service = new OrganizationService(connection);
WhoAmIResponse res = (WhoAmIResponse)_service.Execute(new WhoAmIRequest());
}
示例14: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
var myConnection = new CrmConnection("Xrm");
using (var myService = new OrganizationService(myConnection))
using (var myContext = new Xrm.XRMServiceContext(myService))
{
var accounts = myContext.bro_managetemplateSet.ToList();
}
}
}
示例15: DeleteInactiveProfiles
public override int DeleteInactiveProfiles(ProfileAuthenticationOption authenticationOption, DateTime userInactiveSinceDate)
{
//MAS
using (OrganizationService service = new OrganizationService(OurConnect()))
{
ConditionExpression appCondition = new ConditionExpression();
ConditionExpression authenticationCondition = new ConditionExpression();
appCondition.AttributeName = consts.appname;
appCondition.Operator = ConditionOperator.Equal;
appCondition.Values.Add(_ApplicationName);
switch (authenticationOption)
{
case ProfileAuthenticationOption.Anonymous:
authenticationCondition.AttributeName = consts.isanonymous;
authenticationCondition.Operator = ConditionOperator.Equal;
authenticationCondition.Values.Add(true);
break;
case ProfileAuthenticationOption.Authenticated:
authenticationCondition.AttributeName = consts.isanonymous;
authenticationCondition.Operator = ConditionOperator.Equal;
authenticationCondition.Values.Add(false);
break;
default:
break;
}
FilterExpression filter = new FilterExpression();
filter.Conditions.Add(appCondition);
filter.Conditions.Add(authenticationCondition);
QueryExpression query = new QueryExpression(consts.userprofile);
query.ColumnSet.AddColumn(consts.username);
query.Criteria.AddFilter(filter);
EntityCollection collection = service.RetrieveMultiple(query);
string[] usersToDelete = null;
int j = 0;
for(int i=0;i<collection.TotalRecordCount;i++)
{
if (DateTime.Compare(lastActivity((string)collection.Entities[i][consts.username], String.Empty), userInactiveSinceDate) < 0)
{
usersToDelete[j] = (string)collection.Entities[i][consts.username];
j++;
}
}
return DeleteProfiles(usersToDelete);
}
}