/// <summary> /// 修改过滤Mac /// </summary> /// <param name="TdMac">过滤Mac信息</param> /// <param name="LoginId">管理员登陆标识</param> /// <returns>修改结果</returns> public ResultDesc ModifyTradeMac(TradeMac TdMac, 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_Mac set "); strbld.AppendFormat("Mac='{0}',", TdMac.MAC); strbld.AppendFormat("[desc]='{0}'", TdMac.Desc); strbld.AppendFormat(" where ID='{0}'", TdMac.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}修改过滤Mac:{0}", TdMac.ID, ipmac))); if (!ComFunction.SqlTransaction(sqlList)) { rsdc.Result = false; rsdc.Desc = "修改过滤Mac出错"; return rsdc; } rsdc.Result = true; rsdc.Desc = "修该过滤Mac成功"; } catch (Exception ex) { ComFunction.WriteErr(ex); rsdc.Result = false; rsdc.Desc = "修改过滤Mac失败"; } return rsdc; }
/// <summary> /// 获取过滤Mac信息列表 /// </summary> /// <param name="sql">查询SQL</param> /// <returns>过滤MAC信息列表</returns> public static List<TradeMac> GetTradeMacList(string sql) { System.Data.Common.DbDataReader dbreader = null; List<TradeMac> list = new List<TradeMac>(); try { dbreader = DbHelper.ExecuteReader(sql); while (dbreader.Read()) { TradeMac tradeMac = new TradeMac(); tradeMac.MAC = dbreader["MAC"].ToString(); tradeMac.Desc = dbreader["Desc"].ToString(); tradeMac.ID = dbreader["ID"].ToString(); list.Add(tradeMac); } } catch (Exception ex) { throw new Exception(ex.Message, ex); } finally { if (null != dbreader) { dbreader.Close(); dbreader.Dispose(); } } return list; }
/// <summary> /// 添加过滤Mac /// </summary> /// <param name="TdMac">过滤Mac信息</param> /// <param name="LoginId">管理员登陆标识</param>\ /// <param name="ID">返回ID</param> /// <returns>添加结果</returns> public ResultDesc AddTradeMac(TradeMac TdMac, 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_Mac([mac],[desc],[ID]) values('{0}','{1}','{2}')", TdMac.MAC, TdMac.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}添加过滤Mac:{0}", TdMac.ID, ipmac))); if (!ComFunction.SqlTransaction(sqlList)) { rsdc.Result = false; rsdc.Desc = "添加过滤Mac出错"; return rsdc; } rsdc.Result = true; rsdc.Desc = "添加过滤Mac成功"; } catch (Exception ex) { ComFunction.WriteErr(ex); rsdc.Result = false; rsdc.Desc = "添加过滤Mac失败"; } return rsdc; }