public void Save(CurrencyExport objCurrencyExport)
        {
            string sql = null;
            List<DbParameter> parameterList = new List<DbParameter>();

            if (objCurrencyExport.PkId == 0)
            {
                sql = " insert into tbl_currency_export(PkId, OrgId, DeviceNumber, OperateStartTime, OperateEndTime, CurrencyNumber, ExportStatus, DataCount, FileName, FileSize, CreateUserId, CreateTime) " +
                      " values(TCE_PKID.NEXTVAL, :OrgId, :DeviceNumber, :OperateStartTime, :OperateEndTime, :CurrencyNumber, :ExportStatus, :DataCount, :FileName, :FileSize, :CreateUserId, :CreateTime) ";

                parameterList.Add(new OracleParameter(":OrgId", objCurrencyExport.OrgId));
                parameterList.Add(new OracleParameter(":DeviceNumber", objCurrencyExport.DeviceNumber));
                parameterList.Add(new OracleParameter(":OperateStartTime", objCurrencyExport.OperateStartTime));
                parameterList.Add(new OracleParameter(":OperateEndTime", objCurrencyExport.OperateEndTime));
                parameterList.Add(new OracleParameter(":CurrencyNumber", objCurrencyExport.CurrencyNumber));
                parameterList.Add(new OracleParameter(":ExportStatus", objCurrencyExport.ExportStatus));
                parameterList.Add(new OracleParameter(":DataCount", objCurrencyExport.DataCount));
                parameterList.Add(new OracleParameter(":FileName", objCurrencyExport.FileName));
                parameterList.Add(new OracleParameter(":FileSize", objCurrencyExport.FileSize));
                parameterList.Add(new OracleParameter(":CreateUserId", objCurrencyExport.CreateUserId));
                parameterList.Add(new OracleParameter(":CreateTime", objCurrencyExport.CreateTime));
            }

            else
            {
                sql = " update tbl_currency_export set ExportStatus=:ExportStatus, DataCount=:DataCount, FileName=:FileName, FileSize=:FileSize where PkId=:PkId ";

                parameterList.Add(new OracleParameter(":ExportStatus", objCurrencyExport.ExportStatus));
                parameterList.Add(new OracleParameter(":DataCount", objCurrencyExport.DataCount));
                parameterList.Add(new OracleParameter(":FileName", objCurrencyExport.FileName));
                parameterList.Add(new OracleParameter(":FileSize", objCurrencyExport.FileSize));
                parameterList.Add(new OracleParameter(":PkId", objCurrencyExport.PkId));
            }

            DbHelper.ExecuteNonQuery(sql, CommandType.Text, parameterList.ToArray());
        }
        public void Save_Export(CurrencyExport objCurrencyExport)
        {
            var repository = ServiceFactory.GetService<ICurrencyExportRepository>();

            repository.Save(objCurrencyExport);
        }
        protected void btnExport_Click(object sender, EventArgs e)
        {
            ICurrencyService service = ServiceFactory.GetService<ICurrencyService>();

            var currencyInfoPaging = new Pagination()
            {
                CurrentPageIndex = 1,
                PageSize = 1
            };

            var currencyInfoList = service.GetList_Info(this.OrgId.ToInt(0), false, this.StartTime, this.EndTime, this.DeviceNumber, this.CurrencyNumber, currencyInfoPaging);

            if (currencyInfoPaging.RowCount > 25000)
            {
                this.JscriptMsg("单次导出数据量不能超过25000", null, "Error");

                return;
            }

            if (currencyInfoPaging.RowCount == 0)
            {
                this.JscriptMsg("暂无数据,无法导出", null, "Error");

                return;
            }

            CurrencyExport entity = new CurrencyExport()
            {
                OrgId = this.OrgId.ToInt(0),
                DeviceNumber = this.DeviceNumber,
                OperateStartTime = this.StartTime,
                OperateEndTime = this.EndTime,
                CurrencyNumber = this.CurrencyNumber,
                ExportStatus = 0,
                DataCount = 0,
                FileName = "",
                FileSize = "",
                CreateUserId = this.CurrentUser.PkId,
                CreateTime = DateTime.Now
            };

            service.Save_Export(entity);

            ExportCurrencyTask.AddNext(FileHelper.ConvertPath("~/App_File/Export/"));

            TaskFactory.CreateTimer();

            var currencyExportPaging = new Pagination()
            {
                CurrentPageIndex = 2,
                PageSize = (int)SystemParameter.FileStorageCount
            };

            var currencyExportList = service.GetList_Export(this.CurrentUser.PkId, currencyExportPaging);

            if (currencyExportPaging.CurrentPageIndex == 2 && currencyExportPaging.RowCount > SystemParameter.FileStorageCount)
            {
                foreach (var item in currencyExportList)
                {
                    if (item.ExportStatus == 2)
                    {
                        FileHelper.DeleteFile("~/App_File/Export/" + item.FileName);

                        service.Delete_Export(item.PkId);
                    }
                }
            }

            this.JscriptMsg("数据导出任务已建立,请到数据导出页面下载", null, "Success");
        }
        public void Save(CurrencyExport objCurrencyExport)
        {
            string sql = null;
            List<DbParameter> parameterList = new List<DbParameter>();

            if (objCurrencyExport.PkId == 0)
            {
                sql = " insert into tbl_currency_export(OrgId, DeviceNumber, OperateStartTime, OperateEndTime, CurrencyNumber, ExportStatus, DataCount, FileName, FileSize, CreateUserId, CreateTime) " +
                      " values(@OrgId, @DeviceNumber, @OperateStartTime, @OperateEndTime, @CurrencyNumber, @ExportStatus, @DataCount, @FileName, @FileSize, @CreateUserId, @CreateTime) ";

                parameterList.Add(new MySqlParameter("@OrgId", objCurrencyExport.OrgId));
                parameterList.Add(new MySqlParameter("@DeviceNumber", objCurrencyExport.DeviceNumber));
                parameterList.Add(new MySqlParameter("@OperateStartTime", objCurrencyExport.OperateStartTime));
                parameterList.Add(new MySqlParameter("@OperateEndTime", objCurrencyExport.OperateEndTime));
                parameterList.Add(new MySqlParameter("@CurrencyNumber", objCurrencyExport.CurrencyNumber));
                parameterList.Add(new MySqlParameter("@ExportStatus", objCurrencyExport.ExportStatus));
                parameterList.Add(new MySqlParameter("@DataCount", objCurrencyExport.DataCount));
                parameterList.Add(new MySqlParameter("@FileName", objCurrencyExport.FileName));
                parameterList.Add(new MySqlParameter("@FileSize", objCurrencyExport.FileSize));
                parameterList.Add(new MySqlParameter("@CreateUserId", objCurrencyExport.CreateUserId));
                parameterList.Add(new MySqlParameter("@CreateTime", objCurrencyExport.CreateTime));
            }

            else
            {
                sql = " update tbl_currency_export set ExportStatus=@ExportStatus, DataCount=@DataCount, FileName=@FileName, FileSize=@FileSize where PkId=@PkId ";

                parameterList.Add(new MySqlParameter("@ExportStatus", objCurrencyExport.ExportStatus));
                parameterList.Add(new MySqlParameter("@DataCount", objCurrencyExport.DataCount));
                parameterList.Add(new MySqlParameter("@FileName", objCurrencyExport.FileName));
                parameterList.Add(new MySqlParameter("@FileSize", objCurrencyExport.FileSize));
                parameterList.Add(new MySqlParameter("@PkId", objCurrencyExport.PkId));
            }

            DbHelper.ExecuteNonQuery(sql, CommandType.Text, parameterList.ToArray());
        }