Пример #1
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"));
            }
        }
        public void QueryHisConvPartByID(string _convID, string initiator)
        {
            List <ParticipantItem> list = new List <ParticipantItem>();
            int iSizeSTConfPartData     = Marshal.SizeOf(typeof(STConfPartData));
            int iSizeSTConfPartItem     = Marshal.SizeOf(typeof(STConfPartItem));
            int uiBufSize = (iSizeSTConfPartData + iSizeSTConfPartItem * (count - 1));

            byte[] pCallHistory = new byte[uiBufSize];

            UCServiceRetvCode iRet = (UCServiceRetvCode)query.QueryHisConvPartByID(_convID, 0, count - 1, pCallHistory, uiBufSize);

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

                Marshal.Copy(pCallHistory, 0, tempInfoIntPtr, (int)iSizeSTConfPartData);
                STConfPartData  head = (STConfPartData)Marshal.PtrToStructure(tempInfoIntPtr, typeof(STConfPartData));
                ParticipantItem it;
                if (head.partNum > count)
                {
                    uiBufSize    = (iSizeSTConfPartData + iSizeSTConfPartItem * (head.partNum - 1));
                    pCallHistory = new byte[uiBufSize];
                    query.QueryHisConvPartByID(_convID, 0, head.partNum - 1, pCallHistory, uiBufSize);
                }
                it           = new ParticipantItem();
                it.Initiator = initiator;
                it.IsMain    = true;
                list.Add(it);
                for (int i = -1; i < head.partNum - 1; i++)
                {
                    Marshal.Copy(pCallHistory, iSizeSTConfPartData + iSizeSTConfPartItem * i, tempInfoIntPtr, (int)iSizeSTConfPartItem);
                    STConfPartItem item = (STConfPartItem)Marshal.PtrToStructure(tempInfoIntPtr, typeof(STConfPartItem));
                    //2015/8/24    UTF8 转码UNICODE
                    //byte[] buffer1 = Encoding.Default.GetBytes(item.partName);
                    //byte[] buffer2 = Encoding.Convert(Encoding.UTF8, Encoding.Default, buffer1, 0, buffer1.Length);
                    //string item1 = Encoding.Default.GetString(buffer2, 0, buffer2.Length);
                    //2015/8/24    UTF8 转码UNICODE
                    it = new ParticipantItem();
                    //it.Initiator = item1;
                    it.Initiator = item.partName;
                    it.IsMain    = false;
                    list.Add(it);
                }
                Marshal.Release(tempInfoIntPtr);
            }
            winHisitory.listParticipants.ItemsSource = null;
            winHisitory.listParticipants.ItemsSource = list;
        }
Пример #3
0
 void BtnIP_Click(object sender, EventArgs e)
 {
     //通话时不能更改话机联动状态
     //You can't change joint type in a call
     if (Lync.winCall != null)
     {
         DialogShow.Show(StringHelper.FindLanguageResource("Cannotdothisincall"), StringHelper.FindLanguageResource("error"), 2);
         return;
     }
     else if (Lync.isHave == true)   //通话未接通时也不许更改话机联动状态
     {
         DialogShow.Show(StringHelper.FindLanguageResource("Cannotdothisincall"), StringHelper.FindLanguageResource("error"), 2);
         return;
     }
     else
     {
         UCServiceRetvCode iRet = (UCServiceRetvCode)log.SetPhoneJointDevType((int)PhoneJointType.IPPhone_Device);
         if (iRet != UCServiceRetvCode.UC_SDK_Success)
         {
             Dialog.Show(StringHelper.FindLanguageResource("ConfigPhoneJointDevFail"), StringHelper.FindLanguageResource("error"));
         }
     }
 }
Пример #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);
            }
        }
Пример #5
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;
        }
        /// <summary>
        /// 获取前两百条数据
        /// </summary>
        /// <param name="strSearchKey">查询关键字</param>
        void GetAllLyncContacts(string strSearchKey = "", int page = 0)
        {
            dtContact = new DataTable();
            dtContact.Columns.Add("Name");
            dtContact.Columns.Add("Url");
            dtContact.Columns.Add("Phone");

            if (dtSelectedContact.Columns.Count == 0)
            {
                dtSelectedContact.Columns.Add("Name");
                dtSelectedContact.Columns.Add("Url");
                dtSelectedContact.Columns.Add("Phone");
            }

            MakeCallBusiness call = new MakeCallBusiness();

            int maxCount           = 200; //最多查询的数量
            int count              = 100; //每次查询的数量
            int iSizeSTContactList = Marshal.SizeOf(typeof(STContactList));
            int iSizeSTContact     = Marshal.SizeOf(typeof(STContact));
            int uiBufSize          = (iSizeSTContactList + iSizeSTContact * (count - 1));

            byte[] pSTContactList = new byte[uiBufSize];

            UCServiceRetvCode iRet = (UCServiceRetvCode)call.GetEntContactList(strSearchKey, page * count, page * count + count - 1, pSTContactList);

            if (UCServiceRetvCode.UC_SDK_Success == iRet)
            {
                string strLyncURI     = StringHelper.GetLyncDomainString(SingletonObj.LoginInfo.LyncName);
                IntPtr tempInfoIntPtr = Marshal.AllocHGlobal((int)iSizeSTContactList);
                byte[] tempInfoByte   = new byte[iSizeSTContactList];
                try
                {
                    Marshal.Copy(pSTContactList, 0, tempInfoIntPtr, (int)iSizeSTContactList);
                    STContactList head = (STContactList)Marshal.PtrToStructure(tempInfoIntPtr, typeof(STContactList));
                    this.labTotal.Content = "/" + ((head.iTotal % count) == 0 ? (head.iTotal / count == 0 ? 1 : head.iTotal / count).ToString() : (head.iTotal / count + 1).ToString());
                    this.txtPage.Text     = (page + 1).ToString();

                    //for (int index = -1; index < head.iTotal - 1 && index < count - 1; index++)
                    //{
                    //    Marshal.Copy(pSTContactList, iSizeSTContactList + iSizeSTContact * index, tempInfoIntPtr, (int)iSizeSTContact);
                    //    STContact item = (STContact)Marshal.PtrToStructure(tempInfoIntPtr, typeof(STContact));
                    //    dtContact.Rows.Add(item.name_, string.IsNullOrEmpty(item.uri_) ? "" : item.uri_ + strLyncURI, item.mobile_);
                    //}
                    //if (head.iTotal > count)//继续查询
                    //{
                    //最多查询maxCount条数据
                    if (head.iTotal < maxCount)
                    {
                        maxCount = head.iTotal;
                    }
                    int num = maxCount % count != 0 ? (maxCount / count + 1) : maxCount / count;//需要查询的次数
                    for (int iNum = 1; iNum < num; iNum++)
                    {
                        iRet = (UCServiceRetvCode)call.GetEntContactList(strSearchKey, iNum * count, iNum * count + count - 1, pSTContactList);
                        if (UCServiceRetvCode.UC_SDK_Success == iRet)
                        {
                            Marshal.Copy(pSTContactList, 0, tempInfoIntPtr, (int)iSizeSTContactList);
                            head = (STContactList)Marshal.PtrToStructure(tempInfoIntPtr, typeof(STContactList));

                            for (int index = -1; index < (maxCount - iNum * count - 1) && index < count - 1; index++)
                            {
                                Marshal.Copy(pSTContactList, iSizeSTContactList + iSizeSTContact * index, tempInfoIntPtr, (int)iSizeSTContact);
                                STContact item = (STContact)Marshal.PtrToStructure(tempInfoIntPtr, typeof(STContact));
                                if (item.name_ != null && item.name_ != "")
                                {
                                    dtContact.Rows.Add(item.name_, string.IsNullOrEmpty(item.uri_) ? "" : item.uri_ + strLyncURI, item.mobile_);
                                }
                            }
                        }
                        else
                        {
                            LogManager.SystemLog.Error("GetAllLyncContacts failed");
                            break;
                        }
                    }
                    //}
                }
                finally
                {
                    Marshal.Release(tempInfoIntPtr);
                }
            }
            else
            {
                LogManager.SystemLog.Error("GetAllLyncContacts failed");
            }

            #region 根据lync接口查询lync用户的联系人列表
            //foreach (Microsoft.Lync.Model.Group.Group group in WinLync.LyncContactGroups)
            //{
            //    foreach (Contact contact in (ContactCollection)(group))
            //    {
            //        int index = -1;
            //        foreach (DataRow dr in dtContact.Rows)
            //        {
            //            if (dr["Url"].ToString() == contact.Uri)
            //            {
            //                index = 0;
            //            }
            //        }
            //        if (index == -1)
            //        {
            //            string phone = "";
            //            List<object> list = contact.GetContactInformation(ContactInformationType.ContactEndpoints) as List<object>;
            //            foreach (object point in list)
            //            {
            //                if (((Microsoft.Lync.Model.ContactEndpoint)point).Type == ContactEndpointType.WorkPhone)
            //                {
            //                    phone = ((Microsoft.Lync.Model.ContactEndpoint)point).DisplayName;
            //                }
            //            }
            //           string name = contact.GetContactInformation(ContactInformationType.DisplayName).ToString();
            //           dtContact.Rows.Add(name, contact.Uri, phone);

            //        }
            //    }
            //}
            #endregion
        }
        public void QueryHistoryByPage(int index, int page)
        {
            int iSizeSTCallHistroyData = Marshal.SizeOf(typeof(STCallHistroyData));
            int iSizeSTCallHistroyItem = Marshal.SizeOf(typeof(STCallHistroyItem));
            int uiBufSize = (iSizeSTCallHistroyData + iSizeSTCallHistroyItem * (count - 1));

            byte[] pCallHistory = new byte[uiBufSize];

            DataTable dt = new DataTable();

            dt.Columns.Add("Phone");
            dt.Columns.Add("Name");
            dt.Columns.Add("Time");
            dt.Columns.Add("Duration");
            dt.Columns.Add("TelType");


            List <CallItem>   list = new List <CallItem>();
            UCServiceRetvCode iRet = (UCServiceRetvCode)query.QueryCallHistory((CallHistoryType)index, page * count, page * count + count - 1, pCallHistory, uiBufSize);

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

                Marshal.Copy(pCallHistory, 0, tempInfoIntPtr, (int)iSizeSTCallHistroyData);
                STCallHistroyData head = (STCallHistroyData)Marshal.PtrToStructure(tempInfoIntPtr, typeof(STCallHistroyData));

                winHisitory.labTotal.Content = "/" + ((head.iTotal % count) == 0 ? (head.iTotal / count == 0 ? 1 : head.iTotal / count).ToString() : (head.iTotal / count + 1).ToString());
                winHisitory.txtPage.Text     = (page + 1).ToString();
                int second = 0;
                for (int i = -1; i < head.iTotal - 1 && i < head.iTo - head.iFrom; i++)
                {
                    Marshal.Copy(pCallHistory, iSizeSTCallHistroyData + iSizeSTCallHistroyItem * i, tempInfoIntPtr, (int)iSizeSTCallHistroyItem);
                    STCallHistroyItem item = (STCallHistroyItem)Marshal.PtrToStructure(tempInfoIntPtr, typeof(STCallHistroyItem));

                    CallItem callItem = new CallItem();
                    //2015/8/24    UTF8 转码UNICODE
                    //byte[] buffer1 = Encoding.Default.GetBytes(item.CallName);
                    //byte[] buffer2 = Encoding.Convert(Encoding.UTF8, Encoding.Default, buffer1, 0, buffer1.Length);
                    //string item1= Encoding.Default.GetString(buffer2, 0, buffer2.Length);
                    //callItem.Name = item1;
                    //byte[] buffer3 = Encoding.Default.GetBytes(item.CallNum);
                    //byte[] buffer4 = Encoding.Convert(Encoding.UTF8, Encoding.Default, buffer3, 0, buffer3.Length);
                    //string item2 = Encoding.Default.GetString(buffer4, 0, buffer4.Length);
                    //callItem.Phone = item2;
                    //
                    callItem.Phone = item.CallNum;
                    callItem.Name  = item.CallName;
                    DateTime dtTime = DateTime.Parse(item.startTime.year.ToString() + "-" + item.startTime.month + "-" + item.startTime.day
                                                     + " " + item.startTime.hour + ":" + item.startTime.minute + ":" + item.startTime.second);
                    callItem.Time     = dtTime.ToString("yyyy-MM-dd HH:mm:ss");
                    second            = Convert.ToInt32(item.duration);
                    callItem.Duration = (second == -1 ? "00:00:00" : DateTime.Today.AddSeconds(second).ToString("HH:mm:ss"));
                    callItem.TelType  = (CallHistoryType)item.callType;

                    list.Add(callItem);
                }
                Marshal.Release(tempInfoIntPtr);
            }
            else
            {
                winHisitory.labTotal.Content = "/1";
                winHisitory.txtPage.Text     = "1";
            }

            switch ((CallHistoryType)index)
            {
            case CallHistoryType.HISTORY_CALL_ALL:
                winHisitory.listAll.DataContext = null;
                winHisitory.listAll.DataContext = list;
                break;

            case CallHistoryType.HISTORY_CALL_ANSWERED:
                winHisitory.listAnswered.DataContext = null;
                winHisitory.listAnswered.DataContext = list;
                break;

            case CallHistoryType.HISTORY_CALL_DIALED:
                winHisitory.listDialed.DataContext = null;
                winHisitory.listDialed.DataContext = list;
                break;

            case CallHistoryType.HISTORY_CALL_MISSED:
                winHisitory.listMissed.DataContext = null;
                winHisitory.listMissed.DataContext = list;
                break;
            }
        }
        public void QueryConferenceHistory(int page, bool refresh = false)
        {
            List <ConferenceItem> list = new List <ConferenceItem>();
            int iSizeSTConvHistroyData = Marshal.SizeOf(typeof(STConvHistroyData));
            int iSizeSTConvHistroyItem = Marshal.SizeOf(typeof(STConvHistroyItem));
            int uiBufSize = (iSizeSTConvHistroyData + iSizeSTConvHistroyItem * (count - 1));

            byte[] pCallHistory = new byte[uiBufSize];

            UCServiceRetvCode iRet = (UCServiceRetvCode)query.QueryConvHistory(page * count, (page + 1) * count - 1, pCallHistory, uiBufSize);

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

                Marshal.Copy(pCallHistory, 0, tempInfoIntPtr, (int)iSizeSTConvHistroyData);
                STConvHistroyData head = (STConvHistroyData)Marshal.PtrToStructure(tempInfoIntPtr, typeof(STConvHistroyData));

                winHisitory.labTotal.Content = "/" + ((head.iTotal % count) == 0 ? (head.iTotal / count == 0 ? 1 : head.iTotal / count).ToString() : (head.iTotal / count + 1).ToString());
                winHisitory.txtPage.Text     = (page + 1).ToString();
                int second = 0;
                for (int i = -1; i < head.iTotal - 1 && i < head.iTo - head.iFrom; i++)
                {
                    Marshal.Copy(pCallHistory, iSizeSTConvHistroyData + iSizeSTConvHistroyItem * i, tempInfoIntPtr, (int)iSizeSTConvHistroyItem);
                    STConvHistroyItem item = (STConvHistroyItem)Marshal.PtrToStructure(tempInfoIntPtr, typeof(STConvHistroyItem));

                    ConferenceItem it = new ConferenceItem();
                    //2015/8/24    UTF8 转码UNICODE
                    //byte[] buffer1 = Encoding.Default.GetBytes(item.compereName);
                    //byte[] buffer2 = Encoding.Convert(Encoding.UTF8, Encoding.Default, buffer1, 0, buffer1.Length);
                    //string item1 = Encoding.Default.GetString(buffer2, 0, buffer2.Length);
                    //it.Initiator = item1;
                    it.Initiator = item.compereName;

                    DateTime dt = DateTime.Parse(item.startTime.year.ToString() + "-" + item.startTime.month + "-" + item.startTime.day
                                                 + " " + item.startTime.hour + ":" + item.startTime.minute + ":" + item.startTime.second);
                    it.StartTime = dt.ToString("yyyy-MM-dd HH:mm:ss");
                    second       = Convert.ToInt32(item.duration);
                    it.Duration  = (second == -1 ? "00:00:00" : DateTime.Today.AddSeconds(second).ToString("HH:mm:ss"));
                    it.ConvID    = item.convID;

                    list.Add(it);
                }

                winHisitory.listConference.ItemsSource = null;
                winHisitory.listConference.ItemsSource = list;
                Marshal.Release(tempInfoIntPtr);
            }
            else
            {
                winHisitory.labTotal.Content = "/1";
                winHisitory.txtPage.Text     = "1";
            }
            if (list.Count > 0)
            {
                string _convID   = list[0].ConvID;
                string initiator = list[0].Initiator;
                QueryHisConvPartByID(_convID, initiator);
            }
            else
            {
                winHisitory.listParticipants.ItemsSource = null;
            }
        }