void DataScriptMapModify_Loaded(object sender, RoutedEventArgs e)
        {
            // columnConnection.Source = TextImportHelper.GetDataTable(@"G:\workspace\动控实现数据管理\src\TestData\data.txt", ',');
            //columnConnection.Target = TableDAL.getTableStructure("MDS_IMP_DATA_TEST");

            if (DataScript.FileType == "mdb")
            {
                AccessImportHelper helper = new AccessImportHelper(this.DataScriptRule.DesFile);
                columnConnection.Source = helper.getDataTable();
            }
            else if (DataScript.FileType == "db")
            {
                columnConnection.Source = SQLiteImportHelper.GetDataTable(this.DataScriptRule.DesFile);
            }
            else if (DataScript.FileType == "xls/xlsx")
            {
                columnConnection.Source = ExcelImportHelper.GetDataTable(this.DataScriptRule.DesFile);
            }
            else
            {
                columnConnection.Source = TextImportHelper.GetDataTable(this.DataScriptRule.DesFile, this.DataScriptRule.getColSeperatorChar());
            }

            columnConnection.FID        = FID;
            columnConnection.BusinessPK = this.DataScriptRule.DesBusinessPk;
            columnConnection.Target     = TableDAL.getTableStructure(this.DataScriptRule.DesTable);
        }
        void ImportMapModify_Loaded(object sender, RoutedEventArgs e)
        {
            if (DataScript.FileType == "mdb")
            {
                AccessImportHelper helper = new AccessImportHelper(sourceFile);
                columnConnection.Source = helper.getDataTable();
            }
            else if (DataScript.FileType == "db")
            {
                columnConnection.Source = SQLiteImportHelper.GetDataTable(sourceFile);
            }
            else if (DataScript.FileType == "xls/xlsx")
            {
                columnConnection.Source = ExcelImportHelper.GetDataTable(sourceFile);
            }
            else
            {
                columnConnection.Source = TextImportHelper.GetDataTable(sourceFile, this.DataScriptRule.getColSeperatorChar());
            }

            columnConnection.Target     = TableDAL.getTableStructure(this.DataScriptRule.DesTable);
            columnConnection.BusinessPK = DataScriptRule.DesBusinessPk;
            columnConnection.FID        = FID;

            columnConnection.ShowComplete += columnConnection_ShowComplete;
        }
Beispiel #3
0
        private bool xls2db()
        {
            DataTable dt = ExcelImportHelper.GetDataTable(this.sourceFile);

            this.calColumnMap(dt);
            bool result = insertDataTable(dt, structList, this.tableName);

            return(result);
        }
Beispiel #4
0
        private void xls2db()
        {
            DataTable dataTable = ExcelImportHelper.GetDataTable(sourceFile);

            if (!insertDataTable(dataTable, structList, this.tableName))
            {
                return;
            }
        }
Beispiel #5
0
        private List <string> getHeaders()
        {
            List <string> result   = new List <string>();
            DataTable     dt       = new DataTable();
            string        fileType = System.IO.Path.GetExtension(this.sourceFile);

            if (fileType == ".xls" || fileType == ".xlsx")
            {
                dt = ExcelImportHelper.GetDataTable(this.sourceFile);
            }
            else
            {
                dt = TextImportHelper.GetDataTable(this.sourceFile, this.dataScriptRule.getColSeperatorChar());
            }

            foreach (DataColumn column in dt.Columns)
            {
                result.Add(column.ColumnName);
            }
            return(result);
        }
Beispiel #6
0
        private DataTable GetDataTable(string fileName)
        {
            DataTable dt;

            if (FileType.SelectedValue.ToString() == "mdb")
            {
                AccessImportHelper helper = new AccessImportHelper(fileName);
                dt = helper.getDataTable();
            }
            else if (FileType.SelectedValue.ToString() == "xls/xlsx")
            {
                dt = ExcelImportHelper.GetDataTable(fileName);
            }
            else if (FileType.SelectedValue.ToString() == "db")
            {
                dt = SQLiteImportHelper.GetDataTable(fileName);
            }
            else
            {
                dt = TextImportHelper.GetDataTable(fileName, DataScriptRule.getColSeperatorChar(GetColSperator()));
            }
            return(dt);
        }
Beispiel #7
0
        private void nextButton_Click(object sender, RoutedEventArgs e)
        {
            string erromsg = "";

            if (string.IsNullOrEmpty(txtTemplageFile.Text.Trim()))
            {
                erromsg += "请选择样例文件!\r\n";
            }

            if (Des_Table.SelectedIndex == -1)
            {
                erromsg += "请选择目标数据表!\r\n";
            }

            if (Des_Table.SelectedIndex == 0 && string.IsNullOrEmpty(txtTableName.Text))
            {
                erromsg += "请输入数据表名称!\r\n";
            }

            if (Des_Table.SelectedIndex == 0 && string.IsNullOrEmpty(txtTableCode.Text))
            {
                erromsg += "请输入数据表代码!\r\n";
            }


            if (cbSave.IsChecked.Value)
            {
                if (string.IsNullOrEmpty(MidsScriptCode.Text.Trim()))
                {
                    erromsg += "请输入解析器编码!\r\n";
                }
                else
                {
                    if (!checkCode())
                    {
                        erromsg += "解析器编码重复!\r\n";
                    }
                }
                if (string.IsNullOrEmpty(MidsScriptName.Text.Trim()))
                {
                    erromsg += "请输入解析器名称!\r\n";
                }
            }

            if (!string.IsNullOrEmpty(erromsg))
            {
                MessageBox.Show(erromsg);
                return;
            }

            builderScript();


            if (cbSave.IsChecked.Value)
            {
                insert();
            }
            DataTable dt = new DataTable();

            if (FileType.SelectedValue.ToString() == "xls/xlsx")
            {
                dt = ExcelImportHelper.GetDataTable(txtTemplageFile.Text.Trim());
            }
            else
            {
                dt = TextImportHelper.GetDataTable(txtTemplageFile.Text.Trim(), DataScriptRule.getColSeperatorChar(GetColSperator()));
            }

            TableDAL.CreateTable(txtTableCode.Text.ToUpper(), dt);

            int count = ObjtableInfoDAL.Count(txtTableCode.Text.ToUpper());

            if (count == 0)
            {
                ObjtableInfo oinfo = new ObjtableInfo();
                oinfo.FID             = Guid.NewGuid().ToString().Replace("-", "");
                oinfo.CreatedBy       = MainWindow.UserID;
                oinfo.LastUpdatedBy   = MainWindow.UserID;
                oinfo.ObjectTableCode = txtTableCode.Text.ToUpper();
                oinfo.ObjectTableName = txtTableName.Text;
                oinfo.Status          = "02";
                oinfo.Version         = 1;
                oinfo.LastUpdateIp    = "127.0.0.1";
                oinfo.LastUpdateDate  = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                oinfo.CreationDate    = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                ObjtableInfoDAL.Insert(oinfo);
            }

            ImportMapModify mapModify = new ImportMapModify();

            mapModify.FID            = FID;
            mapModify.DataScriptRule = dRule;
            mapModify.DataScript     = dScript;
            mapModify.sourceFile     = txtTemplageFile.Text.Trim();
            mapModify.isAutoDrawLine = true;

            ImportStack.Push(this);
            MainWindow window = App.Current.MainWindow as MainWindow;

            window.StartPage(mapModify);
        }
        private void openTemplateFile_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            dataScript = ScriptName.SelectedItem as DataScript;

            dataRule = DataScriptRuleDAL.getInfo(dataScript.FID);

            System.Windows.Forms.OpenFileDialog dialog = new System.Windows.Forms.OpenFileDialog();

            if (FileType.SelectedValue.ToString() == "xls/xlsx")
            {
                dialog.Filter = "(Excel 文件)|*.xls;*.xlsx";
            }
            else if (FileType.SelectedValue.ToString() == "dat")
            {
                dialog.Filter = "(dat 文件)|*.dat";
            }
            else if (FileType.SelectedValue.ToString() == "db")
            {
                dialog.Filter = "(sqlite 文件)|*.db";
            }
            else if (FileType.SelectedValue.ToString() == "mdb")
            {
                dialog.Filter = "(mdb 文件)|*.mdb";
            }
            else if (FileType.SelectedValue.ToString() == "fws10")
            {
                dialog.Filter = "(fws10 文件)|*.fws10";
            }
            else
            {
                dialog.Filter = "(文本文件)|*.txt";
            }

            System.Windows.Forms.DialogResult result = dialog.ShowDialog();

            DataTable dt = new DataTable();

            if (result == System.Windows.Forms.DialogResult.OK)
            {
                txtTemplageFile.Text = dialog.FileName;

                if (FileType.SelectedValue.ToString() == "mdb")
                {
                    AccessImportHelper helper = new AccessImportHelper(dialog.FileName);
                    dt = helper.getDataTable();
                }
                else if (FileType.SelectedValue.ToString() == "xls/xlsx")
                {
                    dt = ExcelImportHelper.GetDataTable(dialog.FileName);
                }
                else if (FileType.SelectedValue.ToString() == "db")
                {
                    dt = SQLiteImportHelper.GetDataTable(dialog.FileName);
                }
                else
                {
                    dt = TextImportHelper.GetDataTable(dialog.FileName, dataRule.getColSeperatorChar());
                }

                dataGrid.ItemsSource   = dt.AsDataView();
                importGrid.ItemsSource = dt;
                checkStruct(dt, dataScript);
            }
        }