/// <summary> /// 获取Article列表 /// </summary> /// <param name="keyword">查询关键字</param> /// <param name="isUse">是否可用:1为可用,0为不可用,如果为空则默认为1</param> /// <returns>Json字符串</returns> public string GetArticles(string keyword, int type = 0, int isUse = 1) { JsonStateResult jsonResult = new JsonStateResult(); jsonResult.Error = -1001; jsonResult.Msg = "null"; string sql = "select * from Hqlk_Article where 1=1 "; StringBuilder sbSql = new StringBuilder(); Hqlk_Article model = new Hqlk_Article(); model.IsUse = isUse; if (type == 1 || type == 2) { sbSql.Append("and Type=@Type "); model.Type = type; } if (keyword.AsNullOrWhiteSpace() == false) { sbSql.Append("and IsUse=@IsUse and Title like @Title or Description like @Description or Content like @Content "); model.Title = string.Format("%{0}%", keyword); model.Description = string.Format("%{0}%", keyword); model.Content = string.Format("%{0}%", keyword); } sbSql.Insert(0, sql); var list = _db_hqlk_article.GetList(sbSql.ToStr(), model); if (list != null && list.Count() > 0) { jsonResult.Error = 1000; jsonResult.Msg = "ok"; list = list.OrderBy(a => a.SortingIndex); jsonResult.Data = list; } return(JsonConvert.SerializeObject(jsonResult)); }
public JsonResult ChangePassword(string id, string password) { JsonStateResult result = new JsonStateResult(); try { var user = _dataApiService.IsExistOwner(id); if (user != null) { user.Password = (password + id).ToSHA1(); _dataApiService.UpdateOwner(user); result.Error = 0; return(Json(result, JsonRequestBehavior.AllowGet)); } result.Error = 1; result.Msg = "非法用户"; return(Json(result, JsonRequestBehavior.AllowGet)); } catch (Exception) { result.Error = 1; result.Msg = "出错了"; return(Json(result, JsonRequestBehavior.AllowGet)); } }
public JsonResult GetAdverLogo(decimal latitude, decimal longitude, int pageIndex, int pageSize) { JsonStateResult r = new JsonStateResult(); int areaId = _service.GetAreaByPosition(latitude, longitude); int count = 0; var list = _service.GetUserByAreaId(out count, areaId: areaId, pageIndex: pageIndex, pageSize: pageSize); if (list != null && list.Count() > 0) { r.Data = list.Where(l => l.Level == 0); r.Data2 = list.Where(l => l.Level == 1); if (pageSize > 50) { r.Data4 = list.Where(t => string.IsNullOrEmpty(t.Company) == false).Select(t => t.Company); } else { r.Data4 = _service.GetUserByAreaId(out count, areaId: areaId, pageIndex: 1, pageSize: 999).Where(t => string.IsNullOrEmpty(t.Company) == false).Select(t => t.Company); } r.Msg = areaId.ToString(); r.Error = 0; } r.Data3 = _service.GetBanner().Select(t => t.Url); return(Json(r)); }
public JsonResult EditDataById(Api_EquipmentData model, int flag = 0) { JsonStateResult result = new JsonStateResult(); try { if (flag > 0)//新增 { if (_dataApiService.IsExistEquipmentData(model.EquipmentId, model.Mark.ToUpper()) != null) { result.Error = 1; result.Msg = "已存在标识为“" + model.Mark + "”的数据了,请勿重复添加"; return(Json(result, JsonRequestBehavior.AllowGet)); } _dataApiService.InsertEquipmentData(model); result.Error = 0; result.Msg = "添加成功"; return(Json(result, JsonRequestBehavior.AllowGet)); } _dataApiService.UpdateEquimentData(model); result.Error = 0; result.Msg = "修改成功"; return(Json(result, JsonRequestBehavior.AllowGet)); } catch (Exception) { result.Error = 1; result.Msg = "修改失败"; return(Json(result, JsonRequestBehavior.AllowGet)); } }
public JsonResult UpLoadLogo(string openId, HttpPostedFileBase logo) { JsonStateResult r = new JsonStateResult(); if (string.IsNullOrEmpty(openId)) { return(Json(r)); } try { string fileName = string.Format("{0}.jpg", DateTime.Now.ToString("yyyy_MM_dd_hh_mm_ss_hhh")); string dir = CommonVariable.baseUrl + openId + "/images/logo/"; if (!Directory.Exists(Server.MapPath(dir))) { Directory.CreateDirectory(Server.MapPath(dir)); } logo.SaveAs(Server.MapPath(dir + fileName)); if (_service.UpdateLogo(openId, dir + fileName) > 0) { r.Error = 0; } } catch (Exception) {} return(Json(r)); }
public JsonResult SetUserArea(string area, string openId) { JsonStateResult j = new JsonStateResult(); if (_service.SetUserArea(area, openId) > 0) { j.Error = 0; } return(Json(j)); }
public JsonResult AjaxDeletePropagandaBannerById(int id) { JsonStateResult j = new JsonStateResult(); if (_propagandaUserService.DeletePropagandaBannerById(id) > 0) { j.Error = 0; } return(Json(j)); }
public JsonResult UpdateUserIntro(int userId, string company, string weixinAccount, string qq, string email, string address) { JsonStateResult r = new JsonStateResult(); if (_service.UpdateUserIntroById(userId, company, weixinAccount, qq, email, address) > 0) { r.Error = 0; } return(Json(r)); }
public JsonResult DeletAdverByAId(int aId) { JsonStateResult r = new JsonStateResult(); if (_service.DeletAdverByAId(aId) > 0) { r.Error = 0; } return(Json(r)); }
public JsonResult UpdateUserInfo(string openId, string head, string name) { JsonStateResult r = new JsonStateResult(); if (_service.UpdateUserInfo(openId, head, name) > 0) { r.Error = 0; } return(Json(r)); }
public JsonResult GetArea() { JsonStateResult j = new JsonStateResult(); var list = _service.GetAllAreas(); if (list != null && list.Count() > 0) { j.Error = 0; j.Data = list; } return(Json(j)); }
public JsonResult AjaxChangeEquipmentDataState(int state, int eId, string mark) { JsonStateResult r = new JsonStateResult(); r.Error = 1; r.Msg = "操作失败"; if (_dataApiService.ChangeEquipmentDataState(state, eId) && TcpClient(string.Format("key{0}={1}", mark, state))) { r.Error = 0; } return(Json(r)); }
public JsonResult GetUserByOpenId(string openId) { JsonStateResult r = new JsonStateResult(); var model = _service.GetUserAndAdverByUserOpenId(openId); if (model != null) { r.Error = 0; r.Data = model; } return(Json(r)); }
public JsonResult AjaxGetPropagandaBanner() { JsonStateResult j = new JsonStateResult(); var list = _propagandaUserService.GetBanner(); if (list != null && list.Count() > 0) { j.Error = 0; j.Data = list; } return(Json(j)); }
public JsonResult GetAreaByPosition(decimal latitude, decimal longitude) { JsonStateResult j = new JsonStateResult(); var areaId = _service.GetAreaByPosition(latitude, longitude); if (areaId > 0) { j.Error = 0; j.Data = areaId; } return(Json(j)); }
public JsonResult AjaxAddEquipment(Api_ClientEquipment model, int flag) { JsonStateResult result = new JsonStateResult(); string loginUserId = loginUser.Id; var equipment = _dataApiService.IsExistEquipment(0, model.Name); if (flag == 0)//添加 { if (equipment != null) { result.Error = 1; result.Msg = "已经添加过此设备"; return(Json(result, JsonRequestBehavior.AllowGet)); } model.IsDelete = false; _dataApiService.AddEquipment(model); if (model.Id > 0) { result.Error = 0; result.Msg = "添加成功"; return(Json(result, JsonRequestBehavior.AllowGet)); } result.Error = 2; result.Msg = "添加失败,请重试"; return(Json(result, JsonRequestBehavior.AllowGet)); } if (flag == 1)//修改 { equipment.Sorting = model.Sorting; equipment.Address = model.Address; equipment.Intro = model.Intro; equipment.IsControl = model.IsControl; equipment.IsPublic = model.IsPublic; equipment.Status = model.Status; try { _dataApiService.UpdateEquipment(equipment); result.Error = 0; result.Msg = "修改成功"; return(Json(result, JsonRequestBehavior.AllowGet)); } catch (Exception) { result.Error = 2; result.Msg = "修改失败,请重试"; return(Json(result, JsonRequestBehavior.AllowGet)); } } result.Error = 3; result.Msg = "未知错误"; return(Json(result, JsonRequestBehavior.AllowGet)); }
public JsonResult GetBusinessByKeyword(string keyword, int areaId) { JsonStateResult j = new JsonStateResult(); int count = 0; var list = _service.GetUserByAreaId(out count, areaId: areaId, keyword: keyword, pageSize: 999); if (list != null && list.Count() > 0) { j.Error = 0; j.Data = list; } return(Json(j)); }
public string GetAdverByUserId(int userId) { JsonStateResult r = new JsonStateResult(); IList <string> images = null; var list = _service.GetAdverByUserId(userId, out images); if (list != null && list.Count() > 0) { r.Error = 0; r.Data = list; r.Data2 = images; } return(JsonConverter.SerializeObject(r)); }
public JsonResult CheckUserKey(string userkey) { JsonStateResult result = new JsonStateResult(); var owner = _dataApiService.IsExistOwner(userkey); if (owner != null) { result.Error = 0; return(Json(result, JsonRequestBehavior.AllowGet)); } result.Error = 1; result.Msg = "非法UserKey"; return(Json(result, JsonRequestBehavior.AllowGet)); }
public ActionResult GetDataById(int id) { JsonStateResult result = new JsonStateResult(); var data = _dataApiService.GetDataById(id); if (data != null) { result.Error = 0; result.Data = data; return(Content(JsonConverter.SerializeObject(result))); } result.Error = 1; result.Msg = "不存在的设备"; return(Json(result, JsonRequestBehavior.AllowGet)); }
public ActionResult GetDataList(string ownerId) { JsonStateResult result = new JsonStateResult(); var list = _dataApiService.GetEquipmentData(ownerId); if (list != null && list.Count > 0) { result.Error = 0; result.Msg = list.Count.ToString(); result.Data = list.OrderBy(d => d.SortingIndex); return(Content(JsonConverter.SerializeObject(result))); } result.Error = 1; result.Msg = "没有数据"; return(Json(result, JsonRequestBehavior.AllowGet)); }
//[JsonException] public ActionResult GetAllDataByEquipmentIdAndMark(int equipmentId, string mark, ChartSearchParam param, int pageIndex, int pageSize) { JsonStateResult result = new JsonStateResult(); var list = _dataApiService.GetAllDataByEquipmentIdAndMark(equipmentId, mark, param, pageIndex, pageSize); if (list != null && list.Count() > 0) { result.Error = 0; result.Msg = _dataApiService.GetAllDataByEquipmentIdAndMarkCount(equipmentId, mark, param).ToString(); result.Data = list; return(Content(JsonConverter.SerializeObject(result))); } result.Error = 1; result.Msg = "没有数据"; return(Json(result, JsonRequestBehavior.AllowGet)); }
public JsonResult GetDataListByEquipmentId(int euipmentId) { JsonStateResult result = new JsonStateResult(); var list = _dataApiService.GetEquipmentDataByEquipmentId(euipmentId, 1, 9999); if (list != null && list.Count > 0) { result.Error = 0; result.Msg = list.Count.ToString(); result.Data = list; return(Json(result, JsonRequestBehavior.AllowGet)); } result.Error = 1; result.Msg = "没有数据"; return(Json(result, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 根据id获取文章 /// </summary> /// <param name="id"></param> /// <returns></returns> public string GetArticleById(int id) { JsonStateResult jsonResult = new JsonStateResult(); jsonResult.Error = -1001; jsonResult.Msg = "null"; Hqlk_Article model = _db_hqlk_article.Get(id); if (model != null) { jsonResult.Error = 1000; jsonResult.Msg = "ok"; jsonResult.Data = model; } return(JsonConvert.SerializeObject(jsonResult)); }
public ActionResult WeiXinLogin(string code, string rawData, string signature, string encryptedData, string iv) { JsonStateResult j = new JsonStateResult(); if (string.IsNullOrEmpty(code) || string.IsNullOrEmpty(rawData) || string.IsNullOrEmpty(signature) || string.IsNullOrEmpty(encryptedData) || string.IsNullOrEmpty(iv)) { j.Msg = "缺失参数"; return(Json(j, JsonRequestBehavior.AllowGet)); } string result = CommonVariable.HttpGet(string.Format("https://api.weixin.qq.com/sns/jscode2session?appid={0}&secret={1}&js_code={2}&grant_type=authorization_code", CommonVariable.appid, CommonVariable.secret, code)); string openId = string.Empty; string sessionKey = string.Empty; Dictionary <string, string> dicResult = JsonConverter.DeserializeObject <Dictionary <string, string> >(result); if (!dicResult.ContainsKey("openid") || !dicResult.ContainsKey("session_key")) { return(Json(j, JsonRequestBehavior.AllowGet)); } openId = dicResult["openid"]; sessionKey = dicResult["session_key"]; string signature2 = (rawData + sessionKey).ToSHA1(); if (string.Compare(signature, signature2, true) != 0) { j.Msg = "非法请求,签名校验失败"; return(Json(j, JsonRequestBehavior.AllowGet)); } string data = Cryptography.AESDecrypt(encryptedData, sessionKey, iv); if (string.IsNullOrEmpty(data)) { j.Msg = "AES解密出错"; return(Json(j, JsonRequestBehavior.AllowGet)); } WeiXinLoginUser user = JsonConverter.DeserializeObject <WeiXinLoginUser>(data); if (string.IsNullOrEmpty(user.openId) || string.IsNullOrEmpty(user.avatarUrl) || string.IsNullOrEmpty(user.nickName)) { j.Msg = "json反序列化出错"; return(Json(j, JsonRequestBehavior.AllowGet)); } j.Error = 0; j.Data = user; return(Json(j, JsonRequestBehavior.AllowGet)); }
public JsonResult UpdateMobile(string openId, string mobile) { JsonStateResult r = new JsonStateResult(); var model = _service.ExistUser(new Propaganda_User { WeiXinOpenId = openId.Trim() }); if (model != null) { model.Account = mobile.Trim(); if (_service.UpdateUser(model)) { r.Data = model.Id; r.Error = 0; } } return(Json(r)); }
//[JsonException] public JsonResult DeleteEquipmentById(int id) { JsonStateResult result = new JsonStateResult(); try { _dataApiService.DeleteEquipment(id); result.Error = 0; result.Msg = "删除成功"; return(Json(result, JsonRequestBehavior.AllowGet)); } catch (Exception) { result.Error = 1; result.Msg = "删除失败"; return(Json(result, JsonRequestBehavior.AllowGet)); } }
public JsonResult DeleteDataByEquipmentId(int equipmentId, string mark) { JsonStateResult result = new JsonStateResult(); try { _dataApiService.DeleteDataByEquipmentIdAndMark(equipmentId, mark); result.Error = 0; result.Msg = "删除成功"; return(Json(result, JsonRequestBehavior.AllowGet)); } catch (Exception) { result.Error = 1; result.Msg = "删除失败"; return(Json(result, JsonRequestBehavior.AllowGet)); } }
public JsonResult CompleteInfo(string id, string userName, int cid, string cname) { JsonStateResult result = new JsonStateResult(); try { var user = _dataApiService.IsExistOwner(id); user.Name = userName; _dataApiService.UpdateOwner(user); result.Error = 0; return(Json(result, JsonRequestBehavior.AllowGet)); } catch (Exception) { result.Error = 1; result.Msg = "出错了"; return(Json(result, JsonRequestBehavior.AllowGet)); } }
public JsonResult PublishAdver(int userId, string openId, HttpPostedFileBase adver, string desc, int type, string url) { JsonStateResult r = new JsonStateResult(); try { string fileName = string.Format("{0}.jpg", DateTime.Now.ToString("yyyy_MM_dd_hh_mm_ss_hhh")); string dir = CommonVariable.baseUrl + openId + "/images/adver/"; if (!Directory.Exists(Server.MapPath(dir))) { Directory.CreateDirectory(Server.MapPath(dir)); } adver.SaveAs(Server.MapPath(dir + fileName)); _service.AddAdverAndAdverContent(userId, desc, type, dir + fileName, url); r.Error = 0; } catch (Exception e) { } return(Json(r)); }