/// <summary>
 /// 将选定的IP地址过滤信息从列表中移除
 /// </summary>
 /// <param name="ipAddrFilterInfo">要移除的某个IP地址过滤信息</param>
 private void RemoveIPAddrFilterInfo(IPAddressFilterInformation ipAddrFilterInfo)
 {
     if (_dpObj.CheckAccess())
         IPAddrFilterInfoes.Remove(ipAddrFilterInfo);
     else
         _dpObj.Dispatcher.BeginInvoke(DispatcherPriority.Normal,
             new IPAddrFilterInfoDelegate(item => IPAddrFilterInfoes.Remove(item)),
             ipAddrFilterInfo);
 }
 /// <summary>
 /// 同步IP地址过滤信息数据
 /// </summary>
 /// <param name="clone">同步数据源</param>
 public void Sync( IPAddressFilterInformation clone ) {
     StartIPAddr = clone.StartIPAddr;
     EndIPAddr = clone.EndIPAddr;
     FilterDesc = clone.FilterDesc;
 }
        /// <summary>
        /// 显示详细的选中的IP地址过滤信息
        /// </summary>
        /// <param name="IpFilterInfo">选中的IP地址过滤条件</param>
        public void ShowIPAddressFilterInfo(IPAddressFilterInformation IpFilterInfo)
        {
            IPAddressFilterInformation clone = (IPAddressFilterInformation)IpFilterInfo.Clone();
            IPAddrFilterInfoWindow wnd = new IPAddrFilterInfoWindow
            {
                Owner = Application.Current.MainWindow,
                DataContext = clone,
            };

            if (wnd.ShowDialog() == true)
            {
                ErrType err = _businessService.ModifyIPAddrFilteringInfo(_loginID, clone);
                if (err == GeneralErr.Success)
                    IpFilterInfo.Sync(clone);
                else
                    MessageBox.Show(err.ErrMsg, err.ErrTitle, MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
 /// <summary>
 /// 删除指定的IP地址过滤信息
 /// </summary>
 /// <param name="IpFilterInfo">要删除的IP地址过滤信息</param>
 public void DeleteIPAddressFilterInfo(IPAddressFilterInformation IpFilterInfo)
 {
     MessageBoxResult mbResult = MessageBox.Show("确认删除该条记录吗?", "删除确认", MessageBoxButton.YesNo, MessageBoxImage.Question);
     if (mbResult == MessageBoxResult.Yes)
     {
         ErrType err = _businessService.DeleteIPAddrFilteringInfo(_loginID, IpFilterInfo.FilterID);
         if (err == GeneralErr.Success)
             RemoveIPAddrFilterInfo(IpFilterInfo);
         else
             MessageBox.Show(err.ErrMsg, err.ErrTitle, MessageBoxButton.OK, MessageBoxImage.Warning);
     }
 }
        /// <summary>
        /// 执行添加IP地址过滤信息命令的方法
        /// </summary>
        public void AddIPAddrFilterInfoExecute()
        {
            IPAddressFilterInformation ipInfo = new IPAddressFilterInformation();
            IPAddrFilterInfoWindow wnd = new IPAddrFilterInfoWindow
            {
                Owner = Application.Current.MainWindow,
                DataContext = ipInfo,
            };

            if (wnd.ShowDialog() == true)
            {
                ErrType err = _businessService.AddIPAddrFilteringInfo(_loginID, ipInfo);
                if (err == GeneralErr.Success)
                    AddIPAddrFilterInfo(ipInfo);
                else
                    MessageBox.Show(err.ErrMsg, err.ErrTitle, MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
 /// <summary>
 /// 修改选中的IP地址过滤信息
 /// </summary>
 /// <param name="loginID">登陆标识</param>
 /// <param name="ipAddrFilterInfo">修改后的IP地址过滤信息</param>
 /// <returns>ErrType</returns>
 public ErrType ModifyIPAddrFilteringInfo(string loginID, IPAddressFilterInformation ipAddrFilterInfo)
 {
     try
     {
         TradeIp tradeIP = MyConverter.ToTradeIp(ipAddrFilterInfo);
         ResultDesc result = ManagerService.ModifyTradeIp(tradeIP, loginID);
         return result.Result ? GeneralErr.Success : new ErrType(ERR.SERVICE, result.Desc);
     }
     catch (TimeoutException te)
     {
         FileLog.WriteLog("", Assembly.GetExecutingAssembly().GetName().Name, this.GetType().Name, new StackTrace().GetFrame(0).GetMethod().Name, te.Message);
         return new ErrType(ERR.EXEPTION, ErrorText.TimeoutException);
     }
     catch (Exception ex)
     {
         FileLog.WriteLog("", Assembly.GetExecutingAssembly().GetName().Name, this.GetType().Name,
      new StackTrace().GetFrame(0).GetMethod().Name, ex.Message);
         return new ErrType(ERR.EXEPTION, ErrorText.OperationError);
     }
 }
 /// <summary>
 /// 添加新的IP地址过滤信息
 /// </summary>
 /// <param name="loginID">登陆标识</param>
 /// <param name="ipAddrFilterInfo">要添加的新的IP地址过滤条件</param>
 /// <returns>ErrType</returns>
 public ErrType AddIPAddrFilteringInfo(string loginID, IPAddressFilterInformation ipAddrFilterInfo)
 {
     try
     {
         TradeIp ipInfo = MyConverter.ToTradeIp(ipAddrFilterInfo);
         string filterID = "";
         ResultDesc result = ManagerService.AddTradeIp(ipInfo, loginID, ref filterID);
         if (result.Result)
         {
             ipAddrFilterInfo.FilterID = filterID;
             return GeneralErr.Success;
         }
         else
             return new ErrType(ERR.SERVICE, result.Desc);
     }
     catch (TimeoutException te)
     {
         FileLog.WriteLog("", Assembly.GetExecutingAssembly().GetName().Name, this.GetType().Name, new StackTrace().GetFrame(0).GetMethod().Name, te.Message);
         return new ErrType(ERR.EXEPTION, ErrorText.TimeoutException);
     }
     catch (Exception ex)
     {
         FileLog.WriteLog("", Assembly.GetExecutingAssembly().GetName().Name, this.GetType().Name,
      new StackTrace().GetFrame(0).GetMethod().Name, ex.Message);
         return new ErrType(ERR.EXEPTION, ErrorText.OperationError);
     }
 }
Ejemplo n.º 8
0
 internal static TradeIp ToTradeIp(IPAddressFilterInformation ipAddrFilterInfo)
 {
     return new TradeIp
     {
         StartIp = ipAddrFilterInfo.StartIPAddr,
         EndIp = ipAddrFilterInfo.EndIPAddr,
         Desc = ipAddrFilterInfo.FilterDesc,
         ID = ipAddrFilterInfo.FilterID,
     };
 }
 /// <summary>
 /// 同步IP地址过滤信息数据
 /// </summary>
 /// <param name="clone">同步数据源</param>
 public void Sync(IPAddressFilterInformation clone)
 {
     StartIPAddr = clone.StartIPAddr;
     EndIPAddr   = clone.EndIPAddr;
     FilterDesc  = clone.FilterDesc;
 }