Beispiel #1
0
        private void BookConf_Portal_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (SingletonObj.LoginInfo == null)
            {
                return;
            }
            UserConfigBusiness conf = new UserConfigBusiness();

            conf.OpenPortal((int)PortalType.BookConf_Portal);
        }
Beispiel #2
0
        private void OpenSelfMgr_Portal_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            UserConfigBusiness conf = new UserConfigBusiness();
            UCServiceRetvCode  iRet = (UCServiceRetvCode)conf.OpenPortal((int)PortalType.SelfMgr_Portal);

            if (iRet == UCServiceRetvCode.UC_SDK_NotLogin)
            {
                Dialog.Show(StringHelper.FindLanguageResource("NoLogin"), StringHelper.FindLanguageResource("error"));
            }
        }
Beispiel #3
0
        //获取本人和对方的话机号码
        //get the phoneNos of your own and caller's
        private void GetPhone()
        {
            //7/28
            UserConfigBusiness conf = new UserConfigBusiness();
            STContact          con  = new STContact();
            int iRet = conf.GetContactInfo(new StringBuilder(SingletonObj.LoginInfo.UserID), ref con);

            if (iRet == 0)
            {
                UcPhoneNo = con.ipphone1_;
            }
            string name1 = StringHelper.GetSubString(callName);
            int    iRet1 = conf.GetContactInfo(new StringBuilder(name1), ref con);

            if (iRet1 == 0)
            {
                UcPhoneNo1 = con.ipphone1_;
            }
            else  //modify by 00327190   2015/9/17  纯话机用户拨打Lync
            {
                UcPhoneNo1 = name1;
            }
        }
Beispiel #4
0
        private int GetCamera()
        {
            try
            {
                UserConfigBusiness conf = new UserConfigBusiness();

                int    iSizeSTDeviceParam = Marshal.SizeOf(typeof(STDeviceParam));
                byte[] pSTDeviceParam     = new byte[iSizeSTDeviceParam];

                UCServiceRetvCode iRet = (UCServiceRetvCode)conf.GetCurrentVideoDev(pSTDeviceParam);
                if (iRet == UCServiceRetvCode.UC_SDK_Success)
                {
                    IntPtr tempInfoIntPtr = Marshal.AllocHGlobal(iSizeSTDeviceParam);

                    Marshal.Copy(pSTDeviceParam, 0, tempInfoIntPtr, (int)iSizeSTDeviceParam);
                    STDeviceParam head = (STDeviceParam)Marshal.PtrToStructure(tempInfoIntPtr, typeof(STDeviceParam));

                    if (head.index < 0)
                    {
                        return(0);
                    }
                    else
                    {
                        return(head.index);
                    }
                }
                else
                {
                    return(0);
                }
            }
            catch (Exception ex)
            {
                LogManager.SystemLog.Error(ex.ToString());
                return(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");
               }
        }
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            if (txtNumber.Text.ToString().Trim() == "" || txtNumber.Text.ToString()== "")
            {
                return;
            }
            else
            {
                boolnum(txtNumber.Text.ToString());
            }
            if (boolnum(txtNumber.Text.ToString()) == true)
            {
                //modify by jinyeqing  00327190  2015/6/10  添加号码时先看是否是UC用户,如果是按照UC帐号添加,不是就按话机号码添加
                MakeCallBusiness call = new MakeCallBusiness();
                StringBuilder ucName = new StringBuilder(100);

                string strLyncURI = StringHelper.GetLyncDomainString(SingletonObj.LoginInfo.LyncName);
                if (call.GetUCAccountByPhoneNo(txtNumber.Text.ToString().Trim(), ucName) != "" && call.GetUCAccountByPhoneNo(txtNumber.Text.ToString().Trim(), ucName) != null)
                {

                    foreach (DataRow d in dtSelectedContact.Rows)
                    {
                        if (d["Phone"].ToString() == txtNumber.Text.ToString())
                        {
                            DialogShow.Show(StringHelper.FindLanguageResource("theNumisExist"), StringHelper.FindLanguageResource("error"), 2);
                            return;
                        }
                        if (d["Url"].ToString() == ucName + strLyncURI)   //2015/8/6  如果URL 一致,则不添加
                        {
                            DialogShow.Show(StringHelper.FindLanguageResource("theNameisExist"), StringHelper.FindLanguageResource("error"), 2);
                            return;
                        }
                    }
                    DataRow dr = dtSelectedContact.NewRow();
                    string str = txtNumber.Text.ToString();
                    int page=0;
                    GetAllLyncContacts(str, page);
                    dtSource = dtContact.Copy();
                    string name = "";
                    //modify by 00327190 2015/8/6  如果号码是UC用户,则连用户名一起查出来,这样为了避免加人重复
                    UserConfigBusiness conf = new UserConfigBusiness();
                    STContact con = new STContact();
                    string name1 = StringHelper.GetSubString(ucName.ToString());
                    int iRet1 = conf.GetContactInfo(new StringBuilder(name1), ref con);
                    if (0 == iRet1)
                    {
                        name = con.name_;
                    }
                    //modify by 00327190 2015/8/6  如果号码是UC用户,则连用户名一起查出来,这样为了避免加人重复

                    for (int i = 0; i < dtSource.Rows.Count; i++)
                    {
                        if (dtSource.Rows[i]["URL"].ToString().Trim() == call.GetUCAccountByPhoneNo(txtNumber.Text.ToString(), ucName) + strLyncURI)
                        {
                            name = dtSource.Rows[i]["NAME"].ToString().Trim();
                        }
                    }
                    dr[0] = name;
                    //2015/8/24    UTF8 转码UNICODE
                    //byte[] buffer1 = Encoding.Default.GetBytes(call.GetUCAccountByPhoneNo(txtNumber.Text.ToString(), ucName));
                    //byte[] buffer2 = Encoding.Convert(Encoding.UTF8, Encoding.Default, buffer1, 0, buffer1.Length);
                    //string item1 = Encoding.Default.GetString(buffer2, 0, buffer2.Length);
                    //dr[1] = item1 + strLyncURI;
                    dr[1] = call.GetUCAccountByPhoneNo(txtNumber.Text.ToString(), ucName) + strLyncURI;
                    dr[2] = txtNumber.Text.ToString();
                    dtSelectedContact.Rows.Add(dr);
                    listSelectedContact.DataContext = null;
                    listSelectedContact.DataContext = dtSelectedContact;
                    listSelectedContact.ScrollIntoView(listSelectedContact.Items[dtSelectedContact.Rows.Count - 1], listSelectedContact.Columns[0]);

                    txtName.Text = "";
                    txtNumber.Text = "";
                }
                //之前没有if ,只有中间的循环体部分
                else
                {
                    foreach (DataRow d in dtSelectedContact.Rows)
                    {
                        if (d["Phone"].ToString() == txtNumber.Text.ToString())
                        {
                            return;
                        }
                    }
                    DataRow dr = dtSelectedContact.NewRow();
                    dr[0] = txtName.Text.ToString();
                    dr[2] = txtNumber.Text.ToString();
                    dtSelectedContact.Rows.Add(dr);
                    listSelectedContact.DataContext = null;
                    listSelectedContact.DataContext = dtSelectedContact;
                    listSelectedContact.ScrollIntoView(listSelectedContact.Items[dtSelectedContact.Rows.Count - 1], listSelectedContact.Columns[0]);

                    txtName.Text = "";
                    txtNumber.Text = "";
                }

                //是否是盲转窗体
                if (isBlindTransCall)
                {
                    btnOK_Click(null, null);
                }
            }
            else
            {
                lync.winCall.OpenDialogTiming(StringHelper.FindLanguageResource("Invalidnum"), StringHelper.FindLanguageResource("error"), 2);
                return;
            }
        }
 private void OpenSelfMgr_Portal_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     UserConfigBusiness conf = new UserConfigBusiness();
     UCServiceRetvCode iRet = (UCServiceRetvCode)conf.OpenPortal((int)PortalType.SelfMgr_Portal);
     if (iRet == UCServiceRetvCode.UC_SDK_NotLogin)
     {
         Dialog.Show(StringHelper.FindLanguageResource("NoLogin"), StringHelper.FindLanguageResource("error"));
     }
 }
 private void BookConf_Portal_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     if (SingletonObj.LoginInfo == null)
     {
         return;
     }
     UserConfigBusiness conf = new UserConfigBusiness();
     conf.OpenPortal((int)PortalType.BookConf_Portal);
 }
Beispiel #9
0
        /// <summary>
        /// 设置呼叫前传
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void BtnFWD_Click(object sender, EventArgs e)
        {
            try
            {
                //通话时不能更改话机联动状态
                //You can't change joint type in a call
                if (Lync.winCall != null)
                {
                    DialogShow.Show(StringHelper.FindLanguageResource("CannotchangeFWDincall"), StringHelper.FindLanguageResource("error"), 2);
                    return;
                }
                else
                {
                    GetFWDInfo();
                    UserConfigBusiness conf = new UserConfigBusiness();
                    STContact          con  = new STContact();
                    int iRet = conf.GetContactInfo(new StringBuilder(SingletonObj.LoginInfo.UserID), ref con);
                    if (iRet != (int)UCServiceRetvCode.UC_SDK_Success)
                    {
                        LogManager.SystemLog.Error("GetContactInfo error");
                        return;
                    }

                    STCallExData data = new STCallExData();

                    if (!isSetFWDUnCond)
                    {
                        if (string.IsNullOrEmpty(con.mobile_))
                        {
                            LogManager.SystemLog.Warn("user mobile is null");
                            Dialog.Show(StringHelper.FindLanguageResource("NoMoblePhone"), StringHelper.FindLanguageResource("error"));
                            return;
                        }
                        data.Num = con.mobile_;
                        LogManager.SystemLog.Info(string.Format("user mobile is {0}", data.Num));
                        iRet = call.SetCallExService((int)ForwardServiceType.FORWARD_UNCONDITION, data);

                        if (iRet != (int)UCServiceRetvCode.UC_SDK_Success)
                        {
                            LogManager.SystemLog.Error("SetCallExService error");
                            return;
                        }

                        //查询设置结果
                        GetFWDInfo();

                        if (isSetFWDUnCond)
                        {
                            Dialog.Show(StringHelper.FindLanguageResource("FWDSuccess"), StringHelper.FindLanguageResource("Success"));
                        }
                        else
                        {
                            Dialog.Show(StringHelper.FindLanguageResource("FWDFailed"), StringHelper.FindLanguageResource("error"));
                        }
                    }
                    else
                    {
                        iRet = call.SetCallExService((int)ForwardServiceType.FORWARD_UNCONDITION, data);

                        if (iRet != (int)UCServiceRetvCode.UC_SDK_Success)
                        {
                            LogManager.SystemLog.Error("SetCallExService error");
                            return;
                        }

                        //查询设置结果
                        GetFWDInfo();

                        if (!isSetFWDUnCond)
                        {
                            Dialog.Show(StringHelper.FindLanguageResource("CancelFWDSuccess"), StringHelper.FindLanguageResource("Success"));
                        }
                        else
                        {
                            Dialog.Show(StringHelper.FindLanguageResource("CancelFWDFailed"), StringHelper.FindLanguageResource("error"));
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                LogManager.SystemLog.Error(ex.ToString());
            }
        }
        /// <summary>
        /// 语音邮箱呼叫前传
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void BtnMail_Click(object sender, EventArgs e)
        {
            //语音邮箱
            //通话时不能更改话机联动状态
            //You can't change joint type in a call
            if (Lync.winCall != null)
            {
                DialogShow.Show(StringHelper.FindLanguageResource("Cannotchangemailincall"), StringHelper.FindLanguageResource("error"), 2);
                return;
            }
            else
            {
                GetMailFrwInfo();  //7/30  先查询语音邮箱配置
                UserConfigBusiness conf = new UserConfigBusiness();
                STContact con = new STContact();
                int iRet = conf.GetContactInfo(new StringBuilder(SingletonObj.LoginInfo.UserID), ref con);
                if (iRet != (int)UCServiceRetvCode.UC_SDK_Success)
                {
                    LogManager.SystemLog.Error("GetContactInfo error");
                    return;
                }
                //7/30
                STCallExData data = new STCallExData();
                //int iRet = 0;
                if (!isSetVoiceMailUnCond)
                {
                    //if (string.IsNullOrEmpty(con.email_))
                    //{
                    //    LogManager.SystemLog.Warn("email_ is null");
                    //    Dialog.Show(StringHelper.FindLanguageResource("NoVoicemail"), StringHelper.FindLanguageResource("error"));
                    //    return;
                    //}
                    //data.Num = con.email_;   //2015/8/13
                    data.Num = "1";
                    LogManager.SystemLog.Info(string.Format("email_ is {0}", data.Num));

                    iRet = call.SetCallExService((int)ForwardServiceType.VOICEMAIL_UNCONDITION, data);

                    if (iRet != (int)UCServiceRetvCode.UC_SDK_Success)
                    {
                        LogManager.SystemLog.Error("SetCallExService error");
                        isSetVoiceMailUnCond = false;
                        Dialog.Show(StringHelper.FindLanguageResource("FWDMailFail"), StringHelper.FindLanguageResource("error"));
                        return;
                    }
                    else
                    {
                        GetMailFrwInfo();
                        if (isSetVoiceMailUnCond == true)
                        {
                            Dialog.Show(StringHelper.FindLanguageResource("FWDMailSuccess"), StringHelper.FindLanguageResource("Success"));
                        }
                        else
                        {
                            Dialog.Show(StringHelper.FindLanguageResource("FWDMailFail"), StringHelper.FindLanguageResource("error"));
                        }

                    }
                }
                else
                {
                    iRet = call.SetCallExService((int)ForwardServiceType.VOICEMAIL_UNCONDITION, data);

                    if (iRet != (int)UCServiceRetvCode.UC_SDK_Success)
                    {
                        LogManager.SystemLog.Error("SetCallExService error");
                        isSetVoiceMailUnCond = true;
                        Dialog.Show(StringHelper.FindLanguageResource("CancelFWDMailFail"), StringHelper.FindLanguageResource("error"));
                        return;
                    }
                    else
                    {
                        GetMailFrwInfo();
                        if (!isSetVoiceMailUnCond)
                        {
                            Dialog.Show(StringHelper.FindLanguageResource("CancelFWDMailSuccess"), StringHelper.FindLanguageResource("Success"));
                        }
                        else
                        {
                            Dialog.Show(StringHelper.FindLanguageResource("CancelFWDMailFail"), StringHelper.FindLanguageResource("error"));
                        }

                    }

                }
            }
        }
 //获取本人和对方的话机号码
 //get the phoneNos of your own and caller's
 private void GetPhone()
 {
     //7/28
     UserConfigBusiness conf = new UserConfigBusiness();
     STContact con = new STContact();
     int iRet = conf.GetContactInfo(new StringBuilder(SingletonObj.LoginInfo.UserID), ref con);
     if (iRet == 0)
     {
         UcPhoneNo = con.ipphone1_;
     }
     string name1 = StringHelper.GetSubString(callName);
     int iRet1 = conf.GetContactInfo(new StringBuilder(name1), ref con);
     if (iRet1 == 0)
     {
         UcPhoneNo1 = con.ipphone1_;
     }
     else  //modify by 00327190   2015/9/17  纯话机用户拨打Lync
     {
         UcPhoneNo1 = name1;
     }
 }
Beispiel #12
0
        /// <summary>
        /// 加载系统设备
        /// </summary>
        void LoadSystDve()
        {
            UserConfigBusiness conf = new UserConfigBusiness();

            int iSizeSTDeviceListParam = Marshal.SizeOf(typeof(STDeviceListParam));
            int iSizeSTDeviceParam     = Marshal.SizeOf(typeof(STDeviceParam));
            int iBufSize = (iSizeSTDeviceListParam + iSizeSTDeviceParam * (count - 1));

            byte[] pSTDeviceList = new byte[iBufSize];

            UCServiceRetvCode iRet = (UCServiceRetvCode)conf.GetMicDevList(0, 9, iBufSize, pSTDeviceList);

            Dictionary <int, string> dicMicrophone = new Dictionary <int, string>();

            if (iRet == UCServiceRetvCode.UC_SDK_Success)
            {
                IntPtr tempInfoIntPtr = Marshal.AllocHGlobal((int)iSizeSTDeviceListParam);
                byte[] tempInfoByte   = new byte[iSizeSTDeviceListParam];

                Marshal.Copy(pSTDeviceList, 0, tempInfoIntPtr, (int)iSizeSTDeviceListParam);
                STDeviceListParam head = (STDeviceListParam)Marshal.PtrToStructure(tempInfoIntPtr, typeof(STDeviceListParam));

                for (int i = -1; i < head.iTotal - 1 && i < count - 1; i++)
                {
                    Marshal.Copy(pSTDeviceList, iSizeSTDeviceListParam + iSizeSTDeviceParam * i, tempInfoIntPtr, (int)iSizeSTDeviceParam);
                    STDeviceParam item = (STDeviceParam)Marshal.PtrToStructure(tempInfoIntPtr, typeof(STDeviceParam));
                    dicMicrophone.Add(item.index, item.name);
                }
                Marshal.Release(tempInfoIntPtr);
            }
            winOptionSetting.comMicrophone.ItemsSource       = dicMicrophone;
            winOptionSetting.comMicrophone.SelectedValuePath = "Key";
            winOptionSetting.comMicrophone.DisplayMemberPath = "Value";
            winOptionSetting.comMicrophone.SelectedIndex     = 0;

            pSTDeviceList = new byte[iBufSize];
            iRet          = (UCServiceRetvCode)conf.GetSpeakerDevList(0, 9, iBufSize, pSTDeviceList);
            Dictionary <int, string> dicSpeakerDev = new Dictionary <int, string>();

            if (iRet == UCServiceRetvCode.UC_SDK_Success)
            {
                IntPtr tempInfoIntPtr = Marshal.AllocHGlobal((int)iSizeSTDeviceListParam);
                byte[] tempInfoByte   = new byte[iSizeSTDeviceListParam];

                Marshal.Copy(pSTDeviceList, 0, tempInfoIntPtr, (int)iSizeSTDeviceListParam);
                STDeviceListParam head = (STDeviceListParam)Marshal.PtrToStructure(tempInfoIntPtr, typeof(STDeviceListParam));

                for (int i = -1; i < head.iTotal - 1 && i < count - 1; i++)
                {
                    Marshal.Copy(pSTDeviceList, iSizeSTDeviceListParam + iSizeSTDeviceParam * i, tempInfoIntPtr, (int)iSizeSTDeviceParam);
                    STDeviceParam item = (STDeviceParam)Marshal.PtrToStructure(tempInfoIntPtr, typeof(STDeviceParam));
                    dicSpeakerDev.Add(item.index, item.name);
                }
                Marshal.Release(tempInfoIntPtr);
            }
            winOptionSetting.comSpeaker.ItemsSource       = dicSpeakerDev;
            winOptionSetting.comSpeaker.SelectedValuePath = "Key";
            winOptionSetting.comSpeaker.DisplayMemberPath = "Value";
            winOptionSetting.comSpeaker.SelectedIndex     = 0;

            pSTDeviceList = new byte[iBufSize];
            iRet          = (UCServiceRetvCode)conf.GetVideoDevList(0, 9, iBufSize, pSTDeviceList);
            Dictionary <int, string> dicVideoDev = new Dictionary <int, string>();

            if (iRet == UCServiceRetvCode.UC_SDK_Success)
            {
                IntPtr tempInfoIntPtr = Marshal.AllocHGlobal((int)iSizeSTDeviceListParam);
                byte[] tempInfoByte   = new byte[iSizeSTDeviceListParam];

                Marshal.Copy(pSTDeviceList, 0, tempInfoIntPtr, (int)iSizeSTDeviceListParam);
                STDeviceListParam head = (STDeviceListParam)Marshal.PtrToStructure(tempInfoIntPtr, typeof(STDeviceListParam));

                for (int i = -1; i < head.iTotal - 1 && i < count - 1; i++)
                {
                    Marshal.Copy(pSTDeviceList, iSizeSTDeviceListParam + iSizeSTDeviceParam * i, tempInfoIntPtr, (int)iSizeSTDeviceParam);
                    STDeviceParam item = (STDeviceParam)Marshal.PtrToStructure(tempInfoIntPtr, typeof(STDeviceParam));
                    dicVideoDev.Add(item.index, item.name);
                }
                Marshal.Release(tempInfoIntPtr);
            }
            winOptionSetting.comCamera.ItemsSource       = dicVideoDev;
            winOptionSetting.comCamera.SelectedValuePath = "Key";
            winOptionSetting.comCamera.DisplayMemberPath = "Value";
            winOptionSetting.comCamera.SelectedIndex     = 0;
        }
Beispiel #13
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");
            }
        }
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            if (txtNumber.Text.ToString().Trim() == "" || txtNumber.Text.ToString() == "")
            {
                return;
            }
            else
            {
                boolnum(txtNumber.Text.ToString());
            }
            if (boolnum(txtNumber.Text.ToString()) == true)
            {
                //modify by jinyeqing  00327190  2015/6/10  添加号码时先看是否是UC用户,如果是按照UC帐号添加,不是就按话机号码添加
                MakeCallBusiness call   = new MakeCallBusiness();
                StringBuilder    ucName = new StringBuilder(100);

                string strLyncURI = StringHelper.GetLyncDomainString(SingletonObj.LoginInfo.LyncName);
                if (call.GetUCAccountByPhoneNo(txtNumber.Text.ToString().Trim(), ucName) != "" && call.GetUCAccountByPhoneNo(txtNumber.Text.ToString().Trim(), ucName) != null)
                {
                    foreach (DataRow d in dtSelectedContact.Rows)
                    {
                        if (d["Phone"].ToString() == txtNumber.Text.ToString())
                        {
                            DialogShow.Show(StringHelper.FindLanguageResource("theNumisExist"), StringHelper.FindLanguageResource("error"), 2);
                            return;
                        }
                        if (d["Url"].ToString() == ucName + strLyncURI)   //2015/8/6  如果URL 一致,则不添加
                        {
                            DialogShow.Show(StringHelper.FindLanguageResource("theNameisExist"), StringHelper.FindLanguageResource("error"), 2);
                            return;
                        }
                    }
                    DataRow dr   = dtSelectedContact.NewRow();
                    string  str  = txtNumber.Text.ToString();
                    int     page = 0;
                    GetAllLyncContacts(str, page);
                    dtSource = dtContact.Copy();
                    string name = "";
                    //modify by 00327190 2015/8/6  如果号码是UC用户,则连用户名一起查出来,这样为了避免加人重复
                    UserConfigBusiness conf  = new UserConfigBusiness();
                    STContact          con   = new STContact();
                    string             name1 = StringHelper.GetSubString(ucName.ToString());
                    int iRet1 = conf.GetContactInfo(new StringBuilder(name1), ref con);
                    if (0 == iRet1)
                    {
                        name = con.name_;
                    }
                    //modify by 00327190 2015/8/6  如果号码是UC用户,则连用户名一起查出来,这样为了避免加人重复

                    for (int i = 0; i < dtSource.Rows.Count; i++)
                    {
                        if (dtSource.Rows[i]["URL"].ToString().Trim() == call.GetUCAccountByPhoneNo(txtNumber.Text.ToString(), ucName) + strLyncURI)
                        {
                            name = dtSource.Rows[i]["NAME"].ToString().Trim();
                        }
                    }
                    dr[0] = name;
                    //2015/8/24    UTF8 转码UNICODE
                    //byte[] buffer1 = Encoding.Default.GetBytes(call.GetUCAccountByPhoneNo(txtNumber.Text.ToString(), ucName));
                    //byte[] buffer2 = Encoding.Convert(Encoding.UTF8, Encoding.Default, buffer1, 0, buffer1.Length);
                    //string item1 = Encoding.Default.GetString(buffer2, 0, buffer2.Length);
                    //dr[1] = item1 + strLyncURI;
                    dr[1] = call.GetUCAccountByPhoneNo(txtNumber.Text.ToString(), ucName) + strLyncURI;
                    dr[2] = txtNumber.Text.ToString();
                    dtSelectedContact.Rows.Add(dr);
                    listSelectedContact.DataContext = null;
                    listSelectedContact.DataContext = dtSelectedContact;
                    listSelectedContact.ScrollIntoView(listSelectedContact.Items[dtSelectedContact.Rows.Count - 1], listSelectedContact.Columns[0]);

                    txtName.Text   = "";
                    txtNumber.Text = "";
                }
                //之前没有if ,只有中间的循环体部分
                else
                {
                    foreach (DataRow d in dtSelectedContact.Rows)
                    {
                        if (d["Phone"].ToString() == txtNumber.Text.ToString())
                        {
                            return;
                        }
                    }
                    DataRow dr = dtSelectedContact.NewRow();
                    dr[0] = txtName.Text.ToString();
                    dr[2] = txtNumber.Text.ToString();
                    dtSelectedContact.Rows.Add(dr);
                    listSelectedContact.DataContext = null;
                    listSelectedContact.DataContext = dtSelectedContact;
                    listSelectedContact.ScrollIntoView(listSelectedContact.Items[dtSelectedContact.Rows.Count - 1], listSelectedContact.Columns[0]);

                    txtName.Text   = "";
                    txtNumber.Text = "";
                }

                //是否是盲转窗体
                if (isBlindTransCall)
                {
                    btnOK_Click(null, null);
                }
            }
            else
            {
                lync.winCall.OpenDialogTiming(StringHelper.FindLanguageResource("Invalidnum"), StringHelper.FindLanguageResource("error"), 2);
                return;
            }
        }
        private int GetSpeaker()
        {
            try
               {
               UserConfigBusiness conf = new UserConfigBusiness();

               int iSizeSTDeviceParam = Marshal.SizeOf(typeof(STDeviceParam));
               byte[] pSTDeviceParam = new byte[iSizeSTDeviceParam];

               UCServiceRetvCode iRet = (UCServiceRetvCode)conf.GetCurrentSpeakerDev(pSTDeviceParam);
               if (iRet == UCServiceRetvCode.UC_SDK_Success)
               {
                   IntPtr tempInfoIntPtr = Marshal.AllocHGlobal(iSizeSTDeviceParam);

                   Marshal.Copy(pSTDeviceParam, 0, tempInfoIntPtr, (int)iSizeSTDeviceParam);
                   STDeviceParam head = (STDeviceParam)Marshal.PtrToStructure(tempInfoIntPtr, typeof(STDeviceParam));

                   if (head.index < 0)
                   {
                       return 0;
                   }
                   else
                   {
                       return head.index;
                   }
               }
               else
               {
                   return 0;
               }
               }
               catch (Exception ex)
               {
               LogManager.SystemLog.Error(ex.ToString());
               return 0;
               }
        }
Beispiel #16
0
        /// <summary>
        /// 语音邮箱呼叫前传
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void BtnMail_Click(object sender, EventArgs e)
        {
            //语音邮箱
            //通话时不能更改话机联动状态
            //You can't change joint type in a call
            if (Lync.winCall != null)
            {
                DialogShow.Show(StringHelper.FindLanguageResource("Cannotchangemailincall"), StringHelper.FindLanguageResource("error"), 2);
                return;
            }
            else
            {
                GetMailFrwInfo();  //7/30  先查询语音邮箱配置
                UserConfigBusiness conf = new UserConfigBusiness();
                STContact          con  = new STContact();
                int iRet = conf.GetContactInfo(new StringBuilder(SingletonObj.LoginInfo.UserID), ref con);
                if (iRet != (int)UCServiceRetvCode.UC_SDK_Success)
                {
                    LogManager.SystemLog.Error("GetContactInfo error");
                    return;
                }
                //7/30
                STCallExData data = new STCallExData();
                //int iRet = 0;
                if (!isSetVoiceMailUnCond)
                {
                    //if (string.IsNullOrEmpty(con.email_))
                    //{
                    //    LogManager.SystemLog.Warn("email_ is null");
                    //    Dialog.Show(StringHelper.FindLanguageResource("NoVoicemail"), StringHelper.FindLanguageResource("error"));
                    //    return;
                    //}
                    //data.Num = con.email_;   //2015/8/13
                    data.Num = "1";
                    LogManager.SystemLog.Info(string.Format("email_ is {0}", data.Num));

                    iRet = call.SetCallExService((int)ForwardServiceType.VOICEMAIL_UNCONDITION, data);

                    if (iRet != (int)UCServiceRetvCode.UC_SDK_Success)
                    {
                        LogManager.SystemLog.Error("SetCallExService error");
                        isSetVoiceMailUnCond = false;
                        Dialog.Show(StringHelper.FindLanguageResource("FWDMailFail"), StringHelper.FindLanguageResource("error"));
                        return;
                    }
                    else
                    {
                        GetMailFrwInfo();
                        if (isSetVoiceMailUnCond == true)
                        {
                            Dialog.Show(StringHelper.FindLanguageResource("FWDMailSuccess"), StringHelper.FindLanguageResource("Success"));
                        }
                        else
                        {
                            Dialog.Show(StringHelper.FindLanguageResource("FWDMailFail"), StringHelper.FindLanguageResource("error"));
                        }
                    }
                }
                else
                {
                    iRet = call.SetCallExService((int)ForwardServiceType.VOICEMAIL_UNCONDITION, data);

                    if (iRet != (int)UCServiceRetvCode.UC_SDK_Success)
                    {
                        LogManager.SystemLog.Error("SetCallExService error");
                        isSetVoiceMailUnCond = true;
                        Dialog.Show(StringHelper.FindLanguageResource("CancelFWDMailFail"), StringHelper.FindLanguageResource("error"));
                        return;
                    }
                    else
                    {
                        GetMailFrwInfo();
                        if (!isSetVoiceMailUnCond)
                        {
                            Dialog.Show(StringHelper.FindLanguageResource("CancelFWDMailSuccess"), StringHelper.FindLanguageResource("Success"));
                        }
                        else
                        {
                            Dialog.Show(StringHelper.FindLanguageResource("CancelFWDMailFail"), StringHelper.FindLanguageResource("error"));
                        }
                    }
                }
            }
        }
        /// <summary>
        /// 加载系统设备
        /// </summary>
        void LoadSystDve()
        {
            UserConfigBusiness conf = new UserConfigBusiness();

               int iSizeSTDeviceListParam = Marshal.SizeOf(typeof(STDeviceListParam));
               int iSizeSTDeviceParam = Marshal.SizeOf(typeof(STDeviceParam));
               int iBufSize = (iSizeSTDeviceListParam + iSizeSTDeviceParam * (count - 1));
               byte[] pSTDeviceList = new byte[iBufSize];

               UCServiceRetvCode iRet = (UCServiceRetvCode)conf.GetMicDevList(0, 9, iBufSize, pSTDeviceList);

               Dictionary<int, string> dicMicrophone = new Dictionary<int, string>();
               if (iRet == UCServiceRetvCode.UC_SDK_Success)
               {
               IntPtr tempInfoIntPtr = Marshal.AllocHGlobal((int)iSizeSTDeviceListParam);
               byte[] tempInfoByte = new byte[iSizeSTDeviceListParam];

               Marshal.Copy(pSTDeviceList, 0, tempInfoIntPtr, (int)iSizeSTDeviceListParam);
               STDeviceListParam head = (STDeviceListParam)Marshal.PtrToStructure(tempInfoIntPtr, typeof(STDeviceListParam));

               for (int i = -1; i < head.iTotal - 1 && i < count - 1; i++)
               {
                   Marshal.Copy(pSTDeviceList, iSizeSTDeviceListParam + iSizeSTDeviceParam * i, tempInfoIntPtr, (int)iSizeSTDeviceParam);
                   STDeviceParam item = (STDeviceParam)Marshal.PtrToStructure(tempInfoIntPtr, typeof(STDeviceParam));
                   dicMicrophone.Add(item.index, item.name);
               }
               Marshal.Release(tempInfoIntPtr);
               }
               winOptionSetting.comMicrophone.ItemsSource = dicMicrophone;
               winOptionSetting.comMicrophone.SelectedValuePath = "Key";
               winOptionSetting.comMicrophone.DisplayMemberPath = "Value";
               winOptionSetting.comMicrophone.SelectedIndex = 0;

               pSTDeviceList = new byte[iBufSize];
               iRet = (UCServiceRetvCode)conf.GetSpeakerDevList(0, 9, iBufSize, pSTDeviceList);
               Dictionary<int, string> dicSpeakerDev = new Dictionary<int, string>();
               if (iRet == UCServiceRetvCode.UC_SDK_Success)
               {
               IntPtr tempInfoIntPtr = Marshal.AllocHGlobal((int)iSizeSTDeviceListParam);
               byte[] tempInfoByte = new byte[iSizeSTDeviceListParam];

               Marshal.Copy(pSTDeviceList, 0, tempInfoIntPtr, (int)iSizeSTDeviceListParam);
               STDeviceListParam head = (STDeviceListParam)Marshal.PtrToStructure(tempInfoIntPtr, typeof(STDeviceListParam));

               for (int i = -1; i < head.iTotal - 1 && i < count - 1; i++)
               {
                   Marshal.Copy(pSTDeviceList, iSizeSTDeviceListParam + iSizeSTDeviceParam * i, tempInfoIntPtr, (int)iSizeSTDeviceParam);
                   STDeviceParam item = (STDeviceParam)Marshal.PtrToStructure(tempInfoIntPtr, typeof(STDeviceParam));
                   dicSpeakerDev.Add(item.index, item.name);
               }
               Marshal.Release(tempInfoIntPtr);
               }
               winOptionSetting.comSpeaker.ItemsSource = dicSpeakerDev;
               winOptionSetting.comSpeaker.SelectedValuePath = "Key";
               winOptionSetting.comSpeaker.DisplayMemberPath = "Value";
               winOptionSetting.comSpeaker.SelectedIndex = 0;

               pSTDeviceList = new byte[iBufSize];
               iRet = (UCServiceRetvCode)conf.GetVideoDevList(0, 9, iBufSize, pSTDeviceList);
               Dictionary<int, string> dicVideoDev = new Dictionary<int, string>();
               if (iRet == UCServiceRetvCode.UC_SDK_Success)
               {
               IntPtr tempInfoIntPtr = Marshal.AllocHGlobal((int)iSizeSTDeviceListParam);
               byte[] tempInfoByte = new byte[iSizeSTDeviceListParam];

               Marshal.Copy(pSTDeviceList, 0, tempInfoIntPtr, (int)iSizeSTDeviceListParam);
               STDeviceListParam head = (STDeviceListParam)Marshal.PtrToStructure(tempInfoIntPtr, typeof(STDeviceListParam));

               for (int i = -1; i < head.iTotal - 1 && i < count - 1; i++)
               {
                   Marshal.Copy(pSTDeviceList, iSizeSTDeviceListParam + iSizeSTDeviceParam * i, tempInfoIntPtr, (int)iSizeSTDeviceParam);
                   STDeviceParam item = (STDeviceParam)Marshal.PtrToStructure(tempInfoIntPtr, typeof(STDeviceParam));
                   dicVideoDev.Add(item.index, item.name);
               }
               Marshal.Release(tempInfoIntPtr);
               }
               winOptionSetting.comCamera.ItemsSource = dicVideoDev;
               winOptionSetting.comCamera.SelectedValuePath = "Key";
               winOptionSetting.comCamera.DisplayMemberPath = "Value";
               winOptionSetting.comCamera.SelectedIndex = 0;
        }
        /// <summary>
        /// 设置呼叫前传
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void BtnFWD_Click(object sender, EventArgs e)
        {
            try
            {
                //通话时不能更改话机联动状态
                //You can't change joint type in a call
                if (Lync.winCall != null)
                {
                    DialogShow.Show(StringHelper.FindLanguageResource("CannotchangeFWDincall"), StringHelper.FindLanguageResource("error"), 2);
                    return;
                }
                else
                {
                    GetFWDInfo();
                    UserConfigBusiness conf = new UserConfigBusiness();
                    STContact con = new STContact();
                    int iRet = conf.GetContactInfo(new StringBuilder(SingletonObj.LoginInfo.UserID), ref con);
                    if (iRet != (int)UCServiceRetvCode.UC_SDK_Success)
                    {
                        LogManager.SystemLog.Error("GetContactInfo error");
                        return;
                    }

                    STCallExData data = new STCallExData();

                    if (!isSetFWDUnCond)
                    {
                        if (string.IsNullOrEmpty(con.mobile_))
                        {
                            LogManager.SystemLog.Warn("user mobile is null");
                            Dialog.Show(StringHelper.FindLanguageResource("NoMoblePhone"), StringHelper.FindLanguageResource("error"));
                            return;
                        }
                        data.Num = con.mobile_;
                        LogManager.SystemLog.Info(string.Format("user mobile is {0}", data.Num));
                        iRet = call.SetCallExService((int)ForwardServiceType.FORWARD_UNCONDITION, data);

                        if (iRet != (int)UCServiceRetvCode.UC_SDK_Success)
                        {
                            LogManager.SystemLog.Error("SetCallExService error");
                            return;
                        }

                        //查询设置结果
                        GetFWDInfo();

                        if (isSetFWDUnCond)
                        {
                            Dialog.Show(StringHelper.FindLanguageResource("FWDSuccess"), StringHelper.FindLanguageResource("Success"));
                        }
                        else
                        {
                            Dialog.Show(StringHelper.FindLanguageResource("FWDFailed"), StringHelper.FindLanguageResource("error"));
                        }
                    }
                    else
                    {
                        iRet = call.SetCallExService((int)ForwardServiceType.FORWARD_UNCONDITION, data);

                        if (iRet != (int)UCServiceRetvCode.UC_SDK_Success)
                        {
                            LogManager.SystemLog.Error("SetCallExService error");
                            return;
                        }

                        //查询设置结果
                        GetFWDInfo();

                        if (!isSetFWDUnCond)
                        {
                            Dialog.Show(StringHelper.FindLanguageResource("CancelFWDSuccess"), StringHelper.FindLanguageResource("Success"));
                        }
                        else
                        {
                            Dialog.Show(StringHelper.FindLanguageResource("CancelFWDFailed"), StringHelper.FindLanguageResource("error"));
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                LogManager.SystemLog.Error(ex.ToString());
            }
        }