/// <summary> /// 得到一个实体对象根据站网名 /// </summary> /// <param name="Id"></param> /// <returns></returns> public static Model.StationNetInfo GetModel(string NetName) { string strSql = "select * from StationNetInfo where NetName = '" + NetName + "'"; Model.StationNetInfo model = new Model.StationNetInfo(); DataSet ds = DBHelperSQL.GetDataSet(strSql, connectionString); model.NetName = NetName; if (ds.Tables[0].Rows.Count > 0) { model.ID = Convert.ToInt32(ds.Tables[0].Rows[0]["ID"]); model.IP = Convert.ToString(ds.Tables[0].Rows[0]["IP"]); model.Port = Convert.ToString(ds.Tables[0].Rows[0]["Port"]); model.BuildTime = Convert.ToDateTime(ds.Tables[0].Rows[0]["BuildTime"]); model.Number = Convert.ToString(ds.Tables[0].Rows[0]["Number"]); model.DistributionDiagram = Convert.ToString(ds.Tables[0].Rows[0]["DistributionDiagram"]); model.SourceNode = Convert.ToString(ds.Tables[0].Rows[0]["SourceNode"]); model.NetworkProtocol = Convert.ToString(ds.Tables[0].Rows[0]["NetworkProtocol"]); model.ServiceContent = Convert.ToString(ds.Tables[0].Rows[0]["ServiceContent"]); model.DataFormat = Convert.ToString(ds.Tables[0].Rows[0]["DataFormat"]); model.SatelliteSystem = Convert.ToString(ds.Tables[0].Rows[0]["SatelliteSystem"]); return(model); } else { return(null); } }
private void Add() { var cont = Request["net"].ToString(); Content content = CORSV2.cs.JSONHelper.JSONToObject <Content>(cont); Model.StationNetInfo MS = new Model.StationNetInfo(); MS.IP = content.IP; MS.Port = content.Port; MS.NetName = content.NetName; MS.NetworkProtocol = content.NetworkProtocol; MS.SourceNode = content.SourceNode; MS.Number = content.Number; string[] sys = content.SatelliteSystem.Split(' '); string SateSys = ""; foreach (string s in sys) { if (s != "") { SateSys += (s + ';'); } } MS.SatelliteSystem = SateSys; MS.ServiceContent = content.ServiceContent; if (DAL.StationNetInfo.Exists(MS.NetName)) { Response.Clear(); Response.Write("2"); Response.End(); return; } else { bool result = DAL.StationNetInfo.Add(MS); if (result) { Response.Clear(); Response.Write("1"); Response.End(); return; } else { Response.Clear(); Response.Write("0"); Response.End(); } } }
/// <summary> /// 更新一条数据,根据ID /// </summary> /// <param name="model"></param> /// <returns></returns> public static bool Update(Model.StationNetInfo model) { string strSql = "update StationNetInfo set NetName=@NetName, BuildTime=@BuildTime, Number=@Number, DistributionDiagram=@DistributionDiagram, IP=@IP, Port=@Port, SourceNode=@SourceNode, NetworkProtocol=@NetworkProtocol, ServiceContent=@ServiceContent, DataFormat=@DataFormat, SatelliteSystem=@SatelliteSystem where ID = " + model.ID.ToString(); SqlParameter NetName = new SqlParameter("NetName", SqlDbType.NVarChar); NetName.Value = model.NetName; SqlParameter BuildTime = new SqlParameter("BuildTime", SqlDbType.DateTime); BuildTime.Value = model.BuildTime; SqlParameter Number = new SqlParameter("Number", SqlDbType.NVarChar); Number.Value = model.Number; SqlParameter DistributionDiagram = new SqlParameter("DistributionDiagram", SqlDbType.NVarChar); DistributionDiagram.Value = model.DistributionDiagram; SqlParameter IP = new SqlParameter("IP", SqlDbType.NVarChar); IP.Value = model.IP; SqlParameter Port = new SqlParameter("Port", SqlDbType.NVarChar); Port.Value = model.Port; SqlParameter SourceNode = new SqlParameter("SourceNode", SqlDbType.NVarChar); SourceNode.Value = model.SourceNode; SqlParameter NetworkProtocol = new SqlParameter("NetworkProtocol", SqlDbType.NVarChar); NetworkProtocol.Value = model.NetworkProtocol; SqlParameter ServiceContent = new SqlParameter("ServiceContent", SqlDbType.NVarChar); ServiceContent.Value = model.ServiceContent; SqlParameter DataFormat = new SqlParameter("DataFormat", SqlDbType.NVarChar); DataFormat.Value = model.DataFormat; SqlParameter SatelliteSystem = new SqlParameter("SatelliteSystem", SqlDbType.NVarChar); SatelliteSystem.Value = model.SatelliteSystem; return(DBHelperSQL.GetNums(strSql, new SqlParameter[] { NetName, BuildTime, Number, DistributionDiagram, IP, Port, SourceNode, NetworkProtocol, ServiceContent, DataFormat, SatelliteSystem }, connectionString) == 1 ? true : false); }
private void DeleteStas() { int[] ids; string a = Request["id[]"]; string[] temp = a.Split(','); ids = new int[temp.Length]; try { for (int m = 0; m < temp.Length; m++) { ids[m] = Convert.ToInt32(temp[m]); Model.StationNetInfo ms = DAL.StationNetInfo.GetModel(ids[m]); string name = ms.NetName; DAL.StationNetInfo.Delete(ids[m]); Model.SysLog mSysLog = new Model.SysLog(); mSysLog.LogTime = DateTime.Now; mSysLog.LogType = 0; mSysLog.UserName = Session["UserName"].ToString(); mSysLog.Remark = "管理员删除了站网:" + name; DAL.SysLog.Add(mSysLog); } Response.Clear(); Response.Write("1"); Response.End(); } catch (Exception) { } }
protected void Page_Load(object sender, EventArgs e) { if (Session["UserName"] == null) { Response.Write("<script>alert(\"请登录\");location.href = location.origin+\"/forms/Index.aspx\";</script>"); Response.End(); } if (Session["UserType"] == null || (Convert.ToInt32(Session["UserType"]) != 2 && Convert.ToInt32(Session["UserType"]) != 3)) { Response.Write("<script>alert(\"登录账户类型有误\");location.href = location.origin+\"/forms/Index.aspx\";</script>"); Response.End(); } if (!IsPostBack) { int id = int.Parse(Request["id"].ToString()); Model.StationNetInfo MSN = DAL.StationNetInfo.GetModel(id); netid.Value = MSN.ID.ToString(); NetName.Value = MSN.NetName; Number.Value = MSN.Number; DistributionDiagram.Value = MSN.DistributionDiagram; if (MSN.DistributionDiagram == "") { viewDistributionDiagram.Disabled = true; } IP.Value = MSN.IP; Port.Value = MSN.Port; SourceNode.Value = MSN.SourceNode; NetworkProtocol.Value = MSN.NetworkProtocol; DataFormat.Value = MSN.DataFormat; ServiceContent.Value = MSN.ServiceContent; sysselect = MSN.SatelliteSystem; BuildTime.Value = MSN.BuildTime.ToString(); } if (Request["action"] != null && Request["action"] == "save") { string sysdata = Request["sysdata"].ToString(); string[] sys = sysdata.Split(' '); string SateSys = ""; foreach (string s in sys) { if (s != "") { SateSys += (s + ';'); } } int id = int.Parse(Request.Form["netid"].ToString().Trim()); Model.StationNetInfo ms = DAL.StationNetInfo.GetModel(id); #region 对修改信息进行对比 Model.EquipReviceRecord MERR = new Model.EquipReviceRecord(); bool IsRevice = false; MERR.Contents = "战网" + ms.NetName + "的信息发生了修改:"; if (ms.BuildTime != Convert.ToDateTime(Request.Form["BuildTime"].ToString().Trim())) { IsRevice = true; MERR.Contents += "建设完成时间;"; } if (ms.Number != Request.Form["Number"].ToString().Trim()) { IsRevice = true; MERR.Contents += "站点数量;"; } if (ms.IP != Request.Form["IP"].ToString().Trim()) { IsRevice = true; MERR.Contents += "IP地址;"; } if (ms.Port != Request.Form["Port"].ToString().Trim()) { IsRevice = true; MERR.Contents += "端口;"; } if (ms.SourceNode != Request.Form["SourceNode"].ToString().Trim()) { IsRevice = true; MERR.Contents += "源节点;"; } if (ms.NetworkProtocol != Request.Form["NetworkProtocol"].ToString().Trim()) { IsRevice = true; MERR.Contents += "网络协议;"; } if (ms.DataFormat != Request.Form["DataFormat"].ToString().Trim()) { IsRevice = true; MERR.Contents += "数据格式;"; } if (ms.SatelliteSystem != SateSys) { IsRevice = true; MERR.Contents += "卫星系统;"; } if (ms.ServiceContent != Request.Form["ServiceContent"].ToString().Trim()) { IsRevice = true; MERR.Contents += "应用服务内容;"; } #endregion ms.BuildTime = Convert.ToDateTime(Request.Form["BuildTime"].ToString().Trim()); ms.DataFormat = Request.Form["DataFormat"].ToString().Trim(); if (Request.Form["DistributionDiagram"].ToString().Trim().Contains("DistributionDiagram")) { ms.DistributionDiagram = Request.Form["DistributionDiagram"].ToString().Trim(); } ms.IP = Request.Form["IP"].ToString().Trim(); ms.Number = Request.Form["Number"].ToString().Trim(); ms.Port = Request.Form["Port"].ToString().Trim(); ms.SatelliteSystem = SateSys; ms.NetName = Request.Form["NetName"].ToString().Trim(); ms.NetworkProtocol = Request.Form["NetworkProtocol"].ToString().Trim(); ms.ServiceContent = Request.Form["ServiceContent"].ToString().Trim(); ms.SourceNode = Request.Form["SourceNode"].ToString().Trim(); if (DAL.StationNetInfo.GetModel(ms.NetName).ID != ms.ID) { Response.Clear(); Response.Write("2"); Response.End(); } else { DAL.StationNetInfo.Update(ms); if (IsRevice) { MERR.ReviceID = ms.ID.ToString(); MERR.RevicePerson = Session["UserName"].ToString(); MERR.ReviceTime = DateTime.Now; MERR.Information = "站网信息"; DAL.EquipReviceRecord.Add(MERR); } Response.Clear(); Response.Write("1"); Response.End(); } } if (Request["upload"] == "DistributionDiagram") { string filename = Request.Files["FileDistributionDiagram"].FileName; int ids = int.Parse(Request.Form["netid"].ToString().Trim()); string[] filenames = filename.Split('.'); Model.StationNetInfo ms = DAL.StationNetInfo.GetModel(ids); Request.Files["FileDistributionDiagram"].SaveAs(Server.MapPath("~/upload/DistributionDiagram/") + ms.NetName + "." + filenames[filenames.Length - 1]); ms.DistributionDiagram = "/upload/DistributionDiagram/" + ms.NetName + "." + filenames[filenames.Length - 1]; DAL.StationNetInfo.Update(ms); Model.EquipReviceRecord MERR = new Model.EquipReviceRecord(); MERR.ReviceID = Request.Form["netid"].ToString().Trim(); MERR.Contents = "战网" + ms.NetName + "的信息发生了修改:站点分布示意图;"; MERR.RevicePerson = Session["UserName"].ToString(); MERR.ReviceTime = DateTime.Now; MERR.Information = "站网信息"; DAL.EquipReviceRecord.Add(MERR); Response.Clear(); Response.Write("1"); Response.End(); } }