Пример #1
0
        private static void CreateLedger(object state)
        {
            LedgerArgument ledgerArgument = (LedgerArgument)state;
            Token          token          = ledgerArgument.Token;
            string         sql            = "EXEC P_RptLedger @xmlAccounts=\'" + XmlTransform.Transform(ledgerArgument.IDs, ',', "Accounts", "Account", "ID") + "\',@tradeDayBegin=\'"
                                            + ledgerArgument.DateFrom + "\',@tradeDayTo=\'" + ledgerArgument.DateTo + "\',@language=\'" + ledgerArgument.Version + "\',@userID=\'" + ledgerArgument.Token.UserID.ToString() + "\'";

            try
            {
                DataSet dataSet = DataAccess.GetData(sql, SettingManager.Default.ConnectionString, LedgerReportTimeout);
                try
                {
                    TradingConsoleServer tradingConsoleServer = ledgerArgument.TradingConsoleServer;
                    tradingConsoleServer.SaveLedger(token, "", ledgerArgument.IDs);
                }
                catch
                {
                }

                if (dataSet.Tables.Count > 0)
                {
                    string             filepath           = Path.Combine(SettingManager.Default.PhysicPath, ledgerArgument.Rdlc); //this.Server.MapPath(ledgerArgument.Rdlc);
                    byte[]             reportContent      = PDFHelper.ExportPDF(filepath, dataSet.Tables[0]);
                    AsyncResultManager asyncResultManager = ledgerArgument.AsyncResultManager;
                    asyncResultManager.SetResult(ledgerArgument.AsyncResult, reportContent);
                    CommandManager.Default.AddCommand(new AsyncCommand(0, ledgerArgument.AsyncResult));
                }
            }
            catch (System.Exception ex)
            {
                CommandManager.Default.AddCommand(new AsyncCommand(0, ledgerArgument.AsyncResult, true, ex));
                _Logger.Error(ex);
            }
        }
Пример #2
0
        private static void CreateAccountSummary(object state)
        {
            AccountSummaryArgument accountSummaryArgument = (AccountSummaryArgument)state;
            Token  token = accountSummaryArgument.Token;
            string sql   = "EXEC P_RptAccountSummary @xmlAccounts=\'" + XmlTransform.Transform(accountSummaryArgument.AccountIds, ',', "Accounts", "Account", "ID") + "\',@tradeDayFrom=\'"
                           + accountSummaryArgument.FromDay + "\',@tradeDayTo=\'" + accountSummaryArgument.ToDay + "\',@language=\'" + accountSummaryArgument.Version + "\',@userID=\'" + accountSummaryArgument.Token.UserID.ToString() + "\', @skipNoTransactionAccount=0";

            try
            {
                DataSet dataSet = DataAccess.GetData(sql, SettingManager.Default.ConnectionString, LedgerReportTimeout);
                if (dataSet.Tables.Count > 0)
                {
                    string filepath = Path.Combine(SettingManager.Default.PhysicPath, accountSummaryArgument.Rdlc);
                    //this.Server.MapPath(accountSummaryArgument.Rdlc);
                    byte[]             reportContent      = PDFHelper.ExportPDF(filepath, dataSet.Tables[0]);
                    AsyncResultManager asyncResultManager = accountSummaryArgument.AsyncResultManager;
                    asyncResultManager.SetResult(accountSummaryArgument.AsyncResult, reportContent);
                    CommandManager.Default.AddCommand(new AsyncCommand(0, accountSummaryArgument.AsyncResult));
                }
            }
            catch (System.Exception ex)
            {
                CommandManager.Default.AddCommand(new AsyncCommand(0, accountSummaryArgument.AsyncResult, true, ex));
                _Logger.Error(ex);
            }
        }
Пример #3
0
        private static void CreateChartData2(object state)
        {
            ChartDataArgument2 chartDataArgument = (ChartDataArgument2)state;

            try
            {
                //DataSet dataSet = this.GetChartData2(chartDataArgument.InstrumentId, chartDataArgument.DataCycle, chartDataArgument.From, chartDataArgument.To);
                //SChart.Datas.StockData stockData = new SChart.Datas.StockData(cookieContainer);
                //DataSet dataSet = stockData.GetChartData2(chartDataArgument.InstrumentId, chartDataArgument.DataCycle, chartDataArgument.From, chartDataArgument.To);
                TradingConsoleState tradingConsoleState = chartDataArgument.TradingConsoleState;
                Guid quotePolicyId = (Guid)tradingConsoleState.Instruments[chartDataArgument.InstrumentId];
                TradingConsoleServer tradingConsoleServer = chartDataArgument.TradingConsoleServer;
                DataSet            dataSet            = tradingConsoleServer.GetChartData2(chartDataArgument.InstrumentId, quotePolicyId, chartDataArgument.DataCycle, chartDataArgument.From, chartDataArgument.To);
                AsyncResultManager asyncResultManager = chartDataArgument.AsyncResultManager;
                asyncResultManager.SetResult(chartDataArgument.AsyncResult, dataSet);
                CommandManager.Default.AddCommand(new AsyncCommand(0, chartDataArgument.AsyncResult));
                //else
                //{
                //    string userIdString = string.Empty;
                //    if (chartDataArgument.Token != null)
                //    {
                //        Token token = chartDataArgument.Token;
                //        userIdString = token.UserID.ToString();
                //    }
                //    AppDebug.LogEvent("TradingConsole.Service.CreateChartData2", "CookieContainer Timeout" + " UserId: " + userIdString, EventLogEntryType.Warning);
                //    Commands commands = chartDataArgument.Commands;
                //    commands.Add(chartDataArgument.Token, new AsyncCommand(0, chartDataArgument.AsyncResult, true, null));
                //}
            }
            catch (Exception e)
            {
                _Logger.Error(e);
                CommandManager.Default.AddCommand(new AsyncCommand(0, chartDataArgument.AsyncResult, true, e));
            }
        }
Пример #4
0
        private void CreateTickByTickHistoryDatas2(object state)
        {
            var tickByTickHistoryDataArgument = (TickByTickHistoryDataArgument2)state;

            try
            {
                TradingConsoleState tradingConsoleState = tickByTickHistoryDataArgument.TradingConsoleState;
                if (tradingConsoleState.Instruments.ContainsKey(tickByTickHistoryDataArgument.InstrumentId))
                {
                    Guid quotePolicyId = (Guid)tradingConsoleState.Instruments[tickByTickHistoryDataArgument.InstrumentId];
                    TradingConsoleServer tradingConsoleServer = tickByTickHistoryDataArgument.TradingConsoleServer;
                    DataSet            dataSet            = tradingConsoleServer.GetTickByTickHistoryDatas2(tickByTickHistoryDataArgument.InstrumentId, quotePolicyId, tickByTickHistoryDataArgument.From, tickByTickHistoryDataArgument.To);
                    AsyncResultManager asyncResultManager = tickByTickHistoryDataArgument.AsyncResultManager;
                    asyncResultManager.SetResult(tickByTickHistoryDataArgument.AsyncResult, dataSet);
                    CommandManager.Default.AddCommand(new AsyncCommand(0, tickByTickHistoryDataArgument.AsyncResult));
                }
                else
                {
                    _Logger.Warn(string.Format("Instrument {0} doesn't exists in TradingConsoleState",
                                               tickByTickHistoryDataArgument.InstrumentId));
                    CommandManager.Default.AddCommand(new AsyncCommand(0, tickByTickHistoryDataArgument.AsyncResult, true, null));
                }
            }
            catch (Exception e)
            {
                _Logger.Error(e);
                CommandManager.Default.AddCommand(new AsyncCommand(0, tickByTickHistoryDataArgument.AsyncResult, true, e));
            }
        }
Пример #5
0
        private static void CreateChartData2ForMobile(object state)
        {
            ChartDataArgument2 chartDataArgument = (ChartDataArgument2)state;

            try
            {
                TradingConsoleState tradingConsoleState = chartDataArgument.TradingConsoleState;
                Guid quotePolicyId = (Guid)tradingConsoleState.Instruments[chartDataArgument.InstrumentId];
                TradingConsoleServer tradingConsoleServer = chartDataArgument.TradingConsoleServer;
                //DataSet dataSet = tradingConsoleServer.GetChartData2(chartDataArgument.InstrumentId, quotePolicyId, chartDataArgument.DataCycle, chartDataArgument.From, chartDataArgument.To);

                string dataCycle  = chartDataArgument.DataCycle.ToLower();
                string dateFormat = ChartQuotation.FormatMinute;

                //DataSet dataSet = DataAccess.GetChartData(instrumentId, quotePolicyId, dataCycle, fromTime.Value, toTime, commandTimeOut);
                DataSet dataSet = tradingConsoleServer.GetChartData2(chartDataArgument.InstrumentId, quotePolicyId, chartDataArgument.DataCycle, chartDataArgument.From, chartDataArgument.To);

                ChartQuotationCollection chartQuotationCollection = ChartQuotationCollection.Create(dataSet, dataCycle, dateFormat);

                DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(ChartQuotationCollection));
                string result;
                using (MemoryStream stream = new MemoryStream())
                {
                    serializer.WriteObject(stream, chartQuotationCollection);
                    stream.Seek(0, SeekOrigin.Begin);
                    StreamReader streamReader = new StreamReader(stream);
                    result = streamReader.ReadToEnd();
                }

                AsyncResultManager asyncResultManager = chartDataArgument.AsyncResultManager;
                XElement           element            = XmlResultHelper.NewResult("ChartData", result);
                asyncResultManager.SetResult(chartDataArgument.AsyncResult, element);
                AsyncCommand command = new AsyncCommand(0, chartDataArgument.AsyncResult);
                command.Content = element.ToXmlNode();
                CommandManager.Default.AddCommand(command);
            }
            catch (Exception e)
            {
                _Logger.Error(e);
                CommandManager.Default.AddCommand(new AsyncCommand(0, chartDataArgument.AsyncResult, true, e));
            }
        }
Пример #6
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);
            }
        }