Exemple #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            string zapytanie = this.textBox1.Text;
            string tabela    = parse(zapytanie);

            if (tabela.Equals("error"))
            {
                this.label2.Text = "błędne zapytanie";
            }
            else
            {
                try {
                    access a = myBase.checkAcces(tabela, myUser);
                    if (a.Equals(access.ACCESS))
                    {
                        Wynik wyniki = new Wynik(zapytanie);
                        wyniki.Show();
                    }
                    else
                    {
                        this.label2.Text = "odmowa dostępu";
                    }
                } catch (NullReferenceException) {
                    this.label2.Text = "nie ma takiej tabeli";
                }
            }
        }
        private static void bulkCopyTableFromAccess(this Models.SQLServerDataContext db, string fileName, string tableName, itemScheduler args, ref int countRow, ref List <string> msgError, string where = "", string fromTable = "")
        {
            var cols = new List <string>();
            var dt   = db.getDataSet($"select top 1 * from {tableName}").Tables[0];

            foreach (DataColumn c in dt.Columns)
            {
                cols.Add(c.ColumnName);
            }
            string col = $"[{string.Join("],[", cols)}]";
            var    f   = new FileInfo(fileName);
            var    acc = new access(f.FullName, "");

            local.taskList.Modify(args.action, $"{f.Name}-{tableName}: {countRow:#,0} processed ..");
            if (string.IsNullOrEmpty(fromTable))
            {
                fromTable = tableName;
            }
            string tsql = $"select {col} from {fromTable}{(string.IsNullOrEmpty(where) ? "" : " where " + where)};";
            var    r    = acc.reader(tsql);

            try
            {
                if (r.HasRows == false)
                {
                    r.Close(); acc.close(); return;
                }
                dt = new DataTable(tableName);
                foreach (var item in cols)
                {
                    dt.Columns.Add(item);
                }
                local.taskList.Modify(args.action, $"{f.Name}-{tableName}: {countRow:#,0} processed ..");
                while (r.Read())
                {
                    if (dt.Rows.Count >= args.packetSize)
                    {
                        dt.bulkCopy(local.connectionstring, tableName);
                        countRow += dt.Rows.Count;
                        dt        = new DataTable(tableName);
                        foreach (var item in cols)
                        {
                            dt.Columns.Add(item);
                        }
                        local.taskList.Modify(args.action, $"{f.Name}-{tableName}: {countRow:#,0} processed ..");
                    }
                    DataRow row = dt.NewRow();
                    foreach (var item in cols)
                    {
                        row[item] = $"{r[item]}";
                    }
                    dt.Rows.Add(row);
                }
                if (dt.Rows.Count > 0)
                {
                    dt.bulkCopy(local.connectionstring, tableName);
                    countRow += dt.Rows.Count;
                    dt        = new DataTable(tableName);
                    local.taskList.Modify(args.action, $"{f.Name}-{tableName}: {countRow:#,0} processed ..");
                }
                r.Close();
                acc.close();
            }
            catch (Exception ex)
            {
                try { r.Close(); } catch { }
                acc.close();
                msgError.Add($"{DateTime.Now:HH:mm:ss}-{f.Name}-{tableName}: " + ex.saveMessage());
                local.taskList.Modify(args.action, $"{msgError[msgError.Count - 1]}");
            }
        }
Exemple #3
0
 ?? provider.RequiredService <IAccessQueue <TResource> >().EnqueueAsyncAccess(access, cancellation, attemptsCount);
Exemple #4
0
 .EnqueueAsyncAccess(access, cancellation, attemptsCount, priority);