示例#1
0
        private void WorkBack_RunWorkerCompleted(DnevnikWork diary)
        {
            diary.InsertMarksInTable();

            Tools.Enabled    = true;
            Status.Visible   = false;
            TabMarks.Enabled = true;
            tables[TabMarks.SelectedIndex].marks.Enabled = true;
            loadBar.MarqueeAnimationSpeed = 0;

            CellFormating(null, null);
        }
示例#2
0
        private void AddMarksFromDnevnik_Click(object sender, EventArgs e)
        {
            LoginReturn login         = CheckLoginInDnevnik();
            bool        closedSuccess = login.closedSuccess;
            string      keyAccess     = login.keyAccess;

            if (closedSuccess)
            //try
            {
                DnevnikWork workDnevnik = new DnevnikWork((keyAccess == "" ? Properties.Settings.Default.keyAccess : keyAccess));

                if (tables[TabMarks.SelectedIndex].startEdit == true)
                {
                    DialogResult rsl = MessageBox.Show("Сохранить таблицу в файл?\nТекущая таблица будет очищена перед вставкой оценок из ЭЖ.", "Сохранить?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                    if (rsl == DialogResult.Yes)
                    {
                        saveFile.PerformClick();
                    }
                }

                ResetClass rst = new ResetClass(tables[TabMarks.SelectedIndex], tables[TabMarks.SelectedIndex].marks);
                ApiDiary   api = new ApiDiary(keyAccess == "" ? Properties.Settings.Default.keyAccess : keyAccess);

                long personId = ((JObject)JsonConvert.DeserializeObject(api.GetContext()))["personId"].Value <long>();
                var  groups   = workDnevnik.GetAllGroups(workDnevnik.GetMembers());

                using SelectDataChildren criteriaForm = new SelectDataChildren(workDnevnik.GetMembers(groups, Properties.Settings.Default.marksClassmates), workDnevnik.GetMembers(), groups);
                criteriaForm.ShowDialog();

                if (criteriaForm.closeWindow)
                {
                    Status.Visible = true;

                    loadBar.Value = 20;
                    loadBar.Style = ProgressBarStyle.Marquee;
                    loadBar.MarqueeAnimationSpeed = 45;
                    TabMarks.Enabled = false;
                    LabelLoad.Text   = "Ожидайте пока программа вставит все оценки.";
                    Tools.Enabled    = false;
                    tables[TabMarks.SelectedIndex].marks.Enabled = false;

                    int indexTab = TabMarks.SelectedIndex;

                    var test = workDnevnik.GetAllGroups(workDnevnik.GetMembers());

                    SelectChildren children = new SelectChildren()
                    {
                        table     = tables[indexTab],
                        Reset     = rst,
                        EndDate   = criteriaForm.EndDate.Value,
                        StartDate = criteriaForm.StartDate.Value,
                        Member    = workDnevnik.GetMembers(workDnevnik.GetAllGroups(workDnevnik.GetMembers()), Properties.Settings.Default.marksClassmates)[criteriaForm.indexGroup][criteriaForm.indexChild],
                        group     = workDnevnik.GetAllGroups(workDnevnik.GetMembers())[criteriaForm.indexChildGroup][criteriaForm.indexGroup]
                    };

                    WorkBack                     = new BackgroundWorker(); //WorkBack.DoWork += (obj, ea) =>
                    WorkBack.DoWork             += (obj, ea) => workDnevnik.GetMarksDiary(children);
                    WorkBack.RunWorkerCompleted += (obj, ea) => WorkBack_RunWorkerCompleted(workDnevnik);
                    WorkBack.RunWorkerAsync();
                }
            }
            //catch (Exception ex) { MessageBox.Show("Непредвиденная ошибка!\nПопробуйте повторить попытку, поменять параметры или перезапустить программу!"); Clipboard.SetText(ex.Message); }
        }