Esempio n. 1
0
        void GetWorkList()
        {
            _fProcessing = new f_Processing();
            _fProcessing.Show();
            _fProcessing.SetTitle("Запрос статистики...");

            _fProcessing.SetPercent(50);
            _dateStart = dp_start.Value.ToDate();
            _dateEnd   = dp_start.Value.ToDate();

            _dateStartArray = _dateStart.ToShortString().Split('.');

            string postData = $"_token={_token}&class_name=&month={_dateStart.Month}&year={_dateStart.Year}";
            string rawJson  =
                HttpWorker.Post("https://new-pk.first-card.ru/reports/work-days", _cookieContainer, postData);


            dynamic json = null;

            try
            {
                _fProcessing.SetPercent(75);
                json = JsonConvert.DeserializeObject <dynamic>(rawJson)["return_data"]["data"]["report"];
            }
            catch (Exception)
            {
                _fProcessing.Close();
                MessageBox.Show("Ошибка получения данных, попробуёте ещё раз...");
                GetToken();
                SendLogin();
                GetPrivateSession();
                Thread.CurrentThread.Abort();
            }

            _fProcessing.SetTitle("Проверка процентности...");
            _fProcessing.SetPercent(0);

            for (int i = 0; i < 147; i++)
            {
                _fProcessing.SetPercent((sbyte)(0.68 * i));

                dynamic str = json[(1 + i) + "_data"];
                if (str != null)
                {
                    int linear = str["learnersCount"];
                    //MessageBox.Show(_dateStartArray[0].ToString());
                    int today = str["dayOfMonth_" + Int32.Parse(_dateStart.Day.ToString()).ToString()];

                    if (linear != today)
                    {
                        richTextBox1.Invoke(new Action(() =>
                        {
                            richTextBox1.Text +=
                                str["className"].ToString() + " - " + today + " из " + linear + "\n";
                        }));
                        GetFullList(str["className"].ToString(), _dateStart);
                    }
                }
            }

            _fProcessing.Close();
            conn.Close();
        }
Esempio n. 2
0
        /// <summary>
        /// Loading classes
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            getToken();
            sendLogin();
            getPrivateSession();

            f_Processing = new f_Processing();
            f_Processing.Show();
            f_Processing.SetTitle("Запрос статистики...");



            f_Processing.SetPercent(50);
            Date date_start = Date.Today;

            string postData = "_token=" + token + $"&class_name=&month={date_start.Month}&year=" + date_start.Year;
            string rawJson  = HttpWorker.Post("http://new-pk.first-card.ru/reports/work-days", cookieContainer, postData);

            dynamic json = null;

            try
            {
                f_Processing.SetPercent(75);
                json = JsonConvert.DeserializeObject <dynamic>(rawJson)["return_data"]["data"]["report"];
            }
            catch (Exception)
            {
                f_Processing.Close();
                MessageBox.Show("Ошибка получения данных, попробуёте ещё раз...");
                getToken();
                sendLogin();
                getPrivateSession();
                Thread.CurrentThread.Abort();
            }

            f_Processing.SetTitle("Проверка процентности...");
            f_Processing.SetPercent(0);

            //if (checkBox1.Checked)
            //{
            //    xlApp = new Microsoft.Office.Interop.Excel.Application();

            //    if (xlApp == null)
            //    {
            //        MessageBox.Show("Excel is not properly installed!!");
            //        return;
            //    }
            //    xlWorkBook = xlApp.Workbooks.Add(1);
            //    xlWorkSheet = (Worksheet)xlWorkBook.Worksheets.get_Item(1);
            //}


            List <string> klas = new List <string>();

            for (int i = 0; i < 147; i++)
            {
                f_Processing.SetPercent((sbyte)(0.68 * i));

                dynamic str = json[(1 + i) + "_data"];

                if (str != null)
                {
                    //while (startdate <= enddate)
                    //{

                    klas.Add(str["className"].ToString());
                    //startdate = startdate.AddDays(1);
                    //}
                    //startdate = dateTimePicker1.Value.ToDate();
                }
            }

            MessageBox.Show(klas.ToString());

            //if (checkBox1.Checked && xlWorkSheet != null)
            //{
            //    if (File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\OLP.xlsx"))
            //        File.Delete(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\OLP.xlsx");

            //    xlWorkBook.SaveAs(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\OLP.xlsx");
            //    xlWorkBook.Close(true, Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\OLP.xlsx");
            //    xlApp.Quit();

            //    Marshal.ReleaseComObject(xlWorkSheet);
            //    Marshal.ReleaseComObject(xlWorkBook);
            //    Marshal.ReleaseComObject(xlApp);
            //}

            f_Processing.Close();
        }