예제 #1
0
 private void Info_listView1_MouseDoubleClick(object sender, MouseEventArgs e)
 {
     if (Info_listView1.Focused)
     {
         int SelectIndex = Info_listView1.FocusedItem.Index;
         globalVar.CommandList.RemoveAt(SelectIndex);
         Info_listView1.Items.RemoveAt(SelectIndex);
         Info_listView1.Refresh();
     }
 }
예제 #2
0
        private void UpdateUI(int status)
        {
            switch (status)
            {
            case (int)ProcessStatus.Status_None:
                groupBox_Info.Enabled  = true;
                Info_listView1.Enabled = true;
                Info_listView1.Clear();
                button1.Enabled = true;
                button2.Enabled = true;
                button3.Enabled = true;
                break;

            case (int)ProcessStatus.Status_Connect:
                groupBox_Info.Enabled  = true;
                Info_listView1.Enabled = true;
                //Info_listView1.Clear();
                button1.Enabled = true;
                button2.Enabled = true;
                button3.Enabled = true;
                break;

            case (int)ProcessStatus.Status_Start:
                groupBox_Info.Enabled  = false;
                Info_listView1.Enabled = false;
                //Info_listView1.Clear();
                button1.Enabled = false;
                button2.Enabled = false;
                button3.Enabled = false;
                break;

            case (int)ProcessStatus.Status_Finish:
                groupBox_Info.Enabled  = true;
                Info_listView1.Enabled = true;
                //Info_listView1.Clear();
                button1.Enabled = true;
                button2.Enabled = true;
                button3.Enabled = true;
                break;
            }
        }
예제 #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            UpdateUI((int)ProcessStatus.Status_Start);
            double[]  TimeEstimation = new double[globalVar.CommandList.Count];
            wifi      WifiAPI        = new wifi();
            string    sURL           = "";
            Stopwatch sw             = new Stopwatch();
            int       index          = 0;

            for (index = 0; index < globalVar.CommandList.Count; index++)
            {
                sw.Reset();
                sw.Start();
                Info_listView1.Items[index].Selected = true;
                Info_listView1.Select();
                if (Info_listView1.Items[index].Text.ToString().Contains("Connect"))
                {
                    string URLConnet = Info_listView1.Items[index].Text.ToString();
                    string SSID      = "";
                    URLConnet = URLConnet.Substring(URLConnet.IndexOf(",") + 1);
                    SSID      = URLConnet.Substring(0, URLConnet.IndexOf(","));
                    URLConnet = URLConnet.Substring(URLConnet.IndexOf(",") + 1);
                    if (URLConnet == "0")
                    {
                        ExecuteConnect(SSID, false);
                    }
                    else
                    {
                        ExecuteConnect(SSID, true);
                    }
                }
                if (Info_listView1.Items[index].Text.ToString().Contains("Socket"))
                {
                    if (Info_listView1.Items[index].Text.ToString().Contains("0"))
                    {
                        ExecuteSocketConnect(false);
                    }
                    else
                    {
                        ExecuteSocketConnect(true);
                    }
                }
                else if (Info_listView1.Items[index].Text.ToString().Contains("Delay"))
                {
                    int sleepMS = Convert.ToInt32(Info_listView1.Items[index].Text.ToString().Substring(Info_listView1.Items[index].Text.ToString().IndexOf(",") + 2));
                    System.Threading.Thread.Sleep(sleepMS);
                }
                else
                {
                    sURL = globalVar.CommandList[index].ToString();
                    WifiAPI.ExecuteHTTPCommand(sURL);
                }
                sw.Stop();
                TimeEstimation[index] = sw.Elapsed.TotalMilliseconds;
            }

            UpdateUI((int)ProcessStatus.Status_Finish);
            foreach (int element in TimeEstimation)
            {
                Console.WriteLine(element.ToString());
            }
            MessageBox.Show("Command Finish");
        }
예제 #4
0
        private void button3_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.Title            = "Select script file";
            dialog.InitialDirectory = Application.StartupPath;
            dialog.Filter           = "xls file (*.*)|*.xls";
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                globalVar.ScriptPath = dialog.FileName;
            }
            else
            {
                return;
            }

            string          ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + globalVar.ScriptPath + ";Extended Properties='Excel 8.0;HDR=Yes;IMEX=1;Mode=Read'";
            OleDbConnection ODConn;

            ODConn = new OleDbConnection(ConnStr);
            try
            {
                ODConn.Open();
            }
            catch { }
            globalVar.CommandList.Clear();
            Info_listView1.Clear();
            string       strSql             = "SELECT * FROM[Script$]";
            int          ScriptCommandCount = 0;
            string       ScriptCommandURL   = "";
            OleDbCommand ODCmd = ODConn.CreateCommand();

            ODCmd.CommandText = strSql;
            DataSet          myDataSet = new DataSet();
            OleDbDataAdapter MyAdapter = new OleDbDataAdapter(strSql, ODConn);

            MyAdapter.Fill(myDataSet, "Script");
            DataTable dt = myDataSet.Tables["Script"];

            foreach (DataRow dr in dt.Rows)
            {
                ScriptCommandURL = "";
                if (dr["Case"].ToString() == "")
                {
                    return;
                }
                if (Convert.ToInt32(dr["Case"].ToString()) == ScriptCommandCount + 1)
                {
                    switch (dr["Type"].ToString())
                    {
                    case "Command":
                        ScriptCommandCount++;
                        ScriptCommandURL = String.Concat("http://192.168.1.254/?custom=1&cmd=", dr["ID"].ToString());
                        if (dr["Parameter"].ToString() != "" && dr["Parameter"].ToString() != "NULL")
                        {
                            if (dr["Parameter Type"].ToString() == "par")
                            {
                                ScriptCommandURL = String.Concat(ScriptCommandURL, "&par=", dr["Parameter"].ToString());
                            }
                            else if (dr["Parameter Type"].ToString() == "str")
                            {
                                ScriptCommandURL = String.Concat(ScriptCommandURL, "&str=", dr["Parameter"].ToString());
                            }
                            Info_listView1.Items.Add(dr["ID"].ToString() + " , " + dr["Parameter"].ToString());
                        }
                        else
                        {
                            Info_listView1.Items.Add(dr["ID"].ToString());
                        }
                        break;

                    case "Liveview":
                        ScriptCommandCount++;
                        if (dr["Parameter"].ToString() != "" && dr["Parameter"].ToString() != "NULL")
                        {
                            ScriptCommandURL = String.Concat("http://192.168.1.254:", dr["Parameter"].ToString());
                        }
                        else
                        {
                            ScriptCommandURL = String.Concat("http://192.168.1.254:", "8192");
                        }
                        Info_listView1.Items.Add("Liveview");
                        break;

                    case "FileSystem":
                        ScriptCommandCount++;
                        if (dr["ID"].ToString() != "")
                        {
                            ScriptCommandURL = String.Concat("http://192.168.1.254/", dr["ID"].ToString());
                            if (dr["Parameter"].ToString() == "0")
                            {
                                ScriptCommandURL = String.Concat(ScriptCommandURL, "?del=1");
                            }
                        }
                        Info_listView1.Items.Add("FileSystem");
                        break;

                    case "Connect":
                        ScriptCommandCount++;
                        ScriptCommandURL = "Connect," + dr["ID"].ToString() + "," + dr["Parameter"].ToString();
                        Info_listView1.Items.Add("Connect" + " , " + dr["ID"].ToString() + " , " + dr["Parameter"].ToString());
                        break;

                    case "Socket":
                        ScriptCommandCount++;
                        ScriptCommandURL = "Socket," + dr["Parameter"].ToString();
                        Info_listView1.Items.Add("Socket" + " , " + dr["Parameter"].ToString());
                        break;

                    case "Delay":
                        ScriptCommandCount++;
                        ScriptCommandURL = "Delay," + dr["Parameter"].ToString();
                        Info_listView1.Items.Add("Delay" + " , " + dr["Parameter"].ToString());
                        break;

                    case "Thumb":
                        ScriptCommandCount++;
                        if (dr["ID"].ToString() != "")
                        {
                            ScriptCommandURL = String.Concat("http://192.168.1.254/", dr["ID"].ToString(), "?custom=1&cmd=6003");
                            Info_listView1.Items.Add("Thumb" + " , " + dr["ID"].ToString());
                        }
                        break;
                    }
                    globalVar.CommandList.Add(ScriptCommandURL);
                    Info_listView1.Refresh();
                }
            }
        }