本文整理汇总了C#中ServerConnection.GetServerConfiguration方法的典型用法代码示例。如果您正苦于以下问题:C# ServerConnection.GetServerConfiguration方法的具体用法?C# ServerConnection.GetServerConfiguration怎么用?C# ServerConnection.GetServerConfiguration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ServerConnection
的用法示例。
在下文中一共展示了ServerConnection.GetServerConfiguration方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetOrgService
private static IOrganizationService GetOrgService(ServerConnection serverConnection, bool reAuthenticate = false)
{
OrganizationServiceProxy serviceProxy;
ServerConnection.Configuration serverConfig = serverConnection.GetServerConfiguration(reAuthenticate);
// Connect to the Organization service.
// The using statement assures that the service proxy will be properly disposed.
using (serviceProxy = new OrganizationServiceProxy(serverConfig.OrganizationUri, serverConfig.HomeRealmUri, serverConfig.Credentials, serverConfig.DeviceCredentials))
{
// This statement is required to enable early-bound type support.
serviceProxy.EnableProxyTypes();
return (IOrganizationService)serviceProxy;
}
}
示例2: FindUsers
/// <summary>
/// Finds and returns the given group's users.
/// </summary>
/// <param name="groupName">A string representing the group name of the group for which users should be returned. Could include wildcards (Starts with: *xyz, End with: xyz*, Contains: *xyz*)</param>
/// <param name="properties">An IDictionary representing the properties used to filter the users returned. You can add additional filter properties to this collection</param>
/// <returns>An IUserCollection representing the users which were found.</returns>
public IUserCollection FindUsers(string groupName, IDictionary<string, object> properties)
{
//TODO: Wildcard search
//NOTE: The wildcards for the group name passed in by K2 are
// Starts with: *xyz
// End with: xyz*
// Contains: *xyz*
//the colleciton we will populate and finally return
UserCollection users = new UserCollection();
try
{
_logger.LogDebugMessage(base.GetType().ToString() + ".FindUsers", "Group: " + groupName);
ServerConnection serverConnect = new ServerConnection(this._crmconfigurations);
ServerConnection.Configuration config = serverConnect.GetServerConfiguration();
if (config == null)
{
if (this._logger != null)
{
this._logger.LogErrorMessage("K2Community.CSP.CRM", "CRM URL not found");
}
}
else
{
using (_serviceProxy = ServerConnection.GetOrganizationProxy(config))
{
_serviceProxy.EnableProxyTypes();
// Obtain the Organization Context.
OrganizationServiceContext context = new OrganizationServiceContext(_serviceProxy);
// Create Linq Query.
var teams = (from t in context.CreateQuery<Team>()
where t.Name == groupName
select t.TeamId);
Guid? lastTeamID = new Guid();
// Display results.
foreach (var team in teams)
{
//Console.WriteLine("Linq Retrieved: {0}", team);
lastTeamID = team;
var teamMembers = (from u in context.CreateQuery<SystemUser>()
join s in context.CreateQuery<TeamMembership>() on u.SystemUserId equals s.SystemUserId
where s.TeamId == lastTeamID
orderby u.DomainName
select u.DomainName);
// Display results.
foreach (var user in teamMembers)
{
_logger.LogDebugMessage("FindUser",string.Format("Linq Retrieved: {0} i n {1}", user, team));
User user1 = new User("K2", user, "", "[email protected]", "", "", "");
users.Add(user1);
}
}
}
}
}
catch (Exception ex)
{
_logger.LogErrorMessage(base.GetType().ToString() + ".FindUsers error", "Group: " + groupName + " Error: " + ex.Message + ex.StackTrace);
}
//return the collection of users for the group
return users;
}
示例3: FindGroups
/// <summary>
/// Finds and returns the given user's groups.
/// </summary>
/// <param name="userName">A string representing the username of the user whose groups should be returned.</param>
/// <param name="properties">An IDictionary representing the properties used to filter the groups returned.</param>
/// <returns>An IGroupCollection representing the groups which were found.</returns>
public IGroupCollection FindGroups(string userName, IDictionary<string, object> properties)
{
//the collection that we will populate and finally return
GroupCollection groups = new GroupCollection();
#region CRM code
try
{
ServerConnection serverConnect = new ServerConnection(this._crmconfigurations);
ServerConnection.Configuration config = serverConnect.GetServerConfiguration();
if (config == null)
{
if (this._logger != null)
{
this._logger.LogErrorMessage("K2Community.CSP.CRM", "CRM URL not found");
}
}
else
{
string FetchXml = @"
<fetch mapping='logical'>
<entity name='team'>
<attribute name='name' />
</entity>
</fetch>";
using (_serviceProxy = ServerConnection.GetOrganizationProxy(config))
{
_serviceProxy.EnableProxyTypes();
// Build fetch request and obtain results.
Microsoft.Xrm.Sdk.Messages.RetrieveMultipleRequest efr = new Microsoft.Xrm.Sdk.Messages.RetrieveMultipleRequest()
{
Query = new FetchExpression(FetchXml)
};
Microsoft.Xrm.Sdk.EntityCollection entityResults = ((Microsoft.Xrm.Sdk.Messages.RetrieveMultipleResponse)_serviceProxy.Execute(efr)).EntityCollection;
//sample of logging debug output
_logger.LogDebugMessage(base.GetType().ToString() + ".FindGroups", "Finding groups for user: " + userName);
foreach (var e in entityResults.Entities)
{
_logger.LogDebugMessage(base.GetType().ToString() + ".FindGroups", "Team Name: {0}", e.Attributes["name"].ToString());
Group group1 = new Group(this.SecurityLabel, e.Attributes["name"].ToString(), "", "");
//add the group to the collection
groups.Add(group1);
}
}
}
}
catch (Exception ex)
{
if (this._logger != null)
{
_logger.LogErrorMessage(base.GetType().ToString() + ".FindGroups error", "User: " + userName + " Error: " + ex.Message + ex.StackTrace);
}
}
#endregion
//return the collection of groups that the user belongs to
return groups;
}