public override List <ServerInfoVO> GetModels(ref ServerInfoPara mp) { string where = GetConditionByPara(mp); int pStart = mp.PageIndex.Value * mp.PageSize.Value; int pEnd = mp.PageSize.Value; string cmd = QUERYPAGE .Replace("@PAGESIZE", pEnd.ToString()) .Replace("@PTOP", pStart.ToString()) .Replace("@WHERE", where) .Replace("@ORDER", GetOrderByPara(mp)); CodeCommand command = new CodeCommand(); command.CommandText = cmd; var table = DbProxyFactory.Instance.Proxy.ExecuteTable(command); List <ServerInfoVO> list = new List <ServerInfoVO>(); for (int i = 0; i < table.Rows.Count; i++) { list.Add(new ServerInfoVO(table.Rows[i])); } if (!mp.Recount.HasValue) { mp.Recount = GetRecords(mp); } return(list); }
public override string GetOrderByPara(ServerInfoPara mp) { if (!string.IsNullOrEmpty(mp.OrderBy)) { return(string.Format(" order by {0}", mp.OrderBy)); } return(""); }
public override ServerInfoVO GetSingle(ServerInfoPara mp) { var list = GetModels(mp); if (list.Count == 1) { return(list[0]); } return(null); }
public override int GetRecords(ServerInfoPara mp) { string where = GetConditionByPara(mp); CodeCommand command = new CodeCommand(); command.CommandText = QUERYCOUNT + where; var result = DbProxyFactory.Instance.Proxy.ExecuteScalar(command); return(int.Parse(result.ToString())); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/json"; string sname = context.Request.Params["sname"] ?? ""; ApiResult result = new ApiResult(); try { if (!string.IsNullOrEmpty(sname)) { ServerInfoPara sip = new ServerInfoPara(); sip.Name = sname; var list = ServerInfoBLL.Instance.GetModels(sip); if (list.Count == 0) { ServerInfoVO info = new ServerInfoVO(); info.CreateDate = DateTime.Now; info.Desc = ""; info.Ip = DN.Framework.Utility.ClientHelper.ClientIP(); info.IsState = 0; info.Name = sname; info.ServerId = Guid.NewGuid().ToString(); info.UpdateDate = DateTime.Now; ServerInfoBLL.Instance.Add(info); result.code = 1; result.msg = "服务器信息上报成功。"; } else { result.code = 0; result.msg = "己存在相同服务器信息。"; } } } catch (Exception ex) { result.code = 2; result.msg = ex.Message; } string json = DN.Framework.Utility.Serializer.SerializeObject(result); context.Response.ClearContent(); context.Response.Write(json); context.Response.End(); }
private void Bind(int pageIndex = 1) { ServerInfoPara cip = new ServerInfoPara(); cip.PageIndex = pageIndex - 1; cip.PageSize = 10; cip.OrderBy = " id desc "; var list = ServerInfoBLL.Instance.GetModels(ref cip); rptTable.DataSource = list; rptTable.DataBind(); apPager.RecordCount = cip.Recount.Value; }
public override bool Delete(ServerInfoPara mp) { string where = GetConditionByPara(mp); CodeCommand command = new CodeCommand(); command.CommandText = DELETE + where; int result = DbProxyFactory.Instance.Proxy.ExecuteNonQuery(command); if (result >= 1) { return(true); } return(false); }
public override string GetConditionByPara(ServerInfoPara mp) { StringBuilder sb = new StringBuilder(); if (mp.Id.HasValue) { sb.AppendFormat(" AND [Id]='{0}' ", mp.Id); } if (!string.IsNullOrEmpty(SqlFilterHelper.CheckPropertyName(mp.ServerId))) { sb.AppendFormat(" AND [ServerId]='{0}' ", mp.ServerId); } if (!string.IsNullOrEmpty(SqlFilterHelper.CheckPropertyName(mp.Name))) { sb.AppendFormat(" AND [Name]='{0}' ", mp.Name); } if (!string.IsNullOrEmpty(SqlFilterHelper.CheckPropertyName(mp.Desc))) { sb.AppendFormat(" AND [Desc]='{0}' ", mp.Desc); } if (!string.IsNullOrEmpty(SqlFilterHelper.CheckPropertyName(mp.Ip))) { sb.AppendFormat(" AND [Ip]='{0}' ", mp.Ip); } if (mp.CreateDate.HasValue) { sb.AppendFormat(" AND [CreateDate]='{0}' ", mp.CreateDate); } if (mp.IsState.HasValue) { sb.AppendFormat(" AND [IsState]='{0}' ", mp.IsState); } if (mp.UpdateDate.HasValue) { sb.AppendFormat(" AND [UpdateDate]='{0}' ", mp.UpdateDate); } if (mp.UserId.HasValue) { sb.AppendFormat(" AND [UserId]='{0}' ", mp.UserId); } sb.Insert(0, " WHERE 1=1 "); return(sb.ToString()); }
public override List <ServerInfoVO> GetModels(ServerInfoPara mp) { string where = GetConditionByPara(mp); CodeCommand command = new CodeCommand(); string cmd = LOAD .Replace("@WHERE", where) .Replace("@ORDER", GetOrderByPara(mp)); command.CommandText = cmd; var table = DbProxyFactory.Instance.Proxy.ExecuteTable(command); List <ServerInfoVO> list = new List <ServerInfoVO>(); for (int i = 0; i < table.Rows.Count; i++) { list.Add(new ServerInfoVO(table.Rows[i])); } return(list); }
private void BindPage() { ServerInfoPara sip = new ServerInfoPara(); sip.OrderBy = " id desc "; sip.IsState = 1; var list = ServerInfoBLL.Instance.GetModels(sip); ddlServer.Items.Clear(); foreach (var item in list) { ListItem lt = new ListItem(); lt.Text = string.Format("{0}-{1}-{2}", item.Id, item.Name, item.Ip); lt.Value = item.Name; ddlServer.Items.Add(lt); } ddlServer.Items.Insert(0, new ListItem() { Text = "请选择同步服务器", Value = "" }); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/json"; string sname = context.Request.Params["sname"]; //获取当前IP string clientIp = DN.Framework.Utility.ClientHelper.ClientIP(); ApiResult result = new ApiResult(); try { //检查IP是否认证的IP ServerInfoPara sip = new ServerInfoPara(); var serv = ServerInfoBLL.Instance.GetSingle(new ServerInfoPara() { Name = sname }); if (serv == null || serv.IsState == 0) { result.code = 0; result.msg = "您的服务器没有经过认证,请联系管理员处理。"; } else { DomainSynchroHistoryPara dsp = new DomainSynchroHistoryPara(); dsp.Name = sname; dsp.IsSynchro = 0; var list = DomainSynchroHistoryBLL.Instance.GetModels(dsp); if (list.Count == 0) { result.code = 0; result.msg = "当前无同步数据。"; } else { result.code = 1; result.datajson = DN.Framework.Utility.Serializer.SerializeObject(list); var domains = DomainInfoBLL.Instance.GetModels(new DomainInfoPara()); foreach (var item in list) { item.SynchroDate = DateTime.Now; item.IsSynchro = 1; DomainSynchroHistoryBLL.Instance.Edit(item); //自动更新域名池信息 if (!string.IsNullOrEmpty(item.Domains)) { var tdlist = item.Domains.Split(new char[] { '\r', '\t', '\n', ',' }); foreach (var tdomain in tdlist) { if (!string.IsNullOrEmpty(tdomain)) { var tdinfo = domains.SingleOrDefault(p => p.Domain == tdomain); if (tdinfo != null) { if (item.OperType == 0) { tdinfo.IsResolution = 1; tdinfo.ResolutionDate = DateTime.Now; tdinfo.SerName = dsp.Name; tdinfo.IsColse = 0; DomainInfoBLL.Instance.Edit(tdinfo); } else if (item.OperType == 1) { tdinfo.IsResolution = 0; //删除 tdinfo.IsColse = 1; tdinfo.ColseDate = DateTime.Now; tdinfo.CloseUserId = 0; DomainInfoBLL.Instance.Edit(tdinfo); } } } } } } } } } catch (Exception ex) { result.code = 2; result.msg = ex.Message; } string json = DN.Framework.Utility.Serializer.SerializeObject(result); context.Response.ClearContent(); context.Response.Write(json); context.Response.End(); }
public override string GetOtherConditionByPara(ServerInfoPara mp) { return(""); }