Exemple #1
0
        internal bool Update(XElement accountNode)
        {
            foreach (var attribute in accountNode.Attributes())
            {
                switch (attribute.Name.ToString())
                {
                case "ID":
                    this.id = XmlConvert.ToGuid(attribute.Value);
                    break;

                case "TradePolicyID":
                    Guid tradePolicyId = XmlConvert.ToGuid(attribute.Value);
                    if (this.tradePolicyId != tradePolicyId)
                    {
                        this.tradePolicyId = tradePolicyId;
                    }
                    break;

                case "CustomerID":
                    Guid ownerId = XmlConvert.ToGuid(attribute.Value);
                    if (this.customerId != ownerId)
                    {
                        this.customerId = ownerId;
                    }
                    break;

                case "CurrencyID":
                    Guid currencyId = XmlConvert.ToGuid(attribute.Value);
                    if (this.currencyId != currencyId)
                    {
                        this.currencyId = currencyId;
                    }
                    break;

                case "SpecialTradePolicyID":
                    Guid?specialTradePolicyId = null;
                    if (!string.IsNullOrEmpty(attribute.Value))
                    {
                        specialTradePolicyId = XmlConvert.ToGuid(attribute.Value);
                    }
                    if (this.specialTradePolicyId != specialTradePolicyId)
                    {
                        this.specialTradePolicyId = specialTradePolicyId;
                    }

                    break;

                case "Code":
                    this.code = attribute.Value;
                    break;

                case "Type":
                    this.type = (AccountType)XmlConvert.ToInt32(attribute.Value);
                    break;

                case "OrganizationID":
                    this.organizationId = XmlConvert.ToGuid(attribute.Value);
                    break;

                case "IsActive":
                    this.isActive = XmlConvert.ToBoolean(attribute.Value);
                    break;

                case "IsTradingAllowed":
                    this.isTradingAllowed = XmlConvert.ToBoolean(attribute.Value);
                    break;

                case "BeginTime":
                    try
                    {
                        this.beginTime = Convert.ToDateTime(attribute.Value);
                    }
                    catch
                    {
                        this.beginTime = DateTime.Now;    //Back office broadcast tiem in wrong format
                    }
                    break;

                case "EndTime":
                    try
                    {
                        this.endTime = Convert.ToDateTime(attribute.Value);
                    }
                    catch
                    {
                        this.endTime = DateTime.MaxValue;    //Back office broadcast tiem in wrong format
                    }
                    break;

                case "IsSplitLot":
                    this.isSplitLot = XmlConvert.ToBoolean(attribute.Value);
                    break;

                case "MaxNecessary":
                    this.maxNecessary = XmlConvert.ToDecimal(attribute.Value);
                    break;

                case "IsAutoClose":
                    this.isAutoClose = XmlConvert.ToBoolean(attribute.Value);
                    break;

                case "IsMultiCurrency":
                    this.isMultiCurrency = XmlConvert.ToBoolean(attribute.Value);
                    break;

                case "CreditLotD":
                    this.creditLotD = XmlConvert.ToDecimal(attribute.Value);
                    break;

                case "CreditLotO":
                    this.creditLotO = XmlConvert.ToDecimal(attribute.Value);
                    break;

                case "CreditAmount":
                    this.creditAmount = XmlConvert.ToDecimal(attribute.Value);
                    break;

                case "ShortMargin":
                    this.shortMargin = XmlConvert.ToDecimal(attribute.Value);
                    break;

                case "RateMarginD":
                    this.rateMarginD = XmlConvert.ToDecimal(attribute.Value);
                    break;

                case "RateMarginO":
                    this.rateMarginO = XmlConvert.ToDecimal(attribute.Value);
                    break;

                case "RateMarginLockD":
                    this.rateMarginLockD = XmlConvert.ToDecimal(attribute.Value);
                    break;

                case "RateMarginLockO":
                    this.rateMarginLockO = XmlConvert.ToDecimal(attribute.Value);
                    break;

                case "RateCommission":
                    this.rateCommission = XmlConvert.ToDecimal(attribute.Value);
                    break;

                case "RateLevy":
                    this.rateLevy = XmlConvert.ToDecimal(attribute.Value);
                    break;

                case "RateOtherFee":
                    this.RateOtherFee = XmlConvert.ToDecimal(attribute.Value);
                    break;

                case "RateRiskNecessary":
                    this.rateRiskNecessary = XmlConvert.ToDecimal(attribute.Value);
                    break;

                case "IsAutoCut":
                    this.isAutoCut = XmlConvert.ToBoolean(attribute.Value);
                    break;

                case "AllowSalesTrading":
                    this.allowSalesTrading = XmlConvert.ToBoolean(attribute.Value);
                    break;

                case "AllowManagerTrading":
                    this.allowManagerTrading = XmlConvert.ToBoolean(attribute.Value);
                    break;

                case "RiskLevelAction":
                    this.riskLevelAction = (RiskLevelAction)XmlConvert.ToInt32(attribute.Value);
                    break;

                case "ForbiddenAlert":
                    this.forbiddenAlert = XmlConvert.ToInt32(attribute.Value);
                    break;

                case "MarginInterestOption":
                    this.MarginInterestOption = (MarginInterestOption)XmlConvert.ToInt32(attribute.Value);
                    break;

                case "RiskActionMode":
                    this.riskActionMode = (RiskActionMode)XmlConvert.ToInt32(attribute.Value);
                    break;

                case "MaxOpenLot":
                    if (string.IsNullOrEmpty(attribute.Value))
                    {
                        this.maxOpenLot = null;
                    }
                    else
                    {
                        this.maxOpenLot = XmlConvert.ToDecimal(attribute.Value);
                    }
                    break;

                case "RiskActionMinimumEquity":
                    if (string.IsNullOrEmpty(attribute.Value))
                    {
                        this.riskActionMinimumEquity = null;
                    }
                    else
                    {
                        this.riskActionMinimumEquity = XmlConvert.ToDecimal(attribute.Value);
                    }
                    break;

                case "MaxPhyscialValue":
                    if (string.IsNullOrEmpty(attribute.Value))
                    {
                        this.maxPhyscialValue = null;
                    }
                    else
                    {
                        this.maxPhyscialValue = XmlConvert.ToDecimal(attribute.Value);
                    }
                    break;

                case "AgentID":
                    if (string.IsNullOrEmpty(attribute.Value))
                    {
                        this.agentId = null;
                    }
                    else
                    {
                        this.agentId = XmlConvert.ToGuid(attribute.Value);
                    }
                    break;

                case "BlotterId":
                    if (string.IsNullOrEmpty(attribute.Value))
                    {
                        this.BlotterID = null;
                    }
                    else
                    {
                        this.BlotterID = XmlConvert.ToGuid(attribute.Value);
                    }
                    break;

                case "QuotePolicyId":
                    if (string.IsNullOrEmpty(attribute.Value))
                    {
                        this.QuotePolicyID = null;
                    }
                    else
                    {
                        this.QuotePolicyID = XmlConvert.ToGuid(attribute.Value);
                    }
                    break;
                }
            }
            return(true);
        }
Exemple #2
0
        internal void Update(IDBRow accountRow)
        {
            this.id            = accountRow.GetColumn <Guid>("ID");
            this.customerId    = accountRow.GetColumn <Guid>("CustomerID");
            this.currencyId    = accountRow.GetColumn <Guid>("CurrencyID");
            this.tradePolicyId = accountRow.GetColumn <Guid>("TradePolicyID");

            if (accountRow["SpecialTradePolicyID"] != DBNull.Value)
            {
                this.specialTradePolicyId = (Guid)accountRow["SpecialTradePolicyID"];
            }

            this.type           = (AccountType)accountRow.GetColumn <int>("Type");
            this.code           = accountRow.GetColumn <string>("Code");
            this.organizationId = accountRow.GetColumn <Guid>("OrganizationID");

            this.isActive         = accountRow.GetColumn <bool>("IsActive");
            this.isTradingAllowed = accountRow.GetColumn <bool>("IsTradingAllowed");
            this.beginTime        = accountRow.GetColumn <DateTime>("BeginTime");
            this.endTime          = accountRow.GetColumn <DateTime>("EndTime");
            this.UpdateTime       = accountRow.GetColumn <DateTime>("UpdateTime");

            this.isSplitLot           = true;// (bool)accountRow["IsSplitLot"];
            this.maxNecessary         = accountRow.GetColumn <decimal>("MaxNecessary");
            this.isAutoClose          = accountRow.GetColumn <bool>("IsAutoClose");
            this.isMultiCurrency      = accountRow.GetColumn <bool>("IsMultiCurrency");
            this.creditLotD           = accountRow.GetColumn <decimal>("CreditLotD");
            this.creditLotO           = accountRow.GetColumn <decimal>("CreditLotO");
            this.creditAmount         = accountRow.GetColumn <decimal>("CreditAmount");
            this.shortMargin          = accountRow.GetColumn <decimal>("ShortMargin");
            this.rateMarginD          = accountRow.GetColumn <decimal>("RateMarginD");
            this.rateMarginO          = accountRow.GetColumn <decimal>("RateMarginO");
            this.rateMarginLockD      = (decimal)accountRow["RateMarginLockD"];
            this.rateMarginLockO      = (decimal)accountRow["RateMarginLockO"];
            this.rateCommission       = (decimal)accountRow["RateCommission"];
            this.rateLevy             = (decimal)accountRow["RateLevy"];
            this.rateRiskNecessary    = (decimal)accountRow["RateRiskNecessary"];
            this.BlotterID            = accountRow["BlotterID"] == DBNull.Value ? null : (Guid?)accountRow["BlotterID"];
            this.RateOtherFee         = (decimal)accountRow["RateOtherFee"];
            this.MarginInterestOption = (MarginInterestOption)((int)accountRow["MarginInterestOption"]);
            this.isAutoCut            = (bool)accountRow["IsAutoCut"];
            this.riskLevelAction      = (RiskLevelAction)(int)accountRow["RiskLevelAction"];
            this.forbiddenAlert       = (int)accountRow["ForbiddenAlert"];
            this.riskActionMode       = (RiskActionMode)(int)accountRow["RiskActionMode"];
            if (!accountRow.Contains("RiskActionMinimumEquity") || accountRow["RiskActionMinimumEquity"] == DBNull.Value)
            {
                this.riskActionMinimumEquity = null;
            }
            else
            {
                this.riskActionMinimumEquity = (decimal)accountRow["RiskActionMinimumEquity"];
            }
            if (!accountRow.Contains("MaxOpenLot") || accountRow["MaxOpenLot"] == DBNull.Value)
            {
                this.maxOpenLot = null;
            }
            else
            {
                this.maxOpenLot = (decimal)accountRow["MaxOpenLot"];
            }

            if (!accountRow.Contains("MaxPhyscialValue") || accountRow["MaxPhyscialValue"] == DBNull.Value)
            {
                //this.maxPhyscialValue = null; //MaxPhyscialValue has no history, use current settings
            }
            else
            {
                this.maxPhyscialValue = (decimal)accountRow["MaxPhyscialValue"];
            }

            if (accountRow["AgentID"] != DBNull.Value)
            {
                this.agentId = (Guid)accountRow["AgentID"];
            }
            else
            {
                this.agentId = Guid.Empty;
            }
            if (accountRow.Contains("AllowSalesTrading"))
            {
                this.allowSalesTrading = (bool)accountRow["AllowSalesTrading"];
            }
            if (accountRow.Contains("AllowManagerTrading"))
            {
                this.allowManagerTrading = (bool)accountRow["AllowManagerTrading"];
            }

            if (accountRow.Contains("QuotePolicyID"))
            {
                this.QuotePolicyID = accountRow.GetColumn <Guid?>("QuotePolicyID");
            }
        }