Esempio n. 1
0
        private void FillLiveId(EbDataTable dt, EbDataRow dr, int liveId, string columName)
        {
            EbDataColumn col = dt.Columns[columName];

            if (col != null)
            {
                dr[col.ColumnIndex] = liveId;
            }
        }
Esempio n. 2
0
        private void AddColumns(EbDataTable dt, ReadOnlyCollection <NpgsqlDbColumn> schema)
        {
            int pos = 0;

            foreach (NpgsqlDbColumn drow in schema)
            {
                string       columnName = System.Convert.ToString(drow["ColumnName"]);
                EbDataColumn column     = new EbDataColumn(columnName, ConvertToDbType((Type)(drow["DataType"])));
                column.ColumnIndex = pos++;
                dt.Columns.Add(column);
            }
        }
Esempio n. 3
0
        public void DoNonQueryBatch(EbDataTable Table)
        {
            try
            {
                using (SqliteConnection con = new SqliteConnection("Data Source=" + this.DbPath))
                {
                    con.Open();
                    string        query = "INSERT INTO {0} ({1}) VALUES ({2});";
                    List <string> _cols = new List <string>();
                    List <string> _vals = new List <string>();

                    using (SqliteCommand cmd = con.CreateCommand())
                    {
                        using (SqliteTransaction transaction = con.BeginTransaction())
                        {
                            for (int k = 0; k < Table.Rows.Count; k++)
                            {
                                cmd.Parameters.Clear();

                                if (k >= 1000)
                                {
                                    break;
                                }

                                for (int i = 0; i < Table.Rows[k].Count; i++)
                                {
                                    EbDataColumn column = Table.Columns.Find(item => item.ColumnIndex == i);
                                    if (k == 0)
                                    {
                                        _cols.Add(column.ColumnName);
                                        _vals.Add("@" + column.ColumnName);
                                    }

                                    cmd.Parameters.Add(new SqliteParameter {
                                        ParameterName = "@" + column.ColumnName, Value = Table.Rows[k][i]
                                    });
                                }

                                cmd.CommandText = string.Format(query, Table.TableName, string.Join(",", _cols.ToArray()), string.Join(",", _vals.ToArray()));
                                int rowAffected = cmd.ExecuteNonQuery();
                            }

                            transaction.Commit();
                        }
                    }
                    con.Close();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
        private List <SQLiteColumSchema> GetNewControls(List <SQLiteColumSchema> columns, ColumnColletion newColumns)
        {
            List <SQLiteColumSchema> unCreated = new List <SQLiteColumSchema>();

            foreach (SQLiteColumSchema cols in columns)
            {
                EbDataColumn data_col = newColumns.Find(x => x.ColumnName == cols.ColumnName);

                if (data_col == null)
                {
                    unCreated.Add(cols);
                }
            }
            return(unCreated);
        }
        public static EbDataSet ToDataSet(this WebformData data)
        {
            EbDataSet ds = new EbDataSet();

            try
            {
                foreach (KeyValuePair <string, SingleTable> st in data.MultipleTables)
                {
                    EbDataTable dt = new EbDataTable {
                        TableName = st.Key
                    };
                    for (int i = 0; i < st.Value.Count; i++)
                    {
                        EbDataRow dr = dt.NewDataRow();
                        for (int k = 0; k < st.Value[i].Columns.Count; k++)
                        {
                            SingleColumn sc = st.Value[i].Columns[k];

                            if (i == 0)
                            {
                                EbDataColumn dc = new EbDataColumn
                                {
                                    ColumnIndex = k,
                                    Type        = (EbDbTypes)sc.Type,
                                    ColumnName  = sc.Name
                                };
                                dt.Columns.Add(dc);
                            }
                            dr.Add((object)sc.Value);
                        }
                        dt.Rows.Add(dr);
                    }
                    ds.Tables.Add(dt);
                }
            }
            catch (Exception ex)
            {
                EbLog.Info("WebformData to dataset operation failed");
                EbLog.Error(ex.StackTrace);
            }
            return(ds);
        }
        public List <SingleColumn> GetColumnValues(EbDataTable LocalData, int RowIndex)
        {
            List <SingleColumn> SC = new List <SingleColumn>();

            for (int i = 0; i < LocalData.Rows[RowIndex].Count; i++)
            {
                EbDataColumn column = LocalData.Columns.Find(o => o.ColumnIndex == i);

                if (column != null && column.ColumnName != "eb_loc_id" && column.ColumnName != "id")
                {
                    DbTypedValue DTV = this.GetDbType(column.ColumnName, LocalData.Rows[RowIndex][i], column.Type);
                    SC.Add(new SingleColumn
                    {
                        Name  = column.ColumnName,
                        Type  = (int)DTV.Type,
                        Value = DTV.Value
                    });
                }
            }
            return(SC);
        }
Esempio n. 7
0
        public List <SingleColumn> GetColumnValues(ColumnColletion columns, EbDataRow row)
        {
            List <SingleColumn> singleColumn = new List <SingleColumn>();

            for (int i = 0; i < row.Count; i++)
            {
                EbDataColumn column = columns.Find(o => o.ColumnIndex == i);

                if (column != null && column.ColumnName != "eb_loc_id" && column.ColumnName != "id")
                {
                    DbTypedValue DTV = GetDbType(column.ColumnName, row[i], column.Type);

                    singleColumn.Add(new SingleColumn
                    {
                        Name  = column.ColumnName,
                        Type  = (int)DTV.Type,
                        Value = DTV.Value
                    });
                }
            }
            return(singleColumn);
        }