コード例 #1
0
        private DataSet GetReportData(string selectedPrice, Guid accountId)
        {
            StateServerService   stateServer          = (StateServerService)(this.Context.Application["StateServer"]);
            DealingConsoleServer dealingConsoleServer = ((DealingConsoleServer)(this.Context.Application["DealingConsoleServer"]));
            Token   token   = (Token)Session["Token"];
            DataSet dataSet = dealingConsoleServer.ReportAccountStatusAllData(stateServer, token, selectedPrice, accountId, Guid.Empty);

            return(dataSet);
        }
コード例 #2
0
        protected void Application_Start(Object sender, EventArgs e)
        {
            try
            {
                AppDebug.LogEvent("DealingConsole", "Application_Start", EventLogEntryType.Information);

                //Used for kickout--Michael
                this.Context.Application["SessionIDs"] = new Hashtable();

                this.Context.Application["IsRegistered"] = false;
                this.Context.Application["Commands"]     = new Commands(new TimeSpan(0, 10, 0).TotalMilliseconds);
                this.Context.Application["Tokens"]       = new Hashtable();

                StateServerService stateServer = new StateServerService();
                this.StateServerReadyCheck(stateServer);
                this.Context.Application["StateServer"] = stateServer;

                ParticipantServices.ParticipantServices participantServices = new ParticipantServices.ParticipantServices();
                Application["ParticipantServices"] = participantServices;
                SecurityServices.SecurityServices securityServices = new SecurityServices.SecurityServices();
                Application["SecurityServices"] = securityServices;


                //			this.Context.Application["IsRegistered"]=false;
                //			this.Context.Application["Commands"]=null;
                //			this.Context.Application["Tokens"]=new Hashtable();
                ////			this.Context.Application["Sessions"]=new Hashtable();
                //
                //			StateServer.Service stateServer=new StateServer.Service();
                //			this.Context.Application["StateServer"]=stateServer;
                //
                int     commandSequence;
                Token   token   = new Token(Guid.Empty, UserType.System, AppType.DealingConsoleServer);
                DataSet dataSet = stateServer.GetInitData(token, null, out commandSequence);

                string connectionString = ConfigurationSettings.AppSettings["ConnectionString"];
                DealingConsoleServer dealingConsoleServer = new DealingConsoleServer(connectionString);
                dealingConsoleServer.Init(dataSet);
                this.Context.Application["DealingConsoleServer"] = dealingConsoleServer;

                AppDebug.LogEvent("DealingConsole", "DealingConsole started", EventLogEntryType.SuccessAudit);
            }
            catch (Exception exception)
            {
                AppDebug.LogEvent("DealingConsole", exception.ToString(), EventLogEntryType.Error);
            }
            //
            //
            //#if (PERMISSION)
            //			ParticipantServices.ParticipantServices  participantServices = new ParticipantServices.ParticipantServices();
            //			Application["ParticipantServices"] = participantServices;
            //			SecurityServices.SecurityServices securityServices = new SecurityServices.SecurityServices();
            //			Application["SecurityServices"] = securityServices;
            //#endif
        }
コード例 #3
0
 private void StateServerReadyCheck(StateServerService stateServer)
 {
     try
     {
         stateServer.HelloWorld();
     }
     catch (WebException webException)
     {
         if (webException.Status == WebExceptionStatus.Timeout)
         {
             AppDebug.LogEvent("[DealingConsole] Application_Start", webException.ToString(), System.Diagnostics.EventLogEntryType.Error);
             Thread.Sleep(TimeSpan.FromSeconds(5));
             this.StateServerReadyCheck(stateServer);
         }
     }
 }
コード例 #4
0
        public DataSet ReportAccountStatusAllData(StateServerService stateServer, Token token, string selectedPrice, Guid accountId, Guid instrumentId)
        {
            try
            {
                string accountXml = this.GetStateServerAccount(stateServer, new Guid[] { accountId });
                accountXml = this.GetAccountInfo(accountXml, accountId);

                string  sql     = string.Format("exec dbo.P_ReportAccountStatusAllData @accountId='{0}',@xmlAccounts='{1}',@queryType='{2}',@dealerId='{3}',@instrumentId='{4}',@applicationId={5}", accountId, accountXml, selectedPrice, token.UserID, instrumentId, 1);
                DataSet dataSet = DataAccess.GetData(sql, connectionString, TimeSpan.FromMinutes(5));
                return(dataSet);
            }
            catch (System.Exception exception)
            {
                return(null);
            }
        }
コード例 #5
0
        public string GetStateServerAccounts5(StateServerService stateServer, Guid[] accountIDs, Guid[] instrumentIDs)
        {
            string outerXml = string.Empty;

            Token token = new Token();

            token.UserID   = Guid.Empty;
            token.UserType = UserType.System;
            token.AppType  = AppType.BackOffice;

            System.Xml.XmlNode xmlNode = stateServer.GetAccounts5(token, accountIDs, instrumentIDs, true);
            if (xmlNode != null)
            {
                outerXml = xmlNode.OuterXml;// stateService.GetAccounts(token,accountIDs, true).OuterXml;
            }
            return(outerXml);
        }
コード例 #6
0
 private void StateServerReadyCheck(StateServerService stateServer)
 {
     try
     {
         Token token = new Token();
         token.AppType = AppType.TradingConsoleSilverLight;
         stateServer.Register(token, SettingManager.Default.CommandUrl);
         stateServer.HelloWorld();
     }
     catch (WebException webException)
     {
         if (webException.Status == WebExceptionStatus.Timeout)
         {
             _Logger.Error(webException);
             Thread.Sleep(TimeSpan.FromSeconds(5));
             this.StateServerReadyCheck(stateServer);
         }
     }
 }
コード例 #7
0
        public bool AdditionalClient(Token token, StateServerService stateServer, string email, string receive, string organizationName, string customerName,
            string reportDate, string accountCode, string correspondingAddress, string registratedEmailAddress, string tel, string mobile,
            string fax, string fillName1, string ICNo1, string fillName2, string ICNo2, string fillName3, string ICNo3, out string reference)
        {
            Guid submitPerson = token.UserID;
            string remark = ConfigurationManager.AppSettings["FillName1"] + fillName1 + "," + ConfigurationManager.AppSettings["ICNo1"] + ICNo1 + ";"
                + ConfigurationManager.AppSettings["FillName2"] + fillName2 + "," + ConfigurationManager.AppSettings["ICNo2"] + ICNo2 + ";"
                + ConfigurationManager.AppSettings["FillName3"] + fillName3 + "," + ConfigurationManager.AppSettings["ICNo3"] + ICNo3 + ";"
                + ConfigurationManager.AppSettings["From"] + customerName;

            return this.AddMargin("OwnerRegistration", DateTime.Parse(reportDate), accountCode, email, null, null, null, organizationName, correspondingAddress,
                registratedEmailAddress, tel, mobile, fax, null, null, null, null, remark, submitPerson, out reference);
        }
コード例 #8
0
        public void NotifyCustomerExecuteOrder(Token token, StateServerService stateServer, string physicalPath, string[][] parameters)
        {
            this.GetExtend(token, physicalPath);

            string usedExtendXml = ConfigurationManager.AppSettings["UsedExtendXml"];
            if (usedExtendXml == "Extend2.xml")
            {
                this.NotifyCustomerExecuteOrder2(token, stateServer, parameters);
            }
            else
            {
                this.NotifyCustomerExecuteOrder(token, stateServer, parameters);
            }
        }
コード例 #9
0
        public DataSet GetUpdateInstrumentSetting(Token token, StateServerService stateServer, string[] instrumentIDs)
        {
            XmlDocument doc = new XmlDocument();
            XmlNode instrumentSetting = doc.CreateNode(XmlNodeType.Element, "InstrumentSetting", null);
            int index = 1;
            foreach (string instrumentID in instrumentIDs)
            {
                XmlNode instrument = doc.CreateNode(XmlNodeType.Element, "Instrument", null);
                XmlAttribute attribute = doc.CreateAttribute("ID");
                attribute.Value = instrumentID;
                instrument.Attributes.Append(attribute);

                attribute = doc.CreateAttribute("Sequence");
                attribute.Value = index.ToString();
                instrument.Attributes.Append(attribute);

                instrumentSetting.AppendChild(instrument);
                index++;
            }
            DataSet instruments = stateServer.UpdateInstrumentSetting(token, instrumentSetting);
            return instruments;
        }
コード例 #10
0
        public XmlNode GetAccountsForCut(Token token, StateServerService stateServer, Guid[] accountIDs, bool includeTransactions)
        {
            XmlNode accountsData = stateServer.GetAccountsForCut(token, accountIDs, includeTransactions);

            return (accountsData);
        }
コード例 #11
0
        public void EmailExecuteOrders(Token token, StateServerService stateServer, string physicalPath, XmlElement xmlElement)
        {
            this.GetExtend(token, physicalPath);

            Hashtable extend = (Hashtable)this.extends[token.SessionID];
            try
            {
                XmlElement xmlTran = (XmlElement)xmlElement.GetElementsByTagName("Transaction")[0];
                Guid transactionID = XmlConvert.ToGuid(xmlTran.Attributes["ID"].Value);
                string accountIDString = xmlTran.Attributes["AccountID"].Value;
                Guid accountID = XmlConvert.ToGuid(accountIDString);
                string instrumentIDString = xmlTran.Attributes["InstrumentID"].Value;
                Guid instrumentID = XmlConvert.ToGuid(instrumentIDString);
                string executeTime = xmlTran.Attributes["ExecuteTime"].Value;

                //Create execute orders
                string separator = "<p>";
                string executeOrders = string.Empty;
                executeOrders += extend["accountCode"].ToString();
                executeOrders += accountIDString;
                executeOrders += ":";
                executeOrders += separator;

                string xmlOrderRelations = string.Empty;
                string orderCodes = string.Empty;
                foreach (XmlNode xmlOrder in xmlTran.ChildNodes)
                {
                    Guid closeOrderID = XmlConvert.ToGuid(xmlOrder.Attributes["ID"].Value);
                    string orderCode = xmlOrder.Attributes["Code"].Value;
                    orderCodes = (orderCodes == string.Empty) ? orderCode : orderCodes + "," + orderCode;
                    string lot = xmlOrder.Attributes["Lot"].Value;
                    string buySell = (XmlConvert.ToBoolean(xmlOrder.Attributes["IsBuy"].Value)) ? "B" : "S";
                    string executePrice = xmlOrder.Attributes["ExecutePrice"].Value;
                    bool isOpen = XmlConvert.ToBoolean(xmlOrder.Attributes["IsOpen"].Value);
                    string newClose = isOpen ? "N" : "C";

                    string openPrice = string.Empty;
                    foreach (XmlNode xmlOrderRelation in xmlOrder.ChildNodes)
                    {
                        Guid openOrderID = XmlConvert.ToGuid(xmlOrderRelation.Attributes["OpenOrderID"].Value);
                        openPrice += ((openPrice != string.Empty) ? ";" : "") + closeOrderID.ToString() + openOrderID.ToString();

                        xmlOrderRelations += "<OrderRelation ";
                        xmlOrderRelations += "CloseOrderID=\"" + closeOrderID.ToString() + "\" ";
                        xmlOrderRelations += "OpenOrderID=\"" + openOrderID.ToString() + "\" ";
                        xmlOrderRelations += "/>";
                    }

                    executeOrders += separator;
                    executeOrders += extend["orderCode"].ToString();
                    executeOrders += orderCode;
                    executeOrders += extend["instrumentCode"].ToString();
                    executeOrders += instrumentIDString;
                    executeOrders += extend["lot"].ToString();
                    executeOrders += lot;
                    executeOrders += extend["buySell"].ToString();
                    executeOrders += buySell;
                    executeOrders += extend["executePrice"].ToString();
                    executeOrders += executePrice;
                    executeOrders += extend["executeTime"].ToString();
                    executeOrders += executeTime;
                    executeOrders += extend["newClose"].ToString();
                    executeOrders += newClose;
                    executeOrders += extend["openPrice"].ToString();
                    executeOrders += openPrice;
                }

                //Get missing datas
                bool isSendOrderMail = false;
                string organizationName = string.Empty;
                string organizationEmail = string.Empty;
                string customerEmail = string.Empty;
                string agentEmail = string.Empty;
                string accountCode = string.Empty;
                string instrumentCode = string.Empty;

                string sql = string.Empty;
                if (xmlOrderRelations != string.Empty)
                {
                    xmlOrderRelations = "<OrderRelations>" + xmlOrderRelations + "</OrderRelations>";
                    sql = string.Format("Exec dbo.P_GetInfoForEmailExecuteOrder '{0}','{1}','{2}','{3}'", token.UserID, accountID, instrumentID, xmlOrderRelations);
                }
                else
                {
                    sql = string.Format("Exec dbo.P_GetInfoForEmailExecuteOrder '{0}','{1}','{2}'", token.UserID, accountID, instrumentID);
                }

                DataSet dataSet = DataAccess.GetData(sql, this.connectionString);
                DataTable dt = dataSet.Tables[0];
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    isSendOrderMail = (bool)dt.Rows[i]["IsSendOrderMail"];
                    if (!isSendOrderMail) return;

                    organizationName = dt.Rows[i]["OrganizationName"].ToString();
                    organizationEmail = dt.Rows[i]["OrganizationEmail"].ToString();
                    customerEmail = dt.Rows[i]["CustomerEmail"].ToString();
                    agentEmail = dt.Rows[i]["AgentEmail"].ToString();
                    accountCode = dt.Rows[i]["AccountCode"].ToString();
                    instrumentCode = dt.Rows[i]["InstrumentCode"].ToString();
                }
                if (dataSet.Tables.Count == 2)
                {
                    dt = dataSet.Tables[1];
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        executeOrders = executeOrders.Replace(dt.Rows[i]["CloseOrderID"].ToString() + dt.Rows[i]["OpenOrderID"].ToString(),
                            dt.Rows[i]["ClosedLot"].ToString() + extend["RelationLot"] + "*" + dt.Rows[i]["ExecutePrice"]);
                    }
                }
                if (organizationEmail != string.Empty && (customerEmail != string.Empty || agentEmail != string.Empty))
                {
                    executeOrders = executeOrders.Replace(accountIDString, accountCode);
                    executeOrders = executeOrders.Replace(instrumentIDString, instrumentCode);

                    //Create body
                    string body = string.Empty;
                    body = extend["appellation"].ToString();
                    body += separator;
                    body += extend["message1"].ToString();
                    body += separator;
                    body += executeOrders;
                    body += separator;
                    body += extend["message2"].ToString();
                    body += separator;
                    body += extend["message3"].ToString();
                    body += separator;
                    body += extend["message4"].ToString();
                    body += extend["message5"].ToString();
                    body += organizationName;

                    //AppDebug.LogEvent("TradingConsole.EmailExecuteOrders",body,System.Diagnostics.EventLogEntryType.Information);

                    string toEmails = string.Empty;
                    if (customerEmail != string.Empty)
                    {
                        toEmails = customerEmail;
                    }
                    if (agentEmail != string.Empty)
                    {
                        toEmails = (toEmails != string.Empty) ? toEmails + "," + agentEmail : agentEmail;
                    }
                    string subject = extend["subject1"].ToString() + " " + orderCodes + " " + extend["subject2"].ToString() + " " + accountCode;
                    //stateServer.Email(token, "Execute", transactionID, organizationEmail, toEmails, subject, body);
                    this.SendEmail(organizationEmail, toEmails, subject, body);

                }
            }
            catch (System.Exception ex)
            {
                _Logger.Error(ex);
            }
        }
コード例 #12
0
 public Guid[] VerifyTransaction(Token token, StateServerService stateServer, Guid[] transactionIDs)
 {
     return stateServer.VerifyTransaction(token, transactionIDs);
 }
コード例 #13
0
 public TransactionError CancelLMTOrder(Token token, StateServerService stateServer, string transactionID)
 {
     return stateServer.Cancel(token, new Guid(transactionID), CancelReason.CustomerCanceled);
 }
コード例 #14
0
 public bool CallMarginExtension(Token token, StateServerService stateServer, string email, string receive, string organizationName,
     string customerName, string reportDate, string accountCode, string currency, string currencyValue, string dueDate, out string reference)
 {
     Guid submitPerson = token.UserID;
     return this.AddMargin("CMExtension", DateTime.Parse(reportDate), accountCode, email, currency, decimal.Parse(currencyValue), null, null, null,
         null, null, null, null, null, null, null, DateTime.Parse(dueDate), null, submitPerson, out reference);
 }
コード例 #15
0
ファイル: Application.cs プロジェクト: RobertHu/TraderServer
 private void StateServerReadyCheck(StateServerService stateServer)
 {
     try
     {
         Token token = new Token();
         token.AppType=AppType.TradingConsoleSilverLight;
         stateServer.Register(token, SettingManager.Default.CommandUrl);
         stateServer.HelloWorld();
     }
     catch (WebException webException)
     {
         if (webException.Status == WebExceptionStatus.Timeout)
         {
             AppDebug.LogEvent("[TradingConsole] Application_Start", webException.ToString(), System.Diagnostics.EventLogEntryType.Error);
             Thread.Sleep(TimeSpan.FromSeconds(5));
             this.StateServerReadyCheck(stateServer);
         }
     }
 }
コード例 #16
0
 private void StateServerReadyCheck(StateServerService stateServer)
 {
     try
     {
         stateServer.HelloWorld();
     }
     catch (WebException webException)
     {
         if (webException.Status == WebExceptionStatus.Timeout)
         {
             AppDebug.LogEvent("[DealingConsole] Application_Start", webException.ToString(), System.Diagnostics.EventLogEntryType.Error);
             Thread.Sleep(TimeSpan.FromSeconds(5));
             this.StateServerReadyCheck(stateServer);
         }
     }
 }
コード例 #17
0
        protected void Application_Start(Object sender, EventArgs e)
        {
            try
            {
                AppDebug.LogEvent("DealingConsole", "Application_Start", EventLogEntryType.Information);

                //Used for kickout--Michael
                this.Context.Application["SessionIDs"] = new Hashtable();

                this.Context.Application["IsRegistered"] = false;
                this.Context.Application["Commands"] = new Commands(new TimeSpan(0, 10, 0).TotalMilliseconds);
                this.Context.Application["Tokens"] = new Hashtable();

                StateServerService stateServer = new StateServerService();
                this.StateServerReadyCheck(stateServer);
                this.Context.Application["StateServer"] = stateServer;

                ParticipantServices.ParticipantServices participantServices = new ParticipantServices.ParticipantServices();
                Application["ParticipantServices"] = participantServices;
                SecurityServices.SecurityServices securityServices = new SecurityServices.SecurityServices();
                Application["SecurityServices"] = securityServices;

                //			this.Context.Application["IsRegistered"]=false;
                //			this.Context.Application["Commands"]=null;
                //			this.Context.Application["Tokens"]=new Hashtable();
                ////			this.Context.Application["Sessions"]=new Hashtable();
                //
                //			StateServer.Service stateServer=new StateServer.Service();
                //			this.Context.Application["StateServer"]=stateServer;
                //
                int commandSequence;
                Token token = new Token(Guid.Empty, UserType.System, AppType.DealingConsoleServer);
                DataSet dataSet = stateServer.GetInitData(token, null, out commandSequence);

                string connectionString = ConfigurationSettings.AppSettings["ConnectionString"];
                DealingConsoleServer dealingConsoleServer = new DealingConsoleServer(connectionString);
                dealingConsoleServer.Init(dataSet);
                this.Context.Application["DealingConsoleServer"] = dealingConsoleServer;

                AppDebug.LogEvent("DealingConsole", "DealingConsole started", EventLogEntryType.SuccessAudit);
            }
            catch (Exception exception)
            {
                AppDebug.LogEvent("DealingConsole", exception.ToString(), EventLogEntryType.Error);
            }
            //
            //
            //#if (PERMISSION)
            //			ParticipantServices.ParticipantServices  participantServices = new ParticipantServices.ParticipantServices();
            //			Application["ParticipantServices"] = participantServices;
            //			SecurityServices.SecurityServices securityServices = new SecurityServices.SecurityServices();
            //			Application["SecurityServices"] = securityServices;
            //#endif
        }
コード例 #18
0
        public bool UpdateAccountLock(Token token, StateServerService stateServer, string agentAccountID, string[][] arrayAccountLock)
        {
            XmlDocument doc = new XmlDocument();
            XmlNode updateAccountLock = doc.CreateNode(XmlNodeType.Element, "UpdateAccountLock", null);

            XmlAttribute attribute1 = doc.CreateAttribute("AgentAccountID");
            attribute1.Value = agentAccountID;
            updateAccountLock.Attributes.Append(attribute1);

            foreach (string[] arrayAccountLockTmp in arrayAccountLock)
            {
                XmlNode account = doc.CreateNode(XmlNodeType.Element, "Account", null);
                XmlAttribute attribute = doc.CreateAttribute("ID");
                attribute.Value = arrayAccountLockTmp[0];
                account.Attributes.Append(attribute);

                attribute = doc.CreateAttribute("IsLocked");
                attribute.Value = arrayAccountLockTmp[1];
                account.Attributes.Append(attribute);

                updateAccountLock.AppendChild(account);
            }
            bool isSucced = stateServer.UpdateAccountLock(token, updateAccountLock);
            return (isSucced);
        }
コード例 #19
0
        public void NotifyCustomerExecuteOrder2(Token token, StateServerService stateServer, string[][] parameters)
        {
            Hashtable extend = (Hashtable)this.extends[token.SessionID];
            try
            {
                foreach (string[] parameters2 in parameters)
                {
                    int i = 0;
                    Guid transactionID = new Guid(parameters2[i++]);
                    Guid orderID = new Guid(parameters2[i++]);
                    string orderCode = parameters2[i++];
                    string accountCode = parameters2[i++];
                    string instrumentCode = parameters2[i++];
                    string lot = parameters2[i++];
                    string buySell = parameters2[i++];
                    bool isBuy = (buySell == "B");
                    string buySell2 = buySell;
                    buySell = buySell.Replace("B", extend["BuyPrompt"].ToString());
                    buySell = buySell.Replace("S", extend["SellPrompt"].ToString());
                    buySell2 = buySell2.Replace("B", extend["BuyPrompt2"].ToString());
                    buySell2 = buySell2.Replace("S", extend["SellPrompt2"].ToString());
                    string executePrice = parameters2[i++];
                    string executeTime = parameters2[i++];
                    string executeTradeDay = parameters2[i++];
                    string newClose = parameters2[i++];
                    string newClose2 = newClose;
                    newClose = newClose.Replace("C", extend["ClosePrompt"].ToString());
                    newClose = newClose.Replace("N", extend["NewPrompt"].ToString());
                    newClose2 = newClose2.Replace("C", extend["ClosePrompt2"].ToString());
                    newClose2 = newClose2.Replace("N", extend["NewPrompt2"].ToString());
                    string openPrice = parameters2[i++];
                    openPrice = openPrice.Replace("Lot", extend["RelationLot"].ToString());
                    string organizationName = parameters2[i++];
                    string organizationEmail = parameters2[i++];
                    string customerEmail = parameters2[i++];
                    string agentEmail = parameters2[i++];
                    string tradeDay = executeTradeDay;

                    bool isOpen = (buySell == "N");
                    string accountAlias = "&nbsp;";
                    string accountName = "&nbsp;";
                    int deliveryDay = 0;
                    string orderRelationOpenOrderExecutePrice = "&nbsp;";
                    string orderRelationOpenOrderExecuteTime = "&nbsp;";

                    string commission = "&nbsp;";
                    string orderRelationRateInOut = "&nbsp;";
                    string tradePL = "&nbsp;";
                    string accountCurrencyAlias = "&nbsp;";
                    string accountCurrencyName = "&nbsp;";
                    string contractMarginO = "&nbsp;";
                    decimal contractSize = 0;

                    string sql = string.Format("Exec dbo.P_GetEmailExecuteInfo2 '{0}'", orderID);
                    DataSet dataSet = DataAccess.GetData(sql, this.connectionString);
                    DataTable dt = dataSet.Tables[0];
                    for (int j = 0; j < dt.Rows.Count; j++)
                    {
                        accountAlias = Convert.ToString(dt.Rows[j]["AccountAlias"]);
                        accountName = Convert.ToString(dt.Rows[j]["AccountName"]);
                        deliveryDay = Convert.ToInt32(dt.Rows[j]["DeliveryDay"].ToString());
                        orderRelationOpenOrderExecutePrice = Convert.ToString(dt.Rows[j]["OrderRelationOpenOrderExecutePrice"]);
                        orderRelationOpenOrderExecuteTime = Convert.ToString(dt.Rows[j]["OrderRelationOpenOrderExecuteTime"]);
                        commission = Convert.ToString(dt.Rows[j]["Commission"]);
                        orderRelationRateInOut = Convert.ToString(dt.Rows[j]["OrderRelationRateInOut"]);
                        tradePL = dt.Rows[j]["TradePL"].ToString();
                        accountCurrencyAlias = Convert.ToString(dt.Rows[j]["AccountCurrencyAlias"]);
                        accountCurrencyName = Convert.ToString(dt.Rows[j]["AccountCurrencyName"]);
                        contractMarginO = dt.Rows[j]["ContractMarginO"].ToString();
                        contractSize = Convert.ToDecimal(dt.Rows[j]["ContractSize"].ToString());
                    }
                    double contractAmount = (double)contractSize * Convert.ToDouble(lot);

                    //Create body
                    string body = string.Empty;
                    body = extend["body"].ToString();

                    body = body.Replace("@AccountCode", accountCode);
                    body = body.Replace("@AccountAlias", accountAlias + "&nbsp;");
                    body = body.Replace("@AccountName", accountName);
                    body = body.Replace("@TradeDay", tradeDay);
                    body = body.Replace("@OrderCode", orderCode);
                    body = body.Replace("@DeliveryDay", Convert.ToString(deliveryDay));
                    body = body.Replace("@InstrumentCode", instrumentCode);
                    body = body.Replace("@NewClose2", newClose2);
                    body = body.Replace("@NewClose", newClose);
                    body = body.Replace("@BuySell2", buySell2);
                    body = body.Replace("@BuySell", buySell);
                    body = body.Replace("@OrderRelationOpenOrderExecutePrice", orderRelationOpenOrderExecutePrice + "&nbsp;");
                    body = body.Replace("@OrderRelationOpenOrderExecuteTime", orderRelationOpenOrderExecuteTime + "&nbsp;");
                    body = body.Replace("@ExecuteTime", executeTime);
                    body = body.Replace("@Lot", lot);
                    body = body.Replace("@Commission", commission);
                    body = body.Replace("@ContractAmount", Convert.ToString(contractAmount));
                    body = body.Replace("@OrderRelationRateInOut", orderRelationRateInOut);
                    body = body.Replace("@ExecutePrice", executePrice);
                    body = body.Replace("@TradePL", tradePL);
                    body = body.Replace("@AccountCurrencyAlias", accountCurrencyAlias + "&nbsp;");
                    body = body.Replace("@AccountCurrencyName", accountCurrencyName);
                    body = body.Replace("@ContractMarginO", contractMarginO);

                    body = body.Replace("\n", "");
                    body = body.Replace("\t", "");
                    body = body.Replace("\r", "");
                    body = body.Replace("@Empty", "&nbsp;");
                    body = body.Replace("<BR></BR>", "<BR>");
                    body = body.Replace("\"", "'");

                    string toEmails = string.Empty;
                    if (customerEmail != string.Empty)
                    {
                        toEmails = customerEmail;
                    }
                    if (agentEmail != string.Empty)
                    {
                        toEmails = (toEmails != string.Empty) ? toEmails + "," + agentEmail : agentEmail;
                    }
                    string subject = extend["subject1"].ToString() + " " + orderCode + " " + extend["subject2"].ToString() + " " + accountCode;
                    //stateServer.Email(token, "Execute", transactionID, organizationEmail, toEmails, subject, body);
                    this.SendEmail(organizationEmail, toEmails, subject, body);
                }
            }
            catch (System.Exception ex)
            {
                _Logger.Error(ex);
            }
        }
コード例 #20
0
 public void CancelQuote(Token token, StateServerService stateServer, string localIP, string instrumentID, double buyQuoteLot, double sellQuoteLot)
 {
     stateServer.CancelQuote(token, new Guid(instrumentID), buyQuoteLot, sellQuoteLot);
 }
コード例 #21
0
        public bool Agent(Token token, StateServerService stateServer, string email, string receive, string organizationName, string customerName,
           string reportDate, string accountCode, string previousAgentCode, string previousAgentName, string newAgentCode,
           string newAgentName, string newAgentICNo, string dateReply, out string reference, out string errorMessage)
        {
            if (!this.IsValidAgent(newAgentCode, newAgentICNo))
            {
                reference = "";
                errorMessage = "New agent doesn't exist, please check the code and IC No. of new agent";
                return false;
            }

            errorMessage = "";
            Guid submitPerson = token.UserID;
            string remark = ConfigurationManager.AppSettings["PreviousAgentCode"] + previousAgentCode
                + ConfigurationManager.AppSettings["PreviousAgentName"] + previousAgentName;
            return this.AddMargin("AgentRegistration", DateTime.Parse(reportDate), accountCode, email, null, null, newAgentCode, newAgentName, null,
                null, null, null, null, null, null, newAgentICNo, DateTime.Parse(dateReply), remark, submitPerson, out reference);
        }
コード例 #22
0
 internal bool ChangeLeverage(Token token, StateServerService stateServer, Guid accountId, int leverage, out decimal necessary)
 {
     return stateServer.ChangeLeverage(token, accountId, leverage, out necessary);
 }
コード例 #23
0
        public bool PaymentInstruction(Token token, String type, StateServerService stateServer, string email, string receive, string organizationName, string customerName,
            string reportDate, string accountCode, string currency, string currencyValue, string beneficiaryName, string bankAccount, string bankerName,
            string bankerAddress, string swiftCode, string remarks, string thisisClient, string targetAddress, string targetEmail, out string reference)
        {
            Guid submitPerson = token.UserID;
            bool result = this.AddMargin(type, DateTime.Parse(reportDate), accountCode, email, currency, decimal.Parse(currencyValue), bankAccount, beneficiaryName,
                targetAddress, targetEmail, null, null, null, bankerName, bankerAddress, swiftCode, null, remarks, submitPerson, out reference);

            if (result && TradingConsoleServer.AllowInstantPayment)
            {
                this.ApprovePaymentInstruction(reference, type);
            }
            return result;
        }
コード例 #24
0
        public bool FundTransfer(Token token, StateServerService stateServer, string email, string receive, string organizationName, string customerName,
          string reportDate, string currency, string currencyValue, string accountCode, string bankAccount, string beneficiaryName, string replyDate)
        {
            bool isSucceed = false;
            try
            {
                string body = "<HTML><BODY>";
                body += ConfigurationManager.AppSettings["To"] + organizationName + "<BR>";
                body += ConfigurationManager.AppSettings["From"] + customerName + "(" + email + ")<BR>";
                body += ConfigurationManager.AppSettings["Subject"] + ConfigurationManager.AppSettings["FundTransfer"] + "<BR>";
                body += "<BR>";
                body += ConfigurationManager.AppSettings["Account"] + accountCode + "<BR>";
                body += ConfigurationManager.AppSettings["Currency"] + currency + "<BR>";
                body += ConfigurationManager.AppSettings["Amount"] + currencyValue + "<BR>";
                body += ConfigurationManager.AppSettings["BankAccount"] + bankAccount + "<BR>";
                body += ConfigurationManager.AppSettings["BeneficiaryName"] + beneficiaryName + "<BR>";
                body += ConfigurationManager.AppSettings["ReplyDate"] + replyDate + "<BR>";
                body += ConfigurationManager.AppSettings["From"] + customerName + "<BR>";
                body += "</BODY>";
                body += "</HTML>";

                Guid transactionID = Guid.Empty;
                string subject = (string)ConfigurationManager.AppSettings["FundTransfer"];
                //stateServer.Email(token, "FundTransfer", transactionID, email, receive, subject, body);
                isSucceed = this.SendEmail(email, receive, subject, body);
            }
            catch (Exception e)
            {
                isSucceed = false;
                throw;
            }
            return isSucceed;
        }
コード例 #25
0
 public TransactionError Place(Token token, StateServerService stateServer, XmlNode tran, out string tranCode)
 {
     return this.Place(token, stateServer, tran, false, out tranCode);
 }
コード例 #26
0
        public XmlNode GetInstrumentForSetting(Token token, StateServerService stateServer)
        {
            DataSet dataSet = stateServer.GetInstrumentForSetting(token);
            if (dataSet == null) return null;
            XmlDocument doc = new XmlDocument();
            XmlNode xmlNodeTop = doc.CreateNode(XmlNodeType.Element, "Instruments", null);
            DataTable table = dataSet.Tables[0];
            DataRowCollection rows = table.Rows;
            foreach (DataRow row in rows)
            {
                XmlNode xmlNode = doc.CreateNode(XmlNodeType.Element, "Instrument", null);

                XmlAttribute attr = doc.CreateAttribute("ID");
                attr.Value = ((Guid)row["ID"]).ToString();
                xmlNode.Attributes.Append(attr);

                attr = doc.CreateAttribute("Code");
                attr.Value = (string)row["Code"];
                xmlNode.Attributes.Append(attr);

                attr = doc.CreateAttribute("Description");
                attr.Value = (string)row["Description"];
                xmlNode.Attributes.Append(attr);

                attr = doc.CreateAttribute("GroupName");
                attr.Value = row.Table.Columns.Contains("GroupName") ? (string)row["GroupName"] : "";
                xmlNode.Attributes.Append(attr);

                xmlNodeTop.AppendChild(xmlNode);
            }
            return xmlNodeTop;
        }
コード例 #27
0
 public TransactionError Place(Token token, StateServerService stateServer, XmlNode tran, bool fromMobile, out string tranCode)
 {
     return stateServer.Place(token, tran, out tranCode);
 }
コード例 #28
0
 public TransactionError MultipleClose(Token token, StateServerService stateServer, Guid[] orderIds, out XmlNode xmlTran, out XmlNode xmlAccount)
 {
     return stateServer.MultipleClose(token, orderIds, out xmlTran, out xmlAccount);
 }
コード例 #29
0
        public void Quote(Token token, bool isEmployee, StateServerService stateServer, string localIP, string instrumentID, double quoteLot, int bsStatus)
        {
            stateServer.Quote(token, new Guid(instrumentID), quoteLot, bsStatus);

            SaveQuote(token, isEmployee, localIP, instrumentID);
        }
コード例 #30
0
        public void NotifyCustomerExecuteOrder(Token token, StateServerService stateServer, string[][] parameters)
        {
            //this.GetExtend(token,physicalPath);
            try
            {
                Hashtable extend = (Hashtable)this.extends[token.SessionID];
                foreach (string[] parameters2 in parameters)
                {
                    int i = 0;
                    Guid transactionID = new Guid(parameters2[i++]);
                    Guid orderID = new Guid(parameters2[i++]);
                    string orderCode = parameters2[i++];
                    string accountCode = parameters2[i++];
                    string instrumentCode = parameters2[i++];
                    string lot = parameters2[i++];
                    string buySell = parameters2[i++];
                    bool isBuy = (buySell == "B");
                    buySell = buySell.Replace("B", extend["BuyPrompt"].ToString());
                    buySell = buySell.Replace("S", extend["SellPrompt"].ToString());
                    string executePrice = parameters2[i++];
                    string executeTime = parameters2[i++];
                    string executeTradeDay = parameters2[i++];
                    string newClose = parameters2[i++];
                    newClose = newClose.Replace("C", extend["ClosePrompt"].ToString());
                    newClose = newClose.Replace("N", extend["NewPrompt"].ToString());
                    string openPrice = parameters2[i++];
                    openPrice = openPrice.Replace("Lot", extend["RelationLot"].ToString());
                    string organizationName = parameters2[i++];
                    string organizationEmail = parameters2[i++];
                    string customerEmail = parameters2[i++];
                    string agentEmail = parameters2[i++];
                    string tradeDay = executeTradeDay;

                    string contractCurrency = "";
                    string baseCurrency = "";
                    string customerName = "";
                    string organizationAlias = "";
                    string deliveryDay = "";
                    decimal contractSize = 0;

                    string sql = string.Format("Exec dbo.P_GetEmailExecuteInfo '{0}'", orderID);
                    DataSet dataSet = DataAccess.GetData(sql, this.connectionString);
                    DataTable dt = dataSet.Tables[0];
                    for (int j = 0; j < dt.Rows.Count; j++)
                    {
                        contractCurrency = dt.Rows[j]["ContractCurrency"].ToString();
                        baseCurrency = dt.Rows[j]["BaseCurrency"].ToString();
                        deliveryDay = dt.Rows[j]["DeliveryDay"].ToString();
                        organizationAlias = dt.Rows[j]["OrganizationAlias"].ToString();
                        customerName = dt.Rows[j]["CustomerName"].ToString();
                        contractSize = Convert.ToDecimal(dt.Rows[j]["ContractSize"].ToString());
                    }
                    double contractAmount = (double)contractSize * Convert.ToDouble(lot);
                    double contractValue = (double)contractSize * Convert.ToDouble(lot) * Convert.ToDouble(executePrice);

                    //Create body
                    string body = string.Empty;
                    body = extend["body"].ToString();

                    body = body.Replace("OrderCode", orderCode);
                    body = body.Replace("InstrumentCode", instrumentCode);
                    body = body.Replace("LotBalance", lot);
                    body = body.Replace("BuySell", buySell);
                    body = body.Replace("ExecuteTime", executeTime);
                    body = body.Replace("NewClose", newClose);
                    body = body.Replace("OpenPrice", openPrice);
                    body = body.Replace("OrganizationName", organizationName);

                    body = body.Replace("OrganizationEmail", organizationEmail);
                    body = body.Replace("CustomerEmail", customerEmail);
                    body = body.Replace("AgentEmail", agentEmail);

                    body = body.Replace("CustomerName", customerName);
                    body = body.Replace("OrganizationAlias", organizationAlias);
                    body = body.Replace("AccountCode", accountCode);
                    body = body.Replace("CustomerEmail", customerEmail);
                    body = body.Replace("ContractCurrencyCode", ((isBuy) ? contractCurrency : baseCurrency));
                    body = body.Replace("ContractAmount", contractAmount.ToString());
                    body = body.Replace("BaseCurrency", ((isBuy) ? baseCurrency : contractCurrency));
                    body = body.Replace("ContractValue", contractValue.ToString());
                    body = body.Replace("ExecutePrice", executePrice);
                    body = body.Replace("TradeDay", tradeDay);
                    body = body.Replace("DeliveryDay", deliveryDay);

                    body = body.Replace("\n", "");
                    body = body.Replace("\t", "");
                    body = body.Replace("\r", "");

                    string toEmails = string.Empty;
                    if (customerEmail != string.Empty)
                    {
                        toEmails = customerEmail;
                    }
                    if (agentEmail != string.Empty)
                    {
                        toEmails = (toEmails != string.Empty) ? toEmails + "," + agentEmail : agentEmail;
                    }
                    string subject = extend["subject1"].ToString() + " " + orderCode + " " + extend["subject2"].ToString() + " " + accountCode;
                    //stateServer.Email(token, "Execute", transactionID, organizationEmail, toEmails, subject, body);
                    this.SendEmail(organizationEmail, toEmails, subject, body);
                }
            }
            catch (System.Exception ex)
            {
                _Logger.Error(ex);
            }
        }
コード例 #31
0
        public void Quote2(Token token, bool isEmployee, StateServerService stateServer, string localIP, string instrumentID, double buyQuoteLot, double sellQuoteLot, int tick)
        {
            stateServer.Quote2(token, new Guid(instrumentID), buyQuoteLot, sellQuoteLot, tick);

            SaveQuote(token, isEmployee, localIP, instrumentID);
        }
コード例 #32
0
 private void StateServerReadyCheck(StateServerService stateServer)
 {
     try
     {
         Token token = new Token();
         token.AppType=AppType.TradingConsoleSilverLight;
         stateServer.Register(token, SettingManager.Default.CommandUrl);
         stateServer.HelloWorld();
     }
     catch (WebException webException)
     {
         if (webException.Status == WebExceptionStatus.Timeout)
         {
             _Logger.Error(webException);
             Thread.Sleep(TimeSpan.FromSeconds(5));
             this.StateServerReadyCheck(stateServer);
         }
     }
 }
コード例 #33
0
 public TransactionError Assign(Token token, StateServerService stateServer, ref XmlNode xmlTransaction, out XmlNode xmlAccount, out XmlNode xmlInstrument)
 {
     string s = xmlTransaction.OuterXml;
     TransactionError transactionError = stateServer.Assign(token, ref xmlTransaction, out xmlAccount, out xmlInstrument);
     return transactionError;
 }