public void RefreshConnection(string name)
 {
     try
     {
         int position = networkElements.IndexOf(name);
         if (position >= 0)
         {
             int status = dataBaseReference.CheckConn1(name);
             networkElementsStatus[position] = status;
             RefreshStatus(name, status);
         }
         //networkElementsStatus[position] = dataBaseReference.CheckConn1(name);
     }
     catch (Exception ex)
     {
         FileParser.LogException(ex);
     }
 }
 public bool TestConnection(string SSHIp, string Username, string Password)
 {
     try
     {
         bool res = false;
         using (var client = new SshClient(SSHIp, Username, Password))
         {
             client.Connect();
             res = client.IsConnected;
             client.Disconnect();
         }
         return(res);
     }
     catch (Exception ex)
     {
         FileParser.LogException(ex);
         return(false);
     }
 }
예제 #3
0
        private bool Login()
        {
            String logname  = txt_Username.Text;
            String Password = User.Encrypt(txt_Password.Text);

            string[] s        = { "\\bin" };
            string   database =
                Application.StartupPath.Split(s, StringSplitOptions.None)[0] + "\\Data\\Nokia.db";
            string connectionString =
                "Data Source=" + Path.GetFullPath(database);
            SQLiteConnection myconn = new SQLiteConnection(connectionString);

            try
            {
                myconn.Open();

                Queries       q    = new Queries();
                DataTable     show = new DataTable();
                SQLiteCommand cmd  = new SQLiteCommand(q.Login(logname, Password), myconn);

                int Result = Convert.ToInt32(cmd.ExecuteScalar());
                Console.WriteLine(Result);
                myconn.Close();
                if (Result > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("PROBLEM RETRIEVING DATA PLEASE TRY AGAIN");
                FileParser.LogException(ex);
            }


            return(false);
        }
예제 #4
0
        private void RefreshUsers()
        {
            SQLiteConnection myconn = new SQLiteConnection(pathh);

            myconn.Open();
            DataTable         show = new DataTable();
            SQLiteDataAdapter adap = new SQLiteDataAdapter("Select * from usersTable", myconn);

            adap.Fill(show);
            try
            {
                usersGrid.DataSource = show;
            }
            catch (Exception ex)
            {
                usersGrid.Rows[User.row].Cells[2].Value = User.oldUsername;
                usersGrid.Rows[User.row].Cells[3].Value = User.Encrypt(User.oldPassword);
                FileParser.LogException(ex);
            }
            myconn.Close();
        }
        private void ListingNetworks()
        {
            SQLiteConnection myconn = new SQLiteConnection(pathh);

            try
            {
                myconn.Open();
            }
            catch (Exception ex)
            {
                FileParser.LogException(ex);
                MessageBox.Show("Check Network");
            }
            Queries           q    = new Queries();
            DataTable         show = new DataTable();
            SQLiteDataAdapter adap = new SQLiteDataAdapter(q.ShowNetworks(), myconn);

            adap.Fill(show);
            NetworkGrid.DataSource = show;
            myconn.Close();
        }
예제 #6
0
        //////////--------------------Networks Tab--------------------\\\\\\\\\\

        private void NetworkGrid_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 0)
            {
                try
                {
                    string str = NetworkGrid.Rows[e.RowIndex].Cells[5].Value.ToString();
                    if (MessageBox.Show("Are you sure you want to delete network element '" + str + "' ?", "Confirm Deletion", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        SQLiteConnection myconnection = new SQLiteConnection(path);
                        myconnection.Open();
                        SQLiteCommand cmd = new SQLiteCommand(q.DeleteNetwork(str), myconnection);
                        cmd.ExecuteNonQuery();
                        myconnection.Close();
                        ListingNetworks();
                    }
                }
                catch (Exception ex)
                {
                    FileParser.LogException(ex);
                }
            }
        }
예제 #7
0
 private void UsersGrid_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex == 0)
     {
         try
         {
             string str = usersGrid.Rows[e.RowIndex].Cells[2].Value.ToString();
             if (MessageBox.Show("Are you sure you want to delete user '" + str + "' ?", "Confirm Deletion", MessageBoxButtons.YesNo) == DialogResult.Yes)
             {
                 SQLiteConnection myconnection = new SQLiteConnection(path);
                 myconnection.Open();
                 SQLiteCommand cmd = new SQLiteCommand("delete from usersTable where username = @username;", myconnection);
                 cmd.Parameters.Add(new SQLiteParameter("@username", str));
                 cmd.ExecuteNonQuery();
                 myconnection.Close();
                 RefreshUsers();
             }
         }
         catch (Exception ex)
         {
             FileParser.LogException(ex);
         }
     }
 }
예제 #8
0
 private static void MyCommonExceptionHandlingMethod(object sender, ThreadExceptionEventArgs e)
 {
     //#comment use your logger
     FileParser.LogException(e.Exception);
     throw new NotImplementedException();
 }