Example #1
0
        void DataScriptInfo_Loaded(object sender, RoutedEventArgs e)
        {
            string[] tablelist = System.Configuration.ConfigurationManager.AppSettings["tables"].Split(new char[] { ',' });
            string[] descs     = System.Configuration.ConfigurationManager.AppSettings["tabledescs"].Split(new char[] { ',' });
            // 所有Script的列表,用于计算版本号
            scripts = DataScriptDAL.getList();
            var objTableList = ObjtableInfoDAL.getList();

            foreach (var objTable in objTableList)
            {
                tables.Add(new TableInfo()
                {
                    TableDesc = string.Format("{0}({1})", objTable.ObjectTableName, objTable.ObjectTableCode),
                    TableName = objTable.ObjectTableCode
                });
            }

            projectList                   = WebHelper.listProject(MainWindow.UserName);
            ProjectCode.ItemsSource       = projectList;
            ProjectCode.DisplayMemberPath = "ProjectName";
            ProjectCode.SelectedValuePath = "ProjectCode";

            ProjectCode.KeyUp += ProjectCode_KeyUp;


            if (projectList.Count > 0)
            {
                ProjectCode.SelectedIndex = 0;
            }
            ScriptType.SelectedIndex = 0;

            if (string.IsNullOrEmpty(FID))
            {
                // new row
                MidsScriptCode.Text = "";
                getScriptCode();
            }
            else
            {
                nextButton.IsEnabled  = false;
                nextButton.Visibility = System.Windows.Visibility.Collapsed;
                // edit row
                showData();
            }
        }
Example #2
0
        void DataScriptInfo_Loaded(object sender, RoutedEventArgs e)
        {
            // 获取这个项目唯一使用目标表
            string singleTable = DataLogDAL.getSingleTableName(TaskCenter.TaskID);

            if (tables.Count == 0)
            {
                tables.Add(new TableInfo()
                {
                    TableDesc = "新建表", TableName = "new"
                });

                var objTableList = ObjtableInfoDAL.getList();


                foreach (var objTable in objTableList)
                {
                    tables.Add(new TableInfo()
                    {
                        TableDesc = string.Format("{0}({1})", objTable.ObjectTableName, objTable.ObjectTableCode),
                        TableName = objTable.ObjectTableCode
                    });
                }

                Des_Table.ItemsSource       = tables;
                Des_Table.DisplayMemberPath = "TableDesc";



                TableInfo singleTinfo = tables.FirstOrDefault(it => it.TableName == singleTable);
                if (singleTinfo != null)
                {
                    Des_Table.SelectedItem = singleTinfo;
                    Des_Table.IsEnabled    = false;
                }
                else
                {
                    Des_Table.SelectedIndex = 0;
                }

                ApplyTestProject.SelectedIndex = 0;
            }
        }
Example #3
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);
        }
Example #4
0
        void DataScriptInfo_Loaded(object sender, RoutedEventArgs e)
        {
            string[] tablelist = System.Configuration.ConfigurationManager.AppSettings["tables"].Split(new char[] { ',' });
            string[] descs     = System.Configuration.ConfigurationManager.AppSettings["tabledescs"].Split(new char[] { ',' });

            //for (int i = 0; i < tablelist.Length; i++) {
            //    tables.Add(new TableInfo() {  TableDesc=descs[i], TableName = tablelist[i]});
            //}

            var objTableList = ObjtableInfoDAL.getList();

            ScriptType.SelectedIndex = 0;


            foreach (var objTable in objTableList)
            {
                tables.Add(new TableInfo()
                {
                    TableDesc = string.Format("{0}({1})", objTable.ObjectTableName, objTable.ObjectTableCode),
                    TableName = objTable.ObjectTableCode
                });
            }

            Des_Table.ItemsSource       = tables;
            Des_Table.DisplayMemberPath = "TableDesc";

            if (string.IsNullOrEmpty(FID))
            {
                // new row
            }
            else
            {
                // edit row
                showData();
            }
        }
Example #5
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);
        }