// SHOW ALL
        protected void ButtonW3_Click(object sender, EventArgs e)
        {
            TextBoxW1.Text    = "";
            curr_status       = "ALL";
            GridView1.Visible = false;
            GridView2.Visible = false;
            string sqlType = "WIFICOUNT";

            string user_name = DropDownList1.SelectedValue;


            if (datasource == "SQL")
            {
                string date_string1 = Calendar1.SelectedDate.Date.ToString();
                string date_string2 = Calendar2.SelectedDate.Date.AddDays(1).ToString();
                string testDate1    = $@"'{date_string1}'";
                string testDate2    = $@"'{date_string2}'";

                if (user_name == "")                                // If no username given, search with all users
                {
                    Wifi_All = $@"
            SELECT WifisFound,SaveTime,Location,UserName,Id 
            FROM {dbname} 
            WHERE SaveTime >= {testDate1} AND SaveTime <= {testDate2} AND Location NOT LIKE '%NO_LOCATION%' 
            ORDER BY Text;";
                }
                else
                {                                                   // Filter with user name
                    Wifi_All = $@"
            SELECT WifisFound,SaveTime,Location,UserName,Id 
            FROM {dbname} 
            WHERE SaveTime >= {testDate1} AND SaveTime <= {testDate2} AND UserName={$@"'{user_name}'"} AND Location NOT LIKE '%NO_LOCATION%' 
            ORDER BY Text;";
                }

                inputstring = Wifi_All;
                var sqlget = new SQL_query();
                outputstring = sqlget.SQL_read(inputstring, sqlType);
            }
            else
            {
                outputstring = read_data_from_blob(curr_status);
                mapstring    = read_map_from_blob(curr_status);
            }
            if (outputstring != "")
            {
                if (outputstring.StartsWith("Error"))
                {
                    TextBoxW1.Text = outputstring;
                }
                else
                {
                    show_table(outputstring);
                }
            }
            else
            {
                TextBoxW1.Text = "No matching records found.\n";
            }
        }
        //SHOW ALL
        protected void ButtonC3_Click(object sender, EventArgs e)
        {
            TextBoxC1.Text    = "";
            GridView1.Visible = false;

            string user_name = DropDownList1.SelectedValue;

            string date_string1 = Calendar1.SelectedDate.Date.ToString();
            string date_string2 = Calendar2.SelectedDate.Date.AddDays(1).ToString();
            string testDate1    = $@"'{date_string1}'";
            string testDate2    = $@"'{date_string2}'";


            string sqlType = "CELLSTRENGTH";

            if (user_name == "")                                // If no username given, search with all users
            {
                Cell_All = $@"
            SELECT Strength,SaveTime,Location,UserName,DataConnState,Net_Type,Data_Activity
            FROM {dbname}
            WHERE SaveTime >= {testDate1} AND SaveTime <= {testDate2}
            ORDER BY Text;";
            }
            else
            {                                                   // Username given, filter with username
                Cell_All = $@"
            SELECT Strength,SaveTime,Location,UserName,DataConnState,Net_Type,Data_Activity
            FROM {dbname}
            WHERE SaveTime >= {testDate1} AND SaveTime <= {testDate2} AND UserName={$@"'{user_name}'"}
            ORDER BY Text;";
            }

            inputstring = Cell_All;
            var sqlget = new SQL_query();

            outputstring = sqlget.SQL_read(inputstring, sqlType);

            //TextBoxC1.Text = outputstring;

            curr_status = "ALL";

            if (outputstring != "")
            {
                if (outputstring.StartsWith("Error"))
                {
                    TextBoxC1.Text = outputstring;
                }
                else
                {
                    show_table(outputstring);
                }
            }
            else
            {
                TextBoxC1.Text = "No matching records found.\n";
            }
        }
예제 #3
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            TextBoxC1.Text    = "";
            GridView1.Visible = false;
            string user_name = DropDownList1.SelectedValue;

            string date_string1 = Calendar1.SelectedDate.Date.ToString();
            string date_string2 = Calendar2.SelectedDate.Date.AddDays(1).ToString();
            string testDate1    = $@"'{date_string1}'";
            string testDate2    = $@"'{date_string2}'";


            string sqlType = "CELLSTRENGTH";

            string where_string = "WHERE ";

            where_string = where_string + $@"SaveTime >= {testDate1} AND SaveTime <= {testDate2}";
            bool firstCondition = false;

            if (DropDownList2.SelectedValue != "")
            {
                string min_signal = DropDownList2.SelectedValue;
                string sqlstr     = $@"'{min_signal}'";
                if (firstCondition)
                {
                    where_string = where_string + $@"Strength >= {sqlstr}";
                }
                else
                {
                    where_string = where_string + $@" AND Strength >= {sqlstr}";
                }
                firstCondition = false;
            }

            if (DropDownList3.SelectedValue != "")
            {
                string max_signal = DropDownList3.SelectedValue;
                string sqlstr     = $@"'{max_signal}'";
                if (firstCondition)
                {
                    where_string = where_string + $@"Strength <= {sqlstr}";
                }
                else
                {
                    where_string = where_string + $@" AND Strength <= {sqlstr}";
                }
                firstCondition = false;
            }


            if (user_name != "")                                // If no username given, search with all users
            {
                string sqlstr = $@"'{user_name}'";
                if (firstCondition)
                {
                    where_string = where_string + $@"UserName={sqlstr}";
                }
                else
                {
                    where_string = where_string + $@" AND UserName={sqlstr}";
                }
                firstCondition = false;
            }

            if (DropDownList4.SelectedValue != "")                                // Data Connection Status
            {
                string dconn  = DropDownList4.SelectedValue;
                string sqlstr = $@"'{dconn}'";
                if (firstCondition)
                {
                    where_string = where_string + $@"DataConnState={sqlstr}";
                }
                else
                {
                    where_string = where_string + $@" AND DataConnState={sqlstr}";
                }
                firstCondition = false;
            }

            if (DropDownList5.SelectedValue != "")                                // Network Type
            {
                string ntype  = DropDownList5.SelectedValue;
                string sqlstr = $@"'{ntype}'";
                if (firstCondition)
                {
                    where_string = where_string + $@"Net_Type={sqlstr}";
                }
                else
                {
                    where_string = where_string + $@" AND Net_Type={sqlstr}";
                }
                firstCondition = false;
            }

            if (DropDownList6.SelectedValue != "")                                // Data Activity Status
            {
                string dact   = DropDownList6.SelectedValue;
                string sqlstr = $@"'{dact}'";
                if (firstCondition)
                {
                    where_string = where_string + $@"Data_Activity={sqlstr}";
                }
                else
                {
                    where_string = where_string + $@" AND Data_Activity={sqlstr}";
                }
                firstCondition = false;
            }

            string CellDetails = $@"
            SELECT Strength,SaveTime,Location,UserName,DataConnState,Net_Type,Data_Activity
            FROM {dbname}
            {where_string}
            ORDER BY SaveTime ASC;";

            inputstring = CellDetails;
            var sqlget = new SQL_query();

            outputstring = sqlget.SQL_read(inputstring, sqlType);

            if (outputstring != "")
            {
                if (outputstring.StartsWith("Error"))
                {
                    TextBoxC1.Text = outputstring;
                }
                else
                {
                    show_table(outputstring);
                }
            }
            else
            {
                TextBoxC1.Text = "No matching records.\n";
            }
        }
예제 #4
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            TextBox11.Text = "";

            GridView1.Visible = false;

            string user_name = DropDownList1.SelectedValue;

            string sqlType      = "WIFISIGNAL";
            string date_string1 = Calendar1.SelectedDate.Date.ToString();

            string date_string2 = Calendar2.SelectedDate.Date.AddDays(1).ToString();

            string testDate1 = $@"'{date_string1}'";
            string testDate2 = $@"'{date_string2}'";

            string signal_level = "";

            string username     = "";
            string ssidsearch   = "";
            string wifitype     = "All";
            string where_string = "WHERE ";

            where_string = where_string + $@"SaveTime >= {testDate1} and SaveTime <= {testDate2}";
            bool firstCondition = false;

            if (TextBox5.Text != "")
            {
                signal_level = TextBox5.Text;
                try
                {
                    int sgn = Convert.ToInt16(signal_level);

                    if ((sgn > 0) | (sgn < -100))
                    {
                        TextBox11.Text = "Invalid signal strength value. Give a negative dBm value between -1 and -100.\n";
                        return;
                    }
                } catch (Exception ex)
                {
                    TextBox11.Text = "Invalid signal strength value: " + ex.Message + ". Give a negative dBm value between -1 and -100.\n";
                    return;
                }

                string sigstr = $@"'{signal_level}'";
                if (firstCondition)
                {
                    where_string = where_string + $@"Level >= {sigstr}";
                }
                else
                {
                    where_string = where_string + $@" AND Level >= {sigstr}";
                }
                firstCondition = false;
            }

            if ((TextBox8.Text != "") | (DropDownList2.SelectedValue != ""))
            {
                if (DropDownList2.SelectedValue != "")
                {
                    ssidsearch = DropDownList2.SelectedValue;
                }
                else
                {
                    ssidsearch = TextBox8.Text;
                }

                string ssidstr = $@"'{ssidsearch}'";
                if (firstCondition)
                {
                    where_string = where_string + $@"SSID={ssidstr}";
                }
                else
                {
                    where_string = where_string + $@" AND SSID={ssidstr}";
                }
                firstCondition = false;
            }

            if (DropDownList4.SelectedValue != "All")
            {
                wifitype = DropDownList4.SelectedValue;
                if (wifitype != "Open")
                {
                    if (wifitype == "WPA")
                    {
                        wifitype = "WPA-";
                    }
                    string typestr = $@"'%{wifitype}%'";
                    if (firstCondition)
                    {
                        where_string = where_string + $@"Capabilities LIKE {typestr}";
                    }
                    else
                    {
                        where_string = where_string + $@" AND Capabilities LIKE {typestr}";
                    }
                }
                else
                {
                    if (firstCondition)
                    {
                        where_string = where_string + $@"Capabilities NOT LIKE '%WEP%' AND Capabilities NOT LIKE '%WPA%' AND Capabilities NOT LIKE '%WPS%'";
                    }
                    else
                    {
                        where_string = where_string + $@" AND Capabilities NOT LIKE '%WEP%' AND Capabilities NOT LIKE '%WPA%' AND Capabilities NOT LIKE '%WPS%'";
                    }
                }
                firstCondition = false;
            }



            string Signal_Top;

            if (where_string != "WHERE ")                                                       // WHERE conditions selected
            {
                if (DropDownList3.SelectedValue != "All")                                       // Distinct BSSID selected
                {
                    Signal_Top = $@"
                    SELECT a.SSID,a.BSSID,a.Capabilities,a.Frequency,a.Level,a.WifiItemId 
                    FROM {dbdetails} a 
                    INNER JOIN
                    (SELECT BSSID,
                    MAX(id) as id
                    FROM {dbdetails}
                    {where_string}
                    GROUP BY BSSID ) AS b
                    ON a.BSSID = b.BSSID 
                    AND a.id = b.id;";
                }
                else
                {                                                                               // All BSSIDs selected
                    Signal_Top = $@"                                                            
                    SELECT SSID,BSSID,Capabilities,Frequency,Level,WifiItemId
                    FROM {dbdetails} 
                    {where_string}
                    ORDER BY Level DESC;";
                }
            }
            else
            {                                                                                   // No WHERE conditions
                Signal_Top = $@"
            SELECT SSID,BSSID,Capabilities,Frequency,Level,WifiItemId
            FROM {dbdetails} 
            ORDER BY Level DESC;";
            }


            //TextBox11.Text = Signal_Top + "\n";                                       // Turn on if SQL debugging needed

            var    sqlget = new SQL_query();
            string strength_outputstring = sqlget.SQL_read(Signal_Top, sqlType);

            if (strength_outputstring != "")
            {
                if (strength_outputstring.StartsWith("Error"))
                {
                    TextBox11.Text = strength_outputstring;
                }
                else
                {
                    show_wifi_signal(strength_outputstring);
                }
            }
            else
            {
                TextBox11.Text = "No matching records found\n";
            }
        }
예제 #5
0
        private void show_wifi_signal(string inputstring)
        {
            string parent_id = "";

            string sqlType = "WIFITIME";

            string[] lines;
            string[] line_entries;


            wifidisplay3.Clear();


            try
            {
                lines = inputstring.Split(new Char[] { '\n' });
            } catch (Exception ex)
            {
                TextBox11.Text = "Error in extracting the lines: " + ex.Message;
                return;
            }

            int i1 = 0;

            for (i1 = 0; i1 < lines.Length - 1; i1++)
            {
                try
                {
                    line_entries = lines[i1].Split(new Char[] { '\t' });

                    parent_id = line_entries[5];
                } catch (Exception ex)
                {
                    TextBox11.Text = "Error in extracting the parent id: " + ex.Message;
                    return;
                }

                string Wifi_byId = $@"
            SELECT WifisFound,SaveTime,Location,UserName,Id 
            FROM {dbname} 
            WHERE Id={$@"'{parent_id}'"} 
            ORDER BY WifisFound DESC;";


                var    sqlget = new SQL_query();
                string strength_outputstring = sqlget.SQL_read(Wifi_byId, sqlType);

                if (strength_outputstring.StartsWith("Error"))
                {
                    TextBox11.Text = strength_outputstring;
                    return;
                }



                try
                {
                    string[] w_entry = strength_outputstring.Split(new Char[] { '\t' });
                    if (w_entry.Length > 4)
                    {
                        // Show entry if no specific username selected or if the entry matches with the given name

                        if ((DropDownList1.SelectedValue == "") | (w_entry[3] == DropDownList1.SelectedValue))
                        {
                            wifidisplay3.Add(new wifiDisp3 {
                                Time = w_entry[0], Location = w_entry[1], SSID = line_entries[0], BSSID = line_entries[1], Capabilities = line_entries[2], Freq_str = line_entries[3], Level_str = line_entries[4], User = w_entry[3]
                            });
                        }
                    }
                    else
                    {
                        wifidisplay3.Add(new wifiDisp3 {
                            Time = "Time not found", Location = "Location not found", SSID = line_entries[0], BSSID = line_entries[1], Capabilities = line_entries[2], Freq_str = line_entries[3], Level_str = line_entries[4]
                        });
                    }
                } catch (Exception ex)
                {
                    TextBox11.Text = "Error in creating Wifi signal list: " + ex.Message;
                    return;
                }
            }


            try
            {
                GridView1.DataSource = wifidisplay3;
                GridView1.DataBind();
                GridView1.Visible = true;
            }
            catch (Exception ex)
            {
                TextBox11.Text = "Gridview error: " + ex.Message;
            }
        }
        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int gr_index;

            try
            {
                if (GridView1.SelectedIndex == -1)
                {
                    colorDef = GridView1.BackColor;
                }
                else
                {
                    GridView1.SelectedRow.BackColor = colorDef;
                }

                gr_index = Convert.ToInt32(e.CommandArgument);
                GridView1.SelectedIndex         = gr_index;
                GridView1.SelectedRow.BackColor = System.Drawing.Color.Yellow;
            } catch (Exception ex)
            {
                TextBoxW1.Text = "Error in reading the gridview row: " + ex.Message;
                return;
            }

            if (e.CommandName == "Details")
            {
                string wifi_id     = wifi_ids[gr_index];
                string wifi_id_sql = $@"'{wifi_id}'";
                string sqlType     = "WIFIDETAIL1";

                string Wifi_details = $@"
            SELECT SSID,BSSID,Capabilities,Frequency,Level
            FROM {dbdetails} 
            WHERE WifiItemId = {wifi_id_sql}
            ORDER BY Level DESC;";

                inputstring = Wifi_details;

                var    sqlget = new SQL_query();
                string wifidetail_outputstring = sqlget.SQL_read(inputstring, sqlType);

                //TextBoxW1.Text = TextBoxW1.Text + "SQL Read completed\n";

                if (wifidetail_outputstring != "")
                {
                    if (wifidetail_outputstring.StartsWith("Error"))
                    {
                        TextBoxW1.Text = outputstring;
                    }
                    else
                    {
                        show_wifi_details(wifidetail_outputstring);
                    }
                }
                else
                {
                    TextBoxW1.Text = "No matching Wifi details record\n";
                }
            }
            else
            {
                // Show the selected place on the map

                wifilist.Clear();

                string   loc_entry;
                string[] lat_lon_str;
                string   time_entry;
                string   count_entry;

                try
                {
                    loc_entry   = GridView1.SelectedRow.Cells[2].Text;
                    lat_lon_str = loc_entry.Split(new Char[] { ',' });
                    time_entry  = GridView1.SelectedRow.Cells[1].Text;
                    count_entry = GridView1.SelectedRow.Cells[3].Text;

                    wifilist.Add(new WifiData {
                        wtime = time_entry, wlat = double.Parse(lat_lon_str[0]), wlon = double.Parse(lat_lon_str[1]), wcount = count_entry
                    });
                } catch (Exception ex)
                {
                    TextBoxW1.Text = "Error in creating the map request for a single Wifi record: " + ex.Message;
                    return;
                }
                if (loc_entry != "NO_LOCATION")
                {
                    show_map_image();
                }
                else
                {
                    TextBoxW1.Text = "No location data available\n";
                }
            }
        }