/// <summary> /// 获取监测设备列表 /// </summary> /// <param name="condition">条件</param> /// <param name="page">数据页</param> /// <returns>数据页</returns> public DataPage GetList(InspectDataEntity condition, DataPage page) { string sql = null; List <DataParameter> parameters = new List <DataParameter>(); try { sql = this.GetQuerySql(condition, ref parameters); //分页关键字段及排序 page.KeyName = "Id"; if (string.IsNullOrEmpty(page.SortExpression)) { page.SortExpression = " A.UpdateTime DESC "; } using (IDataSession session = AppDataFactory.CreateMainSession()) { page = session.GetDataPage <InspectDataEntity>(sql, parameters.ToArray(), page); } return(page); } catch (Exception ex) { throw ex; } }
private void BindData() { string DeviceCodeLink = Request.QueryString["DeviceCodeLink"]; this.DeviceName.Text = DeviceCodeLink; InspectDataBLL bll = null; DataPage dp = new DataPage(); InspectDataEntity condition = new InspectDataEntity(); condition.DeviceCode = this.DeviceName.Text; condition.StartTime = this.StartTime.Text; condition.EndTime = this.EndTime.Text; try { bll = BLLFactory.CreateBLL <InspectDataBLL>(); PagerHelper.InitPageControl(this.AspNetPager1, dp, true); dp = bll.GetList(condition, dp); List <InspectDataEntity> list = dp.Result as List <InspectDataEntity>; this.GvList.DataSource = list; this.GvList.DataBind(); PagerHelper.SetPageControl(AspNetPager1, dp, true); } catch (Exception ex) { throw ex; } }
/// <summary> /// 获取监测数据列表 /// </summary> /// <param name="condition">条件</param> /// <param name="page">数据页</param> /// <returns>数据页</returns> public DataPage GetList(InspectDataEntity condition, DataPage page) { try { return(new InspectDataDAL().GetList(condition, page)); } catch (Exception ex) { throw ex; } }
protected void btQuery_Click(object sender, EventArgs e) { InspectDataEntity condition = new InspectDataEntity(); condition.ItemCode = this.ItemCode.Text; condition.StartTime = this.StartDate.Value; condition.EndTime = this.EndDate.Value; condition.DeviceType = this.DeviceType.Text; Session["InspectDataCondition"] = condition; Response.Redirect("InspectDataResult.aspx"); }
private void BindData() { InspectDataBLL bll = null; DataPage dp = new DataPage(); InspectDataEntity condition = Session["InspectDataCondition"] as InspectDataEntity; bll = BLLFactory.CreateBLL <InspectDataBLL>(); dp.PageIndex = 1; dp.PageSize = 100; dp = bll.GetList(condition, dp); List <InspectDataEntity> list = dp.Result as List <InspectDataEntity>; this.hiInspectData.Value = LAF.Common.Serialization.JsonConvertHelper.GetSerializes(list); }
private void BindData() { InspectDataBLL bll = null; DataPage dp = new DataPage(); InspectDataEntity condition = new InspectDataEntity(); try { bll = BLLFactory.CreateBLL <InspectDataBLL>(); condition.ItemCode = this.ItemCode.Text; condition.DeviceCode = this.DeviceCode.Text; condition.StartTime = this.StartTime.Text; condition.EndTime = this.EndTime.Text; condition.OrganID = this.OrganID.Text; condition.DeviceType = this.DeviceType.Text; PagerHelper.InitPageControl(this.AspNetPager1, dp, true); dp = bll.GetList(condition, dp); List <InspectDataEntity> list = dp.Result as List <InspectDataEntity>; this.GvList.DataSource = list; this.GvList.DataBind(); //for (int i = 0; i < this.GvList.Rows.Count; i++) //{ // string click = string.Format("return edit('{0}');", this.GvList.DataKeys[i]["Id"].ToString()); // (this.GvList.Rows[i].Cells[6].Controls[0] as WebControl).Attributes.Add("onclick", click); //} PagerHelper.SetPageControl(AspNetPager1, dp, true); } catch (Exception ex) { throw ex; } }
/// <summary> /// 获取查询语句 /// </summary> /// <param name="condition">查询条件</param> /// <param name="parameters">查询</param> /// <returns>查询语句</returns> private string GetQuerySql(InspectDataEntity condition, ref List <DataParameter> parameters) { StringBuilder sqlBuilder = new StringBuilder(); StringBuilder whereBuilder = new StringBuilder(); sqlBuilder.Append(" SELECT A.ID AS Id,A.DeviceCode,D.DeviceName, "); sqlBuilder.Append(" A.ItemCode,T.ItemName,A.InspectTime,A.InspectData,A.OrganID,O.ORGANDESC AS OrganDESC,A.UpdateTime "); sqlBuilder.Append(" FROM inspectdatainfo A "); sqlBuilder.Append(" LEFT JOIN deviceinfo D ON A.DeviceCode = D.DeviceCode"); sqlBuilder.Append(" LEFT JOIN inspectiteminfo T ON A.ItemCode = T.ItemCode"); sqlBuilder.Append(" LEFT JOIN t_organization O ON A.OrganID = O.OrganID "); //查询条件 if (!string.IsNullOrEmpty(condition.DeviceCode)) { whereBuilder.Append(" AND A.DeviceCode = @DeviceCode"); parameters.Add(new DataParameter { ParameterName = "DeviceCode", DataType = DbType.String, Value = condition.DeviceCode }); } if (string.IsNullOrEmpty(condition.ItemCode) == false) { whereBuilder.Append(" AND A.ItemCode = @ItemCode"); parameters.Add(new DataParameter { ParameterName = "ItemCode", DataType = DbType.String, Value = condition.ItemCode }); } if (string.IsNullOrEmpty(condition.DeviceType) == false) { whereBuilder.Append(" AND D.DeviceType = @DeviceType"); parameters.Add(new DataParameter { ParameterName = "DeviceType", DataType = DbType.String, Value = condition.DeviceType }); } if (string.IsNullOrEmpty(condition.OrganID) == false) { whereBuilder.Append(" AND O.OrganID = @OrganID"); parameters.Add(new DataParameter { ParameterName = "OrganID", DataType = DbType.String, Value = condition.OrganID }); } if (!string.IsNullOrEmpty(condition.StartTime)) { whereBuilder.Append(" AND A.InspectTime >= @StartTime"); parameters.Add(new DataParameter("StartTime", DateTime.Parse(condition.StartTime))); } if (!string.IsNullOrEmpty(condition.EndTime)) { whereBuilder.Append(" AND A.InspectTime < @EndTime"); parameters.Add(new DataParameter("EndTime", DateTime.Parse(condition.EndTime + " 23:59:59"))); } if (whereBuilder.Length > 0) { sqlBuilder.Append(" WHERE " + whereBuilder.ToString().Substring(4)); } return(sqlBuilder.ToString()); }
protected void Button1_Click(object sender, EventArgs e) { DateTime dt1 = DateTime.Parse("2018-5-1"); DateTime dt2 = DateTime.Parse("2018-5-26"); //删除数据 using (IDataSession session = AppDataFactory.CreateMainSession()) { session.ExecuteSql("delete from inspectdatainfo"); } List <string> salinitys = new List <string> { "30", "30.1", "31.1", "31.2", "31.3", "31.4" }; List <string> chlorophyls = new List <string> { "8", "9", "10", "11", "12", "13" }; List <string> turbiditys = new List <string> { "200", "210", "220", "230", "240", "250" }; Random rm = new Random(); //插入数据 while (dt1 < dt2) { using (IDataSession session = AppDataFactory.CreateMainSession()) { //温度值 InspectDataEntity infotemp = new InspectDataEntity(); infotemp.Id = Guid.NewGuid().ToString(); infotemp.DeviceCode = "ACTW-CAR1"; infotemp.ItemCode = "temp"; infotemp.InspectTime = dt1; infotemp.InspectData = (13.2 + double.Parse(dt1.Day.ToString()) * 1.5 / 30).ToString(); infotemp.OrganID = "b3a97409-f63f-46db-8277-b47014657217"; infotemp.UpdateTime = dt1; session.Insert <InspectDataEntity>(infotemp); //盐度值 InspectDataEntity infosalinity = new InspectDataEntity(); infosalinity.Id = Guid.NewGuid().ToString(); infosalinity.DeviceCode = "ACTW-CAR1"; infosalinity.ItemCode = "salinity"; infosalinity.InspectTime = dt1; infosalinity.InspectData = salinitys[rm.Next(0, 5)]; infosalinity.OrganID = "b3a97409-f63f-46db-8277-b47014657217"; infosalinity.UpdateTime = dt1; session.Insert <InspectDataEntity>(infosalinity); //叶绿素值 InspectDataEntity infchlorophyl = new InspectDataEntity(); infchlorophyl.Id = Guid.NewGuid().ToString(); infchlorophyl.DeviceCode = "ACLW-CAR1"; infchlorophyl.ItemCode = "chlorophyl"; infchlorophyl.InspectTime = dt1; infchlorophyl.InspectData = chlorophyls[rm.Next(0, 5)]; infchlorophyl.OrganID = "b3a97409-f63f-46db-8277-b47014657217"; infchlorophyl.UpdateTime = dt1; session.Insert <InspectDataEntity>(infchlorophyl); //浊度值 InspectDataEntity infturbidity = new InspectDataEntity(); infturbidity.Id = Guid.NewGuid().ToString(); infturbidity.DeviceCode = "ACLW-CAR1"; infturbidity.ItemCode = "turbidity"; infturbidity.InspectTime = dt1; infturbidity.InspectData = turbiditys[rm.Next(0, 5)]; infturbidity.OrganID = "b3a97409-f63f-46db-8277-b47014657217"; infturbidity.UpdateTime = dt1; session.Insert <InspectDataEntity>(infturbidity); } dt1 = dt1.AddMinutes(60); } Response.Write("end"); }