/// <summary> /// 保存新数据到本地 /// </summary> /// <param name="data"></param> /// <returns></returns> public bool InsertCodeData(object data) { DataTable dt = FStreamHelper.ExcelToDataTable(DataFilePath); DataTable newdt = FDataHelper.JArrToDT(data.ToString()); if (newdt.Rows.Count > 0) { foreach (var item in newdt.Rows) { dt.Rows.Add(item); } } return(FStreamHelper.ToExcel(dt, string.Empty, "sheet1", DataFilePath)); }
/// <summary> /// 根据时间获取数据 /// </summary> /// <param name="time1"></param> /// <param name="time2"></param> /// <returns></returns> public DataTable GetDataInfobyDate(string time1, string time2) { HttpHelper httphelper = new HttpHelper(); HttpItem httpitem = new HttpItem() { URL = string.Format("{0}/api/Codedata/bytime?time1={1}&time2={2}", Url, time1, time2), Method = "GET" }; HttpResult result = httphelper.GetHtml(httpitem); if (result.StatusCode == System.Net.HttpStatusCode.OK) { return(FDataHelper.JArrToDT(result.Html)); } return(null); }
/// <summary> /// 获取所有二维码数据 /// </summary> /// <returns></returns> public DataTable GetCodeData() { HttpHelper httphelper = new HttpHelper(); HttpItem httpitem = new HttpItem() { URL = string.Format("{0}/api/Codedata", Url), Method = "GET" }; HttpResult result = httphelper.GetHtml(httpitem); if (result.StatusCode == System.Net.HttpStatusCode.OK) { return(FDataHelper.JArrToDT(result.Html)); } return(null); }
/// <summary> /// 根据id更新本地数据 /// </summary> /// <param name="id"></param> /// <param name="data"></param> /// <returns></returns> public bool UpdateInfobyId(string id, object data) { DataTable dt = FStreamHelper.ExcelToDataTable(DataFilePath); DataRow[] drt = dt.Select("id = '" + id + "'"); if (drt != null) { if (drt.Length > 0) { foreach (var item in drt) { dt.Rows.Remove(item); } } } DataTable newdt = FDataHelper.JArrToDT(data.ToString()); foreach (var item in newdt.Rows) { dt.Rows.Add(item); } return(FStreamHelper.ToExcel(dt, string.Empty, "sheet1", DataFilePath)); }