コード例 #1
0
ファイル: LyncHelper.cs プロジェクト: Jackjet/conference
        /// <summary>
        /// 参会人状态更改捕获事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        static void contact_ContactInformationChanged(object sender, ContactInformationChangedEventArgs e)
        {
            try
            {
                App.Current.Dispatcher.BeginInvoke(new Action(() =>
                {
                    if (Constant.lyncClient != null && Constant.lyncClient.State == ClientState.SignedIn)
                    {
                        //获取联系人
                        Contact contact = sender as Contact;
                        if (contact != null)
                        {

                            System.Collections.Generic.List<object> list = (System.Collections.Generic.List<object>)contact.GetContactInformation(ContactInformationType.EmailAddresses);
                            if (list.Count > 0 && currentParticipantsEntityList != null)
                            {
                                //double state = Convert.ToDouble(contact.GetContactInformation(ContactInformationType.Availability));

                                List<ParticipantsEntity> participantsEntityTempList = currentParticipantsEntityList.Where(item => item.LoginUri.ToLower().Equals(Convert.ToString(list[0]).ToLower())).ToList<ParticipantsEntity>();

                                if (participantsEntityTempList.Count > 0)
                                {
                                    ParticipantsEntity Participant = participantsEntityTempList[0];

                                    string uriImg = Constant.TreeServiceAddressFront + Constant.FtpServercePersonImgName + Participant.LoginName + ".png";
                                    BitmapImage btimap = new BitmapImage(new Uri(uriImg));
                                    string strState = Convert.ToString(contact.GetContactInformation(ContactInformationType.Activity));
                                    //bool imgIsExit = UriManage.RemoteFileExists(uriImg);
                                    if (strState.Equals("脱机"))
                                    {
                                        Participant.LoginState = "未登录";
                                        Participant.StateForeBrush = App.Current.Resources["NormalColorBrush"] as SolidColorBrush;
                                        Participant.HeadPortrait = ImageManage.ToGray(btimap);
                                    }
                                    else
                                    {
                                        Participant.LoginState = "在线";
                                        Participant.StateForeBrush = App.Current.Resources["GreenColorBrush"] as SolidColorBrush;
                                        Participant.HeadPortrait = btimap;
                                    }
                                    //获取当前人的公司名称
                                    Participant.Company = Convert.ToString(contact.GetContactInformation(ContactInformationType.Company));
                                    ////获取当前人的职位
                                    Participant.Position = Convert.ToString(contact.GetContactInformation(ContactInformationType.Title));
                                }
                                if (BeginRefleshDataGridCallBack != null)
                                {
                                    BeginRefleshDataGridCallBack(currentParticipantsEntityList);
                                }
                            }
                        }
                    }
                }));

            }
            catch (Exception ex)
            {
                LogManage.WriteLog(typeof(LyncHelper), ex);
            }
        }
コード例 #2
0
ファイル: LyncHelper.cs プロジェクト: Jackjet/conference
        /// <summary>
        /// 填充参会人列表
        /// </summary>
        public static void FillLyncOnlineInfo(DataGrid datagrid, ObservableCollection<ParticipantsEntity> ParticipantsEntityList)
        {
            try
            {
                if (Constant.lyncClient != null)
                {
                    currentParticipantsEntityList = ParticipantsEntityList;

                    //数据清除
                    currentParticipantsEntityList.Clear();

                    //递增序号
                    int number = 0;

                    //遍历添加参会人
                    foreach (var item in Constant.ParticipantList)
                    {
                        //创建参会人子项实体
                        ParticipantsEntity participantsEntity = new ParticipantsEntity();


                        //将参会人的名称取出
                        if (Constant.DicParticipant.ContainsKey(item))
                        {
                            participantsEntity.ParticipantsName = Constant.DicParticipant[item];
                            number++;
                            //序号
                            participantsEntity.Number = number;

                            if (Constant.lyncClient != null)
                            {
                                Contact contact = Constant.lyncClient.ContactManager.GetContactByUri(item);
                                contact.ContactInformationChanged += contact_ContactInformationChanged;
                                //获取当前人的公司名称
                                participantsEntity.Company = Convert.ToString(contact.GetContactInformation(ContactInformationType.Company));
                                //获取当前人的职位
                                participantsEntity.Position = Convert.ToString(contact.GetContactInformation(ContactInformationType.Title));

                                //int state = Convert.ToInt32(contact.GetContactInformation(ContactInformationType.Availability));

                                participantsEntity.LoginUri = item;
                                participantsEntity.LoginName = item.Replace("sip:", string.Empty).Replace(Constant.UserDomain, string.Empty).Replace("@", string.Empty);
                                string uriImg = Constant.TreeServiceAddressFront + Constant.FtpServercePersonImgName + participantsEntity.LoginName + ".png";
                                BitmapImage btimap = new BitmapImage(new Uri(uriImg));
                                string strState = Convert.ToString(contact.GetContactInformation(ContactInformationType.Activity));
                                //bool imgIsExit = UriManage.RemoteFileExists(uriImg);
                                if (strState.Equals("脱机"))
                                {
                                    participantsEntity.LoginState = "未登录";
                                    participantsEntity.StateForeBrush = App.Current.Resources["NormalColorBrush"] as SolidColorBrush;
                                    participantsEntity.HeadPortrait = ImageManage.ToGray(btimap);
                                }
                                else
                                {
                                    participantsEntity.LoginState = "在线";
                                    participantsEntity.StateForeBrush = App.Current.Resources["GreenColorBrush"] as SolidColorBrush;
                                    participantsEntity.HeadPortrait = btimap;
                                }
                                //添加参会人
                                ParticipantsEntityList.Add(participantsEntity);
                            }
                        }
                    }
                    if (BeginRefleshDataGridCallBack != null)
                    {
                        BeginRefleshDataGridCallBack(currentParticipantsEntityList);
                    }
                }
            }
            catch (Exception ex)
            {
                LogManage.WriteLog(typeof(LyncHelper), ex);
            }
            finally
            {

            }
        }