Пример #1
0
        /// <summary>
        /// MQ查找好友
        /// </summary>
        /// <param name="PageSize">每页条数</param>
        /// <param name="PageIndex">当前页数</param>
        /// <param name="RecordCount">总记录数</param>
        /// <param name="CompanyName">公司名称</param>
        /// <param name="ContactName">联系人名称</param>
        /// <param name="UserName">用户名</param>
        /// <param name="ProvinceId">公司所在省份</param>
        /// <param name="CityId">公司所在城市</param>
        /// <param name="CityName">城市名称</param>
        /// <param name="MQID">MQID</param>
        /// <param name="FriendSearchType">查找方式</param>
        /// <param name="IsOnline">是否在线</param>
        /// <param name="CurrCompanyType">当前查找好友的公司类型数组</param>
        /// <returns>返回MQ查找好友实体集合</returns>
        public virtual IList <Model.MQStructure.IMMemberAndUser> GetSearchFriend(int PageSize, int PageIndex, ref int RecordCount
                                                                                 , string CompanyName, string ContactName, string UserName, int ProvinceId, int CityId, string CityName, int MQID
                                                                                 , EyouSoft.Model.MQStructure.MQFriendSearchType?FriendSearchType, bool IsOnline
                                                                                 , params EyouSoft.Model.CompanyStructure.CompanyType[] CurrCompanyType)
        {
            IList <Model.MQStructure.IMMemberAndUser> List = new List <Model.MQStructure.IMMemberAndUser>();
            string        strFiles = " im_uid,im_displayname,im_username,im_status,UserId,CompanyType,CompanyName,CityName,ProvinceId,CityId,IsOnline,ContactName,CompanyId ";
            StringBuilder strWhere = new StringBuilder(" 1 = 1 ");
            //zhangzy  2010-11-17  修改了排序方式
            string strOrder = " IsOnline desc,[IsAutoLogin],[im_latest_time] desc ";

            if (!string.IsNullOrEmpty(CompanyName))
            {
                strWhere.AppendFormat(" and CompanyName like '%{0}%' ", CompanyName);
            }
            if (!string.IsNullOrEmpty(ContactName))
            {
                strWhere.AppendFormat(" and ContactName like '%{0}%' ", ContactName);
            }
            if (!string.IsNullOrEmpty(UserName))
            {
                strWhere.AppendFormat(" and im_username like '%{0}%' ", UserName);
            }
            if (ProvinceId > 0)
            {
                strWhere.AppendFormat(" and ProvinceId = {0} ", ProvinceId);
            }
            if (CityId > 0)
            {
                strWhere.AppendFormat(" and CityId = {0} ", CityId);
            }
            if (!string.IsNullOrEmpty(CityName))
            {
                strWhere.AppendFormat(" and CityName like '%{0}%' ", CityName);
            }
            if (MQID > 0)
            {
                strWhere.AppendFormat(" and im_uid = {0} ", MQID);
            }
            if (IsOnline)
            {
                strWhere.Append(" and im_status>11 and IsAutoLogin=0 ");
            }
            if (FriendSearchType.HasValue)
            {
                switch (FriendSearchType)
                {
                case EyouSoft.Model.MQStructure.MQFriendSearchType.找专线商:
                    strWhere.AppendFormat(" and exists (select 1 from tbl_CompanyTypeList where tbl_CompanyTypeList.CompanyId = view_im_member_SearchFriend.CompanyId and TypeId = {0}) ", (int)EyouSoft.Model.CompanyStructure.CompanyType.专线);
                    break;

                case EyouSoft.Model.MQStructure.MQFriendSearchType.找组团社:
                    strWhere.AppendFormat(" and exists (select 1 from tbl_CompanyTypeList where tbl_CompanyTypeList.CompanyId = view_im_member_SearchFriend.CompanyId and TypeId = {0}) ", (int)EyouSoft.Model.CompanyStructure.CompanyType.组团);
                    break;

                case EyouSoft.Model.MQStructure.MQFriendSearchType.找地接社:
                    strWhere.AppendFormat(" and exists (select 1 from tbl_CompanyTypeList where tbl_CompanyTypeList.CompanyId = view_im_member_SearchFriend.CompanyId and TypeId = {0}) ", (int)EyouSoft.Model.CompanyStructure.CompanyType.地接);
                    break;

                case EyouSoft.Model.MQStructure.MQFriendSearchType.找其他企业:
                    strWhere.AppendFormat(" and CompanyType > 1 ");
                    break;

                case EyouSoft.Model.MQStructure.MQFriendSearchType.精确查找:     //精确查找,地接不能查到组团
                    if (CurrCompanyType == null || CurrCompanyType.Length <= 0)
                    {
                        break;
                    }
                    if (CurrCompanyType.Contains(EyouSoft.Model.CompanyStructure.CompanyType.地接) && CurrCompanyType.Length == 1)
                    {
                        strWhere.Append(" and exists (select 1 from tbl_CompanyTypeList where tbl_CompanyTypeList.CompanyId = view_im_member_SearchFriend.CompanyId and TypeId IN (1,3,4,5,6,7,8)) ");
                    }
                    break;
                }
            }

            using (IDataReader dr = DbHelper.ExecuteReader(base.MQStore, PageSize, PageIndex, ref RecordCount, "view_im_member_SearchFriend", "im_uid", strFiles, strWhere.ToString(), strOrder))
            {
                EyouSoft.Model.MQStructure.IMMemberAndUser model = null;
                while (dr.Read())
                {
                    model = new EyouSoft.Model.MQStructure.IMMemberAndUser();
                    if (!dr.IsDBNull(dr.GetOrdinal("im_uid")))
                    {
                        model.MQId = dr.GetInt32(dr.GetOrdinal("im_uid"));
                    }
                    if (!dr.IsDBNull(dr.GetOrdinal("im_username")))
                    {
                        model.MQUserName = dr.GetString(dr.GetOrdinal("im_username"));
                    }
                    if (!dr.IsDBNull(dr.GetOrdinal("im_displayname")))
                    {
                        model.MQDisplayName = dr.GetString(dr.GetOrdinal("im_displayname"));
                    }
                    if (!dr.IsDBNull(dr.GetOrdinal("UserId")))
                    {
                        model.UserId = dr.GetString(dr.GetOrdinal("UserId"));
                    }
                    if (!dr.IsDBNull(dr.GetOrdinal("CompanyId")))
                    {
                        model.CompanyId = dr.GetString(dr.GetOrdinal("CompanyId"));
                    }
                    if (!dr.IsDBNull(dr.GetOrdinal("CompanyName")))
                    {
                        model.CompanyName = dr.GetString(dr.GetOrdinal("CompanyName"));
                    }
                    if (!dr.IsDBNull(dr.GetOrdinal("CityId")))
                    {
                        model.CityId = dr.GetInt32(dr.GetOrdinal("CityId"));
                    }
                    if (!dr.IsDBNull(dr.GetOrdinal("ProvinceId")))
                    {
                        model.ProvinceId = dr.GetInt32(dr.GetOrdinal("ProvinceId"));
                    }
                    if (!dr.IsDBNull(dr.GetOrdinal("im_status")))
                    {
                        model.MQStatus = dr.GetInt16(dr.GetOrdinal("im_status"));
                    }
                    if (!dr.IsDBNull(dr.GetOrdinal("IsOnline")) && dr["IsOnline"].ToString() == "1")
                    {
                        model.IsOnline = true;
                    }
                    if (!dr.IsDBNull(dr.GetOrdinal("ContactName")))
                    {
                        model.ContactName = dr.GetString(dr.GetOrdinal("ContactName"));
                    }
                    if (!dr.IsDBNull(dr.GetOrdinal("CityName")))
                    {
                        model.CityName = dr.GetString(dr.GetOrdinal("CityName"));
                    }
                    if (!dr.IsDBNull(dr.GetOrdinal("CompanyType")))
                    {
                        model.CompanyType = (EyouSoft.Model.CompanyStructure.BusinessProperties)dr.GetByte(dr.GetOrdinal("CompanyType"));
                    }

                    List.Add(model);
                }
                model = null;
            }

            return(List);
        }
Пример #2
0
        /// <summary>
        /// 获得每一行的用户信息
        /// </summary>
        /// <param name="drv">数据实体</param>
        /// <param name="myFriendIdList">已加好友的列表</param>
        /// <param name="isCheckdCompany">当前公司有无审核通过</param>
        /// <param name="CompanyTypeId">公司类型 1:专线  2:组团  3:地接</param>
        /// <returns></returns>
        private string GetListTrValue(EyouSoft.Model.MQStructure.IMMemberAndUser drv, List <int> myFriendIdList)
        {
            StringBuilder strVal = new StringBuilder();

            if (drv == null)
            {
                return(strVal.ToString());
            }

            string im_uid      = drv.MQId.ToString();
            string contactName = string.IsNullOrEmpty(drv.ContactName) ? string.Empty : drv.ContactName.ToString().Trim();

            string im_displayname = string.IsNullOrEmpty(drv.MQDisplayName) ? string.Empty : drv.MQDisplayName.ToString().Trim();
            string userName       = string.IsNullOrEmpty(drv.MQUserName) ? string.Empty : drv.MQUserName.ToString().Trim();
            string im_status      = drv.MQStatus.ToString();
            string CompanyName    = string.IsNullOrEmpty(drv.CompanyName) ? string.Empty : drv.CompanyName.ToString().Trim();
            string CityName       = string.IsNullOrEmpty(drv.CityName) ? string.Empty : drv.CityName.ToString().Trim();
            string CompanyId      = string.IsNullOrEmpty(drv.CompanyId) ? string.Empty : drv.CompanyId.ToString().Trim();

            //显示的用户名称
            string showName = contactName;

            if (contactName == "")
            {
                if (im_displayname != "")
                {
                    showName = im_displayname;
                }
                else
                {
                    showName = userName;
                }
            }
            //用户名,联系人,昵称
            string userNameContactName = string.Format("用户名:{0},联系人:{1},昵称:{2}", userName, contactName, im_displayname);

            string icoSrc = ImageServerUrl + "/IM/images/icounline.gif"; //头像src地址,默认不在线的

            if (Int32.Parse(im_status) > 11)                             //表示用户不在线  >11在线  否则不在线
            {
                icoSrc = ImageServerUrl + "/IM/images/icoonline.gif";
            }

            #region 初始化tr

            string isLookUserInfo = string.Format(" href='/Card/LookUserInfo.aspx?im_username={0}'", im_uid);
            if (!IsCompanyCheck)
            {
                isLookUserInfo = "";
            }

            strVal.Append("<tr>");
            strVal.AppendFormat("<td align='left' bgcolor='#fbfbfb'><img src='{0}' title='{2}' width='14' height='17' /><span title='{2}'><a target=\"_blank\" {3}>{1}</a></span></td>", icoSrc, Utils.GetText(showName, 8), userNameContactName, isLookUserInfo);

            //公司名称
            strVal.AppendFormat("<td align='left' bgcolor='#fbfbfb'><span title='{1}'><a target=\"_blank\" {2}>{0}</a></span></td>", Utils.GetText(CompanyName, 17), CompanyName, isLookUserInfo);

            //城市
            strVal.AppendFormat("<td align='left' bgcolor='#fbfbfb'><span title='{1}'>{0}</span></td>", Utils.GetText(CityName, 6), CityName);
            //string isCheckOnclick = string.Empty;
            //if (IsCompanyCheck && SiteUserInfo != null && SiteUserInfo.CompanyRole != null && SiteUserInfo.CompanyRole.RoleItems != null && SiteUserInfo.CompanyRole.RoleItems.Length > 0)
            //{
            //    if ((SiteUserInfo.CompanyRole.RoleItems.Contains(EyouSoft.Model.CompanyStructure.CompanyType.专线) || SiteUserInfo.CompanyRole.RoleItems.Contains(EyouSoft.Model.CompanyStructure.CompanyType.组团) || SiteUserInfo.CompanyRole.RoleItems.Contains(EyouSoft.Model.CompanyStructure.CompanyType.地接)) && drv.CompanyType == EyouSoft.Model.CompanyStructure.BusinessProperties.旅游社)
            //    {
            //        isCheckOnclick = string.Format("onclick='CheckFormAdd(\"{0}\",\"{1}\",\"{2}\")'", im_uid, CompanyId, SiteUserInfo.ContactInfo.MQ);
            //    }
            //    else
            //    {
            //        isCheckOnclick = string.Format("onclick='CheckFormAdd(\"{0}\",\"{1}\",\"{2}\")'", im_uid, string.Empty, SiteUserInfo.ContactInfo.MQ);
            //    }
            //}

            //if (myFriendIdList != null)
            //{
            //    if (myFriendIdList.Contains(Convert.ToInt32(im_uid)))
            //    {
            //        strVal.AppendFormat("<td align='left' bgcolor='#fbfbfb'><img style='cursor:pointer' src='{0}/IM/images/addedFriend.gif' /></td>", ImageServerUrl);
            //    }
            //    else
            //    {
            //        strVal.AppendFormat("<td align='left' bgcolor='#fbfbfb'><img style='cursor:pointer' {0}  src='{1}/IM/images/addFriend.gif' /></td>", isCheckOnclick, ImageServerUrl);
            //    }
            //}
            //else
            //{
            //    strVal.AppendFormat("<td align='left' bgcolor='#fbfbfb'><img style='cursor:pointer' {0} src='{1}/IM/images/addFriend.gif' /></td>", isCheckOnclick, ImageServerUrl);
            //}

            strVal.Append("</tr>");

            #endregion


            return(strVal.ToString());
        }