private void WriteTable()
        {
            try
            {
                if (this.funcCopyTable == null)
                {
                    this.funcCopyTable = new FunctionCopyTable();
                }

                this.funcCopyTable.ImportDelimiter = this.ImportDelimiter;

                this.funcCopyTable.writeOperation = OperationType.write;

                this.funcCopyTable.TargetSystemName = this.TargetSystem;
                this.funcCopyTable.TargetTableName = this.TargetTableName;
                this.funcCopyTable.Fields = this.getFields();
                this.funcCopyTable.writeOperation = this.writeOperation;
                this.funcCopyTable.ExchangeData = this.getData();
                this.funcCopyTable.isDelete = chkDelete.Checked;
                this.funcCopyTable.isInsert = chkInsert.Checked;
                this.funcCopyTable.isModify = chkModify.Checked;
                this.funcCopyTable.isUpdate = chkUpdate.Checked;

                //funcCopyTable.TargetSystemName = this.TargetSystem;
                //funcCopyTable.TargetTableName = this.TargetTableName;
                funcCopyTable.WriteTable();
            }
            catch (Exception ex)
            {
                log.Error(ex.Message);
                //this.textBoxLog.AppendText(ex.Message);
                //this.textBoxLog.AppendText("\r\n");
                //this.textBoxLog.ScrollToCaret();
                if (!IsBatchRunnig)
                {
                    MessageBox.Show(ex.Message);
                }
                //throw new Exception(ex.Message);
            }
        }
        private void setResult(FunctionCopyTable sender, List<CopyTableField> fields, List<String> data)
        {
            DataList = data;
            if (data != null)
            {
                if (this.dgvPreviewTable.InvokeRequired)
                {
                    this.Invoke(new SetPreviewResult(setResult), new object[] { sender, fields, data });
                }
                else
                {
                    this.dt.Rows.Clear();
                    foreach (var item in data)
                    {
                        this.dt.Rows.Add(item);
                    }

                    this.dgvPreviewTable.DataSource = dt;

                    this.dgvPreviewTable.AutoResizeColumns();

                    this.dgvFields.Rows.Clear();
                    foreach (var item in fields)
                    {
                        this.dgvFields.Rows.Add(item.FieldName, item.Offset, item.Length);
                    }
                }
            }
        }
        private void ReadTable()
        {
            try
            {
                int.TryParse(txtRowCount.Text.Trim(), out this.RowCount);

                if (funcCopyTable == null)
                {
                    funcCopyTable = new FunctionCopyTable();
                    funcCopyTable.EventCopied += new DelegateCopyFinished(funcCopyTable_eventReadTableDone);
                }
                funcCopyTable.readOperation = this.readOperation;

                funcCopyTable.Conditions = getCondition();
                funcCopyTable.Fields = getFields();
                funcCopyTable.RowCount = this.RowCount;
                funcCopyTable.Delimiter = Delimeter;

                funcCopyTable.SourceSystemName = SourceSystem;
                funcCopyTable.SourceTableName = SourceTableName;
                funcCopyTable.readOperation = this.readOperation;
                funcCopyTable.ReadTable();
            }
            catch (Exception ex)
            {
                log.Error(ex.Message);
                //this.textBoxLog.AppendText(ex.Message);
                //this.textBoxLog.AppendText("\r\n");
                //this.textBoxLog.ScrollToCaret();
                if (!IsBatchRunnig)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
 private void setLog(FunctionCopyTable sender, List<CopyTableField> fields, List<String> dt)
 {
     if (sender != null && sender.Message != null)
     {
         if (this.textBoxLog.InvokeRequired)
         {
             this.Invoke(new SetPreviewResult(setLog), new object[] { sender, null, null });
         }
         else
         {
             this.textBoxLog.AppendText(sender.Message);
             this.textBoxLog.AppendText("\r\n");
             this.textBoxLog.ScrollToCaret();
         }
     }
 }
        void funcCopyTable_eventReadTableDone(FunctionCopyTable sender, List<CopyTableField> fields, List<String> result)
        {
            if (this.readOperation != OperationType.direct)
            {
                setResult(sender, fields, result);
            }

            setLog(sender, null, null);

            //if (this.dgvPreviewTable.InvokeRequired)
            //{
            //
            //    SetPreviewResult e = new SetPreviewResult(setResult);
            //    BeginInvoke(e, new object[] { result });
            //   // e.BeginInvoke(result,setResult,"");
            //   // IAsyncResult re = e.BeginInvoke(result, "", "");
            //}
            //  MessageBox.Show("读取完毕!");
        }