private void textBoxInputFileName_TextChanged(object sender, EventArgs e) { string filename = textBoxInputFileName.Text.Trim(); if (File.Exists(filename)) { //Create input database adapter tp.InputDatabase = DatabaseAdapterFactory.CreateReader(Path.GetExtension(filename), CheckBoxEditMode.Checked); tp.InputDatabase.FileName = filename; textBoxInputFileName.ForeColor = System.Drawing.SystemColors.WindowText; //Fill tables list comboBoxTableName.Items.Clear(); comboBoxTableName.Items.AddRange(tp.InputDatabase.GetTables()); if (comboBoxTableName.Items.Count == 1) { comboBoxTableName.SelectedIndex = 0; } else { comboBoxTableName.Text = ""; } } else { textBoxInputFileName.ForeColor = Color.Red; } }
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; } } }
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(); }
private void buttonStart_Click(object sender, System.EventArgs e) { buttonStart.Enabled = false; try { string filename = textBoxInputFileName.Text.Trim(); string outfilename = textBoxOutputFileName.Text.Trim(); //extract settings tp.InputDatabase = DatabaseAdapterFactory.CreateReader(Path.GetExtension(filename), CheckBoxEditMode.Checked); tp.InputDatabase.FileName = filename; //transform settings tp.tableName = comboBoxTableName.Text; tp.InputFieldNamesMap = TableProcessor.DeserializeFieldsMap(textBoxFieldsMapping.Text); //load settings //If Edit mode - copy original and open for wrtiting if (CheckBoxEditMode.Checked) { tp.OutputDatabase = DatabaseAdapterFactory.CreateWriter(Path.GetExtension(outfilename)); tp.ProcessMode = ProcessMode.pmEdit; } tp.OutputDatabase.FileName = outfilename; tp.Progress = new ProgressBarMonitor(toolStripProgressBar1, toolStripStatusLabel1, 100); int.TryParse(textBoxOffset.Text, out tp.ProcessOffset); tp.Process(); string Msg = Path.GetFileName(tp.InputDatabase.FileName) + " processing complete"; MessageBox.Show(this, Msg, "Results"); } catch (Exception ex) { MessageBox.Show(this, ex.Message + " " + ex.StackTrace, "Error"); } buttonStart.Enabled = true; }
void FillTables() { //OleDbDatabaseAdapter inputDatabase = new OleDbDatabaseAdapter(); string infilename = Session["InputFileName"].ToString(); IDatabaseAdapter inputDatabase = DatabaseAdapterFactory.CreateReader(Path.GetExtension(infilename), CheckBoxEditMode.Checked); inputDatabase.FileName = infilename; string[] tables = inputDatabase.GetTables(); CheckBoxListTables.Items.Clear(); foreach (string tablename in tables) { CheckBoxListTables.Items.Add(tablename); } if (CheckBoxListTables.Items.Count == 1) { CheckBoxListTables.Items[0].Selected = true; } }
protected void Wizard1_FinishButtonClick(object sender, WizardNavigationEventArgs e) { Session["progress"] = new BaseProgress(); SetMappings(); //Start Processing TableProcessorNS.TableProcessor tp = new TableProcessorNS.TableProcessor(); tp.Progress = (BaseProgress)Session["progress"]; string inputFileName = Session["InputFileName"].ToString().Trim(); string outputFileName = Path.Combine(Path.GetDirectoryName(inputFileName), TextBoxOutputFileName.Text); tp.InputDatabase = DatabaseAdapterFactory.CreateReader(Path.GetExtension(inputFileName), CheckBoxEditMode.Checked); tp.InputDatabase.FileName = inputFileName; tp.InputDatabase.Connect(inputFileName); List <string> tables = (List <string>)Session["tables"]; tp.tableName = tables[0]; List <string> modules = (List <string>)Session["Modules"]; tp.SetRecordProcessor(Server.MapPath(Path.Combine("Modules", modules[0]))); tp.InputFieldNamesMap = TableProcessor.DeserializeFieldsMap((string)Session["Mappings"]); //If Edit mode - copy original and open for wrtiting if (CheckBoxEditMode.Checked) { tp.OutputDatabase = DatabaseAdapterFactory.CreateWriter(Path.GetExtension(outputFileName)); tp.ProcessMode = ProcessMode.pmEdit; } tp.OutputDatabase.FileName = outputFileName; Thread run = new Thread(new ThreadStart(tp.Process)); run.Start(); Response.Write("Process started"); }