public string GetMaxLng(string hostGUID) { object ob = DbHelperSQL.GetSingle("select max(fLng) from tLightInfoes where iEnable=1 and sHostInfoGUID='" + hostGUID + "'"); LumluxSSYDB.BLL.tHostInfo host_bll = new LumluxSSYDB.BLL.tHostInfo(); LumluxSSYDB.Model.tHostInfo host_mod = host_bll.GetModel(hostGUID); if (ob != null) { return(comMax(Convert.ToSingle(ob.ToString()), Convert.ToSingle(host_mod.fLng))); } return(""); }
/// <summary> /// 得到一个对象实体 /// </summary> public LumluxSSYDB.Model.tHostInfo GetModel(string sGUID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 sGUID,sName,fLng,fLat,iIDType,sID_ID,sID_Addr,sID_IP,sID_MAC,sID_SIM,sHardware_Version,iHardware_Type,iState_Online,iState_Alarm,iState_Enable,iState_Command,sGroupInfoGUID,sProjectInfoGUID,dCreateDate,dUpdateTime,sRemark,sHostInfoStateGUID from tHostInfo "); strSql.Append(" where sGUID=@sGUID "); SqlParameter[] parameters = { new SqlParameter("@sGUID", SqlDbType.Char, 36) }; parameters[0].Value = sGUID; LumluxSSYDB.Model.tHostInfo model = new LumluxSSYDB.Model.tHostInfo(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
// // GET: /Lamp/AlarmPage/ public ActionResult Index() { string strLightName = " 1=1 and "; string curTime = DateTime.Now.ToString("yyyy-MM-dd"); DateTime dtStart = DateTime.Now.AddDays(-7);//DateTime.Parse("1999-01-01"); DateTime dtEnd = DateTime.Parse(curTime).Add(new TimeSpan(23, 59, 59)); if (Request.QueryString["sGUID"] != null) { ViewBag.sHostGUID = Request.QueryString["sGUID"].ToString(); AlarmSelectedGUID = Request.QueryString["sGUID"].ToString(); LumluxSSYDB.BLL.tHostInfo thostbll = new LumluxSSYDB.BLL.tHostInfo(); LumluxSSYDB.Model.tHostInfo thostmode = thostbll.GetModel(AlarmSelectedGUID); if (thostmode != null) { ViewBag.HostNames = thostmode.sName; } //getdataresource gd = new getdataresource(); //PagingHelper<AlarmInfo> DataPaging = new PagingHelper<AlarmInfo>(10, GetDataSouceByTime(AlarmSelectedGUID, dtStart, dtEnd, 10)); List <AlarmInfo> DataPaging = GetDataSouceByTime(PrjGUID, AlarmSelectedGUID, dtStart, dtEnd, 0, strLightName); ViewBag.CurPageIndex = 1;//当前页 ViewBag.CurPageIndex = 1; if (DataPaging.Count > 0) { ViewBag.iCount = DataPaging[0].iCount;//总记录 ViewBag.iPage = (int)Math.Ceiling(Convert.ToInt32(DataPaging[0].iCount) / (double)10); ViewBag.Alarms = DataPaging; } else { ViewBag.iCount = 0;//总记录 ViewBag.iPage = 0; ViewBag.Alarms = new List <AlarmInfo>(); } ViewBag.vHost = new List <LumluxSSYDB.Model.tHostInfo>(); } else { #region MyRegion LumluxSSYDB.BLL.tHostInfo lbt = new LumluxSSYDB.BLL.tHostInfo(); //and iState_Alarm=1 List <LumluxSSYDB.Model.tHostInfo> listhost = lbt.GetModelList("sProjectInfoGUID='" + PrjGUID + "' and iState_Enable='" + (int)StateEnable.Enable + "' ");; if (listhost.Count > 0) { ViewBag.vHost = listhost; } else { ViewBag.vHost = new List <LumluxSSYDB.Model.tHostInfo>(); } #endregion // ViewBag.Alarms = new List<AlarmInfo>(); List <AlarmInfo> DataPagingall = GetDataSouceByTime(PrjGUID, dtStart, dtEnd, 0, strLightName); ViewBag.CurPageIndex = 1;; //当前页 ViewBag.HostNames = "单灯信息"; //"全部主机"; if (DataPagingall.Count > 0) { ViewBag.iCount = DataPagingall[0].iCount; //总记录 ViewBag.iPage = (int)Math.Ceiling(Convert.ToInt32(DataPagingall[0].iCount) / (double)10); //总页数 ViewBag.Alarms = DataPagingall; } else { ViewBag.iCount = 0;//总记录 ViewBag.iPage = 0; ViewBag.Alarms = new List <AlarmInfo>(); } } #region MyRegion List <PrjectSetInfoVM> pslist = new List <PrjectSetInfoVM>(); LumluxSSYDB.BLL.tPrjectSet light_bll = new LumluxSSYDB.BLL.tPrjectSet(); LightsViewModel lightVM = new LightsViewModel(); DataTable dt = light_bll.GetTableByWhere("sPrjectGUID='" + PrjGUID + "' and sKey like '%Light_Image_%'"); if (dt != null) { PrjectSetInfoVM psm; foreach (DataRow dr in dt.Rows) { psm = addprjectsetInfo(dr); pslist.Add(psm); } ViewBag.AlarmDemos = pslist; } else { ViewBag.AlarmDemos = new List <PrjectSetInfoVM>(); } #endregion return(View()); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(LumluxSSYDB.Model.tHostInfo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into tHostInfo("); strSql.Append("sGUID,sName,fLng,fLat,iIDType,sID_ID,sID_Addr,sID_IP,sID_MAC,sID_SIM,sHardware_Version,iHardware_Type,iState_Online,iState_Alarm,iState_Enable,iState_Command,sGroupInfoGUID,sProjectInfoGUID,dCreateDate,dUpdateTime,sRemark,sHostInfoStateGUID)"); strSql.Append(" values ("); strSql.Append("@sGUID,@sName,@fLng,@fLat,@iIDType,@sID_ID,@sID_Addr,@sID_IP,@sID_MAC,@sID_SIM,@sHardware_Version,@iHardware_Type,@iState_Online,@iState_Alarm,@iState_Enable,@iState_Command,@sGroupInfoGUID,@sProjectInfoGUID,@dCreateDate,@dUpdateTime,@sRemark,@sHostInfoStateGUID)"); SqlParameter[] parameters = { new SqlParameter("@sGUID", SqlDbType.Char, 36), new SqlParameter("@sName", SqlDbType.NVarChar, 100), new SqlParameter("@fLng", SqlDbType.Float, 8), new SqlParameter("@fLat", SqlDbType.Float, 8), new SqlParameter("@iIDType", SqlDbType.Int, 4), new SqlParameter("@sID_ID", SqlDbType.VarChar, 20), new SqlParameter("@sID_Addr", SqlDbType.NVarChar, 100), new SqlParameter("@sID_IP", SqlDbType.NVarChar, 100), new SqlParameter("@sID_MAC", SqlDbType.NVarChar, 100), new SqlParameter("@sID_SIM", SqlDbType.NVarChar, 100), new SqlParameter("@sHardware_Version", SqlDbType.NVarChar, 100), new SqlParameter("@iHardware_Type", SqlDbType.Int, 4), new SqlParameter("@iState_Online", SqlDbType.Int, 4), new SqlParameter("@iState_Alarm", SqlDbType.Int, 4), new SqlParameter("@iState_Enable", SqlDbType.Int, 4), new SqlParameter("@iState_Command", SqlDbType.Int, 4), new SqlParameter("@sGroupInfoGUID", SqlDbType.Char, 36), new SqlParameter("@sProjectInfoGUID", SqlDbType.Char, 36), new SqlParameter("@dCreateDate", SqlDbType.DateTime), new SqlParameter("@dUpdateTime", SqlDbType.DateTime), new SqlParameter("@sRemark", SqlDbType.NVarChar, 500), new SqlParameter("@sHostInfoStateGUID", SqlDbType.Char, 36) }; parameters[0].Value = model.sGUID; parameters[1].Value = model.sName; parameters[2].Value = model.fLng; parameters[3].Value = model.fLat; parameters[4].Value = model.iIDType; parameters[5].Value = model.sID_ID; parameters[6].Value = model.sID_Addr; parameters[7].Value = model.sID_IP; parameters[8].Value = model.sID_MAC; parameters[9].Value = model.sID_SIM; parameters[10].Value = model.sHardware_Version; parameters[11].Value = model.iHardware_Type; parameters[12].Value = model.iState_Online; parameters[13].Value = model.iState_Alarm; parameters[14].Value = model.iState_Enable; parameters[15].Value = model.iState_Command; parameters[16].Value = model.sGroupInfoGUID; parameters[17].Value = model.sProjectInfoGUID; parameters[18].Value = model.dCreateDate; parameters[19].Value = model.dUpdateTime; parameters[20].Value = model.sRemark; parameters[21].Value = model.sHostInfoStateGUID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public LumluxSSYDB.Model.tHostInfo DataRowToModel(DataRow row) { LumluxSSYDB.Model.tHostInfo model = new LumluxSSYDB.Model.tHostInfo(); if (row != null) { if (row["sGUID"] != null) { model.sGUID = row["sGUID"].ToString(); } if (row["sName"] != null) { model.sName = row["sName"].ToString(); } if (row["fLng"] != null && row["fLng"].ToString() != "") { model.fLng = decimal.Parse(row["fLng"].ToString()); } if (row["fLat"] != null && row["fLat"].ToString() != "") { model.fLat = decimal.Parse(row["fLat"].ToString()); } if (row["iIDType"] != null && row["iIDType"].ToString() != "") { model.iIDType = int.Parse(row["iIDType"].ToString()); } if (row["sID_ID"] != null) { model.sID_ID = row["sID_ID"].ToString(); } if (row["sID_Addr"] != null) { model.sID_Addr = row["sID_Addr"].ToString(); } if (row["sID_IP"] != null) { model.sID_IP = row["sID_IP"].ToString(); } if (row["sID_MAC"] != null) { model.sID_MAC = row["sID_MAC"].ToString(); } if (row["sID_SIM"] != null) { model.sID_SIM = row["sID_SIM"].ToString(); } if (row["sHardware_Version"] != null) { model.sHardware_Version = row["sHardware_Version"].ToString(); } if (row["iHardware_Type"] != null && row["iHardware_Type"].ToString() != "") { model.iHardware_Type = int.Parse(row["iHardware_Type"].ToString()); } if (row["iState_Online"] != null && row["iState_Online"].ToString() != "") { model.iState_Online = int.Parse(row["iState_Online"].ToString()); } if (row["iState_Alarm"] != null && row["iState_Alarm"].ToString() != "") { model.iState_Alarm = int.Parse(row["iState_Alarm"].ToString()); } if (row["iState_Enable"] != null && row["iState_Enable"].ToString() != "") { model.iState_Enable = int.Parse(row["iState_Enable"].ToString()); } if (row["iState_Command"] != null && row["iState_Command"].ToString() != "") { model.iState_Command = int.Parse(row["iState_Command"].ToString()); } if (row["sGroupInfoGUID"] != null) { model.sGroupInfoGUID = row["sGroupInfoGUID"].ToString(); } if (row["sProjectInfoGUID"] != null) { model.sProjectInfoGUID = row["sProjectInfoGUID"].ToString(); } if (row["dCreateDate"] != null && row["dCreateDate"].ToString() != "") { model.dCreateDate = DateTime.Parse(row["dCreateDate"].ToString()); } if (row["dUpdateTime"] != null && row["dUpdateTime"].ToString() != "") { model.dUpdateTime = DateTime.Parse(row["dUpdateTime"].ToString()); } if (row["sRemark"] != null) { model.sRemark = row["sRemark"].ToString(); } if (row["sHostInfoStateGUID"] != null) { model.sHostInfoStateGUID = row["sHostInfoStateGUID"].ToString(); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(LumluxSSYDB.Model.tHostInfo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update tHostInfo set "); strSql.Append("sName=@sName,"); strSql.Append("fLng=@fLng,"); strSql.Append("fLat=@fLat,"); strSql.Append("iIDType=@iIDType,"); strSql.Append("sID_ID=@sID_ID,"); strSql.Append("sID_Addr=@sID_Addr,"); strSql.Append("sID_IP=@sID_IP,"); strSql.Append("sID_MAC=@sID_MAC,"); strSql.Append("sID_SIM=@sID_SIM,"); strSql.Append("sHardware_Version=@sHardware_Version,"); strSql.Append("iHardware_Type=@iHardware_Type,"); strSql.Append("iState_Online=@iState_Online,"); strSql.Append("iState_Alarm=@iState_Alarm,"); strSql.Append("iState_Enable=@iState_Enable,"); strSql.Append("iState_Command=@iState_Command,"); strSql.Append("sGroupInfoGUID=@sGroupInfoGUID,"); strSql.Append("sProjectInfoGUID=@sProjectInfoGUID,"); strSql.Append("dCreateDate=@dCreateDate,"); strSql.Append("dUpdateTime=@dUpdateTime,"); strSql.Append("sRemark=@sRemark,"); strSql.Append("sHostInfoStateGUID=@sHostInfoStateGUID"); strSql.Append(" where sGUID=@sGUID "); SqlParameter[] parameters = { new SqlParameter("@sName", SqlDbType.NVarChar, 100), new SqlParameter("@fLng", SqlDbType.Float, 8), new SqlParameter("@fLat", SqlDbType.Float, 8), new SqlParameter("@iIDType", SqlDbType.Int, 4), new SqlParameter("@sID_ID", SqlDbType.VarChar, 20), new SqlParameter("@sID_Addr", SqlDbType.NVarChar, 100), new SqlParameter("@sID_IP", SqlDbType.NVarChar, 100), new SqlParameter("@sID_MAC", SqlDbType.NVarChar, 100), new SqlParameter("@sID_SIM", SqlDbType.NVarChar, 100), new SqlParameter("@sHardware_Version", SqlDbType.NVarChar, 100), new SqlParameter("@iHardware_Type", SqlDbType.Int, 4), new SqlParameter("@iState_Online", SqlDbType.Int, 4), new SqlParameter("@iState_Alarm", SqlDbType.Int, 4), new SqlParameter("@iState_Enable", SqlDbType.Int, 4), new SqlParameter("@iState_Command", SqlDbType.Int, 4), new SqlParameter("@sGroupInfoGUID", SqlDbType.Char, 36), new SqlParameter("@sProjectInfoGUID", SqlDbType.Char, 36), new SqlParameter("@dCreateDate", SqlDbType.DateTime), new SqlParameter("@dUpdateTime", SqlDbType.DateTime), new SqlParameter("@sRemark", SqlDbType.NVarChar, 500), new SqlParameter("@sHostInfoStateGUID", SqlDbType.Char, 36), new SqlParameter("@sGUID", SqlDbType.Char, 36) }; parameters[0].Value = model.sName; parameters[1].Value = model.fLng; parameters[2].Value = model.fLat; parameters[3].Value = model.iIDType; parameters[4].Value = model.sID_ID; parameters[5].Value = model.sID_Addr; parameters[6].Value = model.sID_IP; parameters[7].Value = model.sID_MAC; parameters[8].Value = model.sID_SIM; parameters[9].Value = model.sHardware_Version; parameters[10].Value = model.iHardware_Type; parameters[11].Value = model.iState_Online; parameters[12].Value = model.iState_Alarm; parameters[13].Value = model.iState_Enable; parameters[14].Value = model.iState_Command; parameters[15].Value = model.sGroupInfoGUID; parameters[16].Value = model.sProjectInfoGUID; parameters[17].Value = model.dCreateDate; parameters[18].Value = model.dUpdateTime; parameters[19].Value = model.sRemark; parameters[20].Value = model.sHostInfoStateGUID; parameters[21].Value = model.sGUID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
public AlarmInfo() { li = new LumluxSSYDB.Model.tLightInfoes(); ls = new LumluxSSYDB.Model.tLightStateInfoes(); thost = new LumluxSSYDB.Model.tHostInfo(); }