#region 根据群ID和用户Id查询 +
string QueryQunByUserIdAndQunId(int userId, int qunId)
V1.0
///
<summary>
/// 13.0
根据群ID和用户Id查询
///
</summary>
/// <param
name="userId"></param>
/// <param
name="qunId"></param>
///
<returns></returns>
public string QueryQunByUserIdAndQunId(int userId, int
qunId)
{
string where =
"";
if
(userId > 0 && qunId >
0)
where = string.Format("UserId={0} and QunId={1} and Deleted=‘{2}‘", userId,
qunId,
false);
T_UserRolePermission model =
m_userRolePermissionManager.GetModelByQunIdAndUserId(qunId,
userId);
//判断是否存在
if (model ==
null)
{
return
Convert.ToString(ErrorCode.DATA_NOT_EXIST);
}
M_User user =
m_userManager.GetModel(userId);
#region 格式
//<qun>
//
<qunId>xxx</qunId>1
//
<qunNo>群编号</qunNo>2
//
<qunName>="群名称"</qunName>3
// <iconUrl>群头像地址</iconUrl>
4
//
<isPublish>公开/私密</isPublish>5
//
<description>群介绍</description>6
// <contact>联系方式</contact>
7
//
<address>地点</address>8
//
<createrId>群主Id</createrId>9
// <createrIconUrl>群主头像地址</createrIconUrl>
10
// <createrName>群主用户名</createrName>
11
// <qunTypeName>类别名称</qunTypeName>
12
//
<groupName>用户所在的组名称</groupName>13
//</qun>
#endregion
M_Qun qun =
m_qunManager.GetModel(qunId);
StringBuilder sb = new
StringBuilder();
M_QunType qunTypeModel =
m_qunTypeManager.GetModelByTypeId((int)t_qunTypeRelationManager.GetModelByqunId(qun.ID).QunTypId);
M_Groups groupsModel =
m_groupsManager.GetModelByQunId(qun.ID);
sb.Append("<quns>");
sb.AppendFormat(@"<qun qunId = ""{0}"" qunNo = ""{1}"" qunName =
""{2}"" iconUrl = ""{3}"" isPublish = ""{4}"" description = ""{5}"" contact =
""{6}"" address = ""{7}"" createrId = ""{8}"" createrIconUrl = ""{9}""
createrName = ""{10}"" qunTypeName = ""{11}"" groupName = ""{12}""
/>",
qun.ID,
//0
qun.QunNo,
//1
qun.QunName,//2
qun.Logo,
//3
qun.IsOpen,
//4
qun.Description,
//5
qun.Contact,
//6
qun.Address,
//7
model.UserId,
//8
user.Icon,
//9
user.UserName,
//10
qunTypeModel == null ? "" : qunTypeModel.TypeName,
//11
groupsModel == null ? "" : groupsModel.GroupsName
//12
);
sb.Append("</quns>");
return sb.ToString();
}
#endregion
#region 根据群ID和用户Id查询 + string QueryQunByUserIdAndQunId(int userId, int
qunId) V2.0
#region 13.0 根据群ID + string
QueryQunByUserIdAndQunId(int userId, int
qunId)
///
<summary>
/// 13.0
根据群ID查询
///
</summary>
/// <param
name="userId"></param>
/// <param
name="qunId"></param>
///
<returns></returns>
public string QueryQunByQunId(int
qunId)
{
M_Qun
qun =
m_qunManager.GetModel(qunId);
string where = string.Format("QunId={0} and IsQunCreater=‘true‘ and
Deleted=‘false‘",
qunId);
DataSet ds =
m_userRolePermissionManager.GetList(where);
M_User user =
null;
if
(ds != null && ds.Tables.Count >
0)
user =
m_userManager.GetModel(Convert.ToInt32(ds.Tables[0].Rows[0]["UserId"]));
//判断是否存在
if (user ==
null)
{
return
Convert.ToString(ErrorCode.DATA_NOT_EXIST);
}
#region 格式
//<qun>
//
<qunId>xxx</qunId>1
//
<qunNo>群编号</qunNo>2
//
<qunName>="群名称"</qunName>3
// <iconUrl>群头像地址</iconUrl>
4
//
<isPublish>公开/私密</isPublish>5
//
<description>群介绍</description>6
// <contact>联系方式</contact>
7
//
<address>地点</address>8
//
<createrId>群主Id</createrId>9
// <createrIconUrl>群主头像地址</createrIconUrl>
10
// <createrName>群主用户名</createrName>
11
// <qunTypeName>类别名称</qunTypeName>
12
//
<groupName>用户所在的组名称</groupName>13
//</qun>
#endregion
StringBuilder sb = new
StringBuilder();
M_QunType qunTypeModel =
m_qunTypeManager.GetModelByTypeId((int)t_qunTypeRelationManager.GetModelByqunId(qun.ID).QunTypId);
M_Groups groupsModel =
m_groupsManager.GetModelByQunId(qun.ID);
sb.Append("<quns>");
sb.AppendFormat(@"<qun qunId = ""{0}"" qunNo = ""{1}"" qunName =
""{2}"" iconUrl = ""{3}"" isPublish = ""{4}"" description = ""{5}"" contact =
""{6}"" address = ""{7}"" createrId = ""{8}"" createrIconUrl = ""{9}""
createrName = ""{10}"" qunTypeName = ""{11}"" groupName = ""{12}""
/>",
qun.ID,
//0
qun.QunNo,
//1
qun.QunName,//2
qun.Logo,
//3
qun.IsOpen,
//4
qun.Description,
//5
qun.Contact,
//6
qun.Address,
//7
user.ID,
//8
user.Icon,
//9
user.UserName,
//10
qunTypeModel == null ? "" : qunTypeModel.TypeName,
//11
groupsModel == null ? "" : groupsModel.GroupsName
//12
);
sb.Append("</quns>");
return sb.ToString();
}
#endregion
根据群ID和用户Id查询 + string QueryQunByUserIdAndQunId(int userId, int
qunId) V1.0