예제 #1
0
        public ClassOption()
        {
            InitializeComponent();

            schedule      = UserData.scheduleClasses[ShareData.num];
            textBox1.Text = schedule.getName();

            //資料一覧の読み込み
            for (int i = 0; i < schedule.DocumentSize(); i++)
            {
                checkedListBox1.Items.Add(schedule.getDocument(i).getDocumentName(),
                                          schedule.getDocument(i).getOpen());
            }

            //時間一覧の読み込み
            for (int i = 0; i < schedule.TimeSize(); i++)
            {
                TimeClass time = schedule.getTime(i);
                string    text = "";
                for (int j = 0; j < ShareData.dayofWeek.Length; j++)
                {
                    if (time.getDay()[j])
                    {
                        text += ShareData.dayofWeek[j];
                    }
                }
                text += " " + time.getBeginTime().ToShortTimeString() + "~" + time.getEndTime().ToShortTimeString() + " " + time.getRoomName();
                checkedListBox2.Items.Add(text);
            }
        }
예제 #2
0
        private async void timer1_Tick(object sender, EventArgs e)
        {
            //講義時間が近づいたら通知するシステム
            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();
                    //Console.WriteLine((DateTime.Now.TimeOfDay - beginSpan).TotalSeconds + "秒前");
                    //10分前になったら もちろん曜日も考慮
                    if (beginSecond > -600 && beginSecond < -599 && day[(int)DateTime.Now.DayOfWeek])
                    {
                        notifyIcon1.BalloonTipIcon  = ToolTipIcon.Info;
                        notifyIcon1.BalloonTipTitle = "まもなく「" + schedule.getName() + "」";
                        notifyIcon1.BalloonTipText  = time.getRoomName() + "\n" + time.getBeginTime().ToShortTimeString() + "~";
                        notifyIcon1.ShowBalloonTip(5000);
                    }

                    //授業前後は出席していないことにする(実施されていないので当然である)
                    if (beginSecond < -10 && endSecond > 0)
                    {
                        time.setClass(false);
                        UserData.scheduleClasses[i].renewTime(time, j);
                    }

                    //スケジュール実行中の時間帯はこのタイマーを切る
                    if (beginSecond > -10 && endSecond < 0 && day[(int)DateTime.Now.DayOfWeek])
                    {
                        timer1.Enabled = false;
                        label3.Visible = true;
                        timer2.Enabled = true;
                    }
                }
            }
        }
예제 #3
0
        private void SubFormClosed(object sender, EventArgs e)
        {
            checkedListBox2.Items.Clear();
            //時間一覧の読み込み
            for (int i = 0; i < schedule.TimeSize(); i++)
            {
                TimeClass time = schedule.getTime(i);
                string    text = "";
                for (int j = 0; j < ShareData.dayofWeek.Length; j++)
                {
                    if (time.getDay()[j])
                    {
                        text += ShareData.dayofWeek[j];
                    }
                }
                text += " " + time.getBeginTime().ToShortTimeString() + "~" + time.getEndTime().ToShortTimeString() + " " + time.getRoomName();
                checkedListBox2.Items.Add(text);
            }

            this.Enabled = true;
        }
예제 #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            //ここからサーバー通信
            WebRequest  req = WebRequest.Create(url + "user_id=" + textBox1.Text + "&password="******"UTF-8"));
                String       result = reader.ReadToEnd();
                if (result.Contains("エラー"))
                {
                    MessageBox.Show("入力内容が違います!\nそれかUNIPAメンテナンス",
                                    "エラー",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
                //エラーでないなら時間割取得成功!JSONが返ってきているはず
                else
                {
                    var json = (dynamic)JsonConvert.DeserializeObject(result);
                    int num  = 0;
                    //string[] dayofWeek = new string[] { "sun", "mon", "tue", "wed", "thu", "fri", "sat" };
                    //曜日ずつforeach
                    foreach (var day in json)
                    {
                        //Console.WriteLine(day.ToString());
                        foreach (var time in day)
                        {
                            //時限ずつforeach
                            foreach (var element in time)
                            {
                                string TimeName = element["TimeName"];
                                string Name     = element["Name"];

                                TimeClass timeClass = new TimeClass();
                                TimeClass unipa     = new TimeClass();
                                timeClass.setType(1);
                                //TimeTableの特定
                                for (int i = 0; i < ShareData.timeTables.Count; i++)
                                {
                                    TimeTable timeTable = ShareData.timeTables[i];
                                    //もし"J1限"といった文字列が同じだったら
                                    if (TimeName == timeTable.getUnipaName())
                                    {
                                        unipa.setTimeTable(TimeName);
                                        unipa.setBeginTime(timeTable.getBeginTime());
                                        unipa.setEndTime(timeTable.getEndTime());
                                        Console.WriteLine(TimeName + "を登録");
                                        break;
                                    }
                                }


                                //もしないときこうなります
                                if (UserData.scheduleClasses.Count == 0)
                                {
                                    ScheduleClass schedule = new ScheduleClass();

                                    schedule.setName(Name);
                                    timeClass.setTimeTable(TimeName);
                                    timeClass.setBeginTime(unipa.getBeginTime());
                                    timeClass.setEndTime(unipa.getEndTime());
                                    timeClass.setOneDay(true, num);
                                    schedule.addTime(timeClass);
                                    UserData.scheduleClasses.Add(schedule);
                                    Console.WriteLine("はじめましての追加" + schedule.getName() + ShareData.dayofWeek[num]);
                                    //新規フォルダ作成
                                    System.IO.DirectoryInfo di = System.IO.Directory.CreateDirectory(Environment.CurrentDirectory + "\\" + schedule.getName());
                                    continue;
                                }
                                //すでにスケジュールが入っている場合
                                else
                                {
                                    for (int i = 0; i < UserData.scheduleClasses.Count; i++)
                                    {
                                        ScheduleClass schedule = UserData.scheduleClasses[i];
                                        if (Name == schedule.getName())
                                        {
                                            //開始時間と終了時間が同じなら曜日のみ追加
                                            for (int j = 0; j < schedule.TimeSize(); j++)
                                            {
                                                timeClass = schedule.getTime(j);
                                                //時限が同じだったら"J1限"といった文字列が同じだったらということ
                                                if (timeClass.getTimeTable() == TimeName)
                                                {
                                                    //曜日の登録
                                                    timeClass.setOneDay(true, num);
                                                    UserData.scheduleClasses[i].renewTime(timeClass, j);
                                                    Console.WriteLine("おきかえました" + UserData.scheduleClasses[i].getName() + ShareData.dayofWeek[num]);
                                                    break;
                                                }
                                                else if (j == schedule.TimeSize() - 1)
                                                {
                                                    TimeClass newTime = new TimeClass();
                                                    newTime.setTimeTable(TimeName);
                                                    newTime.setOneDay(true, num);
                                                    newTime.setBeginTime(unipa.getBeginTime());
                                                    newTime.setEndTime(unipa.getEndTime());
                                                    UserData.scheduleClasses[i].addTime(newTime);
                                                    Console.WriteLine(schedule.getName() + "のタイムを追加");
                                                }
                                            }
                                            break;
                                        }
                                        //その授業のスケジュールが追加されていない場合
                                        else if (i == UserData.scheduleClasses.Count - 1)
                                        {
                                            Console.WriteLine("スケジュールの新規追加");
                                            ScheduleClass newSchedule = new ScheduleClass();
                                            TimeClass     newTime     = new TimeClass();
                                            newSchedule.setName(Name);
                                            newTime.setOneDay(true, num);
                                            newTime.setTimeTable(TimeName);
                                            newTime.setBeginTime(unipa.getBeginTime());
                                            newTime.setEndTime(unipa.getEndTime());
                                            newSchedule.addTime(newTime);
                                            UserData.scheduleClasses.Add(newSchedule);
                                            System.IO.DirectoryInfo di = System.IO.Directory.CreateDirectory(Environment.CurrentDirectory + "\\" + newSchedule.getName());
                                        }
                                    }
                                }
                            }
                        }
                        num++;
                    }
                    //最後にできたという表示をしてウィンドウを閉じる
                    DialogResult message = MessageBox.Show("UNIPAから時間割を追加しました!",
                                                           "正常終了",
                                                           MessageBoxButtons.OK,
                                                           MessageBoxIcon.Information);
                    if (message == DialogResult.Yes)
                    {
                        this.Close();
                    }
                }
                stm.Close();
            }
            rsp.Close();
        }
예제 #5
0
        //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();
        }