public void SetButtonVisible(bool isVisable) { int devType = 0; int iRet = 0; if (isVisable) { LogInBusiness log = new LogInBusiness(); iRet = log.GetPhoneJointDevType(ref devType); } BtnHisitory.Visible = isVisable; BtnDail.Visible = isVisable; BtnFWD.Visible = isVisable; BtnMail.Visible = isVisable; BtnPC.Visible = isVisable && iRet != (int)UCServiceRetvCode.UC_SDK_NoRight; BtnIP.Visible = isVisable && iRet != (int)UCServiceRetvCode.UC_SDK_NoRight; //获取设置前传结果 GetFWDInfo(); }
void LyncClientStateChangedMethod(object ob) { ////通话时不能更改话机联动状态 2015/7/16 ////You can't change joint type in a call //if (winCall != null) //{ // Dispatcher.Invoke(new Action(() => // { // DialogShow.Show(StringHelper.FindLanguageResource("Cannotdothisincall"), StringHelper.FindLanguageResource("error"), 2); // return; // })); //} if (lockLyncUCLoginOut.TryEnterWriteLock(-1)) { try { ClientStateChangedEventArgs e = ob as ClientStateChangedEventArgs; if (e.NewState == ClientState.SignedOut || e.NewState == ClientState.SigningOut)//lync登出 { iWpfHeightButtomOff = iWpfHeightTopOff; if (null != toolBar) { if (e.NewState == ClientState.SigningOut) { Visibility isVisible = Visibility.Visible; Dispatcher.Invoke(new Action(() => { toolBar.Visible = false; isVisible = this.Visibility; //隐藏时不重新设置lync尺寸 if (isVisible == Visibility.Visible && this.WindowState != WindowState.Maximized) { MoveWindowVisible();//恢复lync高度 } }), System.Windows.Threading.DispatcherPriority.Send);//隐藏工具盘 } } LogInBusiness log = new LogInBusiness(); log.SignOut();//lync 注销时 注销UC } if (e.NewState == ClientState.SignedIn)//登录成功 开始订阅自身状态 { iWpfHeightButtomOff = 0; WinOptionSettingViewModel set = new WinOptionSettingViewModel(); set.SaveLyncAccountToConfig(StringHelper.GetLyncNameString(_Client.Self.Contact.Uri)); _Client.Self.Contact.ContactInformationChanged += new EventHandler<ContactInformationChangedEventArgs>(Contact_ContactInformationChanged); ContactSubscription foundContactSubscription = LyncClient.GetClient().ContactManager.CreateSubscription(); foundContactSubscription.AddContact(_Client.Self.Contact); List<ContactInformationType> subscribeTypeList = new List<ContactInformationType>(); subscribeTypeList.Add(ContactInformationType.Availability); foundContactSubscription.Subscribe(ContactSubscriptionRefreshRate.High, subscribeTypeList); LyncSignedInFun(); //2015/8/14 登录时根据Lync状态获取UC状态 GetLyncUserState(); GetUCState(userState); LogInBusiness log = new LogInBusiness(); log.PubSelfStatus((int)userState, new StringBuilder()); } LogManager.SystemLog.Debug(string.Format("SingletonObj.LoginInfo = {0}", SingletonObj.LoginInfo)); LogManager.SystemLog.Debug(string.Format("Leave LyncClientStateChanged.NewState = {0}", e.NewState)); } finally { lockLyncUCLoginOut.ExitWriteLock(); } } }
/// <summary> /// Set the contact's current availability value from Lync /// </summary> public void SetAvailability(ContactAvailability state) { try { LogManager.SystemLog.Debug(string.Format("SetAvailability state = {0}", state)); //Add the availability to the contact information items to be published Dictionary<PublishableContactInformationType, object> newInformation = new Dictionary<PublishableContactInformationType, object>(); newInformation.Add(PublishableContactInformationType.Availability, state); _Client.Self.BeginPublishContactInformation(newInformation, PublishContactInformationCallback, null); UCContactAvailability ucAvailability = GetUCState(state); LogInBusiness log = new LogInBusiness(); log.PubSelfStatus((int)ucAvailability, new StringBuilder()); } catch (Exception ex) { LogManager.SystemLog.Error(ex.ToString()); } }
/// <summary> /// 是否UC资源 /// </summary> private void StartUnInit()//释放资源 { LogInBusiness log = new LogInBusiness(); log.UnInit(); }
/// <summary> /// 注销UC /// </summary> public void StartSignOutUC()//注销UC { LogManager.SystemLog.Debug("Start StartSignOutUC"); LogInBusiness log = new LogInBusiness(); log.SignOut(); SingletonObj.LoginInfo = null; LogManager.SystemLog.Debug("Start StartSignOutUC.Invoke"); Dispatcher.Invoke(new Action(() => { toolBar.LabState.Text = StringHelper.FindLanguageResource("LogOutUC"); toolBar.SetButtonVisible(false); })); LogManager.SystemLog.Debug("End StartSignOutUC.Invoke"); }
/// <summary> /// 使用账号和密码登陆UC /// </summary> public void StartLoginUC() { try { if (canReLogin == false) { Dialog.Show(StringHelper.FindLanguageResource("logouting"), StringHelper.FindLanguageResource("error")); return; } LogManager.SystemLog.Debug("Start StartLoginUC"); UCUserInfo user = new UCUserInfo(); user = XmlHelper.GetUserConfig(); if (user != null && user.UserID != null && user.UserID != string.Empty && user.Password != null && user.Server != string.Empty && user.Port != string.Empty && user.Password != string.Empty) { Dispatcher.BeginInvoke(new Action(() => { toolBar.LabState.Text = ""; toolBar.LabState.Visible = false; toolBar.PictureBoxProgress.Visible = true;//开始登录UC,显示进度条 })); LogInBusiness log = new LogInBusiness(); Dispatcher.Invoke(new Action(() //modify by 00327190 6/12 之前是没有这个Dispatcher 放在主线程 => { UCServiceRetvCode iRet = (UCServiceRetvCode)log.Login(user.UserID, user.Password, user.Server + ":" + user.Port, user.Lang == "0" ? "2052" : "1033"); process.WaitForExit(5); //modify by jinyeqing 2015/6/15 原先是没有5毫秒的等待超时的,现在定义5ms等待超时,这样就可以强制执行下面的程序 LogManager.SystemLog.DebugFormat("StartLoginUC iRet = {0}", iRet); if (iRet != UCServiceRetvCode.UC_SDK_Success) { LogManager.SystemLog.Debug("Start StartLoginUC.Failed.Invoke"); Dispatcher.Invoke(new Action(() => { try { toolBar.LabState.Text = SingletonObj.LoginInfo == null ? StringHelper.FindLanguageResource("SignedUCFailed") : SingletonObj.LoginInfo.UserID; toolBar.SetButtonVisible(SingletonObj.LoginInfo == null ? false : true); if (SingletonObj.LoginInfo != null) { toolTipLabState.SetToolTip(toolBar.LabState, StringHelper.FindLanguageResource("SignedInUC")); string url = _Client.Self.Contact.Uri; SingletonObj.LoginInfo.LyncName = url.Substring(url.IndexOf(":") + 1); } } finally { toolBar.LabState.Visible = true; toolBar.PictureBoxProgress.Visible = false; } })); LogManager.SystemLog.Debug("End StartLoginUC.Failed.Invoke"); } })); } else { toolBar.LabState.Text = StringHelper.FindLanguageResource("SignedUCFailed"); Dialog.Show(StringHelper.FindLanguageResource("NoUCAccount"), StringHelper.FindLanguageResource("SettingUC")); } LogManager.SystemLog.Debug("End StartLoginUC"); } catch (System.Exception ex) { LogManager.SystemLog.Error(ex.ToString()); } }
/// <summary> /// lync 联系人信息变化 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void Contact_ContactInformationChanged(object sender, ContactInformationChangedEventArgs e) { try { Contact contact = (sender as Contact); if (_Client.Self.Contact == null) { return; } ContactAvailability availability = (ContactAvailability)contact.GetContactInformation(ContactInformationType.Availability);//Get the current availability value from Lync UCContactAvailability ucAvailability = GetUCState(availability); LogInBusiness log = new LogInBusiness(); log.PubSelfStatus((int)ucAvailability, new StringBuilder()); } catch (System.Exception ex) { LogManager.SystemLog.Error(ex.ToString()); } }
/// <summary> /// UC状态改变处理函数 /// </summary> /// <param name="ucStatePara"></param> void UCContactStateChangedMothod(object ucStatePara) { if (lockLyncUCLoginOut.TryEnterWriteLock(-1)) { try { SignInState st = (ucStatePara as UCStatePara).signInState; StringBuilder _reason = (ucStatePara as UCStatePara).reason; if (st == SignInState.Client_SignedIn) { isSigned = true; LogInBusiness log = new LogInBusiness(); int devType = 0; if (isSigned == true) { log.SetPhoneJointEventCallBack(toolBar.phoneJointEventCB); log.GetPhoneJointDevType(ref devType); } UCUserInfo user = new UCUserInfo(); user = XmlHelper.GetUserConfig(); SingletonObj.LoginInfo = user; if (_Client.Self == null || _Client.Self.Contact == null) { return; } string url = _Client.Self.Contact.Uri; SingletonObj.LoginInfo.LyncName = url.Substring(url.IndexOf(":") + 1); Dispatcher.Invoke(new Action(() => { toolBar.LabState.Visible = true; toolBar.PictureBoxProgress.Visible = false; LogManager.SystemLog.Debug("UCContactStateChanged.SingletonObj.LoginInfo = " + SingletonObj.LoginInfo); toolBar.SetButtonVisible(true); toolBar.SetBtnImage(devType); })); SetLabStateToolTip(_reason);//设置状态提示信息 2015/8/13 } else { isSigned = false; SingletonObj.LoginInfo = null; if (_reason == null) { return; } Dispatcher.Invoke(new Action(() => { toolBar.LabState.Visible = true; toolBar.SetButtonVisible(false); toolBar.PictureBoxProgress.Visible = false; if (winCall != null)//关闭通话界面,需要在uninit之后执行,否则不能再次登录 { winCall.Close(); } if (winDial != null) { winDial.Close(); } if (toolBar.Setting != null) { toolBar.Setting.Close(); } if (toolBar.History != null) { toolBar.History.Close(); } }) ); } SetLabStateToolTip(_reason);//设置状态提示信息 } catch (System.Exception ex) { LogManager.SystemLog.Error(ex.ToString()); } finally { lockLyncUCLoginOut.ExitWriteLock(); } } }