/// <summary> /// 修改过滤IP /// </summary> /// <param name="TdIp">过滤IP信息</param> /// <param name="LoginId">管理员登陆标识</param> /// <returns>修改结果</returns> public ResultDesc ModifyTradeIp(TradeIp TdIp, String LoginId) { ResultDesc rsdc = new ResultDesc(); string operUser = string.Empty;//操作人 try { TradeUser TdUser = new TradeUser(); #region 判断登陆标识是否过期 if (!ComFunction.ExistUserLoginID(LoginId, ref TdUser)) { rsdc.Result = false; rsdc.Desc = ResCode.UL003Desc; return rsdc; } if (UserType.NormalType == TdUser.UType) { rsdc.Result = false; rsdc.Desc = ComFunction.NotRightUser; return rsdc; } operUser = TdUser.Account; #endregion List<string> sqlList = new List<string>(); StringBuilder strbld = new StringBuilder(); strbld.AppendFormat("update Trade_IP set "); strbld.AppendFormat("StartIp='{0}',", TdIp.StartIp); strbld.AppendFormat("EndIp='{0}',", TdIp.EndIp); strbld.AppendFormat("[desc]='{0}'", TdIp.Desc); strbld.AppendFormat(" where ID='{0}'", TdIp.ID); sqlList.Add(strbld.ToString()); string ipmac = ComFunction.GetIpMac(TdUser.Ip, TdUser.Mac); //添加操作记录 sqlList.Add(string.Format("insert into Base_OperrationLog([OperTime],[Account],[UserType],[Remark]) values('{0}','{1}',{2},'{3}')", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), operUser, (int)TdUser.UType, string.Format("{1}修改过滤IP:{0}", TdIp.ID, ipmac))); if (!ComFunction.SqlTransaction(sqlList)) { rsdc.Result = false; rsdc.Desc = "修改过滤IP出错"; return rsdc; } rsdc.Result = true; //rsdc.Desc = "修该过滤IP成功"; rsdc.Desc = strbld.ToString(); } catch (Exception ex) { ComFunction.WriteErr(ex); rsdc.Result = false; rsdc.Desc = "修改过滤IP失败"; } return rsdc; }
/// <summary> /// 获取过滤IP信息列表 /// </summary> /// <param name="sql">查询SQL</param> /// <returns>过滤IP信息列表</returns> public static List<TradeIp> GetTradeIpList(string sql) { System.Data.Common.DbDataReader dbreader = null; List<TradeIp> list = new List<TradeIp>(); try { dbreader = DbHelper.ExecuteReader(sql); while (dbreader.Read()) { TradeIp tradeIp = new TradeIp(); tradeIp.StartIp = dbreader["StartIp"].ToString(); tradeIp.EndIp = dbreader["EndIp"].ToString(); tradeIp.Desc = dbreader["Desc"].ToString(); tradeIp.ID = dbreader["ID"].ToString(); list.Add(tradeIp); } } catch (Exception ex) { throw new Exception(ex.Message, ex); } finally { if (null != dbreader) { dbreader.Close(); dbreader.Dispose(); } } return list; }
/// <summary> /// 添加过滤IP /// </summary> /// <param name="TdIp">过滤IP信息</param> /// <param name="LoginId">管理员登陆标识</param> /// <param name="ID">返回ID</param> /// <returns>添加结果</returns> public ResultDesc AddTradeIp(TradeIp TdIp, String LoginId, ref string ID) { ResultDesc rsdc = new ResultDesc(); string operUser = string.Empty;//操作人 try { TradeUser TdUser = new TradeUser(); #region 判断登陆标识是否过期 if (!ComFunction.ExistUserLoginID(LoginId, ref TdUser)) { rsdc.Result = false; rsdc.Desc = ResCode.UL003Desc; return rsdc; } if (UserType.NormalType == TdUser.UType) { rsdc.Result = false; rsdc.Desc = ComFunction.NotRightUser; return rsdc; } operUser = TdUser.Account; #endregion List<string> sqlList = new List<string>(); ID = System.Guid.NewGuid().ToString().Replace("-", ""); sqlList.Add(string.Format("insert into Trade_IP([startip],[endip],[desc],[ID]) values('{0}','{1}','{2}','{3}')", TdIp.StartIp, TdIp.EndIp, TdIp.Desc, ID)); string ipmac = ComFunction.GetIpMac(TdUser.Ip, TdUser.Mac); //添加操作记录 sqlList.Add(string.Format("insert into Base_OperrationLog([OperTime],[Account],[UserType],[Remark]) values('{0}','{1}',{2},'{3}')", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), operUser, (int)TdUser.UType, string.Format("{1}添加过滤IP:{0}", TdIp.ID, ipmac))); if (!ComFunction.SqlTransaction(sqlList)) { rsdc.Result = false; rsdc.Desc = "添加过滤IP出错"; return rsdc; } rsdc.Result = true; rsdc.Desc = "添加过滤IP成功"; } catch (Exception ex) { ComFunction.WriteErr(ex); rsdc.Result = false; rsdc.Desc = "添加过滤IP失败"; } return rsdc; }