Exemplo n.º 1
0
        private void insertTableStructure(string tableName)
        {
            DataTable dt = GetDataTable(txtTemplageFile.Text);

            if (scripts.Count(it => it.TableName == tableName) == 0)
            {
                // 创建表
                TableDAL.CreateTable(tableName, dt);
                // 添加主键
                //TableDAL.SetPrimary(txtTableName.Text, "ID");
                // 添加扩展列
                TableDAL.AddAttribute(tableName, 20);

                int count = ObjtableInfoDAL.Count(tableName.ToUpper());
                if (count == 0)
                {
                    ObjtableInfo oinfo = new ObjtableInfo();
                    oinfo.FID             = Guid.NewGuid().ToString().Replace("-", "");
                    oinfo.CreatedBy       = MainWindow.UserID;
                    oinfo.LastUpdatedBy   = MainWindow.UserID;
                    oinfo.ObjectTableCode = tableName.ToUpper();
                    oinfo.ObjectTableName = tableName.ToUpper();
                    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);
                }
            }
            else
            {
                // 追加表结构
                TableDAL.CreateTable(tableName, dt);
            }

            DataScriptMapDAL.AutoScriptMap(FID, dt, tableName, MainWindow.UserID);
        }
Exemplo n.º 2
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);
        }