コード例 #1
0
        public void ProcessETLMode(IRecordProcessor rp)
        {
            inputDatabase.Connect();
            MapFields(rp);

            rp.setDatasetName(inputDatabase.NormTableName(tableName));


            string[] sqls = rp.GetSelectStatements();

            if (Progress != null)
            {
                Progress.ReportProgress(0);
            }
            foreach (string sql in sqls)
            {
                try
                {
                    DbDataReader reader = inputDatabase.Execute(sql);
                    int          count  = 1;
                    rp.Reset();
                    //Extract
                    while (reader.Read())
                    {
                        //Transform
                        rp.ProcessRecord(reader);
                        if (Progress != null)
                        {
                            Progress.ReportProgress(0, "Read records: " + count.ToString());
                        }
                        count++;
                    }
                    reader.Close();
                    reader = null;

                    //Load
                    if (outputDatabase.FileName != null)
                    {
                        //if output is file - Write one
                        WriteData();
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                // Call Close when done reading.
            }
            inputDatabase.Close();
        }
コード例 #2
0
        protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            switch (e.Item.ItemType)
            {
            case ListItemType.Item:
            case ListItemType.AlternatingItem:
            {
                // Find secondary DDL
                DropDownList DropDownList2 = e.Item.FindControl("DropDownList2") as DropDownList;
                if (DropDownList2 != null)
                {
                    string filename = Session["InputFileName"].ToString();
                    //input fields
                    IDatabaseAdapter inputDatabase = DatabaseAdapterFactory.CreateReader(Path.GetExtension(filename), CheckBoxEditMode.Checked);
                    List <string>    tables        = (List <string>)Session["tables"];

                    inputDatabase.Connect(Session["InputFileName"].ToString());
                    Dictionary <string, int> fields = inputDatabase.GetFields(tables[0]);

                    DropDownList2.Items.Clear();
                    DropDownList2.Items.Add("");
                    foreach (KeyValuePair <string, int> row in fields)
                    {
                        var item = new ListItem(row.Key);
                        //Set field if it present in input document
                        DropDownList2.Items.Add(item);
                    }
                }
                break;
            }
            }
        }
コード例 #3
0
        void FillMapFields()
        {
            string filename = Session["InputFileName"].ToString();
            //input fields
            IDatabaseAdapter inputDatabase = DatabaseAdapterFactory.CreateReader(Path.GetExtension(filename), CheckBoxEditMode.Checked);
            List <string>    tables        = (List <string>)Session["tables"];

            inputDatabase.Connect(filename);
            Dictionary <string, int> fields = inputDatabase.GetFields(tables[0]);

            //target fields
            TableProcessorNS.TableProcessor tp = new TableProcessorNS.TableProcessor();
            List <string> modules           = (List <string>)Session["Modules"];
            var           processorFileName = Server.MapPath(Path.Combine("Modules", modules[0]));

            tp.SetRecordProcessor(processorFileName);

            Dictionary <Field, bool> transformFields = tp.GetTransformFields();

            DataTable transformFieldsTable = new DataTable();

            transformFieldsTable = new DataTable();
            transformFieldsTable.Columns.Add("targetField");
            transformFieldsTable.Columns.Add("inputField");
            transformFieldsTable.Columns["targetField"].ReadOnly = true;

            foreach (KeyValuePair <Field, bool> row in transformFields)
            {
                transformFieldsTable.Rows.Add(row.Key.Name, "");
            }

            Repeater1.DataSource = transformFieldsTable;
            Repeater1.DataBind();
        }
コード例 #4
0
        public void ProcessEditMode(IRecordProcessor rp)
        {
            inputDatabase.Connect();
            outputDatabase.Connect();
            MapFields(rp);
            rp.setDatasetName(inputDatabase.NormTableName(tableName));

            if (Progress != null)
            {
                Progress.ReportProgress(0);
            }
            try
            {
                int count          = ProcessOffset;
                int processedCount = 0;
                int totalCount;

                rp.Reset();

                //Extract
                inputDatabase.SetTable(tableName);
                outputDatabase.SetTable(tableName);

                totalCount = inputDatabase.GetRowsCount();

                if (ProcessOffset > 0)
                {
                    inputDatabase.SeekRecord(ProcessOffset);
                }
                else
                {
                    inputDatabase.FirstRecord();
                }

                //!! Skip first line as it Header
                while (inputDatabase.NextRecord())
                {
                    DataRow row = inputDatabase.CurrentRow();

                    //Transform
                    if (rp.ProcessRow(row))
                    {
                        //Load if row changed
                        outputDatabase.UpdateRow(count + 1, row);

                        if (Progress != null)
                        {
                            Progress.ReportProgress((processedCount * 100) / (totalCount - ProcessOffset), string.Format("Records: Read {0} (Processed {1}) of {2}", count, processedCount, totalCount));
                        }

                        processedCount++;
                    }
                    count++;
                }

                //Load
                if (outputDatabase.FileName != null)
                {
                    outputDatabase.Write(outputDatabase.FileName);
                }
                //Set complete
                Progress.ReportProgress(100, string.Format("Read records: {0}, Processed {1}", count, processedCount));
            }
            catch (Exception ex)
            {
                throw ex;
            }
            // Call Close when done reading.

            inputDatabase.Close();
            outputDatabase.Close();
        }