2017-11-28 18 views
0

안녕하세요. Lync SDK 2013을 사용하여 ListBox 연락처의 전화 번호를 표시하고 Items (전화 번호)를 사용하여 API에서이 번호로 전화합니다. 그래서 WPF 응용 프로그램, 그냥 ListBox 및 2 단추 (호출 - 전화 끊기) 않았다. 내 응용 프로그램은 연락처의 RightClick에서 Lync의 사용자 지정 명령으로 추가됩니다. Lync 컨트롤이 없습니다. 그래서 내가하고 싶은 일은 : 연락처를 마우스 오른쪽 버튼으로 클릭하면 응용 프로그램이 시작되고 ListBox에 전화 번호 목록이 표시됩니다. 나는 컨트롤을 포함하고있는 WPF를 사용했다 : ContactSearchInputBox (연락처를 검색하기 위해)와 ContactSearchResultList 그리고 그것은 매우 잘 작동한다, 나는 컨트롤없이 그것을하는 방법을 모른다. 어느 한 사람도 나를 도울 수 있습니다 !!!! :(전화 번호 Lync SDK 2013

답변

0
public partial class ChoosePhoneNumber : Window 
    { 
     LyncClient lync_client; 
     Contact contact; 
     ContactSubscription contact_subscription; 
     List<ContactInformationType> contact_information_list; 
     ContactManager contact_manager; 

     public ChoosePhoneNumber() 
     { 
      InitializeComponent(); 

      connect_lync(); 
      get_subscribed_contact(this.contact); 
     } 
    } 
     private void connect_lync() 
     { 
      try 
      { 
       lync_client = LyncClient.GetClient(); 
       contact_manager = lync_client.ContactManager; 
      } 
      catch (ClientNotFoundException) 
      { 
       MessageBox.Show("Client is ot running", "Error While GetClient", MessageBoxButton.OK, MessageBoxImage.Error); 
      } 
     } 

     private void get_subscribed_contact(Contact contact) 
     { 
      List<object> contact_phone_numbers_list = new List<object>(); 
      contact_information_list = new List<ContactInformationType>(); 
      contact_information_list.Add(ContactInformationType.ContactEndpoints); 
      contact_information_list.Add(ContactInformationType.DisplayName); 

      contact = contact_manager.GetContactByUri("number"); // I put here the number phone of a contact in my list 
      contact_subscription = LyncClient.GetClient().ContactManager.CreateSubscription(); 
      contact_subscription.AddContact(contact); 
      contact.ContactInformationChanged += Contact_ContactInformationChanged; 
      contact_subscription.Subscribe(ContactSubscriptionRefreshRate.High, contact_information_list); 

      List<object> endpoints = (List<object>)contact.GetContactInformation(ContactInformationType.ContactEndpoints); 

      var phone_numbers_list = endpoints.Where<object>(N => ((ContactEndpoint)N).Type == ContactEndpointType.HomePhone || 
      ((ContactEndpoint)N).Type == ContactEndpointType.MobilePhone || ((ContactEndpoint)N).Type == ContactEndpointType.OtherPhone 
      || ((ContactEndpoint)N).Type == ContactEndpointType.WorkPhone).ToList<object>(); 
      var name = contact.GetContactInformation(ContactInformationType.DisplayName); 

      if (phone_numbers_list != null) 
      { 
       foreach (var phone_number in phone_numbers_list) 
       { 
        contact_phone_numbers_list.Add(((ContactEndpoint)phone_number).DisplayName); 
       } 
       conboboxPhoneNumbers.ItemsSource = contact_phone_numbers_list; 
      } 
     } 

     private void Contact_ContactInformationChanged(object sender, ContactInformationChangedEventArgs e) 
     { 
      var contact = (Contact)sender; 
      if (e.ChangedContactInformation.Contains(ContactInformationType.ContactEndpoints)) 
      { 
       update_endpoints(contact); 
      } 
     } 

     private void update_endpoints(Contact contact) 
     { 
      if ((lync_client != null) && (lync_client.State == ClientState.SignedIn)) 
      { 
       ContactEndpoint endpoints = (ContactEndpoint)contact.GetContactInformation(ContactInformationType.ContactEndpoints); 
      } 
     } 
0

당신이 읽고 이해할 필요가있다은 Lync SDK 2013 Lync Contact 설명서를 참조하십시오. 그런 다음에 볼 필요가

당신이 (클라이언트 검색 당)은 Lync 연락처는 "검색" "시뮬레이션"하고자하는 경우

search API.

당신이 이해할 필요가 또 다른 개념은 결과를 요구하는 모든은 Lync 연락처 데이터를 반환 보장되지 않은 모든 API에서 반환합니다.

은은 Lync SDK에 "부하 방법이 없습니다 "대부분의 사람들이 이해하지 못하는 모든 연락처 정보

반환 된 결과는 로컬 캐시에 있으며 더 이상 반환되지 않습니다. Lync 연락처 정보를 모두 얻으려면 ContactSubscription 모델을 이해해야합니다.

Lync Contact에 대한 필드 업데이트 (또는로드)에 대한 알림을 받으려는 Lync Contact마다 Lync Contact에 "가입"하면 Contact.ContactInformationChanged 이벤트를 통해 알림이 전송됩니다.

그래서 Lync Contact 값에서 반환 된 초기 값에서 필드가로드되거나 업데이트되면 UI에서 정보를 자동으로 업데이트 할 수 있어야합니다.

+0

그것이 내가 상상 무엇에 너무 복잡한 것, 그리고 내가 구체적인 예를 찾을 수 없습니다 :(나는 문서화를 읽고 .. 당신이 어떤 examplei'm 복용해야합니다. 감사합니다 다시 대답 –

+0

에 대한 있습니다 내가 아는 예제는 없지만 위의 모든 작업을 여러 번 수행했습니다. 문제가 발생할 때 특정 질문을 한 다음 질문하는 것이 가장 좋습니다. –

+0

문서를 읽는 데 시간이 많이 걸렸습니다. 내 코드, 그의 Uri (전화 번호)로 연락을 검색합니다. 그래서 내 구독 만이 연락처에 대한 것이고, 나는 그의 전화 번호 목록을 반환 할 수 있습니다.하지만 내가하고 싶은 것은,이 Uri를 선택해야합니다. 연락처, 내 응용 프로그램 시작 (오른쪽 클릭). GetContactByUri가 아닌 BeginSearch를 사용해야한다고 생각합니까? –

0
public partial class App : Application 
    { 
     protected override void OnStartup(StartupEventArgs e) 
     { 
      App.Current.DispatcherUnhandledException += Current_DispatcherUnhandledException; ; 
      try 
      { 
       string argsParam = "Contacts="; 

       if (e.Args.Length > 1) 
       { 
        if (e.Args[2].Contains(argsParam)) 
        { 
         var contacts_sip_uri = e.Args[2].Split('<', '>')[1]; 
         Params.contacts = contacts_sip_uri; 
        } 
       } 
      } 
      catch (Exception ex) 
      { 
       MessageBox.Show("Reading Startup Arguments Error - " + ex.Message); 
      } 

     } 

     private void Current_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) 
     { 
      string message = e.Exception.Message; 

      if (e.Exception.InnerException != null) 
      { 
       message += string.Format("{0}Inner Exception: {1}", Environment.NewLine, e.Exception.InnerException.Message); 
      } 
      MessageBox.Show(message, "Unhandled Exception", MessageBoxButton.OK, MessageBoxImage.Error); 
     } 

    } 

에 Params는 공공 정적 문자열 접촉 {얻을로 연락이 포함 된 공공 정적 클래스입니다; 세트; }

public static class ParamContact 
    { 
     public static string contacts { get; set; } 
    }