/// <summary> /// 增加新的与会人 /// </summary> /// <param name="obj"></param> void GetSelectContactFun(object obj) { DataTable dt1 = (DataTable)obj; //modifty by 00327190 做校验,防止已经通话中的人再次入会 for (int i = 0; i < contactList.Count; i++) { for (int j = 0; j < dt1.Rows.Count; j++) { string b = dt1.Rows[j]["Url"].ToString().Trim(); if (b != "" && b != null) //UC帐号和话机联动账号添加,url不空 { string a = contactList[i].UserName.ToString().Trim(); //string c = a.Substring(0, a.Length - 10).ToString().Trim(); //这个是截取 @lync1.com之前的字符串的方法 if (String.Compare(a, b) == 0 || a.Equals(b) || a == b) { string message = (a) + " " + StringHelper.FindLanguageResource("theconferencehassameperson"); winCall.OpenDialogTiming(message, "error", 2); dt1.Rows[j].Delete(); // return; } } else //话机添加(没有对应UC账号),url为空,只能根据phone比较 { string a = contactList[i].UserName.ToString().Trim(); string d = dt1.Rows[j]["phone"].ToString().Trim(); if (String.Compare(a, d) == 0 || a.Equals(d) || a == d) { string message = (a)+ " " +StringHelper.FindLanguageResource("theconferencehassameperson"); winCall.OpenDialogTiming(message, "error", 2); dt1.Rows[j].Delete(); //return; } } } } dt1.AcceptChanges(); int count = dt1.Rows.Count + contactList.Count; if (dt1.Rows.Count != 0) { if (count <= 20) //多于20个人就不添加了 (应该是原先列表加上新加的人数大于20才不添加) { lock (WinCall.lockObject) { if (StrTemp == true) //为conference 时,走这个接口 { try { LogManager.SystemLog.Info("GetSelectContactFun Monitor.Enter"); DataTable dt = (DataTable)obj; int type = 0; foreach (DataRow dr in dt1.Rows) { string str = dr["Url"].ToString() == "" ? dr["Phone"].ToString() : dr["Url"].ToString(); string userName = ""; if (str.IndexOf("sip") > -1) { str = str.Substring(str.IndexOf(":") + 1); } STConfMember ST = new STConfMember(); StringBuilder ucName = new StringBuilder(100); // if (call.GetUCAccount(str, ucName) == 0) //回调成功 modify by 00327190 之前没有if判断,现在只有能成功才可以入会 //{ if (dr["Name"].ToString() == "") { call.GetUCAccount(str, ucName); if (ucName.ToString() != "") { userName = ucName + StringHelper.GetLyncDomainString(SingletonObj.LoginInfo.LyncName); type = 0; str = userName.ToString(); //2015/8/6 ST.membertype = type; ST.account = ucName.ToString(); } else { userName = str; type = 1; //2015/8/6 ST.membertype = type; ST.account = str; } } else { userName = str; type = 0; //2015/8/6 ST.membertype = type; ST.account = str.Replace(StringHelper.GetLyncDomainString(SingletonObj.LoginInfo.LyncName), ""); } UCContact uc = new UCContact(); uc.UCMemberType = (MemberType)type; uc.Mute = MemStatusInCall.CONF_MEM_INVITING; uc.UserName = userName; uc.Online = GetContactAvailability(type, StringHelper.GetSubString(uc.UserName));//查询uc状态 contactList.Add(uc); call.InviteMemberInCall(type, new StringBuilder(StringHelper.GetSubString(str))); //} //else //{ // string message = StringHelper.FindLanguageResource("error") + (str); // winCall.OpenDialogTiming(message, "error", 3); //} } IEnumerable<UCContact> noduplicates = contactList.Distinct(new ContactCompar()); List<UCContact> temp = new List<UCContact>(); foreach (var contact in noduplicates) { temp.Add(contact); } contactList = temp; winCall.Render(contactList); winCall.IsEnableChanged(); } finally { LogManager.SystemLog.Info("GetSelectContactFun Monitor.Exit"); } } else ////为call 时,点呼转多人,走这个接口 { StrTemp = true; LogManager.SystemLog.Info("GetSelectContactFun Monitor.Enter"); DataTable dt = (DataTable)obj; int type = 0; STConfMemList ST1 = new STConfMemList(); ST1.stConfMem = new STConfMember[dt.Rows.Count]; ST1.size = dt.Rows.Count; for (int i = 0; i < dt1.Rows.Count; i++) { DataRow dr = dt.Rows[i]; STConfMember ST = new STConfMember(); string str = dr["Url"].ToString() == "" ? dr["Phone"].ToString() : dr["Url"].ToString(); string userName = ""; if (str.IndexOf("sip") > -1) { str = str.Substring(str.IndexOf(":") + 1); } StringBuilder ucName = new StringBuilder(100); if (dr["Name"].ToString() == "") { call.GetUCAccount(str, ucName); if (ucName.ToString() != "") { userName = ucName + StringHelper.GetLyncDomainString(SingletonObj.LoginInfo.LyncName); type = 0; str = userName.ToString(); ST.membertype = type; ST.account = ucName.ToString(); } else { userName = str; type = 1; ST.membertype = type; ST.account = str; } } else { userName = str; type = 0; ST.membertype = type; ST.account = str.Replace(StringHelper.GetLyncDomainString(SingletonObj.LoginInfo.LyncName), ""); } ST1.stConfMem[i] = ST; ST1.size = i + 1; UCContact uc = new UCContact(); uc.UCMemberType = (MemberType)type; uc.Mute = MemStatusInCall.CONF_MEM_INVITING; uc.UserName = userName; uc.Online = GetContactAvailability(type, StringHelper.GetSubString(uc.UserName));//查询uc状态 contactList.Add(uc); } int iSizeSTContact = Marshal.SizeOf(typeof(STConfMember)); int iSizeSTContactList = Marshal.SizeOf(typeof(STConfMemList)); uiSize = iSizeSTContactList + (dt.Rows.Count - 1) * iSizeSTContact; pSTContactList = StructToBytes(ST1); if (call.UC_SDK_TransCallToConf(pSTContactList, uiSize) == 0) { IEnumerable<UCContact> noduplicates = contactList.Distinct(new ContactCompar()); List<UCContact> temp = new List<UCContact>(); foreach (var contact in noduplicates) { temp.Add(contact); } contactList = temp; winCall.Render(contactList); //winCall.IsConf(); winCall.IsEnableChanged(); } else { DialogShow.Show(StringHelper.FindLanguageResource("error"), StringHelper.FindLanguageResource("error"), 2); return; } } } } else { winCall.OpenDialogTiming("somanypeople", "error", 2); winCall.lync.setBtn(); //2015/8/17 之前由于视频转移导入的添加界面OK键使得加人键禁用原因 return; } } else { //winCall.OpenDialogTiming("PleaseAddOneAccountFirst", "error", 2); //return; } winCall.lync.setBtn(); }
//struct转换为byte[] public static byte[] StructToBytes(STConfMemList structObj) { int iSizeSTContact = Marshal.SizeOf(typeof(STConfMember)); int iSizeSTContactList = Marshal.SizeOf(typeof(STConfMemList)); int uiSize = iSizeSTContactList + (structObj.size - 1) * iSizeSTContact; IntPtr buffer = Marshal.AllocHGlobal(uiSize); try { Marshal.StructureToPtr(structObj, buffer, false); byte[] bytes = new byte[uiSize]; Marshal.Copy(buffer, bytes, 0, uiSize); return bytes; } finally { Marshal.FreeHGlobal(buffer); } }