예제 #1
0
        private void SelectClass(ClassInfo classInfo)
        {
            if (mSelectClassId != classInfo.Id)
            {
                mSelectClassId = classInfo.Id;
                //加载班级信息
                lesson_broder_back.Visibility = Visibility.Visible;
                _lesson_loading.Visibility    = Visibility.Visible;
                ClassRowControl OneClassItem = null;
                for (int loop = 0; loop < ClassList.Children.Count; loop++)
                {
                    if (ClassList.Children[loop].GetType().ToString() == "SignInApp.ClassRowControl")
                    {
                        OneClassItem = ClassList.Children[loop] as ClassRowControl;
                        if (OneClassItem.mClassInfo.Id != classInfo.Id)
                        {
                            OneClassItem.ImageRight.Visibility = Visibility.Collapsed;
                        }
                    }
                }

                LessonList.Children.Clear();
                Thread queryLesson = new Thread(() => QueryLessonHandler(classInfo));
                queryLesson.IsBackground = true;
                queryLesson.Start();
            }
        }
예제 #2
0
        public ClassWindow(JArray classList, Dictionary <long, LessonInfo> selectLessons)
        {
            InitializeComponent();

            int height = (int)SystemParameters.WorkArea.Height;
            int width  = (int)SystemParameters.WorkArea.Width;

            this.Width  = width - CommDef.Size380;
            this.Height = height - CommDef.Size88;
            this.Top    = CommDef.Size88;
            this.Left   = CommDef.Size380;

            mClassWindowFixInfo.Size16  = CommDef.Size16;
            mClassWindowFixInfo.Size18  = CommDef.Size18;
            mClassWindowFixInfo.Size20  = CommDef.Size20;
            mClassWindowFixInfo.Size24  = CommDef.Size24;
            mClassWindowFixInfo.Size40  = CommDef.Size40;
            mClassWindowFixInfo.Size60  = CommDef.Size60;
            mClassWindowFixInfo.Size52  = CommDef.Size52;
            mClassWindowFixInfo.Size80  = CommDef.Size80;
            mClassWindowFixInfo.Size88  = CommDef.Size88;
            mClassWindowFixInfo.Size90  = CommDef.Size90;
            mClassWindowFixInfo.Size100 = CommDef.Size100;
            mClassWindowFixInfo.Size120 = CommDef.Size120;
            mClassWindowFixInfo.Size180 = CommDef.Size180;
            mClassWindowFixInfo.Size213 = CommDef.Size213;
            mClassWindowFixInfo.Size380 = CommDef.Size380;
            this.DataContext            = mClassWindowFixInfo;

            mSelectLessons = selectLessons;
            int index = 0;

            foreach (var item in classList)
            {
                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);
                }
            }
        }
예제 #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;
            }
        }