Exemple #1
0
        private void PopupClosed(object sender, DevExpress.Xpf.Editors.ClosePopupEventArgs e)
        {
            //string selectcodetext = null;

            if (FunctionCodeComboBox.SelectedItem != null)
            {
                string selectcode = FunctionCodeComboBox.SelectedItem.ToString();
                FunctionCodeComboBox.Text = selectcode;
            }
            else
            {
                UserMessageBox.Show("提醒", "请选择功能码!");
            }
            //string[] selectcode = new string[FunctionCodeComboBox.SelectedItems.Count()];
            //if (FunctionCodeComboBox.SelectedItems.Count()!=0)
            //{
            //    int index = 0;
            //    for (int i = 0; i < FunctionCodeComboBox.SelectedItems.Count(); i++)
            //    {
            //        selectcode[index] = FunctionCodeComboBox.SelectedItems[i].ToString();
            //        index++;
            //    }
            //    Array.Sort(selectcode);
            //    selectcodetext += selectcode[0];
            //    for (int j = 1; j < FunctionCodeComboBox.SelectedItems.Count(); j++)
            //    {
            //        selectcodetext += ";" + selectcode[j];
            //    }
            //    FunctionCodeComboBox.Text = selectcodetext;
            //}
            CodeNum.Text = FunctionCodeComboBox.SelectedItems.Count().ToString();
        }
 private void Querybutton_Click(object sender, RoutedEventArgs e)
 {
     if (StateName.SelectedItem.ToString() == "ALL")
     {
         Statetext = "";
     }
     else
     {
         Statetext = "AND handle_result = '" + StateName.SelectedItem.ToString() + "'";
     }
     if (QueryDate.EditValue != null)
     {
         if (FwName.Text != "" && ProtectedIP.Text != "")
         {
             IPinitGridControl();
             IPStatisSearch(Statetext);
             //UnableToExportImage.Visibility = Visibility.Collapsed;
         }
         else
         {
             UserMessageBox.Show("提示", "请先进行设备扫描,然后再进行查询!");
         }
     }
     else
     {
         UserMessageBox.Show("提示", "时间不能为空!");
     }
 }
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.main = ((FireWall.UserMessageBox)(target));
                return;

            case 2:
                this.sbOpShow = ((System.Windows.Media.Animation.Storyboard)(target));
                return;

            case 3:
                this.lblTitle = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 4:
                this.lblMsg = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 5:
                this.Confirm = ((System.Windows.Controls.Border)(target));
                return;

            case 6:
                this.Yes1 = ((System.Windows.Controls.Button)(target));

            #line 28 "..\..\..\Window\UserMessageBox.xaml"
                this.Yes1.Click += new System.Windows.RoutedEventHandler(this.Yes_Click);

            #line default
            #line hidden
                return;

            case 7:
                this.No = ((System.Windows.Controls.Button)(target));

            #line 29 "..\..\..\Window\UserMessageBox.xaml"
                this.No.Click += new System.Windows.RoutedEventHandler(this.No_Click);

            #line default
            #line hidden
                return;

            case 8:
                this.Tip = ((System.Windows.Controls.Border)(target));
                return;

            case 9:
                this.Yes2 = ((System.Windows.Controls.Button)(target));

            #line 33 "..\..\..\Window\UserMessageBox.xaml"
                this.Yes2.Click += new System.Windows.RoutedEventHandler(this.Yes_Click);

            #line default
            #line hidden
                return;
            }
            this._contentLoaded = true;
        }
        //扫描按键事件
        private void Scanbutton_Click(object sender, RoutedEventArgs e)
        {
            scanstarttext = ScanIPStarttextBox_1.Text + "." + ScanIPStarttextBox_2.Text + "." + ScanIPStarttextBox_3.Text + "." + ScanIPStarttextBox_4.Text;
            scanendtext   = ScanIPEndtextBox_1.Text + "." + ScanIPEndtextBox_2.Text + "." + ScanIPEndtextBox_3.Text + "." + ScanIPEndtextBox_4.Text;
            IPAddress ip;

            if (IPAddress.TryParse(scanstarttext, out ip) && IPAddress.TryParse(scanendtext, out ip))
            {
                if ((Convert.ToInt16(ScanIPStarttextBox_1.Text) == Convert.ToInt16(ScanIPEndtextBox_1.Text)) && (Convert.ToInt16(ScanIPStarttextBox_2.Text) == Convert.ToInt16(ScanIPEndtextBox_2.Text)) && (Convert.ToInt16(ScanIPStarttextBox_3.Text) == Convert.ToInt16(ScanIPEndtextBox_3.Text)) && (Convert.ToInt16(ScanIPStarttextBox_4.Text) <= Convert.ToInt16(ScanIPEndtextBox_4.Text)))
                {
                    //MainWindow MW = (MainWindow)Application.Current.Windows[0];
                    //MW.MainBox.Background = new SolidColorBrush(Colors.Gray);
                    //扫描线程开启
                    ScanThread = new Thread(new ThreadStart(Scaning));
                    ScanThread.IsBackground = true;
                    ScanThread.Start();
                    //MW.MainBox.Background = new SolidColorBrush(Color.FromArgb(0xFF,0x2D,0x2D,0x2D));
                }
                else
                {
                    UserMessageBox.Show("提示", "请输入正确的范围!");
                }
            }
            else
            {
                UserMessageBox.Show("提示", "请输入正确的IP!");
            }
        }
        private void APCeditclick(object sender, MouseButtonEventArgs e)
        {
            DB_DataGridbinding APCbind = new DB_DataGridbinding();
            string             dev_ip  = (from devices in StaticGlobal.fwdev_list
                                          where devices.getDev_MAC() == StaticGlobal.firewallmac
                                          select devices).ToList <FWDeviceForm>()[0].getProtecDevIP_list()[0];
            string          proto  = (APCdataGrid.SelectedItem as APCRuleDataTable).protocol.ToString();
            string          status = (APCdataGrid.SelectedItem as APCRuleDataTable).status.ToString();
            IAPCRulesManage APC    = new APCRulesManage();

            if (status == "allow")
            {
                if (APC.ApplicationProtocolControl(dev_ip, proto, false))
                {
                    UserMessageBox.Show("提示", "状态修改成功!");
                    APCbind.APCDB_Gridbinding();
                }
                else
                {
                    UserMessageBox.Show("提示", "状态修改失败,请检查设备连接!");
                }
            }
            if (status == "forbid")
            {
                if (APC.ApplicationProtocolControl(dev_ip, proto, true))
                {
                    UserMessageBox.Show("提示", "状态修改成功!");
                    APCbind.APCDB_Gridbinding();
                }
                else
                {
                    UserMessageBox.Show("提示", "状态修改失败,请检查设备连接!");
                }
            }
        }
Exemple #6
0
        //规则删除按钮
        private void deleteclick(object sender, MouseButtonEventArgs e)
        {
            IDPIRulesManage rulesmg = new DPIRulesManage();
            string          dev_ip  = (from devices in StaticGlobal.fwdev_list
                                       where devices.getDev_MAC() == StaticGlobal.firewallmac
                                       select devices).ToList <FWDeviceForm>()[0].getProtecDevIP_list()[0];
            string source      = (dataGrid.SelectedItem as FireWallRuleDataTable).source.ToString();
            string destination = (dataGrid.SelectedItem as FireWallRuleDataTable).destination.ToString();
            string min_addr    = (dataGrid.SelectedItem as FireWallRuleDataTable).coiladdressstart.ToString();
            string max_addr    = (dataGrid.SelectedItem as FireWallRuleDataTable).coiladdressend.ToString();
            string func        = (dataGrid.SelectedItem as FireWallRuleDataTable).func.ToString();
            int    min_data    = (dataGrid.SelectedItem as FireWallRuleDataTable).mindata;
            int    max_data    = (dataGrid.SelectedItem as FireWallRuleDataTable).maxdata;
            bool   log         = (dataGrid.SelectedItem as FireWallRuleDataTable).log;

            if (rulesmg.ChangeModbusTcpRules(destination, source, min_addr, max_addr, func, min_data, max_data, dev_ip, log, false))
            {
                StaticGlobal.FireWalldevices[StaticGlobal.firewallindex].getFireWallRule_list().Remove((dataGrid.SelectedItem as FireWallRuleDataTable));
                UserMessageBox.Show("提示", "规则删除成功!");
            }
            else
            {
                UserMessageBox.Show("提示", "规则删除失败,请检查设备连接!");
            }
        }
Exemple #7
0
        /*----------------------------------------------------------------
         * //函数说明:查询函数,检测添加用户的合理性//
         * //输入:无//
         * //输出:无//
         * //----------------------------------------------------------------*/
        private void Search()
        {
            string CommandText = "select * from useraccount where UserName='******'";

            try
            {
                DataSet         result = new DataSet();
                MySqlConnection conn   = new MySqlConnection(StaticGlobal.ConnectionString);
                conn.Open();
                MySqlDataAdapter s = new MySqlDataAdapter(CommandText, conn);
                s.Fill(result);
                if (result.Tables[0].Rows.Count > 0)
                {
                    //MessageBox.Show("存在同名用户,请更改后重试!");
                    UserMessageBox.Show("提示", "存在同名用户,请更改后重试!");
                }
                else
                {
                    Add();
                }
                conn.Close();
                conn.Dispose();
            }
            catch (Exception)
            {
                //MessageBox.Show("数据库连接出错!");
                UserMessageBox.Show("提示", "数据库连接出错!");
            }
        }
Exemple #8
0
        private void NATdeleteclick(object sender, MouseButtonEventArgs e)
        {
            //if (NATComboBox.SelectedItem.ToString() == "DNAT")
            //{
            //    StaticGlobal.FireWalldevices[StaticGlobal.firewallindex].getDNATRule_list().Remove((DNATdataGrid.SelectedItem as DNATRuleDataTable));
            //    NATApplyEnabled();
            //}
            //if(NATComboBox.SelectedItem.ToString() == "SNAT")
            //{
            //    StaticGlobal.FireWalldevices[StaticGlobal.firewallindex].getSNATRule_list().Remove((SNATdataGrid.SelectedItem as SNATRuleDataTable));
            //    NATApplyEnabled();
            //}
            string dev_ip = (from devices in StaticGlobal.fwdev_list
                             where devices.getDev_MAC() == StaticGlobal.firewallmac
                             select devices).ToList <FWDeviceForm>()[0].getProtecDevIP_list()[0];
            IConfigureNAT fw = new ConfigureNAT();

            string origin_devIP = (DNATdataGrid.SelectedItem as SNATRuleDataTable).origin_devIP.ToString();
            string EthIP        = (DNATdataGrid.SelectedItem as SNATRuleDataTable).EthIP.ToString();
            string origin_dport = (DNATdataGrid.SelectedItem as DNATRuleDataTable).origin_dport.ToString();
            string map_port     = (DNATdataGrid.SelectedItem as DNATRuleDataTable).map_port.ToString();

            if (fw.ConfigDNAT(dev_ip, origin_devIP, origin_dport, EthIP, map_port, false))
            {
                UserMessageBox.Show("提示", "规则删除成功!");
            }
        }
 /*----------------------------------------------------------------
  * //函数说明:确认按键//
  * //输入:无//
  * //输出:无//
  * //----------------------------------------------------------------*/
 private void OKButton_Click(object sender, RoutedEventArgs e)
 {
     if (passwordBox.Password == "")
     {
         //MessageBox.Show("密码不能为空!");
         UserMessageBox.Show("提示", "密码不能为空!");
     }
     else
     {
         if (passwordBox1.Password == "")
         {
             //MessageBox.Show("请确认密码!");
             UserMessageBox.Show("提示", "请确认密码!");
         }
         else
         {
             if (passwordBox.Password != passwordBox1.Password)
             {
                 //MessageBox.Show("两次密码输入不一致!请重新输入!");
                 UserMessageBox.Show("提示", "两次密码输入不一致!请重新输入!");
             }
             else
             {
                 update();
             }
         }
     }
 }
        /*----------------------------------------------------------------
         * //函数说明:更新指定用户密码的数据库数据//
         * //输入:无//
         * //输出:无//
         * //----------------------------------------------------------------*/
        private void update()
        {
            string action;
            string CommandText = "update useraccount set Password ='******' where UserName='******'";

            try
            {
                MySqlConnection conn = new MySqlConnection(StaticGlobal.ConnectionString);
                conn.Open();
                MySqlCommand comm = new MySqlCommand(CommandText, conn);
                comm.ExecuteNonQuery();
                comm.Dispose();
                conn.Close();
                conn.Dispose();
                //MessageBox.Show("设置密码成功!");
                UserMessageBox.Show("提示", "修改用户" + textBox.Text + "的密码成功!");
                action = "修改用户" + textBox.Text + "密码";
                Log.addlog(StaticGlobal.UserID, action, 0);
                this.Close();
            }
            catch (Exception)
            {
                //MessageBox.Show("设置密码失败,请重试!");
                UserMessageBox.Show("提示", "修改密码失败,请重试!");
            }
        }
 private void Yes_Click(object sender, RoutedEventArgs e)
 {
     if (IPStarttextBox_1.Text != "" && IPStarttextBox_2.Text != "" && IPStarttextBox_3.Text != "" && IPStarttextBox_4.Text != "")
     {
         string resetIP = IPStarttextBox_1.Text + '.' + IPStarttextBox_2.Text + '.' + IPStarttextBox_3.Text + '.' + IPStarttextBox_4.Text;
         StaticGlobal.FwMACandIP[StaticGlobal.firewallmac] = resetIP;
         IResetIP res = new ResetIP();
         for (int i = 0; i < StaticGlobal.fwdev_list.Count(); i++)
         {
             if (StaticGlobal.fwdev_list[i].getDev_MAC() == StaticGlobal.firewallmac)
             {
                 if (res.ResetIP(StaticGlobal.fwdev_list[i].getProtecDev_list()[0], resetIP))
                 {
                     UserMessageBox.Show("提示", "IP重设成功");
                     StaticGlobal.FwMACandIP[StaticGlobal.firewallmac] = resetIP;
                 }
                 else
                 {
                     UserMessageBox.Show("提示", "无IP模式配置失败!");
                 }
             }
         }
         this.Close();
         ConfigFW update = new ConfigFW();
         update.FWIP.Text = StaticGlobal.FwMACandIP[StaticGlobal.firewallmac];
         //update.FWIP.AppendText(StaticGlobal.FwMACandIP[StaticGlobal.firewallmac]);
     }
     else
     {
         UserMessageBox.Show("提示", "请输入正确的IP地址");
     }
 }
Exemple #12
0
 private void Clear_Click(object sender, RoutedEventArgs e)
 {
     if (UserMessageBox.Show("清空", "确定要清空所有的拓扑结构吗?") == true)
     {
         treeView.Items.Clear();
     }
 }
        private void SaveXmlButton_Click(object sender, RoutedEventArgs e)
        {
            if (UserMessageBox.Show("消息提示", "确认修改数据库信息?") == true)
            {
                string          ConnectionString = "Data Source = " + DataSourceBox.Text + "; User Id = " + UserIDBox.Text + "; Password ="******" CREATE database if not exists " + DataBaseBox.Text + ";DROP TABLE IF EXISTS " + DataBaseBox.Text + ".`firewallip`;" +
                                     " CREATE TABLE " + DataBaseBox.Text + ".`firewallip` (fw_ip VARCHAR(255) DEFAULT NULL, `fw_mac` varchar(255) DEFAULT NULL," +
                                     " dev_ip VARCHAR(255) DEFAULT NULL, dev_mac VARCHAR(255) DEFAULT NULL, dev_type VARCHAR(255) DEFAULT NULL)" +
                                     " ENGINE = InnoDB DEFAULT CHARSET = utf8;" +
                                     " DROP TABLE IF EXISTS " + DataBaseBox.Text + ".`firewallrules`;" +
                                     " CREATE TABLE " + DataBaseBox.Text + ".`firewallrules` (`fw_mac` varchar(255) DEFAULT NULL,`protocol` varchar(255) DEFAULT NULL," +
                                     " `source` varchar(255) DEFAULT NULL,`destination` varchar(255) DEFAULT NULL,`coiladdressstart` varchar(255) DEFAULT NULL," +
                                     " `coiladdressend` varchar(255) DEFAULT NULL, minspeed varchar(255) DEFAULT NULL, maxspeed varchar(255) DEFAULT NULL," +
                                     " `functioncode` varchar(255) DEFAULT NULL,`log` varchar(255) DEFAULT NULL" +
                                     " ) ENGINE = InnoDB DEFAULT CHARSET = utf8;" +
                                     " DROP TABLE IF EXISTS " + DataBaseBox.Text + ".`useraccount`;" +
                                     " CREATE TABLE " + DataBaseBox.Text + ".`useraccount` (`UserID` tinyint(3) unsigned NOT NULL AUTO_INCREMENT," +
                                     " `UserName` char(16) NOT NULL,`Password` char(8) DEFAULT NULL,`Purview` char(32) DEFAULT NULL," +
                                     " PRIMARY KEY(`UserID`),UNIQUE KEY `useName` (`UserName`)) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8;" +
                                     " INSERT INTO " + DataBaseBox.Text + ".`useraccount` (`UserID`, `UserName`, `Password`, `Purview`) VALUES('1', 'admin', 'admin', 'SUPER');";
                try
                {
                    //Open DataBase
                    //打开数据库
                    conn.Open();
                    MySqlCommand cmd = new MySqlCommand(CommandText, conn);
                    cmd.ExecuteNonQuery();
                    //读取全局配置信息
                    XmlSerializationHelper configContext = new XmlSerializationHelper("Config");
                    GlobalConfig           globalconfig  = configContext.Get <GlobalConfig>();

                    globalconfig.DataBaseConfigs[0].DataBase   = DataBaseBox.Text;
                    globalconfig.DataBaseConfigs[0].DataSource = DataSourceBox.Text;
                    globalconfig.DataBaseConfigs[0].UserId     = UserIDBox.Text;
                    globalconfig.DataBaseConfigs[0].Password   = PassWordBox.Text;
                    configContext.Save(globalconfig);

                    StaticGlobal.database         = DataBaseBox.Text;
                    StaticGlobal.datasource       = DataSourceBox.Text;
                    StaticGlobal.userid           = UserIDBox.Text;
                    StaticGlobal.password         = PassWordBox.Text;
                    StaticGlobal.ConnectionString = "Database = " + StaticGlobal.database + ";Data Source = " + StaticGlobal.datasource + "; User Id = " + StaticGlobal.userid + "; Password ="******"提示", "输入信息有误或Mysql服务未打开,无法连接数据库!");
                }
                finally
                {
                    //Close DataBase
                    //关闭数据库连接
                    conn.Close();
                }
            }
        }
 /*----------------------------------------------------------------
  * //函数说明:修改选中用户的权限//
  * //输入:无//
  * //输出:无//
  * //----------------------------------------------------------------*/
 private void ChangeRoleButton_Click(object sender, RoutedEventArgs e)
 {
     if (StaticGlobal.UserRole.ToUpper() == "SUPER")
     {
         if (UserData.SelectedItem != null)
         {
             DataRowView SelectedElement = (DataRowView)UserData.SelectedItem;
             string      username        = SelectedElement.Row[1].ToString();
             if (username != "admin")
             {
                 if (UserMessageBox.Show("确认", "确定要改变用户 " + username + " 的权限?") == true)
                 {
                     string CommandText, action;
                     if (SelectedElement.Row[2].ToString() == "操作员")
                     {
                         CommandText = "update useraccount set Purview = 'GUEST' where UserName='******'";
                     }
                     else
                     {
                         CommandText = "update useraccount set Purview = 'OPER' where UserName='******'";
                     }
                     try
                     {
                         MySqlConnection conn = new MySqlConnection(StaticGlobal.ConnectionString);
                         conn.Open();
                         MySqlCommand comm = new MySqlCommand(CommandText, conn);
                         comm.ExecuteNonQuery();
                         comm.Dispose();
                         conn.Close();
                         conn.Dispose();
                         //MessageBox.Show("更改权限成功!");
                         UserMessageBox.Show("提示", "更改用户" + username + "权限成功!");
                         action = "修改用户" + username + "权限";
                         Log.addlog(StaticGlobal.UserID, action, 0);
                         InitDateGrid();
                     }
                     catch (Exception)
                     {
                         //MessageBox.Show("更改权限失败,请重试!");
                         UserMessageBox.Show("提示", "更改权限失败,请重试!");
                     }
                 }
             }
             else
             {
                 UserMessageBox.Show("提示", "超级用户权限不能修改!");
             }
         }
         else
         {
             UserMessageBox.Show("提示", "请选择需要更改权限的用户!");
         }
     }
     else
     {
         UserMessageBox.Show("提示", "您权限不足,无法修改用户权限!");
     }
 }
Exemple #15
0
        private void PRTdeleteclick(object sender, MouseButtonEventArgs e)
        {
            IPRTRulesManage PRTrule = new PRTRulesManage();
            string          devIP   = (from devices in StaticGlobal.fwdev_list
                                       where devices.getDev_MAC() == StaticGlobal.firewallmac
                                       select devices).ToList <FWDeviceForm>()[0].getProtecDevIP_list()[0];
            string route_type = (PRTdataGrid.SelectedItem as PRTRuleDataTable).route_type.ToString();
            string ETH        = (PRTdataGrid.SelectedItem as PRTRuleDataTable).ETH.ToString();
            string Gateway    = (PRTdataGrid.SelectedItem as PRTRuleDataTable).Gateway.ToString();
            bool   log        = (PRTdataGrid.SelectedItem as PRTRuleDataTable).log;

            switch (route_type)
            {
            case "默认路由":
                if (PRTrule.DefaultRouteConfig(devIP, false, ETH, Gateway))
                {
                    StaticGlobal.FireWalldevices[StaticGlobal.firewallindex].getFireWallPRTRule_list().Remove((PRTdataGrid.SelectedItem as PRTRuleDataTable));
                    UserMessageBox.Show("提示", "规则删除成功!");
                }
                else
                {
                    UserMessageBox.Show("提示", "规则删除失败,请检查设备连接!");
                }
                break;

            case "主机路由":
                string host_IP = (PRTdataGrid.SelectedItem as PRTRuleDataTable).host_IP.ToString();
                if (PRTrule.HostRouteConfig(devIP, false, host_IP, ETH, Gateway))
                {
                    StaticGlobal.FireWalldevices[StaticGlobal.firewallindex].getFireWallPRTRule_list().Remove((PRTdataGrid.SelectedItem as PRTRuleDataTable));
                    UserMessageBox.Show("提示", "规则删除成功!");
                }
                else
                {
                    UserMessageBox.Show("提示", "规则删除失败,请检查设备连接!");
                }
                break;

            case "网络路由":
                string dstIP   = (PRTdataGrid.SelectedItem as PRTRuleDataTable).dstIP.ToString();
                string netmask = (PRTdataGrid.SelectedItem as PRTRuleDataTable).netmask.ToString();
                if (PRTrule.NetRouteConfig(devIP, false, dstIP, netmask, ETH, Gateway))
                {
                    StaticGlobal.FireWalldevices[StaticGlobal.firewallindex].getFireWallPRTRule_list().Remove((PRTdataGrid.SelectedItem as PRTRuleDataTable));
                    UserMessageBox.Show("提示", "规则删除成功!");
                }
                else
                {
                    UserMessageBox.Show("提示", "规则删除失败,请检查设备连接!");
                }
                break;
            }
        }
 /*----------------------------------------------------------------
  * //函数说明:添加用户//
  * //输入:无//
  * //输出:无//
  * //----------------------------------------------------------------*/
 private void AddUserButton_Click(object sender, RoutedEventArgs e)
 {
     if (StaticGlobal.UserRole.ToUpper() == "SUPER" || StaticGlobal.UserRole.ToUpper() == "OPER")
     {
         AddUser adduser = new AddUser();
         adduser.ShowDialog();
         InitDateGrid();
     }
     else
     {
         UserMessageBox.Show("提示", "您的权限不足,无法操作!");
     }
 }
 /*----------------------------------------------------------------
  * //函数说明:删除用户//
  * //输入:无//
  * //输出:无//
  * //----------------------------------------------------------------*/
 private void DeleteButton_Click(object sender, RoutedEventArgs e)
 {
     if (StaticGlobal.UserRole.ToUpper() == "SUPER" || StaticGlobal.UserRole.ToUpper() == "OPER")
     {
         string      action;
         DataRowView SelectedElement = (DataRowView)UserData.SelectedItem;
         if (SelectedElement != null)
         {
             string username = SelectedElement.Row[1].ToString();
             if (username != StaticGlobal.UserName)
             {
                 if (UserMessageBox.Show("确认", "确定要删除用户" + username + "吗?") == true)
                 {
                     string CommandText = "delete from useraccount where UserName = '******';";
                     try
                     {
                         MySqlConnection conn = new MySqlConnection(StaticGlobal.ConnectionString);
                         conn.Open();
                         MySqlCommand comm = new MySqlCommand(CommandText, conn);
                         comm.ExecuteNonQuery();
                         comm.Dispose();
                         conn.Close();
                         conn.Dispose();
                         //MessageBox.Show("成功删除用户!");
                         UserMessageBox.Show("提示", "成功删除用户!");
                         action = "删除用户" + username;
                         Log.addlog(StaticGlobal.UserID, action, 0);
                         InitDateGrid();
                     }
                     catch (Exception)
                     {
                         //MessageBox.Show("删除用户失败,请重试!");
                         UserMessageBox.Show("提示", "删除用户失败,请重试!");
                     }
                 }
             }
             else
             {
                 UserMessageBox.Show("提示", "你不能删除你自己!");
             }
         }
         else
         {
             UserMessageBox.Show("提示", "请选择需要删除的用户!");
         }
     }
     else
     {
         UserMessageBox.Show("提示", "您的权限不足,无法操作!");
     }
 }
        /*----------------------------------------------------------------
         * //函数说明:显示登录用户权限可见的用户//
         * //输入:无//
         * //输出:无//
         * //----------------------------------------------------------------*/
        public void InitDateGrid()
        {
            DataSet result      = new DataSet();
            string  CommandText = "select UserID '用户ID' ,UserName '用户名', Purview '用户权限' from useraccount where UserName ='******'";

            if (StaticGlobal.UserRole.ToUpper() == "OPER")
            {
                CommandText += " or Purview = 'GUEST'";
            }
            if (StaticGlobal.UserRole.ToUpper() == "SUPER")
            {
                CommandText += " or Purview = 'GUEST' or Purview = 'OPER'";
            }
            CommandText += " order by 1;";
            try
            {
                MySqlConnection conn = new MySqlConnection(StaticGlobal.ConnectionString);
                conn.Open();
                MySqlDataAdapter s = new MySqlDataAdapter(CommandText, conn);
                s.Fill(result);
                conn.Close();
                for (int i = 0; i < result.Tables[0].Rows.Count; i++)
                {
                    switch (result.Tables[0].Rows[i][2].ToString().ToUpper())
                    {
                    case "SUPER":
                        result.Tables[0].Rows[i][2] = "超级用户";
                        break;

                    case "OPER":
                        result.Tables[0].Rows[i][2] = "操作员";
                        break;

                    case "GUEST":
                        result.Tables[0].Rows[i][2] = "游客";
                        break;

                    default: break;
                    }
                }
                InitGridControl();
                UserData.ItemsSource = result.Tables[0];
            }
            catch (Exception)
            {
                //MessageBox.Show("服务器连接异常!");
                UserMessageBox.Show("提示", "服务器连接异常!");
            }
        }
Exemple #19
0
        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            IPAddress ip;
            string    IPtext = IPtextBox_1.Text + "." + IPtextBox_2.Text + "." + IPtextBox_3.Text + "." + IPtextBox_4.Text;

            if (IPAddress.TryParse(IPtext, out ip) && PLCtype.Text != "")
            {
                StaticGlobal.newPLC = PLCtype.Text + "  IP: " + IPtext;
                this.Close();
            }
            else
            {
                UserMessageBox.Show("提示", "请输入正确的IP地址!");
            }
        }
        /*----------------------------------------------------------------
         * //函数说明:修改选中的用户密码//
         * //输入:无//
         * //输出:无//
         * //----------------------------------------------------------------*/
        private void ChangePasswordButton_Click(object sender, RoutedEventArgs e)
        {
            DataRowView SelectedElement = (DataRowView)UserData.SelectedItem;

            if (SelectedElement != null)
            {
                string            username = SelectedElement.Row[1].ToString();
                SetPasswordWindow ss       = new SetPasswordWindow();
                ss.textBox.Text       = username;
                ss.textBox.IsReadOnly = true;
                ss.ShowDialog();
            }
            else
            {
                UserMessageBox.Show("提示", "请选择需要修改密码的用户!");
            }
        }
Exemple #21
0
 private void NoIPConfigure_Click(object sender, RoutedEventArgs e)
 {
     if (UserMessageBox.Show("无IP配置", "确定要将此防火墙配置成无IP吗?") == true)
     {
         INoIPConfig  noip  = new NoIPConfig();
         FWDeviceForm fwdev = (from devices in StaticGlobal.fwdev_list
                               where devices.getDev_MAC() == currentselectedItem.Header.ToString().Replace("防火墙  MAC: ", "")
                               select devices).ToList <FWDeviceForm>()[0];
         if (noip.NoipConfig(fwdev))
         {
             UserMessageBox.Show("提示", "无IP配置成功!");
         }
         else
         {
             UserMessageBox.Show("提示", "无IP配置失败!");
         }
     }
 }
        private void WHLdeleteclick(object sender, MouseButtonEventArgs e)
        {
            string dev_ip = (from devices in StaticGlobal.fwdev_list
                             where devices.getDev_MAC() == StaticGlobal.firewallmac
                             select devices).ToList <FWDeviceForm>()[0].getProtecDevIP_list()[0];
            string            dst_ip   = (WHLdataGrid.SelectedItem as WHLRuleDataTable).dst_IP.ToString();
            string            src_IP   = (WHLdataGrid.SelectedItem as WHLRuleDataTable).src_IP.ToString();
            string            dst_port = (WHLdataGrid.SelectedItem as WHLRuleDataTable).dst_port.ToString();
            string            src_port = (WHLdataGrid.SelectedItem as WHLRuleDataTable).src_port.ToString();
            bool              log      = (WHLdataGrid.SelectedItem as WHLRuleDataTable).log;
            IConfigWhiteLists fw       = new ConfigWhiteLists();

            if (fw.ChangeWhiteLists(dev_ip, dst_ip, src_IP, dst_port, src_port, log, false))
            {
                StaticGlobal.FireWalldevices[StaticGlobal.firewallindex].getWHLRule_list().Remove((WHLdataGrid.SelectedItem as WHLRuleDataTable));
                UserMessageBox.Show("提示", "规则删除成功!");
            }
        }
        /// <summary>
        /// 静态方法 模拟MESSAGEBOX.Show方法
        /// </summary>
        /// <param name="title">标题</param>
        /// <param name="msg">消息</param>
        /// <returns></returns>

        /*----------------------------------------------------------------
         * //函数说明:根据不同的用户权限加载不同的权限选择框//
         * //输入:string类型标题,string类型信息//
         * //输出:无//
         * //----------------------------------------------------------------*/
        public static bool?Show(string title, string msg)
        {
            var msgBox = new UserMessageBox();

            msgBox.Title   = title;
            msgBox.Message = msg;
            if (title == "提示" || title == "错误")
            {
                msgBox.Tip.Visibility     = Visibility.Visible;
                msgBox.Confirm.Visibility = Visibility.Collapsed;
            }
            else
            {
                msgBox.Tip.Visibility     = Visibility.Collapsed;
                msgBox.Confirm.Visibility = Visibility.Visible;
            }
            msgBox.Focus();
            return(msgBox.ShowDialog());
        }
Exemple #24
0
        /*----------------------------------------------------------------
         * //函数说明:增加用户函数//
         * //输入:无//
         * //输出:无//
         * //----------------------------------------------------------------*/
        private void Add()
        {
            string action;
            string userRole;

            switch (comboBox.Text)
            {
            case "操作员":
                userRole = "OPER";
                break;

            case "游客":
                userRole = "GUEST";
                break;

            default:
                userRole = "OPER";
                break;
            }
            string CommandText = "insert into useraccount (UserName,Password,Purview) values('" + textBox.Text + "','" + passwordBox.Password + "','" + userRole + "');";

            try
            {
                MySqlConnection conn = new MySqlConnection(StaticGlobal.ConnectionString);
                conn.Open();
                MySqlCommand comm = new MySqlCommand(CommandText, conn);
                comm.ExecuteNonQuery();
                comm.Dispose();
                conn.Close();
                conn.Dispose();
                //MessageBox.Show("添加用户成功!");
                UserMessageBox.Show("提示", "添加用户" + textBox.Text + "成功!");
                action = "添加用户" + textBox.Text;
                Log.addlog(StaticGlobal.UserID, action, 0);
                this.Close();
            }
            catch (Exception)
            {
                //MessageBox.Show("添加用户失败,请重试!");
                UserMessageBox.Show("提示", "添加用户失败,请重试!");
            }
        }
Exemple #25
0
        private void NOIP_Click(object sender, RoutedEventArgs e)
        {
            INoIPConfig conf = new NoIPConfig();

            for (int i = 0; i < StaticGlobal.fwdev_list.Count(); i++)
            {
                if (StaticGlobal.fwdev_list[i].getDev_MAC() == StaticGlobal.firewallmac)
                {
                    if (conf.NoipConfig(StaticGlobal.fwdev_list[i]))
                    {
                        UserMessageBox.Show("提示", "无IP模式配置成功!");
                        StaticGlobal.FwMACandIP[StaticGlobal.firewallmac] = "0.0.0.0";
                        FWIP.Text = StaticGlobal.FwMACandIP[StaticGlobal.firewallmac];
                    }
                    else
                    {
                        UserMessageBox.Show("提示", "无IP模式配置失败!");
                        FWIP.Text = StaticGlobal.FwMACandIP[StaticGlobal.firewallmac];
                    }
                }
            }
        }
Exemple #26
0
        private void STDdeleteclick(object sender, MouseButtonEventArgs e)
        {
            ISTDRulesManage fw     = new STDRulesManage();
            string          dev_ip = (from devices in StaticGlobal.fwdev_list
                                      where devices.getDev_MAC() == StaticGlobal.firewallmac
                                      select devices).ToList <FWDeviceForm>()[0].getProtecDevIP_list()[0];
            string protocol = (STDdataGrid.SelectedItem as STDRuleDataTable).protocol;
            string srcIP    = (STDdataGrid.SelectedItem as STDRuleDataTable).srcIP;
            string dstIP    = (STDdataGrid.SelectedItem as STDRuleDataTable).dstIP;
            string sport    = (STDdataGrid.SelectedItem as STDRuleDataTable).sport;
            string dport    = (STDdataGrid.SelectedItem as STDRuleDataTable).dport;
            bool   log      = (STDdataGrid.SelectedItem as STDRuleDataTable).log;

            if (fw.DelSTDRules(dev_ip, log, protocol, srcIP, dstIP, sport, dport))
            {
                StaticGlobal.FireWalldevices[StaticGlobal.firewallindex].getSTDRule_list().Remove((STDdataGrid.SelectedItem as STDRuleDataTable));
                UserMessageBox.Show("提示", "规则删除成功!");
            }
            else
            {
                UserMessageBox.Show("提示", "规则删除失败,请检查设备连接!");
            }
        }
Exemple #27
0
        private void AddWHL(object sender, RoutedEventArgs e)
        {
            //需要加入的规则信息
            string src_ip  = srcStarttextBox_1.Text + '.' + srcStarttextBox_2.Text + '.' + srcStarttextBox_3.Text + '.' + srcStarttextBox_4.Text;
            string dst_ip  = dstStarttextBox_1.Text + '.' + dstStarttextBox_2.Text + '.' + dstStarttextBox_3.Text + '.' + dstStarttextBox_4.Text;
            string sport   = sportBox.Text.ToString();
            string dport   = dportBox.Text.ToString();
            bool   logtext = Convert.ToBoolean(logcheckBox.IsChecked);

            if (src_ip != "" && dst_ip != "" && sport != "" && dport != "")
            {
                WHLConfigurationApply fw = new WHLConfigurationApply();
                if (StaticGlobal.editflag == false)
                {
                    List <string> dt = (from rules in StaticGlobal.FireWalldevices[StaticGlobal.firewallindex].getWHLRule_list()
                                        where rules.dst_IP == dst_ip && rules.src_IP == src_ip && rules.dst_port == dport && rules.src_port == sport
                                        select rules.dst_IP).ToList <string>();
                    if (dt.Count == 0)
                    {
                        StaticGlobal.FireWalldevices[StaticGlobal.firewallindex].addWHLRule(new WHLRuleDataTable()
                        {
                            dst_IP = dst_ip,
                            src_IP = src_ip, dst_port = dport, src_port = sport, log = logtext
                        });
                        this.Close();
                        fw.MACWHLlabel.Content = "MAC: " + StaticGlobal.firewallmac;
                        fw.WHLIPlabel.Content  = "IP: " + StaticGlobal.FwMACandIP[StaticGlobal.firewallmac];
                        fw.ShowDialog();
                    }
                    else
                    {
                        UserMessageBox.Show("提示", "添加失败,已经存在此规则!");
                    }
                }
                else
                {
                    //被修改的规则信息
                    string editeddstIP = StaticGlobal.FireWalldevices[StaticGlobal.firewallindex].getWHLRule_list()[StaticGlobal.selectedindex].dst_IP;
                    string editedsrcIP = StaticGlobal.FireWalldevices[StaticGlobal.firewallindex].getWHLRule_list()[StaticGlobal.selectedindex].src_IP;
                    string editeddport = StaticGlobal.FireWalldevices[StaticGlobal.firewallindex].getWHLRule_list()[StaticGlobal.selectedindex].dst_port;
                    string editedsport = StaticGlobal.FireWalldevices[StaticGlobal.firewallindex].getWHLRule_list()[StaticGlobal.selectedindex].src_port;
                    bool   editedlog   = StaticGlobal.FireWalldevices[StaticGlobal.firewallindex].getWHLRule_list()[StaticGlobal.selectedindex].log;
                    StaticGlobal.FireWalldevices[StaticGlobal.firewallindex].getWHLRule_list()[StaticGlobal.selectedindex] = new WHLRuleDataTable()
                    {
                        dst_IP = ""
                    };
                    List <string> dt = (from rules in StaticGlobal.FireWalldevices[StaticGlobal.firewallindex].getWHLRule_list()
                                        where  rules.dst_IP == dst_ip && rules.src_IP == src_ip && rules.dst_port == dport && rules.src_port == sport
                                        select rules.dst_IP).ToList <string>();
                    if (dt.Count == 0)
                    {
                        fw.MACWHLlabel.Content = "MAC: " + StaticGlobal.firewallmac;
                        fw.WHLIPlabel.Content  = "IP: " + StaticGlobal.FwMACandIP[StaticGlobal.firewallmac];
                        fw.ShowDialog();
                    }
                    else
                    {
                        StaticGlobal.FireWalldevices[StaticGlobal.firewallindex].getWHLRule_list()[StaticGlobal.selectedindex] = (new WHLRuleDataTable()
                        {
                            dst_IP = editeddstIP,
                            src_IP = editedsrcIP,
                            dst_port = editeddport,
                            src_port = editedsport,
                            log = editedlog
                        });
                        UserMessageBox.Show("提示", "编辑失败,已经存在此规则!");
                    }
                }
            }
            else
            {
                UserMessageBox.Show("提示", "请输入正确的规则!");
            }
        }
        private void AddCNC(object sender, RoutedEventArgs e)
        {
            CNCConfigurationApply fw = new CNCConfigurationApply();
            int    connlimittext     = Convert.ToInt16(connBox.Text);
            string srcIPtext         = srcStarttextBox_1.Text + '.' + srcStarttextBox_2.Text + '.' + srcStarttextBox_3.Text + '.' + srcStarttextBox_4.Text;
            string dstIPtext         = dstStarttextBox_1.Text + '.' + dstStarttextBox_2.Text + '.' + dstStarttextBox_3.Text + '.' + dstStarttextBox_4.Text;
            string sporttext         = sportBox.Text;
            string dporttext         = dportBox.Text;
            bool   logtext           = Convert.ToBoolean(logcheckBox.IsChecked);

            if (connlimittext != 0 && srcIPtext != "" && dstIPtext != "" && sporttext != "" && dporttext != "")
            {
                if (StaticGlobal.editflag == false)
                {
                    List <string> dt = (from rules in StaticGlobal.FireWalldevices[StaticGlobal.firewallindex].getCNCRule_list()
                                        where rules.connlimit == connlimittext && rules.srcIP == srcIPtext &&
                                        rules.dstIP == dstIPtext && rules.sport == sporttext && rules.dport == dporttext
                                        select rules.dstIP).ToList <string>();
                    if (dt.Count == 0)
                    {
                        StaticGlobal.FireWalldevices[StaticGlobal.firewallindex].addCNCRule(new CNCRuleDataTable()
                        {
                            connlimit = connlimittext,
                            srcIP     = srcIPtext,
                            dstIP     = dstIPtext,
                            sport     = sporttext,
                            dport     = dporttext,
                            log       = logtext
                        });
                        this.Close();
                        fw.MACCNClabel.Content = "MAC: " + StaticGlobal.firewallmac;
                        fw.CNCIPlabel.Content  = "IP: " + StaticGlobal.FwMACandIP[StaticGlobal.firewallmac];
                        fw.ShowDialog();
                    }
                    else
                    {
                        UserMessageBox.Show("提示", "添加失败,已经存在此规则!");
                    }
                }
                else
                {
                    int           editconnlimittext = StaticGlobal.FireWalldevices[StaticGlobal.firewallindex].getCNCRule_list()[StaticGlobal.selectedindex].connlimit;
                    string        editsrcIPtext     = StaticGlobal.FireWalldevices[StaticGlobal.firewallindex].getCNCRule_list()[StaticGlobal.selectedindex].srcIP;
                    string        editdstIPtext     = StaticGlobal.FireWalldevices[StaticGlobal.firewallindex].getCNCRule_list()[StaticGlobal.selectedindex].dstIP;
                    string        editsporttext     = StaticGlobal.FireWalldevices[StaticGlobal.firewallindex].getCNCRule_list()[StaticGlobal.selectedindex].sport;
                    string        editdporttext     = StaticGlobal.FireWalldevices[StaticGlobal.firewallindex].getCNCRule_list()[StaticGlobal.selectedindex].dport;
                    bool          editlogtext       = StaticGlobal.FireWalldevices[StaticGlobal.firewallindex].getCNCRule_list()[StaticGlobal.selectedindex].log;
                    List <string> dt = (from rules in StaticGlobal.FireWalldevices[StaticGlobal.firewallindex].getCNCRule_list()
                                        where rules.connlimit == editconnlimittext && rules.srcIP == editsrcIPtext &&
                                        rules.dstIP == editdstIPtext && rules.sport == editsporttext && rules.dport == editdporttext
                                        select rules.dstIP).ToList <string>();
                    if (dt.Count == 0)
                    {
                        StaticGlobal.FireWalldevices[StaticGlobal.firewallindex].getCNCRule_list()[StaticGlobal.selectedindex] = new CNCRuleDataTable()
                        {
                            connlimit = connlimittext,
                            srcIP     = srcIPtext,
                            dstIP     = dstIPtext,
                            sport     = sporttext,
                            dport     = dporttext,
                            log       = logtext
                        };
                        this.Close();
                        fw.MACCNClabel.Content = "MAC: " + StaticGlobal.firewallmac;
                        fw.CNCIPlabel.Content  = "IP: " + StaticGlobal.FwMACandIP[StaticGlobal.firewallmac];
                        fw.ShowDialog();
                    }
                    else
                    {
                        UserMessageBox.Show("提示", "添加失败,已经存在此规则!");
                    }
                }
            }
            else
            {
                UserMessageBox.Show("提示", "请输入正确的规则!");
            }
        }
Exemple #29
0
        private void Applying()
        {
            Dispatcher.Invoke(new Action(() =>
            {
                NewRulebutton.IsEnabled = false;
                Applybutton.IsEnabled   = false;
                dataGrid.IsEnabled      = false;
                Closebutton.IsEnabled   = false;
            }));
            //找出需要删除的规则
            var deleteRules = StaticGlobal.oldrules.Where(deleteRule => !StaticGlobal.FireWalldevices[StaticGlobal.firewallindex].getFireWallRule_list().Contains(deleteRule)).ToList();

            //找出需要增加的规则
            var    addRules     = StaticGlobal.FireWalldevices[StaticGlobal.firewallindex].getFireWallRule_list().Where(addRule => !StaticGlobal.oldrules.Contains(addRule)).ToList();
            bool   allApplyFlag = true;
            string dev_ip       = (from devices in StaticGlobal.fwdev_list
                                   where devices.getDev_MAC() == StaticGlobal.firewallmac
                                   select devices).ToList <FWDeviceForm>()[0].getProtecDevIP_list()[0];

            IDPIRulesManage rulesmg = new DPIRulesManage();

            //增加规则
            for (int i = 0; i < addRules.Count(); i++)
            {
                string protocol         = addRules[i].protocol;
                string source           = addRules[i].source;
                string destination      = addRules[i].destination;
                string coiladdressstart = addRules[i].coiladdressstart;
                string coiladdressend   = addRules[i].coiladdressend;
                int    mindata          = addRules[i].mindata;
                int    maxdata          = addRules[i].maxdata;
                string functioncode     = addRules[i].func;
                bool   log = addRules[i].log;
                //string[] functioncode16 = fuctioncode.Split(';');
                //string[] functioncode10 = new string[functioncode16.Length];
                //if (fuctioncode == "")
                //{
                //    functioncode10 = null;
                //}
                //else
                //{
                //    for (int j = 0; j < functioncode16.Length; j++)
                //    {
                //        functioncode10[j] = Convert.ToInt16(functioncode16[j], 16).ToString();
                //    }
                //}

                //IRulesManage rulesmg = new RulesManage();
                switch (protocol)
                {
                case "ModbusTCP":
                    if (rulesmg.ChangeModbusTcpRules(destination, source, coiladdressstart, coiladdressend, functioncode, mindata, maxdata, dev_ip, log, true))
                    {
                        allApplyFlag = true;
                    }
                    else
                    {
                        allApplyFlag = false;
                    }
                    break;

                case "OPC":
                    if (rulesmg.ChangeOPCRules(destination, source, dev_ip, log, true))
                    {
                        allApplyFlag = true;
                    }
                    else
                    {
                        allApplyFlag = false;
                    }
                    break;

                case "DNP3":
                    if (rulesmg.ChangeDNP3Rules(destination, source, dev_ip, log, true))
                    {
                        allApplyFlag = true;
                    }
                    else
                    {
                        allApplyFlag = false;
                    }
                    break;
                }
            }
            //删除规则
            for (int i = 0; i < deleteRules.Count(); i++)
            {
                string protocol         = deleteRules[i].protocol;
                string source           = deleteRules[i].source;
                string destination      = deleteRules[i].destination;
                string coiladdressstart = deleteRules[i].coiladdressstart;
                string coiladdressend   = deleteRules[i].coiladdressend;
                int    mindata          = deleteRules[i].mindata;
                int    maxdata          = deleteRules[i].maxdata;
                string functioncode     = deleteRules[i].func;
                bool   log = deleteRules[i].log;
                //string[] functioncode16 = fuctioncode.Split(';');
                //string[] functioncode10 = new string[functioncode16.Length];
                //if (fuctioncode == "")
                //{
                //    functioncode10 = null;
                //}
                //else
                //{
                //    for (int j = 0; j < functioncode16.Length; j++)
                //    {
                //        functioncode10[j] = Convert.ToInt16(functioncode16[j], 16).ToString();
                //    }
                //}

                //IRulesManage rulesmg = new RulesManage();
                switch (protocol)
                {
                case "ModbusTCP":
                    if (rulesmg.ChangeModbusTcpRules(destination, source, coiladdressstart, coiladdressend, functioncode, mindata, maxdata, dev_ip, log, false))
                    {
                        allApplyFlag = true;
                    }
                    else
                    {
                        allApplyFlag = false;
                    }
                    break;

                case "OPC":
                    if (rulesmg.ChangeOPCRules(destination, source, dev_ip, log, false))
                    {
                        allApplyFlag = true;
                    }
                    else
                    {
                        allApplyFlag = false;
                    }
                    break;

                case "DNP3":
                    if (rulesmg.ChangeDNP3Rules(destination, source, dev_ip, log, false))
                    {
                        allApplyFlag = true;
                    }
                    else
                    {
                        allApplyFlag = false;
                    }
                    break;
                }
            }
            Dispatcher.Invoke(new Action(() =>
            {
                if (allApplyFlag)
                {
                    UserMessageBox.Show("提示", "所有规则已成功应用!");
                }
                else
                {
                    UserMessageBox.Show("提示", "部分规则未成功应用,请检查设备之间的连接!");
                }
                this.Close();
            }
                                         ));
            ApplyThread.Abort();
        }
Exemple #30
0
        //*----------------------------------------------------------------
        //函数说明:导出数据表按钮事件,可导出xls,xlsx,rtf,pdf,scv,txt,html格式
        //输入:无
        //输出:无
        //----------------------------------------------------------------*//
        private void Exportbutton_Click(object sender, RoutedEventArgs e)
        {
            SaveFileDialog saveDialog = new SaveFileDialog();

            saveDialog.Filter   = "Excel (2003) (*.xls)|*.xls|Excel (2010) (*.xlsx)|*.xlsx|Rtf文件 (*.rtf)|*.rtf|Pdf文件 (*.pdf)|*.pdf|Csv文件 (*.csv)|*.csv|文本文件 (*.txt)|*.txt|网页 (*.html)|*.html";
            saveDialog.FileName = Convert.ToDateTime(StartDate.EditValue).ToString("yyyy年MM月dd日HH时mm分ss秒") + "—" + Convert.ToDateTime(EndDate.EditValue).ToString("yyyy年MM月dd日HH时mm分ss秒") + "被保护设备" + ProtectedIP.Text + "的日志";
            if (saveDialog.ShowDialog() != false)
            {
                string exportFilePath = saveDialog.FileName;
                string fileExtenstion = new FileInfo(exportFilePath).Extension;
                switch (fileExtenstion)
                {
                case ".xls":
                    new PrintableControlLink(view).ExportToXls(exportFilePath);
                    break;

                case ".xlsx":
                    new PrintableControlLink(view).ExportToXlsx(exportFilePath);
                    break;

                case ".rtf":
                    view.ExportToRtf(exportFilePath);
                    break;

                case ".pdf":
                    view.ExportToPdf(exportFilePath);
                    break;

                case ".csv":
                    view.ExportToCsv(exportFilePath);
                    break;

                case ".txt":
                    view.ExportToText(exportFilePath);
                    break;

                case ".html":
                    view.ExportToHtml(exportFilePath);
                    break;

                default:
                    break;
                }

                if (File.Exists(exportFilePath))
                {
                    try
                    {
                        if (UserMessageBox.Show("导出", "文件已成功导出,是否打开文件?") == true)
                        {
                            System.Diagnostics.Process.Start(exportFilePath);
                        }
                    }
                    catch
                    {
                        String msg = "无法打开文件!" + Environment.NewLine + Environment.NewLine + "路径:" + exportFilePath;
                        UserMessageBox.Show("错误", msg);
                    }
                }
                else
                {
                    String msg = "无法保存文件!" + Environment.NewLine + Environment.NewLine + "路径:" + exportFilePath;
                    UserMessageBox.Show("错误", msg);
                }
            }
        }