public void CompareDataByParallelTest()
        {
            DataTable dt = b50032.CompareDataByParallel(_data, "2");

            Assert.AreEqual(1945, dt.Rows.Count);
        }
        protected override ResultStatus Retrieve()
        {
            documentViewer1.DocumentSource = null;

            try {
                ShowMsg("開始讀取");
                if (!GetData())
                {
                    return(ResultStatus.Fail);
                }

                ShowMsg("資料搜尋...");
                //判斷連續x個月不符造市規定
                DataTable ids = b50032.CompareDataByParallel(_Data, SleCMth.Text);
                _Data = b50032.FilterDataByParallel(_Data, ids);

                ShowMsg("讀取中...");

                List <ReportProp> caption = new List <ReportProp> {
                    new ReportProp {
                        DataColumn = "CP_ROW", Caption = "筆數", CellWidth = 40, DetailRowFontSize = 8, HeaderFontSize = 11
                    },
                    new ReportProp {
                        DataColumn = "AMM0_BRK_NO", Caption = "期貨商        代號", CellWidth = 70, DetailRowFontSize = 10, HeaderFontSize = 11, DataRowMerge = true
                    },
                    new ReportProp {
                        DataColumn = "BRK_ABBR_NAME", Caption = "期貨商名稱", CellWidth = 150, DetailRowFontSize = 9, HeaderFontSize = 11, DataRowMerge = true
                    },
                    new ReportProp {
                        DataColumn = "AMM0_ACC_NO", Caption = "帳號", CellWidth = 60, DetailRowFontSize = 10, HeaderFontSize = 11, DataRowMerge = true
                    },
                    new ReportProp {
                        DataColumn = "AMM0_PROD_ID", Caption = "商品名稱", CellWidth = 80, DetailRowFontSize = 10, HeaderFontSize = 11, DataRowMerge = true
                    },
                    new ReportProp {
                        DataColumn = "AMM0_YMD", Caption = "日期", CellWidth = 65, DetailRowFontSize = 9, HeaderFontSize = 11
                    },
                    new ReportProp {
                        DataColumn = "AMM0_OM_QNTY", Caption = "委託          成交量", CellWidth = 65, textAlignment = TextAlignment.MiddleRight, TextFormatString = "{0:#,##0}", DetailRowFontSize = 10, HeaderFontSize = 11
                    },
                    new ReportProp {
                        DataColumn = "AMM0_QM_QNTY", Caption = "報價          成交量", CellWidth = 65, textAlignment = TextAlignment.MiddleRight, TextFormatString = "{0:#,##0}", DetailRowFontSize = 10, HeaderFontSize = 11
                    },
                    new ReportProp {
                        DataColumn = "QNTY", Caption = "造市量", CellWidth = 65, textAlignment = TextAlignment.MiddleRight, TextFormatString = "{0:#,##0}", DetailRowFontSize = 10, HeaderFontSize = 11,
                        Expression = new DevExpress.XtraReports.UI.ExpressionBinding[] {
                            new DevExpress.XtraReports.UI.ExpressionBinding("BeforePrint", "Text", "[QNTY]"),
                            new DevExpress.XtraReports.UI.ExpressionBinding("BeforePrint", "BackColor", "Iif ([QNTY] < [MMF_QNTY_LOW], RGB(255,128,255), RGB(255,255,255))")
                        }
                    },
                    new ReportProp {
                        DataColumn = "CP_M_QNTY", Caption = "造市者   總成交量", CellWidth = 75, textAlignment = TextAlignment.MiddleRight, TextFormatString = "{0:#,##0}", DetailRowFontSize = 10, HeaderFontSize = 11
                    },
                    new ReportProp {
                        DataColumn = "CP_RATE_M", Caption = "總成交量   市佔率(%)", CellWidth = 60, textAlignment = TextAlignment.MiddleRight, TextFormatString = "{0:##0.0#}", DetailRowFontSize = 10, HeaderFontSize = 8
                    },
                    new ReportProp {
                        DataColumn = "AMM0_VALID_CNT", Caption = "有效報價     筆數", CellWidth = 75, textAlignment = TextAlignment.MiddleRight, TextFormatString = "{0:#,##0}", DetailRowFontSize = 10, HeaderFontSize = 11
                    },
                    new ReportProp {
                        DataColumn = "VALID_RATE", Caption = "有效報/詢價   比例(%)", CellWidth = 70, textAlignment = TextAlignment.MiddleRight, TextFormatString = "{0:##0.0#}", DetailRowFontSize = 10, HeaderFontSize = 8,
                        Expression = new DevExpress.XtraReports.UI.ExpressionBinding[] {
                            new DevExpress.XtraReports.UI.ExpressionBinding("BeforePrint", "Text", "[VALID_RATE]"),
                            new DevExpress.XtraReports.UI.ExpressionBinding("BeforePrint", "BackColor", "Iif ([VALID_RATE] < [MMF_RESP_RATIO], RGB(255,128,255), RGB(255,255,255))")
                        }
                    },
                    new ReportProp {
                        DataColumn = "AMM0_MARKET_R_CNT", Caption = "全市場   詢價筆數", CellWidth = 75, textAlignment = TextAlignment.MiddleRight, TextFormatString = "{0:#,##0}", DetailRowFontSize = 10, HeaderFontSize = 11
                    },
                    new ReportProp {
                        DataColumn = "AMM0_MARKET_M_QNTY", Caption = "全市場   總成交量", CellWidth = 75, textAlignment = TextAlignment.MiddleRight, TextFormatString = "{0:#,##0}", DetailRowFontSize = 10, HeaderFontSize = 11
                    },
                    new ReportProp {
                        DataColumn = "AMM0_KEEP_FLAG", Caption = "符合報價每日平均維持時間", CellWidth = 55, textAlignment = TextAlignment.MiddleCenter, DetailRowFontSize = 10, HeaderFontSize = 8
                    }
                };
                _defReport = new defReport(_Data, caption);
                ShowReport(_defReport);

                ShowMsg("匯出檔案...");
                string destinationFilePath = Path.Combine(GlobalInfo.DEFAULT_REPORT_DIRECTORY_PATH, "50032.xlsx");
                try {
                    Workbook workbook = new Workbook();
                    workbook.CreateNewDocument();
                    workbook.SaveDocument(destinationFilePath, DocumentFormat.Xlsx);
                    ids.Columns.Remove(ids.Columns["CP_ROW"]);
                    ids.Columns.Remove(ids.Columns["CP_M_QNTY"]);
                    ids.Columns.Remove(ids.Columns["CP_RATE_M"]);
                    ids.Columns.Remove(ids.Columns["CP_INVALID"]);
                    workbook.Worksheets[0].Import(ids, true, 0, 0);
                    workbook.SaveDocument(destinationFilePath);
                }
                catch (Exception ex) {
                    if (File.Exists(destinationFilePath))
                    {
                        File.Delete(destinationFilePath);
                    }
                    throw ex;
                }
            }
            catch (Exception ex) {
                throw ex;
            }
            finally {
                EndExport();
            }

            return(ResultStatus.Success);
        }