//4.1秒ごとにWifi測る(現在位置部屋特定) //このタイマーは授業中のみ実施 private async void timer2_Tick(object sender, EventArgs e) { WifiInfo wifiInfo = new WifiInfo(); foreach (BssNetworkPack network in NativeWifi.EnumerateBssNetworks()) { wifiInfo.setSSID(network.Ssid.ToString()); wifiInfo.setBSSID(network.Bssid.ToString().ToLower()); wifiInfo.setRSSI(network.SignalStrength); } string rssi = WifiRSSI.SVMList(wifiInfo); Console.WriteLine(rssi); //ここからサーバー通信 WebClient wc = new WebClient(); NameValueCollection ps = new NameValueCollection(); ps.Add("rssi", rssi); byte[] resData = wc.UploadValues(url, ps); wc.Dispose(); string resText = System.Text.Encoding.UTF8.GetString(resData); Console.WriteLine(resText); resText = resText.Trim(); resText = WifiRSSI.RoomConv(resText); //label2.Text = resText; isRoom = resText; int num = 0; for (int i = 0; i < UserData.scheduleClasses.Count; i++) { ScheduleClass schedule = UserData.scheduleClasses[i]; for (int j = 0; j < schedule.TimeSize(); j++) { TimeClass time = schedule.getTime(j); DateTime beginTime = time.getBeginTime(); DateTime endTime = time.getEndTime(); TimeSpan beginSpan = beginTime.TimeOfDay; TimeSpan endSpan = endTime.TimeOfDay; TimeSpan fromSpan = DateTime.Now.TimeOfDay - beginSpan; TimeSpan toSpan = DateTime.Now.TimeOfDay - endSpan; double beginSecond = fromSpan.TotalSeconds; double endSecond = toSpan.TotalSeconds; bool[] day = time.getDay(); //実行中である if (beginSecond > 0 && endSecond < 0 && day[(int)DateTime.Now.DayOfWeek]) { num++; label1.Text = "現在"; label3.Text = UserData.scheduleClasses[i].getName(); //部屋にいるか? if (isRoom == time.getRoomName()) { label4.Visible = true; //講義資料自動オープンをするよ for (int k = 0; k < UserData.scheduleClasses[i].DocumentSize(); k++) { DocumentClass document = UserData.scheduleClasses[i].getDocument(k); if (document.getOpen() && !time.getClass()) { //"C:\test\1.txt"を関連付けられたアプリケーションで開く System.Diagnostics.Process p = System.Diagnostics.Process.Start(Environment.CurrentDirectory + "\\" + UserData.scheduleClasses[i].getName() + "\\" + document.getDocumentName()); if (k == UserData.scheduleClasses[i].DocumentSize() - 1) { time.setClass(true); UserData.scheduleClasses[i].renewTime(time, j); } //この辺に出席を送信する処理入れたい Console.WriteLine(document.getDocumentName() + " 開いた"); } await Task.Delay(1000); } } } } } //実行中のものがないときタイマー2を切ってタイマー1をオンにする if (num == 0) { timer1.Enabled = true; label3.Visible = false; label4.Visible = false; timer2.Enabled = false; } //更新 RefreshAsync(); }