예제 #1
0
파일: Program.cs 프로젝트: safronovba/MS
        static void Main(string[] args)
        {
            Console.WriteLine("Hello.");

            monitor m1 = new monitor();
            scan s1 = new scan();
            dbwork db = new dbwork();
            string dbaddress=null;

            try { dbaddress = db.getdbparam("config.txt").GetValue(1).ToString(); }
            catch (System.IO.FileNotFoundException) { Console.WriteLine("Config file is not found"); Console.ReadKey(); return; }

            try
            {
                db.tableexist(dbaddress, "hosts");
            }
            catch (InvalidOperationException)
            {
                Console.WriteLine("You have no AccessDatabaseEngine. Contact your administrator.");
                Console.ReadKey();
                return;
            }

            Console.WriteLine("Database file at "+dbaddress+"\n");

            if (args.Length == 0)
            {
                m1.checknow();
            }
            else
            {
                if (args[0] == "scantd")
                {
                     s1.scannow(); return;
                }
                if (args[0] == "deltd")
                {
                    Console.WriteLine("Now table forscan delete");
                    try
                    {
                        db.droptdforscandb(dbaddress, "forscan");
                    }
                    catch (System.Data.OleDb.OleDbException) { Console.WriteLine("Can not delete"); return; }
                    Console.WriteLine("Complite.\nWrite new cfg");
                    db.setdbparam("config.txt", 2, "scanstopnow");
                    Console.WriteLine("Done\nGood bye.");
                    Thread.Sleep(3000);
                    return;
                }
                if (args[0] == "check")
                {
                    m1.checknow(); return;
                }
            }
        }
예제 #2
0
파일: Program.cs 프로젝트: safronovba/MS
        static void Main(string[] args)
        {
            Console.WriteLine("Hello.");

            monitor m1        = new monitor();
            scan    s1        = new scan();
            dbwork  db        = new dbwork();
            string  dbaddress = null;

            try { dbaddress = db.getdbparam("config.txt").GetValue(1).ToString(); }
            catch (System.IO.FileNotFoundException) { Console.WriteLine("Config file is not found"); Console.ReadKey(); return; }

            try
            {
                db.tableexist(dbaddress, "hosts");
            }
            catch (InvalidOperationException)
            {
                Console.WriteLine("You have no AccessDatabaseEngine. Contact your administrator.");
                Console.ReadKey();
                return;
            }

            Console.WriteLine("Database file at " + dbaddress + "\n");

            if (args.Length == 0)
            {
                m1.checknow();
            }
            else
            {
                if (args[0] == "scantd")
                {
                    s1.scannow(); return;
                }
                if (args[0] == "deltd")
                {
                    Console.WriteLine("Now table forscan delete");
                    try
                    {
                        db.droptdforscandb(dbaddress, "forscan");
                    }
                    catch (System.Data.OleDb.OleDbException) { Console.WriteLine("Can not delete"); return; }
                    Console.WriteLine("Complite.\nWrite new cfg");
                    db.setdbparam("config.txt", 2, "scanstopnow");
                    Console.WriteLine("Done\nGood bye.");
                    Thread.Sleep(3000);
                    return;
                }
                if (args[0] == "check")
                {
                    m1.checknow(); return;
                }
            }
        }
예제 #3
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        dbwork    db     = new dbwork();
        IPAddress fromip = null;
        IPAddress toip   = null;

        if (db.tableexist(dbaddress, "forscan"))
        {
            db.droptdforscandb(dbaddress, "forscan");
            db.addtbforscandb(dbaddress, "forscan");
        }
        else
        {
            db.addtbforscandb(dbaddress, "forscan");
        }


        try
        {
            fromip = IPAddress.Parse(scanrangefrombox.Text);
            toip   = IPAddress.Parse(scanrangetobox.Text);
        }
        catch
        { scanstate.Text = "Wrong ip"; }
        icmp temp = new icmp();

        int re = 1, id = 1;

        re = System.Int32.Parse(retrycountbox.Text);
        string group = groupnamebox.Text;
        var    ips   = temp.ExpandIpRange(fromip, toip);

        foreach (var ip in ips)
        {
            id++;
            db.insertdb(dbaddress, "INSERT INTO forscan (Код,ip,grp) values (" + id + ",'" + ip + "','" + group + "')");
        }
        //      scanstate.Text = "Range send to check";
    }
예제 #4
0
파일: scan.aspx.cs 프로젝트: safronovba/MS
    protected void Button1_Click(object sender, EventArgs e)
    {
        dbwork db = new dbwork();
        IPAddress fromip = null;
        IPAddress toip = null;

        if (db.tableexist(dbaddress, "forscan"))
        {
            db.droptdforscandb(dbaddress, "forscan");
            db.addtbforscandb(dbaddress, "forscan");
        }
        else
        {
            db.addtbforscandb(dbaddress, "forscan");
        }

        try
        {
            fromip = IPAddress.Parse(scanrangefrombox.Text);
            toip = IPAddress.Parse(scanrangetobox.Text);
        }
        catch
        { scanstate.Text = "Wrong ip"; }
        icmp temp = new icmp();

        int re = 1, id = 1;
        re = System.Int32.Parse(retrycountbox.Text);
        string group = groupnamebox.Text;
        var ips = temp.ExpandIpRange(fromip, toip);
        foreach (var ip in ips)
        {
            id++;
            db.insertdb(dbaddress, "INSERT INTO forscan (Код,ip,grp) values (" + id + ",'" + ip + "','" + group + "')");
        }
          //      scanstate.Text = "Range send to check";
    }
예제 #5
0
파일: UnitTest1.cs 프로젝트: safronovba/MS
 public void DbDeleteTableTest()
 {
     dbaddress = newdb.getdbparam("config.txt").GetValue(1).ToString();
     newdb.droptdforscandb(dbaddress, "forscan");
 }