Пример #1
0
        private void ConfirmSelect(Dictionary <long, LessonInfo> lessonList)
        {
            back.Visibility = Visibility.Collapsed;
            foreach (var item in lessonList)
            {
                long       lessonId   = item.Key;
                LessonInfo lessonInfo = item.Value;

                if (!mSelectLessons.ContainsKey(lessonId))
                {
                    mSelectLessons.Add(lessonId, lessonInfo);
                    SelectedLessonControl selectedLessonControl = new SelectedLessonControl(lessonInfo);
                    lessons.Children.Add(selectedLessonControl);
                }
            }

            if (mSelectLessons.Count >= 2)
            {
                mainWindowFixInfo.ClassFixSize = mainWindowFixInfo.Size86 * 2;
            }
            else if (mSelectLessons.Count >= 1)
            {
                mainWindowFixInfo.ClassFixSize = mainWindowFixInfo.Size86 * 1;
            }

            Dictionary <long, String> classCourse = new Dictionary <long, String>();

            foreach (var item in mSelectLessons)
            {
                long       lessonId   = item.Key;
                LessonInfo lessonInfo = item.Value;

                if (classCourse.ContainsKey(lessonInfo.ClassId))
                {
                    classCourse[lessonInfo.ClassId] = classCourse[lessonInfo.ClassId] + "," + lessonInfo.Id.ToString();
                }
                else
                {
                    classCourse[lessonInfo.ClassId] = lessonInfo.Id.ToString();
                }
            }

            JArray jArray = new JArray();

            foreach (var item in classCourse)
            {
                JObject jObject = new JObject();
                jObject.Add("classId", item.Key);
                jObject.Add("courseIds", item.Value);
                jArray.Add(jObject);
            }

            if (jArray.Count > 0)
            {
                JObject jObject = new JObject();
                jObject.Add("classCourse", jArray);
                mClassCourse = jObject.ToString();
                QuerySignUp();
            }
        }
Пример #2
0
 private void SelectLesson(long lessonId, bool isSelected, LessonInfo lessonInfo)
 {
     if (isSelected)
     {
         mLessonList.Add(lessonId, lessonInfo);
     }
     else
     {
         mLessonList.Remove(lessonId);
     }
 }
Пример #3
0
        public SelectedLessonControl(LessonInfo lessonInfo)
        {
            InitializeComponent();

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

            this.Width = width - CommDef.Size380;

            lessonInfo.Size8  = CommDef.Size8;
            lessonInfo.Size18 = CommDef.Size18;
            lessonInfo.Size24 = CommDef.Size24;
            lessonInfo.Size35 = CommDef.Size35;
            lessonInfo.Size48 = CommDef.Size48;
            this.DataContext  = lessonInfo;
            //this.Width = 1535;
        }
Пример #4
0
        public LessonRowControl(int index, LessonInfo lessonInfo)
        {
            InitializeComponent();

            //this.Width = 640;
            this.Height = CommDef.Size60;
            mLessonInfo = lessonInfo;

            mLessonInfo.Size18  = CommDef.Size18;
            mLessonInfo.Size35  = CommDef.Size35;
            mLessonInfo.Size60  = CommDef.Size60;
            mLessonInfo.Size90  = CommDef.Size90;
            mLessonInfo.Size100 = CommDef.Size100;
            mLessonInfo.Size120 = CommDef.Size120;
            this.DataContext    = lessonInfo;
        }
Пример #5
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;
            }
        }