C# 如何使用UCMA连接到Skype For Business
当我从Windows服务项目调用C# 如何使用UCMA连接到Skype For Business,c#,.net,windows-services,skype-for-business,ucma,C#,.net,Windows Services,Skype For Business,Ucma,当我从Windows服务项目调用LyncClient.Get()时,我遇到了一个问题,因为我知道如果在控制台应用程序上进行测试,它会工作得很好 var lyncClient = LyncClient.GetClient(); Dictionary<PublishableContactInformationType, object> statusData = new Dictionary<PublishableContac
LyncClient.Get()
时,我遇到了一个问题,因为我知道如果在控制台应用程序上进行测试,它会工作得很好
var lyncClient = LyncClient.GetClient();
Dictionary<PublishableContactInformationType, object> statusData =
new Dictionary<PublishableContactInformationType, object>
{
{PublishableContactInformationType.LocationName, _position},
{PublishableContactInformationType.Availability, ContactAvailability.Busy}
};
var lyncClient=lyncClient.GetClient();
字典状态数据=
新词典
{
{PublishableContactInformationType.LocationName,_position},
{PublishableContactInformationType.Availability,ContactAvailability.Busy}
};
我得到的例外是:
Microsoft.Lync.Model.ClientNotFoundException:主机进程未运行
在Microsoft.Lync.Model.LyncClient.Ensurei()上
到Microsoft.Lync.Model.LyncClient.GetClient(布尔sideBySideLync)
在进行研究时,我读到在Windows服务中,我们无法通过调用GetClient()获取Lync客户端,因为服务进程和Lync进程处于不同的会话中,这就是为什么我尝试使用UCMA或UCWA,但我不了解它是如何工作的 你不是在谈论,你是在谈论未来
您可以这样认为SDK:
- Lync客户端SDK
- UCMA
- 用户端点
- 受信任的应用程序终结点
{"location":"my new location"}
我在应用程序中尝试做的是更改skype用户在服务中的位置。由于无法使用Lync Client SDK,我必须使用UCWA SDK,但我找不到一个可以遵循他的示例,这是一个建议 您为什么要使用服务进行此操作?您可以使用一个小型控制台应用程序来完成这项工作,该应用程序将在后台运行且不可见,并在会话启动时启动。 这样,您就不需要知道用户的登录名/密码,您只需在代码中轮询,等待Skype for Business client启动(我假设在会话启动后不久启动) 以下是我的意思的一个例子:
class Program
{
[DllImport("user32.dll")]
static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
[DllImport("Kernel32")]
private static extern IntPtr GetConsoleWindow();
const int SW_HIDE = 0;
static void Main(string[] args)
{
// Let's hide the console window first ...
IntPtr hwnd;
hwnd = GetConsoleWindow();
ShowWindow(hwnd, SW_HIDE);
// I recommend you start a separate thread from here, I removed it for the sake of simplicity
Boolean clientConnected = false;
while (!clientConnected)
{
try
{
LyncClient lyncClient = LyncClient.GetClient();
clientConnected = true;
// Do your stuff here...
}
catch (ClientNotFoundException ex)
{
// Client not found : the client is probably not running...
// There is nothing to do besides wait and expect to have the user starting his client...
clientConnected = false; // not needed, just to highlight the fact that we are not connected yet
}
// Don't forget to make your application sleep/do nothing on regular intervals to avoid taking 100% CPU time while you are polling
}
}
当然,用户可以通过查看任务管理器手动终止应用程序,但大多数最终用户不会这样做。我在应用程序中尝试的是更改skype用户在服务中的位置。由于无法使用Lync Client SDK,我必须使用UCWA SDK,但我找不到一个可以遵循他的示例,这是一个建议@迪达你说的“改变立场”是什么意思?AFAIK S4B中称为“位置”的用户没有此类数据。你指的是用户的“状态”还是“位置”、“状态”等“状态”子数据?我指的是位置,我创建了一个程序,可以自动识别公司内部人员的位置。所以我创建了一个服务来检索位置并在skype上更新它!