示例#1
0
 public void ModifySchedule(string CourseName)
 {
     PrintSchedule(CourseName);
     Prompt._Prompt("輸入格式:加入or刪除(I or D) 星期幾(1-7) 第幾節課(1-10)");
     Prompt._Prompt("註:第5節為中午12:00");
     Prompt._Prompt("註:格式錯誤將自動退出設定");
     while (true)
     {
         string input = Prompt.Input("請輸入:");
         Match  mh    = Regex.Match(input, "([ID]) ([1-7]) ([0-9]{1,2})");
         if (mh.Success)
         {
             int    week       = int.Parse(mh.Groups[2].Value);
             int    courseTime = int.Parse(mh.Groups[3].Value);
             string mode       = mh.Groups[1].Value;
             if (mode == "I")
             {
                 schedule[week - 1, courseTime - 1] = CourseName;
                 Prompt.Success($"{CourseName}上課時間 => 星期{_week[week - 1]} 第{courseTime}節({courseTime + 7}:00~{courseTime + 8}:00)");
             }
             else if (mode == "D")
             {
                 schedule[week - 1, courseTime - 1] = "";
                 Prompt.Success($"刪除 {CourseName}的星期{_week[week - 1]} 第{courseTime}節({courseTime + 7}:00~{courseTime + 8}:00)");
             }
         }
         else
         {
             Prompt.Error("格式錯誤 退出設定!");
             break;
         }
     }
 }
示例#2
0
 public void ModifyLocation(string CourseName)
 {
     while (true)
     {
         Prompt._Prompt("輸入格式:經度,緯度");
         string input = Prompt.Input("請輸入:");
         Match  mh    = Regex.Match(input, "[0-9]+.[0-9]*,[0-9]+.[0-9]*");
         if (mh.Success)
         {
             Location[CourseName] = mh.Groups[0].Value;
             Prompt.Success($"{CourseName}定位地點 => {input}");
             break;
         }
         else
         {
             Prompt.Error(Prompt.FormatError);
         }
     }
 }
示例#3
0
        public Zuvio()
        {
            if (!File.Exists("Setting.json"))
            {
                account  = Prompt.Input("請輸入帳號:");
                password = Prompt.Input("請輸入密碼:");

                Login();
                for (int i = 0; i < schedule.GetLength(0); i++)
                {
                    for (int j = 0; j < schedule.GetLength(1); j++)
                    {
                        schedule[i, j] = string.Empty;
                    }
                }
                Location = new Dictionary <string, string>();
                Prompt.Success("登入成功");
            }
            else
            {
                JObject json = JObject.Parse(File.ReadAllText("Setting.json"));
                account  = json["account"].ToString();
                password = json["password"].ToString();
                Login();
                //AccessToken = json["AccessToken"].ToString();
                //UserID = json["UserID"].ToString();
                //Session = json["Session"].ToString();
                int.TryParse(json["DelayTime"].ToString(), out DelayTime);
                Location = JsonConvert.DeserializeObject <Dictionary <string, string> >(json["Location"].ToString());
                for (int i = 0; i < schedule.GetLength(0); i++)
                {
                    for (int j = 0; j < schedule.GetLength(1); j++)
                    {
                        schedule[i, j] = json["schedule"][i][j].ToString();
                    }
                }
                Prompt.Success("設定讀取成功");
            }
        }
示例#4
0
        static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.UTF8;
            Console.Title          = "Zuvio 自動點名系統 Ver1.3 by.Wind";
            Zuvio         zuvio   = new Zuvio();
            List <Course> courses = zuvio.GetCourses();
            string        select  = string.Empty;

            while (true)
            {
                Prompt._Prompt("輸入格式:編號");
                Prompt._Prompt("0.開啟自動簽到");
                Prompt._Prompt($"1.設定檢查時間(Current DelayTime:{zuvio.DelayTime}s)");
                Prompt._Prompt("↓↓以下為設定課程時間↓↓");
                Prompt._Prompt("輸入格式:編號 設定時間orGPS定位地點(T or G)");
                int num = 1;
                courses.ForEach(x =>
                {
                    num++;
                    Prompt._Prompt($"{num}.{x.course_name}");
                });

                select = Prompt.Input("請輸入:");
                Console.ForegroundColor = ConsoleColor.White;
                Prompt.SplitLine();
                if (select == "0")
                {
                    break;
                }
                else if (select == "1")
                {
                    while (!int.TryParse(Prompt.Input("請輸入檢查時間(單位:秒):"), out zuvio.DelayTime))
                    {
                        Prompt.Error(Prompt.FormatError);
                    }
                }
                else
                {
                    Match mh = Regex.Match(select, "([0-9]) ([TG])", RegexOptions.IgnoreCase);
                    if (mh.Success)
                    {
                        string mode       = mh.Groups[2].Value.ToUpper();
                        string courseName = courses[int.Parse(mh.Groups[1].Value) - 2].course_name;
                        if (mode == "T")
                        {
                            zuvio.ModifySchedule(courseName);
                        }
                        else if (mode == "G")
                        {
                            zuvio.ModifyLocation(courseName);
                        }
                    }
                    else
                    {
                        Prompt.Error(Prompt.FormatError);
                    }
                }
                Console.ForegroundColor = ConsoleColor.White;
                Prompt.SplitLine();
            }

            File.WriteAllText("Setting.json", JsonConvert.SerializeObject(zuvio));
            Prompt.DateTimeOutput("Zuvio 自動點名啟動");
            Prompt.DateTimeOutput("按下任意鍵結束程式");
            zuvio.Start(courses);
            Console.Read();
            zuvio.Stop();
        }