Beispiel #1
0
        private static void CreateStatement(object state)
        {
            StatementArg statementArg = (StatementArg)state;
            Token        token        = statementArg.Token;
            string       sql          = string.Empty;

            if (statementArg.Rdlc.ToLower().Contains("statement_mc"))
            {
                sql = "EXEC P_RptStatement_RC2 ";
            }
            else
            {
                switch (statementArg.StatementReportType)
                {
                case 0:
                    sql = "EXEC P_RptStatement_RC2 ";
                    break;

                case 1:
                    sql = "EXEC P_RptStatement2_RC2 ";
                    break;

                case 2:
                    sql = "EXEC P_RptStatement4_RC2 ";
                    break;

                case 3:
                    sql = "EXEC P_RptStatement5_RC2 ";
                    break;
                }
            }
            sql += "@xmlAccounts=" + "\'" + XmlTransform.Transform(statementArg.IDs, ',', "Accounts", "Account", "ID")
                   + "\',@tradeDayBegin=\'" + statementArg.DayBegin + "\',@tradeDayTo=\'" + statementArg.DayTo + "\',@language=\'" + statementArg.Version + "\',@userID=\'" + statementArg.Token.UserID.ToString() + "\'";
            try
            {
                DataSet dataSet = DataAccess.GetData(sql, SettingManager.Default.ConnectionString, StatementReportTimeout);
                try
                {
                    TradingConsoleServer tradingConsoleServer = statementArg.TradingConsoleServer;
                    tradingConsoleServer.SaveStatement(token, "", statementArg.IDs);
                }
                catch
                {
                }
                if (dataSet.Tables.Count > 0)
                {
                    string filepath = Path.Combine(SettingManager.Default.PhysicPath, statementArg.Rdlc); // this.Server.MapPath(statementArg.Rdlc);
                    Console.WriteLine(filepath);
                    if (statementArg.Rdlc.ToLower().Contains("statement_mc") && dataSet.Tables.Count > 0 && dataSet.Tables[0].Rows.Count > 0)
                    {
                        if (!(bool)dataSet.Tables[0].Rows[0]["IsMultiCurrency"])
                        {
                            filepath = filepath.ToLower().Replace("rptStatement_mc.rdlc", "RptStatement.rdlc");
                        }
                    }
                    byte[]             reportContent      = PDFHelper.ExportPDF(filepath, dataSet.Tables[0]);
                    AsyncResultManager asyncResultManager = statementArg.AsyncResultManager;
                    asyncResultManager.SetResult(statementArg.AsyncResult, reportContent);
                    CommandManager.Default.AddCommand(new AsyncCommand(0, statementArg.AsyncResult));
                }
            }
            catch (System.Exception ex)
            {
                CommandManager.Default.AddCommand(new AsyncCommand(0, statementArg.AsyncResult, true, ex));
                _Logger.Error(ex);
            }
        }