protected void Page_Load(object sender, EventArgs e) { string id = Request["id"]; UserInfo user = AdminUtil.GetLoginUser(this); string html = MenuMessageDal.GetPreviewMenuMsgHtml(user, id); Response.Write(html); Response.End(); }
/// <summary> /// 分页控件状态设置 /// </summary> protected void InitAspNetPager() { UserInfo user = AdminUtil.GetLoginUser(this); StringBuilder sb = new StringBuilder(); sb.AppendFormat("select count(1) from SWX_GroupPicture where OrgID='{0}'", user.OrgID); int count = int.Parse(MSSQLHelper.GetSingle(sb.ToString()).ToString()); this.AspNetPager.RecordCount = count; this.AspNetPager.PageSize = pageSize; }
private void OnDataLoad() { UserInfo user = AdminUtil.GetLoginUser(this); InitAspNetPager(); StringBuilder sb = new StringBuilder(); sb.AppendFormat("SELECT Top {0} * FROM (SELECT ROW_NUMBER() OVER(ORDER BY Id DESC) AS RowID,* FROM SWX_GroupPicture where OrgID='{1}') T WHERE T.RowID BETWEEN {2} AND {3} ", pageSize, user.OrgID, ((pageSize * (AspNetPager.CurrentPageIndex - 1)) + 1), pageSize * AspNetPager.CurrentPageIndex); DataTable dt = MSSQLHelper.Query(sb.ToString()).Tables[0]; this.repeaterList1.DataSource = dt; this.repeaterList1.DataBind(); }
private void OnDataLoad() { UserInfo user = AdminUtil.GetLoginUser(this); InitAspNetPager(); StringBuilder sb = new StringBuilder(); sb.AppendFormat(" SELECT Top {0} * FROM (SELECT ROW_NUMBER() OVER(ORDER BY tm.Id DESC) AS RowID,", pageSize); sb.AppendFormat(" tm.* FROM SWX_TextMessage tm "); //sb.AppendFormat(" left join SWX_ImgItem ii on tm.Id = ii.TextMessageId"); sb.AppendFormat(" where OrgID='{0}'", user.OrgID); sb.AppendFormat(" ) T WHERE T.RowID BETWEEN {0} AND {1}", ((pageSize * (AspNetPager.CurrentPageIndex - 1)) + 1), pageSize * AspNetPager.CurrentPageIndex); DataTable dt = MSSQLHelper.Query(sb.ToString()).Tables[0]; this.repeaterList1.DataSource = dt; this.repeaterList1.DataBind(); }
public HttpRequestMessage UpdateWX() { string json = ""; UserInfo user = AdminUtil.GetLoginUser(""); string result = WXApi.CreateMenu(AdminUtil.GetAccessToken(""), user.OrgID); if (Tools.GetJsonValue(result, "errcode") == "0") { json = "{\"code\":1,\"msg\":\"\"}"; } else { json = "{\"code\":0,\"msg\":\"errcode:" + Tools.GetJsonValue(result, "errcode") + ", errmsg:" + Tools.GetJsonValue(result, "errmsg") + "\"}"; } return(null); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { OnDataLoad(); } string json = string.Empty; try { string action = Request["action"]; if (action == "addPicture") { UserInfo user = AdminUtil.GetLoginUser(this); string response = Request["response"]; string ImgUrl = System.IO.Path.Combine(UPLOAD_PATH, DateTime.Now.ToString("yyyyMMdd"), response.Split(',')[0] + response.Split(',')[1]).Replace("\\", "/"); StringBuilder sb = new StringBuilder(); sb.AppendFormat("insert into SWX_GroupPicture(OrgID,ImgUrl,ImgName) "); sb.AppendFormat("values('{0}','{1}','{2}') ", user.OrgID, ImgUrl, response.Split(',')[1]); MSSQLHelper.Exists(sb.ToString()); json = "1"; } } catch (Exception ex) { string err = ex.Message; } if (!string.IsNullOrEmpty(json)) { Response.Write(json); Response.End(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { OnDataLoad(); } string json = string.Empty; try { UserInfo user = AdminUtil.GetLoginUser(this); string action = Request["action"]; if (action == "addPicture") { string response = Request["response"]; string ImgUrl = System.IO.Path.Combine(UPLOAD_PATH, DateTime.Now.ToString("yyyyMMdd"), response.Split(',')[0] + response.Split(',')[1]).Replace("\\", "/"); StringBuilder sb = new StringBuilder(); sb.AppendFormat("insert into SWX_GroupPicture(OrgID,ImgUrl,ImgName) "); sb.AppendFormat("values('{0}','{1}','{2}') ", user.OrgID, ImgUrl, response.Split(',')[1]); MSSQLHelper.Exists(sb.ToString()); json = "1"; } if (action == "deletePic") { string id = Request["Id"]; StringBuilder sb = new StringBuilder(); sb.AppendFormat(" select * from SWX_GroupPicture where Id = {0} ", id); DataTable dt = MSSQLHelper.Query(sb.ToString()).Tables[0]; string ImgUrl = dt.Rows[0]["ImgUrl"].ToString(); StringBuilder sb1 = new StringBuilder(); sb1.AppendFormat("delete from SWX_GroupPicture where Id = {0}", id); MSSQLHelper.Exists(sb1.ToString()); File.Delete(Server.MapPath(ImgUrl)); json = "1"; } if (action == "copyPic") { string id = Request["Id"]; StringBuilder sb = new StringBuilder(); sb.AppendFormat(" select * from SWX_GroupPicture where Id = {0} ", id); DataTable dt = MSSQLHelper.Query(sb.ToString()).Tables[0]; string ImgUrl = dt.Rows[0]["ImgUrl"].ToString(); string ImgPa = AdminUtil.GetRootUrl() + ImgUrl; json = ImgPa; } } catch (Exception ex) { string err = ex.Message; } if (!string.IsNullOrEmpty(json)) { Response.Write(json); Response.End(); } }
protected void Page_Load(object sender, EventArgs e) { string json = string.Empty; try { string action = Request["action"]; if (action == "Load") { string id = Request["Id"]; StringBuilder sb = new StringBuilder(); sb.AppendFormat(" select * from SWX_ImgItem where TextMessageId = {0} ", id); DataTable dt = MSSQLHelper.Query(sb.ToString()).Tables[0]; string list = JsonConvert.SerializeObject(dt); loadtext.Value = list; hiddenid.Value = id; } if (action == "addPicture") { string response = Request["response"]; string ImgUrl = System.IO.Path.Combine(UPLOAD_PATH, DateTime.Now.ToString("yyyyMMdd"), response.Split(',')[0] + response.Split(',')[1]).Replace("\\", "/"); json = ImgUrl; } if (action == "saveText") { UserInfo user = AdminUtil.GetLoginUser(this); List <ImgItem> IISS = new List <ImgItem>(); ArrayList arrayList = new ArrayList(); StringBuilder maxsb = new StringBuilder(); string editid = Request["editid"]; string savevalue = Request["savecontent"]; savevalue = savevalue.Substring(0, savevalue.Length - 1); string[] strs = savevalue.Split('|'); for (int i = 0; i < strs.Count(); i++) { string str = ""; if (i != 0) { str = strs[i].Substring(1, strs[i].Length - 1); } else { str = strs[i]; } if (str == "") { continue; } List <ImgItem> IIS = JsonConvert.DeserializeAnonymousType(str, new List <ImgItem>()); IISS.AddRange(IIS); } bool istrue = false; //id为空新建 if (string.IsNullOrWhiteSpace(editid)) { maxsb.AppendFormat("select max(Id) from SWX_TextMessage"); int maxid = MSSQLHelper.GetSingle(maxsb.ToString()) == null ? 0 : int.Parse(MSSQLHelper.GetSingle(maxsb.ToString()).ToString());; int insertid = maxid + 1; StringBuilder sb = new StringBuilder(); sb.AppendFormat("insert into SWX_TextMessage(Id,OrgID,Status,CreateTime) "); sb.AppendFormat("values({0},'{1}','{2}','{3}') ", insertid, user.OrgID, true, DateTime.Now); arrayList.Add(sb.ToString()); for (int j = 0; j < IISS.Count(); j++) { StringBuilder sbitem = new StringBuilder(); sbitem.AppendFormat("insert into SWX_ImgItem(TextMessageId,Title,Author,ImgUrl,Content,TextUrl) "); sbitem.AppendFormat("values({0},'{1}','{2}','{3}','{4}','{5}') ", insertid, IISS[j].Title, IISS[j].Author, IISS[j].ImgUrl, IISS[j].Content, IISS[j].TextUrl); arrayList.Add(sbitem.ToString()); } if (arrayList.Count != 1) { istrue = MSSQLHelper.ExecuteSqlTran(arrayList); } } else { for (int j = 0; j < IISS.Count(); j++) { if (string.IsNullOrWhiteSpace(IISS[j].Id)) { StringBuilder sbitem = new StringBuilder(); sbitem.AppendFormat("insert into SWX_ImgItem(TextMessageId,Title,Author,ImgUrl,Content,TextUrl) "); sbitem.AppendFormat("values({0},'{1}','{2}','{3}','{4}','{5}') ", editid, IISS[j].Title, IISS[j].Author, IISS[j].ImgUrl, IISS[j].Content, IISS[j].TextUrl); arrayList.Add(sbitem.ToString()); } else { StringBuilder sbitem = new StringBuilder(); sbitem.AppendFormat("update SWX_ImgItem set Title = '{0}',Author = '{1}',ImgUrl = '{2}',Content = '{3}',TextUrl = '{4}' ", IISS[j].Title, IISS[j].Author, IISS[j].ImgUrl, IISS[j].Content, IISS[j].TextUrl); sbitem.AppendFormat(" WHERE ID= {0} ", IISS[j].Id); arrayList.Add(sbitem.ToString()); } } if (arrayList.Count != 0) { istrue = MSSQLHelper.ExecuteSqlTran(arrayList); } } if (istrue) { json = "1"; } } if (action == "deleteText") { string deleteid = Request["deleteid"]; StringBuilder sb = new StringBuilder(); sb.AppendFormat("delete from SWX_ImgItem where Id = {0}", deleteid); bool istrue = MSSQLHelper.Exists(sb.ToString()); json = "1"; } } catch (Exception ex) { string err = ex.Message; } if (!string.IsNullOrEmpty(json)) { Response.Write(json); Response.End(); } }
/// <summary> /// 群发 /// </summary> public string Send() { string type = Request["type"]; string data = Request["data"]; string access_token = AdminUtil.GetAccessToken(this); //获取access_token List <string> openidList = WXApi.GetOpenIDs(access_token); //获取关注者OpenID列表 UserInfo loginUser = AdminUtil.GetLoginUser(this); //当前登录用户 string resultMsg = null; //发送文本 if (type == "1") { resultMsg = WXApi.Send(access_token, WXMsgUtil.CreateTextJson(data, openidList)); } //发送图片 if (type == "2") { string path = MapPath(data); if (!File.Exists(path)) { return("{\"code\":0,\"msg\":\"要发送的图片不存在\"}"); } string msg = WXApi.UploadMedia(access_token, "image", path); string media_id = Tools.GetJsonValue(msg, "media_id"); resultMsg = WXApi.Send(access_token, WXMsgUtil.CreateImageJson(media_id, openidList)); } //发送图文消息 if (type == "3") { DataTable dt = ImgItemDal.GetImgItemTable(loginUser.OrgID, data); string articlesJson = ImgItemDal.GetArticlesJsonStr(this, access_token, dt); string newsMsg = WXApi.UploadNews(access_token, articlesJson); string newsid = Tools.GetJsonValue(newsMsg, "media_id"); resultMsg = WXApi.Send(access_token, WXMsgUtil.CreateNewsJson(newsid, openidList)); } //结果处理 if (!string.IsNullOrWhiteSpace(resultMsg)) { string errcode = Tools.GetJsonValue(resultMsg, "errcode"); string errmsg = Tools.GetJsonValue(resultMsg, "errmsg"); if (errcode == "0") { return("{\"code\":1,\"msg\":\"\"}"); } else { return("{\"code\":0,\"msg\":\"errcode:" + errcode + ", errmsg:" + errmsg + "\"}"); } } else { return("{\"code\":0,\"msg\":\"type参数错误\"}"); } }
public string GetMenusKey() { UserInfo user = AdminUtil.GetLoginUser(this); return(MenuDal.GetMenusLevel3(user)); }
public string GetMenus(string selectId) { UserInfo user = AdminUtil.GetLoginUser(this); return(MenuDal.GetMenusLevel2(user, selectId)); }
protected void Page_Load(object sender, EventArgs e) { string action = Request["action"]; string json = string.Empty; try { switch (action) { case "Load": int pageSize = Convert.ToInt32(Request["rows"]); int pageNum = Convert.ToInt32(Request["page"]); string userName = Session["WebUser"].ToString(); DataTable dt = MenuDal.GetMenuList(userName); int count = dt.Rows.Count; Dictionary <string, object> dic = new Dictionary <string, object>(); dic.Add("total", count); dic.Add("rows", dt); json = JsonConvert.SerializeObject(dic); break; case "edit": string id = Request["id"]; DataTable menudt = MenuDal.GetMenuByID(int.Parse(id)); string codelen = menudt.Rows[0]["Code"].ToString(); if (codelen.Length == 2) { menudt.Rows[0]["Code"] = "0"; } else { menudt.Rows[0]["Code"] = codelen.Substring(0, 2); } json = JsonConvert.SerializeObject(menudt); break; case "add": string codes = Request["code"]; string mname = Request["name"]; string mtype = Request["type"]; string mkey = Request["key"]; string murl = Request["url"]; string username = Session["WebUser"].ToString(); string mcode = ""; if (codes == "0") { mcode = MenuDal.GetOneCode(); } else { mcode = MenuDal.GetTwoCode(codes); } int addrow = MenuDal.AddMenu(mcode, mname, mtype, mkey, murl, username); if (addrow == 1) { json = "1"; } break; case "update": string menuId = Request["id"]; //string code = Request["code"]; string name = Request["name"]; string type = Request["type"]; string key = Request["key"]; string url = Request["url"]; int uprow = MenuDal.UpdateMenu(menuId, name, type, key, url); if (uprow == 1) { json = "1"; } break; case "deleteMenu": var ids = Request["id"]; if (ids != null) { int row = MenuDal.DeleteMenu(ids); if (row == 1) { json = "1"; } else { json = "0"; } } else { json = "0"; } break; case "deleteOneMenu": var oneCode = Request["code"]; if (oneCode != null) { int row = MenuDal.DeleteOneMenu(oneCode, AdminUtil.GetLoginUser(this)); if (row > 0) { json = "1"; } } break; case "updateWX": //同步到微信 UserInfo user = AdminUtil.GetLoginUser(this); string result = WXApi.CreateMenu(AdminUtil.GetAccessToken(this), user.OrgID); if (Tools.GetJsonValue(result, "errcode") == "0") { json = "{\"code\":1,\"msg\":\"\"}"; } else { json = "{\"code\":0,\"msg\":\"errcode:" + Tools.GetJsonValue(result, "errcode") + ", errmsg:" + Tools.GetJsonValue(result, "errmsg") + "\"}"; } break; case "tree": DataTable menudts = MenuDal.GetOneMenuList(AdminUtil.GetLoginUser(this)); List <MenuModel> flowList = new List <MenuModel>(); MenuModel flow; foreach (DataRow drFlowType in menudts.Rows) { flow = new MenuModel(); flow.id = drFlowType["Code"].ToString(); flow.level = 0; flow.parent = "-1"; flow.isLeaf = false; flow.expanded = true; flow.Id = int.Parse(drFlowType["Id"].ToString()); flow.Code = drFlowType["Code"].ToString(); flow.Name = drFlowType["Name"].ToString(); flow.Type = drFlowType["Type"].ToString(); flow.MenuKey = drFlowType["MenuKey"].ToString(); flow.Url = drFlowType["Url"].ToString(); flow.OrgID = drFlowType["OrgID"].ToString(); flowList.Add(flow); DataTable menudts2 = MenuDal.GetTwoMenuList(flow.Code); foreach (DataRow twoRow in menudts2.Rows) { MenuModel flow2 = new MenuModel(); flow2.id = twoRow["Code"].ToString(); flow2.level = 1; flow2.parent = twoRow["Code"].ToString().Substring(0, 2); flow2.isLeaf = true; flow2.expanded = true; flow2.Id = int.Parse(twoRow["Id"].ToString()); flow2.Code = twoRow["Code"].ToString(); flow2.Name = twoRow["Name"].ToString(); flow2.Type = twoRow["Type"].ToString(); flow2.MenuKey = twoRow["MenuKey"].ToString(); flow2.Url = twoRow["Url"].ToString(); flow2.OrgID = twoRow["OrgID"].ToString(); flowList.Add(flow2); } } json = JsonConvert.SerializeObject(flowList); break; case "menulist": DataTable onedt = MenuDal.GetOneMenuList(AdminUtil.GetLoginUser(this)); DataRow onerow = onedt.NewRow(); onerow["Code"] = 0; onerow["Name"] = "无"; onedt.Rows.InsertAt(onerow, 0); json = JsonConvert.SerializeObject(onedt); break; default: break; } } catch (Exception) { throw; } if (!string.IsNullOrEmpty(json)) { Response.Write(json); Response.End(); } }