Example #1
0
        private void opnFileTimer_FileOk(object sender, CancelEventArgs e)
        {
            FileJob fj = new FileJob();

            string[] str = new string[fj.ReadF(opnFileTimer.FileName).Length];
            str = fj.ReadF(opnFileTimer.FileName);
            tTimerList.Clear();
            for (int i = 0; i < str.Length; i++)
            {
                tTimerList.AppendText(str[i] + Environment.NewLine);
            }
        }
Example #2
0
        private void btnTimer_Click(object sender, EventArgs e)
        {
            FileJob fj = new FileJob();

            string[] str = new string[fj.ReadF("F:\\temp\\time.txt").Length];
            str = fj.ReadF("F:\\temp\\time.txt");
            tTimerList.Clear();
            for (int i = 0; i < str.Length; i++)
            {
                tTimerList.AppendText(str[i] + Environment.NewLine);
            }


            str = new string[fj.ReadF("F:\\temp\\volt.txt").Length];
            str = fj.ReadF("F:\\temp\\volt.txt");
            tVoltageList.Clear();
            for (int i = 0; i < str.Length; i++)
            {
                tVoltageList.AppendText(str[i] + Environment.NewLine);
            }
        }
Example #3
0
    /// <summary>
    /// Exports the SQL file.
    /// </summary>
    /// <param name="FileName">Name of the file.</param>
    /// <param name="ConnectingString">The connecting string.</param>
    /// <returns>boolean</returns>
    public bool ExportSQLFile(string FileName, string ConnectingString)
    {
        FileJob fj = new FileJob();

        string[] sql = fj.ReadF(FileName);
        try
        {
            NpgsqlConnection pgcon = new NpgsqlConnection(ConnectingString);
            pgcon.Open();
            for (int i = 0; i < sql.Count(); i++)
            {
                NpgsqlCommand CSend = new NpgsqlCommand(sql[i], pgcon);
                CSend.ExecuteNonQuery();
            }
            pgcon.Close();
            return(true);
        }
        catch (Exception msg)
        {
            Console.WriteLine(msg.ToString());
            return(false);
        }
    }
Example #4
0
    /// <summary>
    /// Dnons the rnon import.
    /// </summary>
    /// <param name="OpenFileDNON">The open file dnon.</param>
    /// <param name="view">The view.</param>
    public void DNON_RNON_Import(string OpenFileDNON, DataGridView view)
    {
        int       cst    = 0;
        DataTable dt     = new DataTable();
        string    fileN1 = OpenFileDNON;
        string    fileN2 = OpenFileDNON.Substring(0, OpenFileDNON.Length - 8) + "RNON.txt";
        DataRow   row;
        FileJob   FJ = new FileJob();

        string[] s;
        try
        {
            s = FJ.ReadF(OpenFileDNON);
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.ToString());
            return;
        }
        for (int i = 0; i < s.GetLength(0); i++)
        {
            ParseStringTab p  = new ParseStringTab();
            ParseStringTab p1 = new ParseStringTab();
            p.AddString(s[i]);
            //создание заголовков таблицы
            if (i == 0)
            {
                p.AddString(s[i]);
                IEnumerable <string> pdis = p.Distinct();
                cst = pdis.Count();
                foreach (string st in pdis)
                {
                    p1.Add(st);
                }
                for (int j = 0; j < p1.Count; j++)
                {
                    p1[j] = FJ.CorrectHead(p1[j]);
                    dt.Columns.Add(p1[j]);
                }
            }
            else
            {
                //цикл для сортировки
                int x = 0;
                row = dt.NewRow();
                for (int j = 0; j < p.Count(); j++)
                {
                    try
                    {
                        row[x] = p[j];
                        ++x;
                        if (x == cst)
                        {
                            dt.Rows.Add(row);
                            row = dt.NewRow();
                            x   = 0;
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                }
            }
            p.Clear();
        }

        try
        {
            s = FJ.ReadF(fileN2);
        }
        catch (Exception ex)
        {
            ex.ToString();
        }
        for (int i = 1; i < s.GetLength(0); i++)
        {
            ParseStringTab p  = new ParseStringTab();
            ParseStringTab p1 = new ParseStringTab();
            p.AddString(s[i]);
            int x = 0;
            row = dt.NewRow();
            for (int j = 0; j < p.Count(); j++)
            {
                try
                {
                    row[x] = p[j];
                    ++x;
                    if (x == cst)
                    {
                        dt.Rows.Add(row);
                        row = dt.NewRow();
                        x   = 0;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
            p.Clear();
        }
        view.DataSource = dt;
    }