Beispiel #1
0
        private void showData()
        {
            dScript = DataScriptDAL.getInfo(FID);
            dRule   = DataScriptRuleDAL.getInfo(FID);

            ProjectCode.SelectedValue = dScript.ProjectCode;
            TaskName.Text             = dScript.TaskName;
            txtTableName.Text         = dScript.TableName;
            MidsScriptCode.Text       = dScript.MidsScriptCode;
            MidsScriptName.Text       = dScript.MidsScriptName;
            MidsScriptVesion.Text     = dScript.MidsScriptVesion;
            FileType.SelectedValue    = dScript.FileType;
            IndexKey.Text             = dScript.IndexKey;
            ValidFlag.Text            = dScript.ValidFlag;
            Remark.Text = dScript.Remark;
            ApplyTestProject.SelectedValue = dScript.ApplyTestProject;
            ScriptType.SelectedIndex       = dScript.ScriptType;

            SetColSperator(dRule.ColSperator);
            ColName_Lines.Text = dRule.ColnameLines.ToString();

            if (tables.SingleOrDefault(it => it.TableName == dRule.DesTable) == null)
            {
                tables.Add(new TableInfo()
                {
                    TableDesc = dRule.DesTable, TableName = dRule.DesTable
                });
            }
            ProjectCode.SelectedValue = dScript.ProjectCode;

            txtTemplageFile.Text = dRule.DesFile;
        }
Beispiel #2
0
        public Class1(string userID, string userName, string projectCode, string taskCode, string scriptCode, int times, string sourceFile)
        {
            this.userID = userID;
            var taskInfoList = WebHelper.listTdmTasks(userName);

            this.taskInfo = taskInfoList.FirstOrDefault(it => it.taskCode == taskCode);

            // "b1190f6a66a94b6eb110b3ffc0739887";
            string fid = scriptCode2Fid(scriptCode);

            this.dataScript     = DataScriptDAL.getInfo(fid);
            this.dataScriptRule = DataScriptRuleDAL.getInfo(fid);
            this.times          = times;
            this.sourceFile     = sourceFile;
            this.columnMap      = getColumnMap();
            this.calColumnMap();

            if (this.dataScriptRule != null)
            {
                this.structList = TableDAL.getTableStructure(this.dataScriptRule.DesTable);
            }
        }
Beispiel #3
0
        public bool init()
        {
            var taskInfoList = TaskinfoDAL.getList(userName);

            if (taskInfoList == null || taskInfoList.Count == 0)
            {
                SendMessageEvent(false, string.Format("用户[{0}],无任务数据", userName));
                CompleteEvent(this, new CompleteArgs()
                {
                    Message = "数据导入失败"
                });
                return(false);
            }

            this.taskInfo = taskInfoList.FirstOrDefault(it => it.taskCode == taskCode);

            if (taskInfo == null)
            {
                SendMessageEvent(false, string.Format("任务[{0}],不存在", taskCode));
                CompleteEvent(this, new CompleteArgs()
                {
                    Message = "数据导入失败"
                });
                return(false);
            }

            var dataSource = WebHelper.listTdmTaskTimesInfo(taskInfo.id);

            if (dataSource.Count(it => it.TestTime == this.times.ToString()) < 1)
            {
                SendMessageEvent(false, string.Format("任务 [ {0} ] ,试验次数 [ {1} ] 不存在,", taskCode, this.times));
                CompleteEvent(this, new CompleteArgs()
                {
                    Message = "数据导入失败"
                });
                return(false);
            }

            string fid = scriptCode2Fid(scriptCode);

            if (string.IsNullOrEmpty(fid))
            {
                SendMessageEvent(false, string.Format("任务[{0}],不存在", taskCode));
                CompleteEvent(this, new CompleteArgs()
                {
                    Message = "数据导入失败"
                });
                return(false);
            }

            this.dataScript = DataScriptDAL.getInfo(fid);

            if (dataScript == null)
            {
                SendMessageEvent(false, string.Format("任务[{0}],不存在", taskCode));
                CompleteEvent(this, new CompleteArgs()
                {
                    Message = "数据导入失败"
                });
                return(false);
            }

            this.dataScriptRule = DataScriptRuleDAL.getInfo(fid);

            if (dataScriptRule == null)
            {
                SendMessageEvent(false, string.Format("任务规则[{0}],不存在", fid));
                CompleteEvent(this, new CompleteArgs()
                {
                    Message = "数据导入失败"
                });
                return(false);
            }

            this.columnMap = getColumnMap();

            if (this.dataScriptRule != null)
            {
                this.structList = TableDAL.getTableStructure(this.dataScriptRule.DesTable);
            }

            return(true);
        }
        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);
            }
        }