Пример #1
0
        public List <File_struct> def_func()
        {
            file_work workfile = new file_work();

            List <File_struct> data = new List <File_struct>();

            return(workfile.read());
        }
Пример #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (search_text.Text.Length > 0 && query.Text.Length > 0)
                {
                    web_site web = new web_site();

                    web.Url = search_text.Text;

                    web.Query = query.Text;

                    load.Visible = true;

                    bool web_load = false;

                    web.Func = "Pozīcijas apskatīšana";

                    string html = web.get_string_html();

                    if (web.html_parse_to_url_array(html))
                    {
                        if (web.position_from_array(web.Url_arr, web.Url))
                        {
                            label4.Visible = true;
                            if (web.Position != 999)
                            {
                                label4.Text = "Tekoša URL pozīcija \"" + web.Url + "\" pēc vaicājuma \"" + web.Query + "\" - " + web.Position.ToString();
                            }
                            else
                            {
                                label4.Text = "Tekoša URL pozīcija \"" + web.Url + "\" pēc vaicājuma \"" + web.Query + "\" - NaN";
                            }
                            button5.Visible = true;
                        }

                        if (web.file_write(web.Url_arr))
                        {
                            load.Visible = false;

                            web_load = true;
                        }
                    }

                    if (web_load)
                    {
                        file_work workfile = new file_work();

                        workfile.date_set();

                        workfile.Url = web.Url;

                        workfile.Query = web.Query;

                        workfile.Pos = web.Position;

                        if (!workfile.isExist_record())
                        {
                            workfile.write();
                            MessageBox.Show("Ieraksts par pozīciju ir veiksmīgi izveidots!\nInformācija:\n\nVaicājums: " + workfile.Query + "\nURL: " + workfile.Url + "\nPozīcija: " + workfile.Pos, "Izpildīts!", MessageBoxButtons.OK, MessageBoxIcon.None);
                        }
                        else
                        {
                            MessageBox.Show("Šodien ieraksts par pozīciju jau eksistē!\n\nURL: " + workfile.Url + " \nVaicājums: " + workfile.Query + "\nPozīcija: " + workfile.Pos, "Uzmanību!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Ir nepieciešams ievadīt datus!", "Kļūda!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }catch (Exception err)
            {
                MessageBox.Show("Izņēmuma izsaukšana! \n" + err, "Kļūda!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }