private void ExportBody(ExportFileParameters parameters, QueryPageCountResult result,ExportIndex index)
 {
     object[] data = GetData(parameters.IsPL,index);
    
     string continuousFileName = GetFileName(parameters.QueryInfo.FilePath, index, result.PageCount);
   
     using (FileStream fs = new FileStream(continuousFileName, FileMode.Create, FileAccess.Write))
     {
         int startFileIndex = index.RecordIndex * 150 + 1;
         if (parameters.IsPL)
         {
             PLExportCenter.Default.Process((PLData[])data, startFileIndex,fs);
         }
         else
         {
             FlexInterface.Helper.FlexPersistence.PersiteDesposit((DepositData[])data, fs,startFileIndex , parameters.QueryInfo.Type);
         }
         
         this._ErrorHandler.WhenExportPerPageSendMsgToUI(parameters.IsPL, index, result.PageCount);
         index.FileIndex++;
         index.PageIndex++;
         index.RecordIndex++;
        
     }
 }
 private object[] GetData(bool isPL,ExportIndex index)
 {
     object[] data = null;
     if (isPL)
     {
         data = Common.Service.GetPLDataByPage(Common.SessionId, index.PageIndex);
     }
     else
     {
         Debug.WriteLine("Deposit");
         data = Common.Service.GetDepositDataByPage(Common.SessionId, index.PageIndex);
     }
     return data;
 }
        private void Export(object obj)
        {
            ExportFileParameters parameters = (ExportFileParameters)obj;
            this._ErrorHandler.ExportStep1(parameters.IsPL);
            QueryPageCountResult result = null;
            if (parameters.IsPL)
            {
                result = Common.Service.GetPLDataPageCount(Common.SessionId, parameters.QueryInfo);
            }
            else
            {
                result = Common.Service.GetDepositPageCount(Common.SessionId, parameters.QueryInfo);
            }

            bool isNormal = this._ErrorHandler.IsDataNormal(result);
            if (!isNormal) return;

            ExportIndex index = new ExportIndex() {  PageIndex=1, FileIndex=1, RecordIndex=0};

            while (index.PageIndex <= result.PageCount)
            {
                ExportBody(parameters, result, index);
            }
        }
 private string GetFileName(string filePath,ExportIndex index, int pageCount)
 {
     string continuousFileName = string.Empty;
     if (pageCount> 1)
     {
         continuousFileName = filePath.Substring(0, filePath.Length - 4) + index.FileIndex + ".txt";
     }
     else
     {
         continuousFileName = filePath;
     }
     return continuousFileName;
 }