Пример #1
0
        private void LoginClickHandler(object sender, EventArgs e)
        {
            if (this.account.Text == "")
            {
                WarningTipWindow tipDialog = new WarningTipWindow("请输入账号");
                tipDialog.ShowDialog();
                return;
            }

            if (this.password.Password == "")
            {
                WarningTipWindow tipDialog = new WarningTipWindow("请输入密码");
                tipDialog.ShowDialog();
                return;
            }

            if (this.remainFlag.IsChecked == true)
            {
                UpdateConfInfo(this.account.Text, this.password.Password, "true");
            }
            else
            {
                UpdateConfInfo(this.account.Text, this.password.Password, "false");
            }

            LogHelper.WriteInfoLog(this.account.Text);
            broder_back.Visibility = Visibility.Visible;
            _loading.Visibility    = Visibility.Visible;
            Thread Login = new Thread(new ThreadStart(LoginHandler));

            Login.IsBackground = true;
            Login.Start();
        }
Пример #2
0
        private void DeletedSignUp(SignUpInfo signUpInfo)
        {
            SignUpControl oneSignUpItem = null;

            for (int loop = 0; loop < signUpList.Children.Count; loop++)
            {
                if (signUpList.Children[loop].GetType().ToString() == "SignInApp.SignUpControl")
                {
                    oneSignUpItem = signUpList.Children[loop] as SignUpControl;
                    if (oneSignUpItem.mSignUpInfo.Id == signUpInfo.Id)
                    {
                        //删除
                        string outMessage = "";
                        string response   = RESTClient.SignOut(signUpInfo.Id, ref outMessage);
                        if (response == null || response == "")
                        {
                            if (outMessage == "")
                            {
                                outMessage = "删除签到失败,服务器错误";
                            }
                            broder_back.Visibility = Visibility.Collapsed;
                            _loading.Visibility    = Visibility.Collapsed;
                            WarningTipWindow tipDialog = new WarningTipWindow(outMessage);
                            tipDialog.ShowDialog();
                            return;
                        }

                        try
                        {
                            JObject jResp  = (JObject)JsonConvert.DeserializeObject(response);
                            String  status = (String)jResp.SelectToken("status", true);
                            if (status != "success")
                            {
                                string message = (String)jResp.SelectToken("message", true);
                                broder_back.Visibility = Visibility.Collapsed;
                                _loading.Visibility    = Visibility.Collapsed;
                                WarningTipWindow tipDialog = new WarningTipWindow("删除签到失败:" + message);
                                tipDialog.ShowDialog();
                                LogHelper.WriteWarnLog("删除签到失败:" + message);
                                return;
                            }

                            LogHelper.WriteInfoLog("查询签到成功");
                            broder_back.Visibility = Visibility.Collapsed;
                            _loading.Visibility    = Visibility.Collapsed;
                            signUpList.Children.RemoveAt(loop);
                            return;
                        }
                        catch (Exception err)
                        {
                            broder_back.Visibility = Visibility.Collapsed;
                            _loading.Visibility    = Visibility.Collapsed;
                            WarningTipWindow tipDialog = new WarningTipWindow("查询签到失败," + err.Message);
                            tipDialog.ShowDialog();
                            return;
                        }
                    }
                }
            }
        }
Пример #3
0
        private void AddLessonHandler(string className)
        {
            string outMessage = "";
            string response   = RESTClient.GetClass(className, ref outMessage);

            if (response == null || response == "")
            {
                if (outMessage == "")
                {
                    outMessage = "获取班级信息失败,服务器错误";
                }
                this.Dispatcher.Invoke(() =>
                {
                    broder_back.Visibility     = Visibility.Collapsed;
                    _loading.Visibility        = Visibility.Collapsed;
                    WarningTipWindow tipDialog = new WarningTipWindow(outMessage);
                    tipDialog.ShowDialog();
                });
                LogHelper.WriteWarnLog(outMessage);
                return;
            }

            try
            {
                JObject jResp  = (JObject)JsonConvert.DeserializeObject(response);
                String  status = (String)jResp.SelectToken("status", true);
                if (status != "success")
                {
                    string message = (String)jResp.SelectToken("message", true);
                    this.Dispatcher.Invoke(() =>
                    {
                        broder_back.Visibility     = Visibility.Collapsed;
                        _loading.Visibility        = Visibility.Collapsed;
                        WarningTipWindow tipDialog = new WarningTipWindow("获取班级信息失败:" + message);
                        tipDialog.ShowDialog();
                    });
                    LogHelper.WriteWarnLog("获取班级信息失败:" + message);
                    return;
                }

                JArray jArray = (JArray)jResp.SelectToken("data", true);
                if (jArray == null || jArray.Count == 0)
                {
                    this.Dispatcher.Invoke(() =>
                    {
                        broder_back.Visibility = Visibility.Collapsed;
                        _loading.Visibility    = Visibility.Collapsed;
                    });
                    LogHelper.WriteWarnLog("获取班级信息失败: data为空");
                    return;
                }

                LogHelper.WriteInfoLog("获取班级信息成功");
                this.Dispatcher.Invoke(() =>
                {
                    broder_back.Visibility = Visibility.Collapsed;
                    _loading.Visibility    = Visibility.Collapsed;

                    int index = 0;
                    foreach (var item in jArray)
                    {
                        JToken jToken       = item;
                        ClassInfo classInfo = new ClassInfo();
                        try
                        {
                            classInfo.Id                    = (long)jToken.SelectToken("id");
                            classInfo.ClassName             = (String)jToken.SelectToken("className");
                            classInfo.StartTime             = (String)jToken.SelectToken("startTime");
                            classInfo.EndTime               = (String)jToken.SelectToken("endTime");
                            classInfo.ExamTypeName          = (String)jToken.SelectToken("examTypeName");
                            classInfo.StudentNums           = (String)jToken.SelectToken("studentNums");
                            ClassRowControl classRowControl = new ClassRowControl(index++, classInfo);
                            classRowControl.SelectClass    += SelectClass;
                            ClassList.Children.Add(classRowControl);
                        }
                        catch (Exception err)
                        {
                            LogHelper.WriteWarnLog(err.Message);
                            continue;
                        }

                        if (index == 1)
                        {
                            SelectClass(classInfo);
                        }
                    }
                });
                return;
            }
            catch (Exception err)
            {
                this.Dispatcher.Invoke(() =>
                {
                    broder_back.Visibility     = Visibility.Collapsed;
                    _loading.Visibility        = Visibility.Collapsed;
                    WarningTipWindow tipDialog = new WarningTipWindow("获取班级信息失败," + err.Message);
                    tipDialog.ShowDialog();
                });
                return;
            }
        }
Пример #4
0
        private void QueryLessonHandler(ClassInfo classInfo)
        {
            string outMessage = "";
            string response   = RESTClient.GetLesson(classInfo.Id, ref outMessage);

            if (response == null || response == "")
            {
                if (outMessage == "")
                {
                    outMessage = "获取课程信息失败,服务器错误";
                }
                this.Dispatcher.Invoke(() =>
                {
                    lesson_broder_back.Visibility = Visibility.Collapsed;
                    _lesson_loading.Visibility    = Visibility.Collapsed;
                    WarningTipWindow tipDialog    = new WarningTipWindow(outMessage);
                    tipDialog.ShowDialog();
                });
                LogHelper.WriteWarnLog(outMessage);
                return;
            }

            try
            {
                JObject jResp  = (JObject)JsonConvert.DeserializeObject(response);
                String  status = (String)jResp.SelectToken("status", true);
                if (status != "success")
                {
                    string message = (String)jResp.SelectToken("message", true);
                    this.Dispatcher.Invoke(() =>
                    {
                        lesson_broder_back.Visibility = Visibility.Collapsed;
                        _lesson_loading.Visibility    = Visibility.Collapsed;
                        WarningTipWindow tipDialog    = new WarningTipWindow("获取课程信息失败:" + message);
                        tipDialog.ShowDialog();
                    });
                    LogHelper.WriteWarnLog("获取课程信息失败:" + message);
                    return;
                }

                JArray jArray = (JArray)jResp.SelectToken("data", true);
                if (jArray == null || jArray.Count == 0)
                {
                    this.Dispatcher.Invoke(() =>
                    {
                        lesson_broder_back.Visibility = Visibility.Collapsed;
                        _lesson_loading.Visibility    = Visibility.Collapsed;
                    });
                    LogHelper.WriteWarnLog("获取课程信息失败: data为空");
                    return;
                }

                LogHelper.WriteInfoLog("获取课程信息成功");
                this.Dispatcher.Invoke(() =>
                {
                    lesson_broder_back.Visibility = Visibility.Collapsed;
                    _lesson_loading.Visibility    = Visibility.Collapsed;

                    int index = 0;
                    foreach (var item in jArray)
                    {
                        JToken jToken         = item;
                        LessonInfo lessonInfo = new LessonInfo();
                        try
                        {
                            lessonInfo.Id        = (long)jToken.SelectToken("id");
                            lessonInfo.Name      = (String)jToken.SelectToken("name");
                            lessonInfo.Teacher   = (String)jToken.SelectToken("teacher");
                            lessonInfo.Number    = (String)jToken.SelectToken("number");
                            lessonInfo.ClassId   = classInfo.Id;
                            lessonInfo.ClassName = "班级:" + classInfo.ClassName;
                            if (mLessonList.ContainsKey(lessonInfo.Id) ||
                                mSelectLessons.ContainsKey(lessonInfo.Id))
                            {
                                lessonInfo.IsChecked = true;
                            }
                            else
                            {
                                lessonInfo.IsChecked = false;
                            }

                            LessonRowControl lessonRowControl = new LessonRowControl(index++, lessonInfo);
                            lessonRowControl.SelectLesson    += SelectLesson;
                            LessonList.Children.Add(lessonRowControl);
                        }
                        catch (Exception err)
                        {
                            LogHelper.WriteWarnLog(err.Message);
                            continue;
                        }
                    }
                });
                return;
            }
            catch (Exception err)
            {
                this.Dispatcher.Invoke(() =>
                {
                    lesson_broder_back.Visibility = Visibility.Collapsed;
                    _lesson_loading.Visibility    = Visibility.Collapsed;
                    WarningTipWindow tipDialog    = new WarningTipWindow("获取课程信息失败," + err.Message);
                    tipDialog.ShowDialog();
                });
                return;
            }
        }
Пример #5
0
        private void LoginHandler()
        {
            string strAccount  = "";
            string strPassword = "";

            this.Dispatcher.Invoke(() => {
                strAccount  = this.account.Text;
                strPassword = this.password.Password;
            });

            string outMessage = "";
            string response   = RESTClient.Login(strAccount, strPassword, ref outMessage, Properties.Settings.Default.Test);

            if (response == null || response == "")
            {
                if (outMessage == "")
                {
                    outMessage = "登录失败,服务器错误";
                }
                this.Dispatcher.Invoke(() => {
                    broder_back.Visibility     = Visibility.Collapsed;
                    _loading.Visibility        = Visibility.Collapsed;
                    WarningTipWindow tipDialog = new WarningTipWindow(outMessage);
                    tipDialog.ShowDialog();
                });
                LogHelper.WriteWarnLog(outMessage);
                return;
            }

            try
            {
                JObject jResp  = (JObject)JsonConvert.DeserializeObject(response);
                String  status = (String)jResp.SelectToken("status", true);
                if (status != "success")
                {
                    string message = (String)jResp.SelectToken("message", true);
                    this.Dispatcher.Invoke(() => {
                        broder_back.Visibility     = Visibility.Collapsed;
                        _loading.Visibility        = Visibility.Collapsed;
                        WarningTipWindow tipDialog = new WarningTipWindow("登录失败:" + message);
                        tipDialog.ShowDialog();
                    });
                    LogHelper.WriteWarnLog(strAccount + "登录失败:" + message);
                    return;
                }

                JArray jArray = (JArray)jResp.SelectToken("data", true);
                if (jArray == null || jArray.Count == 0)
                {
                    this.Dispatcher.Invoke(() => {
                        broder_back.Visibility     = Visibility.Collapsed;
                        _loading.Visibility        = Visibility.Collapsed;
                        WarningTipWindow tipDialog = new WarningTipWindow("登录失败,data为空");
                        tipDialog.ShowDialog();
                    });
                    LogHelper.WriteWarnLog(strAccount + "登录失败: data为空");
                    return;
                }

                JToken jToken = null;
                foreach (var item in jArray)
                {
                    jToken = item;
                    break;
                }

                LogHelper.WriteInfoLog(strAccount + "登录成功");
                string sessionid = (String)jToken.SelectToken("sessionid", true);
                RESTClient.SESSION_ID = sessionid;
                Org org = new Org();
                org.id      = (long)jToken.SelectToken("org_id", true);
                org.name    = (String)jToken.SelectToken("org_name", true);
                org.address = (String)jToken.SelectToken("address", true);
                this.Dispatcher.Invoke(() => {
                    broder_back.Visibility = Visibility.Collapsed;
                    _loading.Visibility    = Visibility.Collapsed;
                    MainWindow mainWindow  = new MainWindow(org);
                    mainWindow.Show();
                    this.Close();
                });
                return;
            }
            catch (Exception err)
            {
                this.Dispatcher.Invoke(() => {
                    broder_back.Visibility     = Visibility.Collapsed;
                    _loading.Visibility        = Visibility.Collapsed;
                    WarningTipWindow tipDialog = new WarningTipWindow(strAccount + "登录失败," + err.Message);
                    tipDialog.ShowDialog();
                });
                return;
            }
        }
Пример #6
0
        private void QuerySignUp()
        {
            if (mClassCourse != null)
            {
                string outMessage = "";
                string response   = RESTClient.QuerySignUp(mClassCourse, ref outMessage);
                if (response == null || response == "")
                {
                    if (outMessage == "")
                    {
                        outMessage = "查询签到失败,服务器错误";
                    }
                    this.Dispatcher.Invoke(() => {
                        broder_back.Visibility     = Visibility.Collapsed;
                        _loading.Visibility        = Visibility.Collapsed;
                        WarningTipWindow tipDialog = new WarningTipWindow(outMessage);
                        tipDialog.ShowDialog();
                    });
                    LogHelper.WriteWarnLog(outMessage);
                    return;
                }

                try
                {
                    JObject jResp  = (JObject)JsonConvert.DeserializeObject(response);
                    String  status = (String)jResp.SelectToken("status", true);
                    if (status != "success")
                    {
                        string message = (String)jResp.SelectToken("message", true);
                        this.Dispatcher.Invoke(() => {
                            broder_back.Visibility     = Visibility.Collapsed;
                            _loading.Visibility        = Visibility.Collapsed;
                            WarningTipWindow tipDialog = new WarningTipWindow("查询签到失败:" + message);
                            tipDialog.ShowDialog();
                        });
                        LogHelper.WriteWarnLog("查询签到失败:" + message);
                        return;
                    }
                    JArray jArray = (JArray)jResp.SelectToken("data", true);

                    LogHelper.WriteInfoLog("查询签到成功");
                    this.Dispatcher.Invoke(() => {
                        broder_back.Visibility = Visibility.Collapsed;
                        _loading.Visibility    = Visibility.Collapsed;
                        signUpList.Children.Clear();

                        int index = 0;
                        foreach (var item in jArray)
                        {
                            JToken jToken         = item;
                            SignUpInfo signUpInfo = new SignUpInfo();
                            try
                            {
                                signUpInfo.Id          = (String)jToken.SelectToken("id");
                                signUpInfo.StudentName = (String)jToken.SelectToken("studentName");
                                signUpInfo.CheckTime   = (String)jToken.SelectToken("checkTime");
                                if ((String)jToken.SelectToken("inOut") == "1")
                                {
                                    signUpInfo.Type = "上课";
                                }
                                else
                                {
                                    signUpInfo.Type = "下课";
                                }
                                signUpInfo.IdCardNum = (String)jToken.SelectToken("idCardNum");
                                if ((String)jToken.SelectToken("sex") == "1")
                                {
                                    signUpInfo.Sex = "男";
                                }
                                else
                                {
                                    signUpInfo.Sex = "女";
                                }
                                signUpInfo.CourseName = (String)jToken.SelectToken("courseName");

                                SignUpControl signUpControl  = new SignUpControl(index++, signUpInfo);
                                signUpControl.DeletedSignUp += DeletedSignUp;
                                signUpList.Children.Add(signUpControl);
                            }
                            catch (Exception err)
                            {
                                LogHelper.WriteWarnLog(err.Message);
                                continue;
                            }
                        }
                    });
                    return;
                }
                catch (Exception err)
                {
                    this.Dispatcher.Invoke(() => {
                        broder_back.Visibility     = Visibility.Collapsed;
                        _loading.Visibility        = Visibility.Collapsed;
                        WarningTipWindow tipDialog = new WarningTipWindow("查询签到失败," + err.Message);
                        tipDialog.ShowDialog();
                    });
                    return;
                }
            }
        }
Пример #7
0
        private void AddLessonHandler()
        {
            string outMessage = "";
            string response   = RESTClient.GetClass(null, ref outMessage);

            if (response == null || response == "")
            {
                if (outMessage == "")
                {
                    outMessage = "获取班级信息失败,服务器错误";
                }
                this.Dispatcher.Invoke(() => {
                    broder_back.Visibility     = Visibility.Collapsed;
                    _loading.Visibility        = Visibility.Collapsed;
                    WarningTipWindow tipDialog = new WarningTipWindow(outMessage);
                    tipDialog.ShowDialog();
                });
                LogHelper.WriteWarnLog(outMessage);
                return;
            }

            try
            {
                JObject jResp  = (JObject)JsonConvert.DeserializeObject(response);
                String  status = (String)jResp.SelectToken("status", true);
                if (status != "success")
                {
                    string message = (String)jResp.SelectToken("message", true);
                    this.Dispatcher.Invoke(() => {
                        broder_back.Visibility     = Visibility.Collapsed;
                        _loading.Visibility        = Visibility.Collapsed;
                        WarningTipWindow tipDialog = new WarningTipWindow("获取班级信息失败:" + message);
                        tipDialog.ShowDialog();
                    });
                    LogHelper.WriteWarnLog("获取班级信息失败:" + message);
                    return;
                }

                JArray jArray = (JArray)jResp.SelectToken("data", true);
                if (jArray == null || jArray.Count == 0)
                {
                    this.Dispatcher.Invoke(() => {
                        broder_back.Visibility     = Visibility.Collapsed;
                        _loading.Visibility        = Visibility.Collapsed;
                        WarningTipWindow tipDialog = new WarningTipWindow("获取班级信息失败,data为空");
                        tipDialog.ShowDialog();
                    });
                    LogHelper.WriteWarnLog("获取班级信息失败: data为空");
                    return;
                }

                LogHelper.WriteInfoLog("获取班级信息成功");
                this.Dispatcher.Invoke(() => {
                    broder_back.Visibility     = Visibility.Collapsed;
                    _loading.Visibility        = Visibility.Collapsed;
                    back.Visibility            = Visibility.Visible;
                    ClassWindow classWindow    = new ClassWindow(jArray, mSelectLessons);
                    classWindow.CancelSelect  += CancelSelect;
                    classWindow.ConfirmSelect += ConfirmSelect;
                    classWindow.ShowDialog();
                });
                return;
            }
            catch (Exception err)
            {
                this.Dispatcher.Invoke(() => {
                    broder_back.Visibility     = Visibility.Collapsed;
                    _loading.Visibility        = Visibility.Collapsed;
                    WarningTipWindow tipDialog = new WarningTipWindow("获取班级信息失败," + err.Message);
                    tipDialog.ShowDialog();
                });
                return;
            }
        }