示例#1
0
 private void LoadSettings()
 {
     this.m_pDsSettings = new DataSet();
     this.m_pDsSettings.Tables.Add("Settings");
     this.m_pDsSettings.Tables["Settings"].Columns.Add("Program");
     this.m_pDsSettings.Tables["Settings"].Columns.Add("Arguments");
     this.m_pDsSettings.Tables["Settings"].Columns.Add("VirusExitCode");
     if (File.Exists(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\VirusScan.xml"))
     {
         this.m_pDsSettings.ReadXml(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\VirusScan.xml");
     }
     else
     {
         DataRow dataRow = this.m_pDsSettings.Tables["Settings"].NewRow();
         dataRow["Program"]       = "";
         dataRow["Arguments"]     = "";
         dataRow["VirusExitCode"] = 1;
         this.m_pDsSettings.Tables["Settings"].Rows.Add(new object[0]);
     }
     this.m_pScanProgram.Text      = this.m_pDsSettings.Tables["Settings"].Rows[0]["Program"].ToString();
     this.m_pScanProgramArgs.Text  = this.m_pDsSettings.Tables["Settings"].Rows[0]["Arguments"].ToString();
     this.m_pVirusIfExitCode.Value = ConvertEx.ToInt32(this.m_pDsSettings.Tables["Settings"].Rows[0]["VirusExitCode"], 1);
 }
示例#2
0
        /// <summary>
        /// Loads settings from xml file to UI.
        /// </summary>
        private void LoadSettings()
        {
            m_pDsSettings = new DataSet();
            m_pDsSettings.Tables.Add("General");
            m_pDsSettings.Tables["General"].Columns.Add("CheckHelo");
            m_pDsSettings.Tables["General"].Columns.Add("LogRejections");
            m_pDsSettings.Tables.Add("BlackListSettings");
            m_pDsSettings.Tables["BlackListSettings"].Columns.Add("ErrorText");
            m_pDsSettings.Tables.Add("BlackList");
            m_pDsSettings.Tables["BlackList"].Columns.Add("IP");
            m_pDsSettings.Tables.Add("Servers");
            m_pDsSettings.Tables["Servers"].Columns.Add("Cost");
            m_pDsSettings.Tables["Servers"].Columns.Add("Server");
            m_pDsSettings.Tables["Servers"].Columns.Add("DefaultRejectionText");

            if (File.Exists(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\lsDNSBL_Filter_db.xml"))
            {
                m_pDsSettings.ReadXml(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\lsDNSBL_Filter_db.xml");
            }

            //--- Load general ----------------------------------------------------------------------------------//
            // If no default settings, create them.
            if (m_pDsSettings.Tables["General"].Rows.Count == 0)
            {
                DataRow dr = m_pDsSettings.Tables["General"].NewRow();
                dr["CheckHelo"]     = false;
                dr["LogRejections"] = false;
                m_pDsSettings.Tables["General"].Rows.Add(dr);
            }

            m_pGeneral_CheckHelo.Checked     = ConvertEx.ToBoolean(m_pDsSettings.Tables["General"].Rows[0]["CheckHelo"]);
            m_pGeneral_LogRejections.Checked = ConvertEx.ToBoolean(m_pDsSettings.Tables["General"].Rows[0]["LogRejections"]);
            //----------------------------------------------------------------------------------------------------//

            //--- Load black list -------------------------------------------------------------------------------//
            // If no default settings, create them.
            if (m_pDsSettings.Tables["BlackListSettings"].Rows.Count == 0)
            {
                DataRow dr = m_pDsSettings.Tables["BlackListSettings"].NewRow();
                dr["ErrorText"] = "Your IP is in server black list !";
                m_pDsSettings.Tables["BlackListSettings"].Rows.Add(dr);
            }

            m_pBlackList_ErrorText.Text = m_pDsSettings.Tables["BlackListSettings"].Rows[0]["ErrorText"].ToString();

            foreach (DataRow dr in m_pDsSettings.Tables["BlackList"].Rows)
            {
                m_pBlackList_IPs.Items.Add(dr["IP"].ToString());
            }
            //----------------------------------------------------------------------------------------------------//

            //--- Load DNSBL servers ------------------------------------//
            foreach (DataRow dr in m_pDsSettings.Tables["Servers"].Rows)
            {
                ListViewItem it = new ListViewItem();
                it.Tag  = dr;
                it.Text = dr["Server"].ToString();
                it.SubItems.Add(dr["DefaultRejectionText"].ToString());
                m_pServers.Items.Add(it);
            }

            m_pServers_SelectedIndexChanged(this, new EventArgs());
            //----------------------------------------------------------//
        }
示例#3
0
 public static int ToInt32(object value)
 {
     return(ConvertEx.ToInt32(value, 0));
 }