/// <summary> /// 获取用户登录信息 /// </summary> public static UserInfo GetLoginUser(PageBase page) { if (page.Session["WebUser"] != null) { string userName = page.Session["WebUser"].ToString(); DataTable dt = MSSQLHelper.Query(string.Format("select * from SWX_Config where UserName='******'", userName)).Tables[0]; if (dt.Rows.Count > 0) { UserInfo userInfo = new UserInfo(); userInfo.UserName = userName; userInfo.OrgID = dt.Rows[0]["OrgID"].ToString(); userInfo.AppID = dt.Rows[0]["AppID"].ToString(); userInfo.Token = dt.Rows[0]["Token"].ToString(); userInfo.EncodingAESKey = dt.Rows[0]["EncodingAESKey"].ToString(); userInfo.access_token = dt.Rows[0]["access_token"].ToString(); userInfo.AppSecret = dt.Rows[0]["AppSecret"].ToString(); return userInfo; } } return null; }
/// <summary> /// 预览菜单消息 /// </summary> public static string GetPreviewMenuMsgHtml(UserInfo user, string id) { DataTable dt = MSSQLHelper.Query(string.Format(@" select * from SWX_MenuMsg where OrgId='{0}' and MenuKey= (select MenuKey from SWX_MenuMsg where Id={1}) order by Sort", user.OrgID, id)).Tables[0]; StringBuilder sb = new StringBuilder(); if (dt.Rows.Count == 1) { #region 单条记录拼HTML sb.Append("<table align='center' cellpadding='0' cellspacing='0' style='border-collapse:collapse; width:310px;'><tr><td>"); string title = dt.Rows[0]["Title"].ToString(); if (title.Length > 36) title = title.Substring(0, 36); sb.Append("<div style='width:300px; padding:5px; font-size:15px; font-weight:bold; ' >"); sb.Append(string.Format("{0}", title)); sb.Append("</div>"); sb.Append("<div style='width:300px; padding:5px; font-size:12px; color:#666; ' >"); sb.Append(string.Format("{0}", DateTime.Now.ToString("M月d日"))); sb.Append("</div>"); sb.Append("<div style='width:300px; height:120px; padding:5px; ' >"); sb.Append(string.Format("<img alt='' src='{0}' style='width:300px; height:120px;' />", dt.Rows[0]["PicUrl"].ToString())); sb.Append("</div>"); sb.Append("<div style='width:300px; padding:5px; font-size:12px; color:#666;' >"); sb.Append(string.Format("{0}", dt.Rows[0]["Description"].ToString().Replace("\n", "<br />"))); sb.Append("</div>"); string url = dt.Rows[0]["Url"].ToString(); if (!string.IsNullOrWhiteSpace(url)) { sb.Append("<div style='width:300px; padding:5px; font-size:12px; margin-top:10px;' >"); sb.Append(string.Format("{0}", "查看全文")); sb.Append("</div>"); } sb.Append("</td></tr></table>"); #endregion } else { #region 多条记录拼HTML sb.Append("<table align='center' cellpadding='0' cellspacing='0' style='border-collapse:collapse; width:310px;'><tr><td>"); sb.Append("<div align='center' style='width:300px; height:120px; padding:5px; border-top:solid 1px #ddd; border-bottom:solid 1px #ddd; border-left:solid 1px #ddd; border-right:solid 1px #ddd;' >"); sb.Append(string.Format("<img alt='' src='{0}' style='width:300px; height:120px;' />", dt.Rows[0]["PicUrl"].ToString())); sb.Append("</div>"); string title = dt.Rows[0]["Title"].ToString(); if (title.Length > 36) title = title.Substring(0, 36); if (title.Length > 18) { sb.Append("<div style='position:absolute; z-index:999; width:290px; height:33px; font-size:15px; margin-left:6px; margin-top:-49px; padding:5px; color:#fff; font-weight:bold; filter:alpha(opacity=60); -moz-opacity:0.6; -khtml-opacity: 0.6; opacity: 0.6; background-color:#000; ' >"); } else { sb.Append("<div style='position:absolute; z-index:999; width:290px; height:17px; font-size:15px; margin-left:6px; margin-top:-33px; padding:5px; color:#fff; font-weight:bold; filter:alpha(opacity=60); -moz-opacity:0.6; -khtml-opacity: 0.6; opacity: 0.6; background-color:#000; ' >"); } sb.Append(string.Format("{0}", title)); sb.Append("</div>"); for (int i = 1; i < dt.Rows.Count; i++) { sb.Append("<div style='width:300px; padding:5px; border-bottom:solid 1px #ddd; border-left:solid 1px #ddd; border-right:solid 1px #ddd;'>"); sb.Append("<table cellpadding='0' cellspacing='0' style='border-collapse:collapse; width:100%; '><tr>"); string picUrl = dt.Rows[i]["PicUrl"].ToString(); if (string.IsNullOrWhiteSpace(picUrl)) { sb.Append("<td style='padding:5px; font-size:15px; line-height:20px;'>"); sb.Append(dt.Rows[i]["Title"].ToString().Replace("\n", "<br />")); sb.Append("</td>"); } else { sb.Append("<td style='width:250px; padding:5px; font-size:15px; line-height:20px;'>"); sb.Append(dt.Rows[i]["Title"].ToString().Replace("\n", "<br />")); sb.Append("</td>"); sb.Append("<td style='vertical-align:top; '>"); sb.Append(string.Format("<img alt='' src='{0}' style='width:50px; height:50px;' />", dt.Rows[i]["PicUrl"].ToString())); sb.Append("</td>"); } sb.Append("</tr></table>"); sb.Append("</div>"); } sb.Append("</td></tr></table>"); #endregion } return sb.ToString(); }
/// <summary> /// 获取二级菜单下拉列表html /// </summary> public static string GetMenusLevel2(UserInfo user, string selectId) { StringBuilder sbHtml = new StringBuilder(); string sql = string.Format("select * from SWX_WxMenu where Code like '____' and Type='click' and OrgID='{0}'", user.OrgID); DataTable dt = MSSQLHelper.Query(sql).Tables[0]; sbHtml.Append(string.Format("<select id='{0}' name='MenuKey' class='SIMPO_Select'>", selectId)); foreach (DataRow dr in dt.Rows) { sbHtml.Append(string.Format("<option value='{1}'>{0}</option>", dr["Name"].ToString(), dr["MenuKey"].ToString())); } sbHtml.Append("</select>"); return sbHtml.ToString(); }
/// <summary> /// 读取一级菜单列表 /// </summary> public static DataTable GetOneMenuList(UserInfo user) { StringBuilder sb = new StringBuilder(); sb.AppendFormat(string.Format("select * from SWX_WxMenu where len(Code) = 2 and OrgID='{0}' order by Code", user.OrgID)); return MSSQLHelper.Query(sb.ToString()).Tables[0]; }
/// <summary> /// 根据菜单code删除 /// </summary> public static int DeleteOneMenu(string code, UserInfo user) { StringBuilder sb = new StringBuilder(); sb.AppendFormat(@"delete from SWX_WxMenu where Code like '{0}%' and OrgID='{1}'", code, user.OrgID); int row = MSSQLHelper.ExecuteSql(sb.ToString()); return row; }
/// <summary> /// 获取二级菜单下拉列表html /// </summary> public static string GetMenusLevel3(UserInfo user) { StringBuilder sbHtml = new StringBuilder(); string sql = string.Format("select * from SWX_WxMenu where Code like '____' and Type='click' and OrgID='{0}'", user.OrgID); DataTable dt = MSSQLHelper.Query(sql).Tables[0]; foreach (DataRow dr in dt.Rows) { sbHtml.Append(string.Format(" <li><a href='javascript:void(0);' id='{0}' onclick=\"menulist('{1}')\">{2}</a></li>", dr["MenuKey"].ToString(), dr["MenuKey"].ToString(),dr["Name"].ToString())); } return sbHtml.ToString(); }