Esempio n. 1
0
        /// <summary>
        /// 程序启动时根据CultureInfo载入不同的语言
        /// 如:中文 currentCultureInfo.Name = zh-CN
        /// 程序自动载入zh-CN.xaml
        /// </summary>
        private void LoadLanguage()
        {
            LogManager.SystemLog.Debug("Start LoadLanguage");
            CultureInfo currentCultureInfo = CultureInfo.CurrentCulture;
            string      name = currentCultureInfo.Name;

            LogManager.SystemLog.Debug(string.Format("Start LoadLanguage name = {0}", name));
            UCUserInfo user = new UCUserInfo();

            user = XmlHelper.GetUserConfig();
            if (user.Lang == "0")//语系地区
            {
                name = "zh-CN";
            }
            else if (user.Lang == "1")
            {
                name = "en-US";
            }
            else if (user.Lang == "2")
            {
                name = "pt-BR";//葡萄牙
            }
            LogManager.SystemLog.Info(string.Format("Start LoadLanguage = {0}", name));
            List <ResourceDictionary> langRdList = new List <ResourceDictionary>();

            try
            {
                langRdList.Add(
                    System.Windows.Application.LoadComponent(
                        new Uri("/Resources/Language/" + name + ".xaml", UriKind.Relative)) as ResourceDictionary);

                string[] strFiles = Directory.GetFiles(System.Windows.Forms.Application.StartupPath.Substring(0, System.Windows.Forms.Application.StartupPath.IndexOf("\\bin")) + "\\Resources\\Style");
                foreach (string strFile in strFiles)
                {
                    langRdList.Add(System.Windows.Application.LoadComponent(
                                       new Uri("/Resources/Style/" + strFile.Substring(strFile.LastIndexOf("\\") + 1), UriKind.Relative)) as ResourceDictionary);
                }
            }
            catch (Exception ex)
            {
                LogManager.SystemLog.Error(ex.ToString());
            }
            if (langRdList.Count > 0)
            {
                if (this.Resources.MergedDictionaries.Count > 0)
                {
                    this.Resources.MergedDictionaries.Clear();
                }
                foreach (ResourceDictionary langRd in langRdList)
                {
                    this.Resources.MergedDictionaries.Add(langRd);
                }
            }
            LogManager.SystemLog.Debug("End LoadLanguage");
        }
 public void SaveLyncAccountToConfig(string account)
 {
     try
        {
        UCUserInfo user = new UCUserInfo();
        user = XmlHelper.GetUserConfig();
        user.UserID = account;
        XmlHelper.SetUserConfig(user);
        }
        catch (System.Exception ex)
        {
        LogManager.SystemLog.Error(ex.ToString());
        }
 }
Esempio n. 3
0
 public void SaveLyncAccountToConfig(string account)
 {
     try
     {
         UCUserInfo user = new UCUserInfo();
         user        = XmlHelper.GetUserConfig();
         user.UserID = account;
         XmlHelper.SetUserConfig(user);
     }
     catch (System.Exception ex)
     {
         LogManager.SystemLog.Error(ex.ToString());
     }
 }
        public void StartLoadData()
        {
            try
               {
               UCUserInfo user = new UCUserInfo();
               user = XmlHelper.GetUserConfig();

               winOptionSetting.txtAccount.Text = user.UserID;
               winOptionSetting.comLang.SelectedIndex = Convert.ToInt32(user.Lang);

               winOptionSetting.txtPassword.Password = user.Password;
               winOptionSetting.txtPort.Text = user.Port;
               winOptionSetting.txtServer1.Text = user.Server;

               winOptionSetting.chkStart.IsChecked = user.AutoStart == "1" ? true : false;

               winOptionSetting.chkAvailable.IsChecked = user.Available;
               winOptionSetting.chkUnavailable.IsChecked = user.Unavailable;
               winOptionSetting.chkBusy.IsChecked = user.Busy;
               winOptionSetting.chkVoicemail.IsChecked = user.Voicemail;
               winOptionSetting.txtAvailable.Text = user.AvailableCallNumber;
               winOptionSetting.txtUnavailable.Text = user.UnavailableCallNumber;
               winOptionSetting.txtBusy.Text = user.BusyCallNumber;
               winOptionSetting.txtVoicemail.Text = user.VoicemailCallNumber;

               //设置呼叫前转信息
               if (SingletonObj.LoginInfo == null || SingletonObj.LoginInfo.UserID == null)
               {
                   return;
               }
               winOptionSetting.comMicrophone.SelectedIndex = GetMicrophone();
               winOptionSetting.comSpeaker.SelectedIndex = GetSpeaker();
               winOptionSetting.comCamera.SelectedIndex = GetCamera();

               int iRet = (int)UCServiceRetvCode.UC_SDK_Success;

               ForwardServiceType type = ForwardServiceType.FORWARD_UNCONDITION;
               STCallExData data = new STCallExData();
               MakeCallBusiness call = new MakeCallBusiness();

               //无条件前传
               iRet  = call.GetCallExService((int)type, ref data);
               if (iRet != (int)UCServiceRetvCode.UC_SDK_Success)
               {
                   LogManager.SystemLog.Error("GetCallExService error");
                   return;
               }
               winOptionSetting.radCallForwardUnCondEn.IsChecked = (string.IsNullOrEmpty(data.Num) ? false : true);
               winOptionSetting.txtCallForwardUnCond.Text = data.Num;

               //遇忙前传
               type = ForwardServiceType.FORWARD_ONBUSY;
               data = new STCallExData();

               iRet = call.GetCallExService((int)type, ref data);
               if (iRet != (int)UCServiceRetvCode.UC_SDK_Success)
               {
                   LogManager.SystemLog.Error("GetCallExService error");
                   return;
               }
               winOptionSetting.radCallForwardBusyEn.IsChecked = (string.IsNullOrEmpty(data.Num) ? false : true);
               winOptionSetting.txtCallForwardBusy.Text = data.Num;

               //无应答前传
               type = ForwardServiceType.FORWARD_NOREPLY;
               data = new STCallExData();

               iRet = call.GetCallExService((int)type, ref data);
               if (iRet != (int)UCServiceRetvCode.UC_SDK_Success)
               {
                   LogManager.SystemLog.Error("GetCallExService error");
                   return;
               }
               winOptionSetting.radCallForwardNoReplyEn.IsChecked = (string.IsNullOrEmpty(data.Num) ? false : true);
               winOptionSetting.txtCallForwardNoReply.Text = data.Num;

               //离线前传
               type = ForwardServiceType.FORWARD_OFFLINE;
               data = new STCallExData();

               iRet = call.GetCallExService((int)type, ref data);
               if (iRet != (int)UCServiceRetvCode.UC_SDK_Success)
               {
                   LogManager.SystemLog.Error("GetCallExService error");
                   return;
               }
               winOptionSetting.radCallForwardOfflineEn.IsChecked = (string.IsNullOrEmpty(data.Num) ? false : true);
               winOptionSetting.txtCallForwardOffline.Text = data.Num;

               //modify by 00327190   2015/7/30
               type = ForwardServiceType.VOICEMAIL_UNCONDITION;  //无条件语音邮箱前转
               data = new STCallExData();
               iRet = call.GetCallExService((int)type, ref data);
               if (iRet != (int)UCServiceRetvCode.UC_SDK_Success)
               {
                   LogManager.SystemLog.Error("GetCallExService error");
                   return;
               }
               winOptionSetting.radVoiceForwardUnCondEn.IsChecked = (string.IsNullOrEmpty(data.Num) ? false : true);
               //winOptionSetting.txtVoiceForwardUnCond.Text = data.Num;   //2015/8/24

               // 无应答语音邮箱前转
               type = ForwardServiceType.VOICEMAIL_NOREPLY;
               data = new STCallExData();
               iRet = call.GetCallExService((int)type, ref data);
               if (iRet != (int)UCServiceRetvCode.UC_SDK_Success)
               {
                   LogManager.SystemLog.Error("GetCallExService error");
                   return;
               }
               winOptionSetting.radVoiceForwardNoReplyEn.IsChecked = (string.IsNullOrEmpty(data.Num) ? false : true);
               //winOptionSetting.txtVoiceForwardNoReply.Text = data.Num;   //2015/8/24

               // 遇忙语音邮箱前转
               type = ForwardServiceType.VOICEMAIL_ONBUSY;
               data = new STCallExData();
               iRet = call.GetCallExService((int)type, ref data);
               if (iRet != (int)UCServiceRetvCode.UC_SDK_Success)
               {
                   LogManager.SystemLog.Error("GetCallExService error");
                   return;
               }
               winOptionSetting.radVoiceForwardBusyEn.IsChecked = (string.IsNullOrEmpty(data.Num) ? false : true);
               //winOptionSetting.txtVoiceForwardBusy.Text = data.Num;   //2015/8/24

               // 离线语音邮箱前转
               type = ForwardServiceType.VOICEMAIL_OFFLINE;
               data = new STCallExData();
               iRet = call.GetCallExService((int)type, ref data);
               if (iRet != (int)UCServiceRetvCode.UC_SDK_Success)
               {
                   LogManager.SystemLog.Error("GetCallExService error");
                   return;
               }
               winOptionSetting.radVoiceForwardOfflineEn.IsChecked = (string.IsNullOrEmpty(data.Num) ? false : true);
               //winOptionSetting.txtVoiceForwardOffline.Text = data.Num;   //2015/8/24

               }
               catch (System.Exception ex)
               {
               LogManager.SystemLog.Error(ex.ToString());
               }
        }
        private void ApplyCommandProcess()
        {
            try
               {
               UCUserInfo user = new UCUserInfo();
               user.Camera = winOptionSetting.comCamera.SelectedIndex.ToString();
               user.Lang = winOptionSetting.comLang.SelectedIndex.ToString();
               user.MicPhone = winOptionSetting.comMicrophone.SelectedIndex.ToString();
               user.Password = winOptionSetting.txtPassword.Password.ToString();
               user.Port = winOptionSetting.txtPort.Text.ToString();
               user.Server = winOptionSetting.txtServer1.Text.ToString();
               user.Speaker = winOptionSetting.comSpeaker.SelectedIndex.ToString();
               user.UserID = winOptionSetting.txtAccount.Text.ToString();
               user.AutoStart = winOptionSetting.chkStart.IsChecked == true ? "1" : "0";
               user.Available = (bool)winOptionSetting.chkAvailable.IsChecked;
               user.Unavailable = (bool)winOptionSetting.chkUnavailable.IsChecked;
               user.Busy = (bool)winOptionSetting.chkBusy.IsChecked;
               user.Voicemail = (bool)winOptionSetting.chkVoicemail.IsChecked;
               user.AvailableCallNumber = winOptionSetting.txtAvailable.Text;
               user.UnavailableCallNumber = winOptionSetting.txtUnavailable.Text;
               user.BusyCallNumber = winOptionSetting.txtBusy.Text;
               user.VoicemailCallNumber = winOptionSetting.txtVoicemail.Text;
               user.SetFWDService = FrmToolBar.isSetFWDUnCond ? "1" : "0";

               XmlHelper.SetUserConfig(user);

               UserConfigBusiness conf = new UserConfigBusiness();
               conf.SetCurrentMicDev(winOptionSetting.comMicrophone.SelectedIndex);
               conf.SetCurrentVideoDev(winOptionSetting.comCamera.SelectedIndex);
               conf.SetCurrentSpeakerDev(winOptionSetting.comSpeaker.SelectedIndex);

               //modify by jinyeqing 2015/6/1   登陆时某些值为空要设置提示 (要求提示语言国际化)
               if (winOptionSetting.txtPort.Text.ToString() == "" || winOptionSetting.txtPort.Text.ToString() == null)
               {
                   Dialog.Show(StringHelper.FindLanguageResource("Portcannotbenull"), StringHelper.FindLanguageResource("error"));
                   return;
               }
               if (winOptionSetting.txtPassword.Password.ToString() == "" || winOptionSetting.txtPassword.Password.ToString() == null)
               {
                   Dialog.Show(StringHelper.FindLanguageResource("Passwordcannotbenull"), StringHelper.FindLanguageResource("error"));
                   return;
               }
               if (winOptionSetting.txtAccount.Text.ToString() == "" || winOptionSetting.txtAccount.Text.ToString() == null)
               {
                   Dialog.Show(StringHelper.FindLanguageResource("UserIDcannotbenull"), StringHelper.FindLanguageResource("error"));
                   return;
               }
               if (winOptionSetting.txtServer1.Text.ToString() == "" || winOptionSetting.txtServer1.Text.ToString() == null)
               {
                   Dialog.Show(StringHelper.FindLanguageResource("Servercannotbenull"), StringHelper.FindLanguageResource("error"));
                   return;
               }
               if (winOptionSetting.comLang.SelectedIndex.ToString() == "" || winOptionSetting.comLang.SelectedIndex.ToString() == null)
               {
                   Dialog.Show(StringHelper.FindLanguageResource("Languagecannotbenull"), StringHelper.FindLanguageResource("error"));
                   return;
               }
              // end modify

               if (winOptionSetting.chkStart.IsChecked == true)
               {
                   RegistryKey runKey = Registry.LocalMachine.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run");
                   runKey.SetValue("LyncWpfApp.exe", System.Windows.Forms.Application.StartupPath + "\\LyncWpfApp.exe");
                   //如果Lync插件自启动,那么就算Lync设置了自启动也不能让它运行   modify by 00327190   2015/8/6
                   RegistryKey runKey1 = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);
                   if (null != runKey1 && null != runKey1.GetValue("LyncWpfApp.exe"))
                   {
                       RegistryKey runKey2 = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);
                       if (null != runKey2 && null != runKey2.GetValue("Lync"))
                       {
                           runKey2.DeleteValue("Lync");
                       }
                   }
               }
               else
               {
                   RegistryKey runKey = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);
                   runKey.DeleteValue("LyncWpfApp.exe");
               }
               }
               catch
               {
               LogManager.SystemLog.Info("DeleteSubKey");
               }
        }
        /// <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>
        /// 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();
                }
            }
        }
Esempio n. 8
0
        public void StartLoadData()
        {
            try
            {
                UCUserInfo user = new UCUserInfo();
                user = XmlHelper.GetUserConfig();

                winOptionSetting.txtAccount.Text       = user.UserID;
                winOptionSetting.comLang.SelectedIndex = Convert.ToInt32(user.Lang);

                winOptionSetting.txtPassword.Password = user.Password;
                winOptionSetting.txtPort.Text         = user.Port;
                winOptionSetting.txtServer1.Text      = user.Server;

                winOptionSetting.chkStart.IsChecked = user.AutoStart == "1" ? true : false;


                winOptionSetting.chkAvailable.IsChecked   = user.Available;
                winOptionSetting.chkUnavailable.IsChecked = user.Unavailable;
                winOptionSetting.chkBusy.IsChecked        = user.Busy;
                winOptionSetting.chkVoicemail.IsChecked   = user.Voicemail;
                winOptionSetting.txtAvailable.Text        = user.AvailableCallNumber;
                winOptionSetting.txtUnavailable.Text      = user.UnavailableCallNumber;
                winOptionSetting.txtBusy.Text             = user.BusyCallNumber;
                winOptionSetting.txtVoicemail.Text        = user.VoicemailCallNumber;

                //设置呼叫前转信息
                if (SingletonObj.LoginInfo == null || SingletonObj.LoginInfo.UserID == null)
                {
                    return;
                }
                winOptionSetting.comMicrophone.SelectedIndex = GetMicrophone();
                winOptionSetting.comSpeaker.SelectedIndex    = GetSpeaker();
                winOptionSetting.comCamera.SelectedIndex     = GetCamera();

                int iRet = (int)UCServiceRetvCode.UC_SDK_Success;

                ForwardServiceType type = ForwardServiceType.FORWARD_UNCONDITION;
                STCallExData       data = new STCallExData();
                MakeCallBusiness   call = new MakeCallBusiness();

                //无条件前传
                iRet = call.GetCallExService((int)type, ref data);
                if (iRet != (int)UCServiceRetvCode.UC_SDK_Success)
                {
                    LogManager.SystemLog.Error("GetCallExService error");
                    return;
                }
                winOptionSetting.radCallForwardUnCondEn.IsChecked = (string.IsNullOrEmpty(data.Num) ? false : true);
                winOptionSetting.txtCallForwardUnCond.Text        = data.Num;

                //遇忙前传
                type = ForwardServiceType.FORWARD_ONBUSY;
                data = new STCallExData();

                iRet = call.GetCallExService((int)type, ref data);
                if (iRet != (int)UCServiceRetvCode.UC_SDK_Success)
                {
                    LogManager.SystemLog.Error("GetCallExService error");
                    return;
                }
                winOptionSetting.radCallForwardBusyEn.IsChecked = (string.IsNullOrEmpty(data.Num) ? false : true);
                winOptionSetting.txtCallForwardBusy.Text        = data.Num;

                //无应答前传
                type = ForwardServiceType.FORWARD_NOREPLY;
                data = new STCallExData();

                iRet = call.GetCallExService((int)type, ref data);
                if (iRet != (int)UCServiceRetvCode.UC_SDK_Success)
                {
                    LogManager.SystemLog.Error("GetCallExService error");
                    return;
                }
                winOptionSetting.radCallForwardNoReplyEn.IsChecked = (string.IsNullOrEmpty(data.Num) ? false : true);
                winOptionSetting.txtCallForwardNoReply.Text        = data.Num;

                //离线前传
                type = ForwardServiceType.FORWARD_OFFLINE;
                data = new STCallExData();

                iRet = call.GetCallExService((int)type, ref data);
                if (iRet != (int)UCServiceRetvCode.UC_SDK_Success)
                {
                    LogManager.SystemLog.Error("GetCallExService error");
                    return;
                }
                winOptionSetting.radCallForwardOfflineEn.IsChecked = (string.IsNullOrEmpty(data.Num) ? false : true);
                winOptionSetting.txtCallForwardOffline.Text        = data.Num;

                //modify by 00327190   2015/7/30
                type = ForwardServiceType.VOICEMAIL_UNCONDITION; //无条件语音邮箱前转
                data = new STCallExData();
                iRet = call.GetCallExService((int)type, ref data);
                if (iRet != (int)UCServiceRetvCode.UC_SDK_Success)
                {
                    LogManager.SystemLog.Error("GetCallExService error");
                    return;
                }
                winOptionSetting.radVoiceForwardUnCondEn.IsChecked = (string.IsNullOrEmpty(data.Num) ? false : true);
                //winOptionSetting.txtVoiceForwardUnCond.Text = data.Num;   //2015/8/24

                // 无应答语音邮箱前转
                type = ForwardServiceType.VOICEMAIL_NOREPLY;
                data = new STCallExData();
                iRet = call.GetCallExService((int)type, ref data);
                if (iRet != (int)UCServiceRetvCode.UC_SDK_Success)
                {
                    LogManager.SystemLog.Error("GetCallExService error");
                    return;
                }
                winOptionSetting.radVoiceForwardNoReplyEn.IsChecked = (string.IsNullOrEmpty(data.Num) ? false : true);
                //winOptionSetting.txtVoiceForwardNoReply.Text = data.Num;   //2015/8/24

                // 遇忙语音邮箱前转
                type = ForwardServiceType.VOICEMAIL_ONBUSY;
                data = new STCallExData();
                iRet = call.GetCallExService((int)type, ref data);
                if (iRet != (int)UCServiceRetvCode.UC_SDK_Success)
                {
                    LogManager.SystemLog.Error("GetCallExService error");
                    return;
                }
                winOptionSetting.radVoiceForwardBusyEn.IsChecked = (string.IsNullOrEmpty(data.Num) ? false : true);
                //winOptionSetting.txtVoiceForwardBusy.Text = data.Num;   //2015/8/24

                // 离线语音邮箱前转
                type = ForwardServiceType.VOICEMAIL_OFFLINE;
                data = new STCallExData();
                iRet = call.GetCallExService((int)type, ref data);
                if (iRet != (int)UCServiceRetvCode.UC_SDK_Success)
                {
                    LogManager.SystemLog.Error("GetCallExService error");
                    return;
                }
                winOptionSetting.radVoiceForwardOfflineEn.IsChecked = (string.IsNullOrEmpty(data.Num) ? false : true);
                //winOptionSetting.txtVoiceForwardOffline.Text = data.Num;   //2015/8/24
            }
            catch (System.Exception ex)
            {
                LogManager.SystemLog.Error(ex.ToString());
            }
        }
Esempio n. 9
0
        private void ApplyCommandProcess()
        {
            try
            {
                UCUserInfo user = new UCUserInfo();
                user.Camera                = winOptionSetting.comCamera.SelectedIndex.ToString();
                user.Lang                  = winOptionSetting.comLang.SelectedIndex.ToString();
                user.MicPhone              = winOptionSetting.comMicrophone.SelectedIndex.ToString();
                user.Password              = winOptionSetting.txtPassword.Password.ToString();
                user.Port                  = winOptionSetting.txtPort.Text.ToString();
                user.Server                = winOptionSetting.txtServer1.Text.ToString();
                user.Speaker               = winOptionSetting.comSpeaker.SelectedIndex.ToString();
                user.UserID                = winOptionSetting.txtAccount.Text.ToString();
                user.AutoStart             = winOptionSetting.chkStart.IsChecked == true ? "1" : "0";
                user.Available             = (bool)winOptionSetting.chkAvailable.IsChecked;
                user.Unavailable           = (bool)winOptionSetting.chkUnavailable.IsChecked;
                user.Busy                  = (bool)winOptionSetting.chkBusy.IsChecked;
                user.Voicemail             = (bool)winOptionSetting.chkVoicemail.IsChecked;
                user.AvailableCallNumber   = winOptionSetting.txtAvailable.Text;
                user.UnavailableCallNumber = winOptionSetting.txtUnavailable.Text;
                user.BusyCallNumber        = winOptionSetting.txtBusy.Text;
                user.VoicemailCallNumber   = winOptionSetting.txtVoicemail.Text;
                user.SetFWDService         = FrmToolBar.isSetFWDUnCond ? "1" : "0";

                XmlHelper.SetUserConfig(user);

                UserConfigBusiness conf = new UserConfigBusiness();
                conf.SetCurrentMicDev(winOptionSetting.comMicrophone.SelectedIndex);
                conf.SetCurrentVideoDev(winOptionSetting.comCamera.SelectedIndex);
                conf.SetCurrentSpeakerDev(winOptionSetting.comSpeaker.SelectedIndex);

                //modify by jinyeqing 2015/6/1   登陆时某些值为空要设置提示 (要求提示语言国际化)
                if (winOptionSetting.txtPort.Text.ToString() == "" || winOptionSetting.txtPort.Text.ToString() == null)
                {
                    Dialog.Show(StringHelper.FindLanguageResource("Portcannotbenull"), StringHelper.FindLanguageResource("error"));
                    return;
                }
                if (winOptionSetting.txtPassword.Password.ToString() == "" || winOptionSetting.txtPassword.Password.ToString() == null)
                {
                    Dialog.Show(StringHelper.FindLanguageResource("Passwordcannotbenull"), StringHelper.FindLanguageResource("error"));
                    return;
                }
                if (winOptionSetting.txtAccount.Text.ToString() == "" || winOptionSetting.txtAccount.Text.ToString() == null)
                {
                    Dialog.Show(StringHelper.FindLanguageResource("UserIDcannotbenull"), StringHelper.FindLanguageResource("error"));
                    return;
                }
                if (winOptionSetting.txtServer1.Text.ToString() == "" || winOptionSetting.txtServer1.Text.ToString() == null)
                {
                    Dialog.Show(StringHelper.FindLanguageResource("Servercannotbenull"), StringHelper.FindLanguageResource("error"));
                    return;
                }
                if (winOptionSetting.comLang.SelectedIndex.ToString() == "" || winOptionSetting.comLang.SelectedIndex.ToString() == null)
                {
                    Dialog.Show(StringHelper.FindLanguageResource("Languagecannotbenull"), StringHelper.FindLanguageResource("error"));
                    return;
                }
                // end modify

                if (winOptionSetting.chkStart.IsChecked == true)
                {
                    RegistryKey runKey = Registry.LocalMachine.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run");
                    runKey.SetValue("LyncWpfApp.exe", System.Windows.Forms.Application.StartupPath + "\\LyncWpfApp.exe");
                    //如果Lync插件自启动,那么就算Lync设置了自启动也不能让它运行   modify by 00327190   2015/8/6
                    RegistryKey runKey1 = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);
                    if (null != runKey1 && null != runKey1.GetValue("LyncWpfApp.exe"))
                    {
                        RegistryKey runKey2 = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);
                        if (null != runKey2 && null != runKey2.GetValue("Lync"))
                        {
                            runKey2.DeleteValue("Lync");
                        }
                    }
                }
                else
                {
                    RegistryKey runKey = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);
                    runKey.DeleteValue("LyncWpfApp.exe");
                }
            }
            catch
            {
                LogManager.SystemLog.Info("DeleteSubKey");
            }
        }
Esempio n. 10
0
        public static void SetUserConfig(UCUserInfo user)
        {
            try
            {
                EncryptDecrypt.DecryptUserConfigFile();
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load(System.Windows.Forms.Application.StartupPath + "\\UserConfigbak.xml");

                XmlNode node = xmlDoc.SelectSingleNode(@"Content/UCUserInfo/UserID");
                node.InnerText = user.UserID;

                node           = xmlDoc.SelectSingleNode(@"Content/UCUserInfo/Password");
                node.InnerText = user.Password;

                node           = xmlDoc.SelectSingleNode(@"Content/UCUserInfo/OutgoingDevice");
                node.InnerText = user.OutgoingDevice;

                node           = xmlDoc.SelectSingleNode(@"Content/UCUserInfo/CallMethod");
                node.InnerText = user.CallMethod;

                node           = xmlDoc.SelectSingleNode(@"Content/UCUserInfo/TransferCallTo");
                node.InnerText = user.TransferCallTo;

                node           = xmlDoc.SelectSingleNode(@"Content/UCUserInfo/MicPhone");
                node.InnerText = user.MicPhone;

                node           = xmlDoc.SelectSingleNode(@"Content/UCUserInfo/Speaker");
                node.InnerText = user.Speaker;

                node           = xmlDoc.SelectSingleNode(@"Content/UCUserInfo/Camera");
                node.InnerText = user.Camera;

                node           = xmlDoc.SelectSingleNode(@"Content/UCUserInfo/Server");
                node.InnerText = user.Server;

                node           = xmlDoc.SelectSingleNode(@"Content/UCUserInfo/Port");
                node.InnerText = user.Port;

                node           = xmlDoc.SelectSingleNode(@"Content/UCUserInfo/Lang");
                node.InnerText = user.Lang;

                node           = xmlDoc.SelectSingleNode(@"Content/UCUserInfo/Ver");
                node.InnerText = user.Ver;

                node           = xmlDoc.SelectSingleNode(@"Content/UCUserInfo/AutoStart");
                node.InnerText = user.AutoStart;

                node           = xmlDoc.SelectSingleNode(@"Content/UCUserInfo/MessageEnable");
                node.InnerText = user.MessageEnable;

                node           = xmlDoc.SelectSingleNode(@"Content/UCUserInfo/CallEnable");
                node.InnerText = user.CallEnable;

                node           = xmlDoc.SelectSingleNode(@"Content/UCUserInfo/MessageFilePath");
                node.InnerText = user.MessageFilePath;

                node           = xmlDoc.SelectSingleNode(@"Content/UCUserInfo/CallFileFilePath");
                node.InnerText = user.CallFileFilePath;

                node           = xmlDoc.SelectSingleNode(@"Content/UCUserInfo/Available");
                node.InnerText = user.Available?"1":"0";

                node           = xmlDoc.SelectSingleNode(@"Content/UCUserInfo/Unavailable");
                node.InnerText = user.Unavailable ? "1" : "0";

                node           = xmlDoc.SelectSingleNode(@"Content/UCUserInfo/Busy");
                node.InnerText = user.Busy ? "1" : "0";

                node           = xmlDoc.SelectSingleNode(@"Content/UCUserInfo/Voicemail");
                node.InnerText = user.Voicemail ? "1" : "0";

                node           = xmlDoc.SelectSingleNode(@"Content/UCUserInfo/AvailableCallNumber");
                node.InnerText = user.AvailableCallNumber;

                node           = xmlDoc.SelectSingleNode(@"Content/UCUserInfo/UnavailableCallNumber");
                node.InnerText = user.UnavailableCallNumber;

                node           = xmlDoc.SelectSingleNode(@"Content/UCUserInfo/BusyCallNumber");
                node.InnerText = user.BusyCallNumber;

                node           = xmlDoc.SelectSingleNode(@"Content/UCUserInfo/VoicemailCallNumber");
                node.InnerText = user.VoicemailCallNumber;

                xmlDoc.Save(System.Windows.Forms.Application.StartupPath + "\\UserConfigbak.xml");
                File.Delete(System.Windows.Forms.Application.StartupPath + "\\UserConfig.xml");
                EncryptDecrypt.EncryptUserConfigFile();
                File.Delete(System.Windows.Forms.Application.StartupPath + "\\UserConfigbak.xml");
            }
            catch (Exception ex)
            {
                LogManager.SystemLog.Error(ex.ToString());
            }
        }