public static List <SYSCode> GetSYSCodeById(int id, FxtAPIClientExtend _fxtApi = null) { List <SYSCode> list = new List <SYSCode>(); FxtAPIClientExtend fxtApi = new FxtAPIClientExtend(_fxtApi); try { string name = "GetSYSCodeByID"; var para = new { id = id }; string jsonStr = Convert.ToString(EntranceApi.Entrance(name, para.ToJSONjss(), _fxtApi: fxtApi)); if (string.IsNullOrEmpty(jsonStr)) { fxtApi.Abort(); return(new List <SYSCode>()); } list = JsonHelp.ParseJSONList <SYSCode>(jsonStr); list.DecodeField <SYSCode>(); fxtApi.Abort(); } catch (Exception ex) { fxtApi.Abort(); log.Error("GetSYSCodeById(int id,FxtAPIClientExtend _fxtApi = null)", ex); } return(list); }
public ActionResult Save(ShopExpress entity) { var json = new JsonHelp(); try { if (entity.ID == 0) { json.IsSuccess = DB.ShopExpress.Insert(entity); json.Msg = "添加"; } else { json.IsSuccess = DB.ShopExpress.Update(entity); json.Msg = "修改"; } if (json.IsSuccess) { json.ReUrl = ControllerPath + "/Index"; //注册成功就跳转到 激活页 json.Msg += "成功"; } else { json.Msg += "失败"; } } catch (Exception e) { json.IsSuccess = false; json.Msg = "操作失败"; LogHelper.Error("保存快递公司失败:" + WebTools.getFinalException(e)); } return(Json(json)); }
/// <summary> /// 生产 /// </summary> /// <param name="userId"></param> /// <param name="seckillArticleId">秒杀商品id</param> /// <returns> /// 1:下单成功、 /// 0:下单失败 /// </returns> public int PushRedis(String userId, string seckillArticleId) { ModelQueueParam modelQueue = new ModelQueueParam(); modelQueue.userId = userId; modelQueue.seckillArticleId = seckillArticleId; //总值模式 lock (lockRedis) { //使用redis存储库存 int stockNum = (int)_redisdb.StringGet(seckillArticleId); if (stockNum > 0) { modelQueue.goodQuantity = stockNum; //此处是为了证明插入顺序和消费顺序一致 stockNum--; _redisdb.StringSet(seckillArticleId, stockNum); //进行生产-可以下单 #region 使用reids队列进行储存 var jsonStr = JsonHelp.ToJsonString(modelQueue); _redisdb.ListLeftPush("stock-y", jsonStr); #endregion return(1); } else { //库存已使用完成 return(0); } } }
public static void trest() { HttpClient client = new HttpClient(); string date = DateTime.Now.ToString("20140611195856"); var para = new { sinfo = JsonHelp.ToJSONjss(new { functionname = "getallotsurveyingproject", appid = "1003106", apppwd = "1300558927", signname = "4106DEF5-A760-4CD7-A6B2-8250420FCB18", time = date, code = GetCode("4106DEF5-A760-4CD7-A6B2-8250420FCB18", date, "getallotsurveyingproject") }), info = JsonHelp.ToJSONjss(new { uinfo = new { username = "******", token = "" }, appinfo = new { splatype = "android", stype = "yck", version = "4.26", vcode = "1", systypecode = "1003034", channel = "360" }, funinfo = new { username = "******", cityid = 1 }// new { userid = "3", cityid = 1, allotid = 1, data =obj2.ToJSONjss()} }) }; string strD = para.ToJSONjss(); HttpResponseMessage hrm = client.PostAsJsonAsync("http://localhost:50887/mobileapi/runflats", para).Result; string str = hrm.Content.ReadAsStringAsync().Result; }
public ActionResult GetFunctionList() { var data = GetFunctionData(); var jsonStr = JsonHelp.objectToJson(data); return(Content(jsonStr)); }
//读取实时数据 public void InitData() { int ComId = PuHua.Common.PhRequest.GetQueryInt("ComId", 0); if (ComId != 0) { object o = DynamicWebServices.InvokeWebService(WebServiceURL.BasInfoeWebService, "GetOnlineVechicleInfoByComIdWebService", new object[] { ComId, PageIndex, PageSize }); Result dr = PuHua.Common.JsonHelper.Deserialize <Result>(Convert.ToString(o)); if (JsonHelp.IsJson(dr.Info.ToString())) { glist = PuHua.Common.JsonHelper.Deserialize <List <GPSOnlineInfo> >(dr.Info.ToString()); if (glist.Count > 0) { foreach (GPSOnlineInfo gInfo in glist) { //计算未上线时长 TimeSpan ts = DateTime.Now - Convert.ToDateTime(gInfo.SendTime); gInfo.UnOnlineTime = ts.Days.ToString(); //格式化时间 //DateTime dt; //DateTime.TryParse(gInfo.SendTime, dt); gInfo.SendTime = Convert.ToDateTime(gInfo.SendTime).ToString("yyyy-MM-dd HH:mm:ss"); } } } rowCount = dr.RowNumber; AspNetPager1.RecordCount = Convert.ToInt32(rowCount); AspNetPager1.PageSize = 30; } }
public JsonHelp Delete(string idList) { JsonHelp json = new JsonHelp() { Status = "n", Msg = "删除数据失败" }; //是否为空 if (string.IsNullOrEmpty(idList)) { json.Msg = "未找到要删除的数据"; return(json); } var list = idList.Split(',').Select(a => Convert.ToInt32(a)).ToList(); var r = DB.Sys_BasicData.Delete(a => list.Contains(a.Id)); if (r > 0) { json.Status = "y"; json.Msg = "删除数据成功"; } //添加操作日志 DB.SysLogs.setAdminLog("Delete", "删除ID为[" + idList + "]的基础数据"); return(json); }
/// <summary> /// Send the request to WCF Service /// </summary> /// <param name="template">Object template like: User</param> /// <param name="action">Action like: Delete</param> /// <param name="method">Request method</param> /// <param name="t">Object like: User</param> private void SendRequest(string template, string action, HttpMethod method, T t) { string jsonData = JsonHelp.JsonSerialize <T>(t); if (string.IsNullOrEmpty(jsonData)) { return; } byte[] data = UnicodeEncoding.UTF8.GetBytes(jsonData); httpRequest = HttpWebRequest.CreateHttp(string.Format(basicUrl, template, action)); httpRequest.Method = method.ToString(); httpRequest.ContentType = "application/json"; httpRequest.ContentLength = data.Length; try { using (dataStream = httpRequest.GetRequestStream()) { dataStream.Write(data, 0, data.Length); } } catch (WebException we) { StrMessage = we.Message; } }
/// <summary> /// 生产 /// </summary> /// <param name="userId"></param> /// <param name="seckillArticleId"></param> /// <returns> /// 1:下单成功、 /// 0:下单失败 /// </returns> public int PushRedis(String userId, string seckillArticleId) { ModelQueueParam modelQueue = new ModelQueueParam(); modelQueue.userId = userId; modelQueue.seckillArticleId = seckillArticleId; //总值模式 lock (lockRedis) { if (GlobalParam.queueStockrNum > 0) { modelQueue.goodQuantity = GlobalParam.queueStockrNum; GlobalParam.queueStockrNum--; //进行生产-可以下单 #region 使用reids队列进行储存 var jsonStr = JsonHelp.ToJsonString(modelQueue); _redisdb.ListLeftPush("order-key", jsonStr); #endregion return(1); } else { //库存已使用完成 return(0); } } }
/// <summary> /// 获取群列表 /// </summary> public List <GroupInfo> GetGroups() { string html = qwin.POSTHtmlByWininetUTF8("http://s.web2.qq.com/api/get_group_name_list_mask2", "r=%7B%22hash%22%3A%22" + GetHash(user.QQID, user.Ptwebqq) + "%22%2C%22vfwebqq%22%3A%22" + user.Vfwebqq + "%22%7D"); ArrayList list = new ArrayList(); list.Add(JsonHelp.GetJson(html, "result", "gnamelist")); List <GroupInfo> ls = new List <GroupInfo>(); for (int i = 0; i < list.Count; i++) { GroupInfo gi = new GroupInfo(); Dictionary <string, object> dic = ((Dictionary <string, object>)list[i]); if (dic.ContainsKey("name")) { gi.Name = dic["name"].ToString(); } if (dic.ContainsKey("code")) { gi.Code = dic["code"].ToString(); } if (dic.ContainsKey("gid")) { gi.GID = dic["gid"].ToString(); } ls.Add(gi); } return(ls); }
public JsonHelp Delete(string idList) { JsonHelp json = new JsonHelp() { Status = "n", Msg = "删除数据失败" }; try { //是否为空 if (string.IsNullOrEmpty(idList)) { json.Msg = "未找到要删除的数据"; return(json); } var id = idList.TrimEnd(',').Split(',').Select(a => Convert.ToInt32(a)).ToList(); try { if (Delete(a => id.Contains(a.ProductId)) > 0) { json.Status = "y"; json.Msg = "删除数据成功"; //添加操作日志 DB.SysLogs.setAdminLog("Delete", "删除 名称为【" + idList + "】的商品信息"); } } catch (Exception ex) { LogHelper.Error("删除商品失败:" + ex.Message); } return(json); } catch (Exception e) { throw e.InnerException; } }
public ActionResult EditDeviceid(YLDeviceidData data) { ReturnResult result = new ReturnResult(); var model = db.YLDeviceidData.Where(d => d.Id == data.Id).SingleOrDefault(); model.Deviceid = data.Deviceid; model.DeviceidName = data.DeviceidName; model.AddTime = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); try { db.SaveChanges(); result.status = "200"; result.msg = "成功!"; result.data = ""; } catch (Exception) { result.status = "2"; result.msg = "失败!"; result.data = ""; } var json = JsonHelp.ObjectToString(result); return(Content(json)); }
public ActionResult AddDeviceid(YLDeviceidData data) { ReturnResult result = new ReturnResult(); YLDeviceidData model = new YLDeviceidData(); model.Deviceid = data.Deviceid; model.DeviceidName = data.DeviceidName; model.AddTime = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); try { db.YLDeviceidData.Add(model); db.SaveChanges(); result.status = "200"; result.msg = "成功!"; result.data = ""; } catch (Exception ex) { result.status = "2"; result.msg = "失败!"; result.data = ""; } var json = JsonHelp.ObjectToString(result); return(Content(json)); }
public static string FxtApi_GetJson(this FxtApi_SYSCity obj) { obj = JsonHelp.EncodeField <FxtApi_SYSCity>(obj); string jsonStr = JsonHelp.ToJSONjss(obj); return(jsonStr); }
public HttpResponseMessage Detail(string appId, string token, int Id) { ReturnResult obj = new ReturnResult(); //dynamic json = jData; //string appId = json.appId; //string token = json.token; //int Id = Convert.ToInt32(json.Id); try { var data = db.Equipment.Where(d => d.token == token && d.Id == Id).SingleOrDefault(); if (data != null) { obj.status = "0"; obj.msg = "ok"; obj.data = JsonHelp.ObjectToString(data); UtilSysLog.NewLogInfo(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"), "设备详情!", "Detail", appId, "Equipment"); } } catch (Exception ex) { obj.status = "6"; obj.msg = "失败"; obj.data = ""; UtilSysLog.NewLogErre(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"), ex.ToString()); } var resultObj = JsonConvert.SerializeObject(obj); HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(resultObj, Encoding.GetEncoding("UTF-8"), "application/json") }; return(result); }
/// <summary> /// 删除 /// </summary> /// <param name="idList"></param> /// <returns></returns> public ActionResult Delete(string idList) { var json = new JsonHelp() { Status = "n", Msg = "删除失败" }; try { var list = idList.Split(','); foreach (var item in list) { var path = Server.MapPath("/backup/" + item); FileOperate.DelFile(path); } json.Status = "y"; json.Msg = "删除成功"; DB.SysLogs.setAdminLog(Enums.EventType.Backup, "数据库删除成功[" + idList + "]"); } catch (Exception e) { LogHelper.Error("删除数据库出错:" + e.Message); } return(Json(json)); }
public void InitAllData() { int ComId = PuHua.Common.PhRequest.GetQueryInt("ComId", 0); if (ComId != 0) { object o = DynamicWebServices.InvokeWebService(WebServiceURL.BasInfoeWebService, "GetOnlineDataByComIdWebService", new object[] { ComId }); Result dr = PuHua.Common.JsonHelper.Deserialize <Result>(Convert.ToString(o)); if (JsonHelp.IsJson(dr.Info.ToString())) { gpslist = PuHua.Common.JsonHelper.Deserialize <List <GPSOnlineInfo> >(dr.Info.ToString()); if (glist.Count > 0) { foreach (GPSOnlineInfo gInfo in gpslist) { //计算未上线时长 TimeSpan ts = DateTime.Now - Convert.ToDateTime(gInfo.SendTime); gInfo.UnOnlineTime = ts.Days.ToString(); //格式化时间 gInfo.SendTime = Convert.ToDateTime(gInfo.SendTime).ToString("yyyy-MM-dd HH:mm:ss"); } } } } }
public JsonResult RestoreDataBase(string name) { var json = new JsonHelp() { Status = "n", Msg = "操作失败" }; try { #region 还原前先备份 //DataBaseHelper.CreateBackup(Before_Restore); #endregion #region 还原 DataBaseHelper.Restore(name); #endregion #region 还原后刷新缓存 DB.RefreshCache(); #endregion json.Status = "y"; json.Msg = "操作成功"; DB.SysLogs.setAdminLog(Enums.EventType.Backup, "数据库还原成功"); } catch (Exception e) { LogHelper.Error("还原数据库出错:" + e.Message); json.Msg = e.Message; } return(Json(json)); }
public async Task <ResultBean <IList <NewsListBean> > > GetNewsList(long time, string type) { string key = "ff3460eb96b32f8dca051ae1248a2e8a"; string result = await HttpHelp.getInstance().Get("http://v.juhe.cn/toutiao/index?type=" + type + "&key=" + key); NewsResultBean resultBean = JsonHelp.FromJson <NewsResultBean>(result); logger.info("GetNewsList - " + time + ", " + resultBean.error_code + ", " + resultBean.reason); ResultBean <IList <NewsListBean> > rb = new ResultBean <IList <NewsListBean> >(); if (resultBean != null && resultBean.result != null && resultBean.result.data != null) { rb.Success = true; rb.Message = "请求成功"; rb.Data = resultBean.result.data; foreach (NewsListBean b in rb.Data) { b.image = b.thumbnail_pic_s; } } else { rb.Success = false; rb.Message = "请求失败"; } return(rb); }
public JsonHelp RecommendMember(Member_Info member, decimal?zhitui) { JsonHelp json = new JsonHelp() { IsSuccess = true, Msg = "" }; var ServiceCenter = DB.Member_Info.FindEntity(member.ServiceCenterId); int i = 1; if (ServiceCenter != null) { var Recommend = DB.Member_Info.FindEntity(ServiceCenter.RecommendId); if (Recommend != null) { decimal?amount = zhitui; string commen = "代理津贴"; if (amount > 0) { InsertFin(Recommend, member, amount.Value, commen); } } } return(json); }
public object Save(Sys_BasicData entity, int type) { JsonHelp json = new JsonHelp() { Status = "n", Msg = "保存失败" }; entity.TypeId = type; if (!Any(p => p.Id == entity.Id)) { if (Insert(entity)) { json.Status = "y"; json.Msg = "保存成功"; //添加操作日志 DB.SysLogs.setAdminLog("Add", "新建名称为[" + entity.BasicDataName + "]的部门"); } } else { //禁止更新列 var model = DB.Sys_BasicData.FindEntity(entity.Id); WebTools.CopyToObject(entity, model); if (Update(model)) { json.Status = "y"; json.Msg = "保存成功"; //添加操作日志 DB.SysLogs.setAdminLog("Edit", "更新名称为[" + entity.BasicDataName + "]的部门"); } } return(json); }
public JsonHelp FenXiang(Member_Info member) { JsonHelp json = new JsonHelp() { IsSuccess = true, Msg = "" }; var Recommend = DB.Member_Info.FindEntity(member.RecommendId); for (int i = 1; i <= 2; i++) { if (Recommend == null) { return(json); } decimal?amount = 0; if (i == 1) { amount = System.DB.XmlConfig.XmlSite.FenXiang1; } else if (i == 2) { amount = System.DB.XmlConfig.XmlSite.FenXiang2; } if (amount > 0) { InsertFin(Recommend, member, amount.Value, "分享消费奖", "分享消费奖"); FuDaoJ(Recommend, amount.Value); } Recommend = DB.Member_Info.FindEntity(Recommend.RecommendId); } return(json); }
public ActionResult UpLoadTu(string File, string path = "/upload/qrimg/") { JsonHelp json = new JsonHelp(true); //上传和返回(保存到数据库中)的路径 var tempPath = Server.MapPath(path); if (!Directory.Exists(tempPath)) { Directory.CreateDirectory(tempPath);//不存在就创建目录 } if (Request.Files.Count <= 0) { return(Json(json)); } var imgFile = Request.Files["file"]; //创建图片新的名称 var nameImg = DateTime.Now.ToString("yyyyMMddHHmmssfff"); //获得上传图片的路径 var strPath = imgFile.FileName; //获得上传图片的类型(后缀名) var type = strPath.Substring(strPath.LastIndexOf(".", StringComparison.Ordinal) + 1).ToLower();; //拼写数据库保存的相对路径字符串 // savepath = "..\\" + path + "\\"; path += nameImg + "." + type; //拼写上传图片的路径 var uppath = Server.MapPath(path); // uppath += nameImg + "." + type; //上传图片 imgFile.SaveAs(uppath); return(Json(json.Msg = path)); }
public JsonResult Delete(string idList) { JsonHelp json = new JsonHelp() { Msg = "删除数据失败" }; //是否为空 if (string.IsNullOrEmpty(idList)) { json.Msg = "未找到要删除的数据"; return(Json(json)); } var ids = idList.TrimEnd(',').Split(',').ToList(); if (DB.ShopOrder.Any(a => ids.Contains(a.GUID) && a.State <= 0)) { var names = DB.ShopOrder.Where(a => ids.Contains(a.GUID)).Select(a => a.OrderCode) .ToList().Aggregate((m, n) => m + "," + n); if (DB.ShopOrder.Delete(a => ids.Contains(a.GUID)) > 0) { json.IsSuccess = true; json.Msg = "删除数据成功"; } //添加操作日志 DB.SysLogs.setMemberLog("Delete", "删除订单编号为[" + names + "]的商品订单 "); } else { json.Msg = "只能删除已取消或已关闭或已退货的订单,请确认"; } return(Json(json)); }
public JsonResult Delete(string idList) { JsonHelp json = new JsonHelp() { Msg = "删除数据失败" }; //是否为空 if (string.IsNullOrEmpty(idList)) { json.Msg = "未找到要删除的数据"; return(Json(json)); } var ids = idList.TrimEnd(',').Split(',').Select(a => Convert.ToInt32(a)).ToList(); if (DB.ShopExpress.Any(a => ids.Contains(a.ID))) { var names = DB.ShopExpress.Where(a => ids.Contains(a.ID)).Select(a => a.Name) .ToList().Aggregate((m, n) => m + "," + n); if (DB.ShopExpress.Delete(a => ids.Contains(a.ID)) > 0) { json.IsSuccess = true; json.Msg = "删除数据成功"; } //添加操作日志 DB.SysLogs.setAdminLog("Delete", "删除名字为[" + names + "]的快递公司 "); } else { json.Msg = "未找到要删除的对象,请刷新页面重试"; } return(Json(json)); }
public ActionResult SaveShangJia_Sku_TuTou() { CResult r = new CResult(); r.IsSuccess = false; r.Msg = "系统错误!"; try { var data = Request["data"]; var list = JsonHelp.josnToObject<List<ShangJia_Sku_TuTou>>(data); if (iopshelves.SaveShangJia_Sku_TuTou(list)) { r.IsSuccess = true; r.Msg = "保存成功!"; } else { r.IsSuccess = false; r.Msg = "保存错误!"; } return Json(r); } catch (Exception ex) { return Json(r); } }
public ActionResult Save(Fin_Draw DataBase) { JsonHelp json = new JsonHelp() { }; var Pwd2 = Common.CryptHelper.DESCrypt.Encrypt(Request["Pwd2"]); int weeknow = Convert.ToInt32(DateTime.Today.DayOfWeek); string tixian = DB.XmlConfig.XmlSite.DrawName; if (tixian.IndexOf(weeknow.ToString()) == -1) { json.Msg = "暂未到提现时间";; json.IsSuccess = false; } else { DataBase.DrawState = "未发放"; DataBase.CreateTime = DateTime.Now; var member = DB.Member_Info.FindEntity(CurrentUser.Id); DataBase.BankAccount = string.IsNullOrEmpty(member.BankAccount) ? member.BankCode : member.BankAccount; DataBase.BankAddress = member.BankAddress; DataBase.BankCode = member.BankCode; DataBase.BankName = member.BankName; DataBase.OpenBank = member.OpenBank; DB.Fin_Draw.Save(Pwd2, DataBase); if (json.IsSuccess) { json.ReUrl = ControllerPath + "/Index"; } } return(Json(json)); }
public JsonHelp FenXiang(DbMallEntities db, Member_Info member) { JsonHelp json = new JsonHelp() { IsSuccess = true, Msg = "" }; var Recommend = db.Member_Info.Where(p => p.MemberId == member.RecommendId).FirstOrDefault(); for (int i = 1; i <= 2; i++) { if (Recommend == null) { return(json); } decimal?amount = 0; if (i == 1) { amount = System.DB.XmlConfig.XmlSite.FenXiang1; } else if (i == 2) { amount = System.DB.XmlConfig.XmlSite.FenXiang1; } if (amount > 0) { InsertFin(db, Recommend, member, amount.Value, "分享消费奖", "分享消费奖"); FuDaoJ(db, Recommend, amount.Value); } Recommend = db.Member_Info.Where(p => p.MemberId == Recommend.RecommendId).FirstOrDefault(); } return(json); }
public IActionResult Index(string result, string genre) { var answers = JsonHelp.Deserialize <List <Answer> >(result); var model = GetTracks(answers, genre); return(View(model)); }
public ActionResult Add(string projectJson, string developersCompany, string managerCompany, UserCenter_LoginUserInfo loginUserInfo) { AjaxResult result = new AjaxResult("新增任务成功!!!"); Project project = JsonHelp.ParseJSONjss <Project>(projectJson); //检查是否已存在任务 Project exists = _unitOfWork.AllotFlowService.ExistsAllot(project); if (exists == null) { var ret = _unitOfWork.AllotFlowService.AddAllot(project, developersCompany, managerCompany, " 从调度中心 <span class=\"red\">创建任务</span>", loginUserInfo.NowCityId, loginUserInfo.FxtCompanyId, loginUserInfo.UserName, loginUserInfo.TrueName, SYSCodeManager.STATECODE_1); if (ret.AllotState == 0) { result.Result = false; result.Message = "新增任务失败。"; } } else { result.Result = false; result.Message = "任务重复"; } return(AjaxJson(result)); }