这似乎很基本,但我无法在网上找到如何做到这一点。如何在“挂起”状态下显示Lync对话窗口?
我有以下代码:
public static void StartChatWithUser(Microsoft.Lync.Model.Contact imContact, string title = null)
{
try
{
var lyncClient = Microsoft.Lync.Model.LyncClient.GetClient();
var conversation = lyncClient.ConversationManager.AddConversation();
conversation.AddParticipant(imContact);
if (!string.IsNullOrEmpty(title))
{
conversation.Properties[Microsoft.Lync.Model.Conversation.ConversationProperty.Subject] = title;
}
var im = conversation.Modalities[Microsoft.Lync.Model.Conversation.ModalityTypes.InstantMessage];
if (im.CanInvoke(Microsoft.Lync.Model.Conversation.ModalityAction.Connect))
{
im.BeginConnect((ar) => { if (ar.IsCompleted) { ((Microsoft.Lync.Model.Conversation.InstantMessageModality)ar.AsyncState).EndConnect(ar); } }, im);
}
}
catch(Exception x)
{
//Handle exception
}
}
这种“排序的”作品,因为它打开接触窗口,并开始聊天 - 这意味着对方请求加入聊天。
有没有办法打开对话窗口而不启动与其他用户的聊天(我想要的方式与双击Lync联系人列表中的用户时的方式相同)。
在Lync Client Dev上发布了相同的问题。 TechNet论坛:http://lksz.me/s8Yn8a。
在此先感谢。
我的最终结果
多亏了穆罕默德·萨卡尔和ckeller提供的答案,我定我的代码,这里是我的新方法。 谢谢你们
需要以下使用条款:
using Microsoft.Lync.Model.Extensibility;
这里是新代码:
public static void StartChatWithUser(Microsoft.Lync.Model.Contact imContact, string title = null)
{
try
{
var lyncAutomation = Microsoft.Lync.Model.LyncClient.GetAutomation();
var inviteeList = new string[] { imContact.Uri };
var modalitySettings = new Dictionary<AutomationModalitySettings, object>();
modalitySettings.Add(AutomationModalitySettings.SendFirstInstantMessageImmediately, false);
if (string.IsNullOrEmpty(title))
{
modalitySettings.Add(AutomationModalitySettings.Subject, title);
}
lyncAutomation.BeginStartConversation(
AutomationModalities.InstantMessage,
inviteeList,
modalitySettings,
(ar) => { if (ar.IsCompleted) { ((Automation)ar.AsyncState).EndStartConversation(ar); }},
lyncAutomation);
}
catch(Exception x)
{
//Handle exception
}
}
你可能会更好过,要求在论坛上的Lync,作为观众的Lync这里是相当有限的。这里的链接:http://social.technet.microsoft.com/Forums/en-US/ocsclients/threads – Polynomial
谢谢我会尝试,如果我得到一个答案,我会在这里发布 – Lockszmith
@Polynomial:它似乎stackoverflow毕竟是发布该问题的正确地方,Lync Dev论坛对此主题仍然保持沉默。 虽然我现在也会发布信息。 – Lockszmith