コード例 #1
0
ファイル: f_Main.cs プロジェクト: hanriel/FirstCardPlus
 private void GetToken()
 {
     _token = Regex.Match(
         HttpWorker.Get("https://new-pk.first-card.ru/", _cookieContainer),
         "ue = \"(.*)\"", RegexOptions.IgnorePatternWhitespace
         ).Groups[1].Value;
 }
コード例 #2
0
 private void getPrivateSession() =>
 //string url = "http://new-pk.first-card.ru/pc";
 //HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
 //request.CookieContainer = cookieContainer;
 //HttpWebResponse responce = (HttpWebResponse)request.GetResponse();
 //responce.Close();
 HttpWorker.Get("http://new-pk.first-card.ru/pc", cookieContainer);
コード例 #3
0
ファイル: f_Main.cs プロジェクト: hanriel/FirstCardPlus
        void SendLogin()
        {
            var postData = "_token=" + _token + "&contract_user=0020001155&pass_user=24schoolnutr";
            var response = HttpWorker.Post("https://new-pk.first-card.ru/proc/login", _cookieContainer, postData);

            if (response[0] == 'Ч')
            {
                MessageBox.Show(response, "Отправка авторизации", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #4
0
        void sendLogin()
        {
            string postData = "_token=" + token + "&contract_user=0020001155&pass_user=24schoolnutr";
            string responce = HttpWorker.Post("http://new-pk.first-card.ru/proc/login", cookieContainer, postData);

            if (responce.StartsWith("Ч"))
            {
                MessageBox.Show(responce, "Отправка авторизации", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #5
0
ファイル: f_Main 2.cs プロジェクト: hanriel/FirstCardPlus
        void GetFullList(string klass, Date date)
        {
            var postData = "_token=" + _token + "&class_name=" + klass +
                           $"&month={_dateStart.Month}&year={_dateStart.Year}";
            var rawJson = HttpWorker.Post("https://new-pk.first-card.ru/reports/for-ae", _cookieContainer,
                                          Encoding.UTF8.GetBytes(postData));

            dynamic json  = JsonConvert.DeserializeObject <dynamic>(rawJson)["return_data"]["data"]["report"];
            var     regex = new Regex("user_([0-9]*)");
            var     mc    = regex.Matches(Regex.Unescape(rawJson));

            string[] uids = new string[mc.Count];
            sbyte    ins  = 0;

            foreach (Match match in mc)
            {
                uids[ins++] = match.Groups[1].Value;
            }

            for (int i = 0; i < uids.Length; i++)
            {
                dynamic user = json["user_" + uids[i]][date.ToString("s")];
                if (user == null)
                {
                    continue;
                }
                if ((bool)user.passages || (bool)user.pays)
                {
                    continue;
                }

                richTextBox1.Invoke(new Action(() =>
                {
                    var sql = $"SELECT ID,CODEKEY FROM `tc-db-main`.personal where EXTID='{uids[i]}';";

                    var cmd = new MySqlCommand(sql, conn);
                    var rdr = cmd.ExecuteReader();
                    if (rdr.Read())
                    {
                        var sql2 =
                            $"INSERT INTO `tc-db-log`.logs (LOGTIME,FRAMETS,AREA,LOGDATA,EMPHINT,DEVHINT) VALUES (curtime(),0,0,UNHEX('FE060000020300000000{BitConverter.ToString((byte[]) rdr[1]).Replace("-", string.Empty)}FFFF'),{rdr[0].ToString()},23);";

                        rdr.Close();

                        MySqlCommand cmd2 = new MySqlCommand(sql2, conn);
                        cmd2.ExecuteNonQuery();
                    }

                    rdr.Close();

                    richTextBox1.Text += "- " + json["user_" + uids[i]]["0"]["2"] + " " + uids[i] + "\n";
                }));
            }
        }
コード例 #6
0
ファイル: f_Main 2.cs プロジェクト: hanriel/FirstCardPlus
        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();
        }
コード例 #7
0
ファイル: f_Main.cs プロジェクト: hanriel/FirstCardPlus
 private void GetPrivateSession() => HttpWorker.Get("https://new-pk.first-card.ru/pc", _cookieContainer);
コード例 #8
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();
        }