public static int AddMetadataObject(QuotationSource entity) { string sql = "INSERT QuotationSource(Name,AuthName,Password) VALUES (@name,@authName,@password);SELECT SCOPE_IDENTITY()"; int objectId = (int)(decimal)DataAccess.GetInstance().ExecuteScalar(sql, CommandType.Text, new SqlParameter("@name", entity.Name), new SqlParameter("@authName", entity.AuthName), new SqlParameter("@password", entity.Password)); return objectId; }
public void Add(QuotationSource source) { this._QuotationSources.Add(new VmQuotationSource(source)); }
internal static void GetQuotationMetadata( Dictionary<string, QuotationSource> quotationSources, Dictionary<int, Instrument> instruments, //Dictionary<int, Dictionary<int, InstrumentSourceRelation>> instrumentSourceRelations, Dictionary<int, Dictionary<string, InstrumentSourceRelation>> instrumentSourceRelations, Dictionary<int, DerivativeRelation> derivativeRelations, Dictionary<int, PriceRangeCheckRule> priceRangeCheckRules, Dictionary<int, WeightedPriceRule> weightedPriceRules, Dictionary<int, GeneralQuotation> lastQuotations ) { string sql = "dbo.GetInitialDataForQuotationManager"; DataAccess.GetInstance().ExecuteReader(sql, CommandType.StoredProcedure, delegate(SqlDataReader reader) { while (reader.Read()) { QuotationSource quotationSource = new QuotationSource(); quotationSource.Id = (int)reader["Id"]; quotationSource.Name = (string)reader["Name"]; quotationSource.AuthName = (string)reader["AuthName"]; quotationSource.Password = (string)reader["Password"]; quotationSources.Add(quotationSource.Name, quotationSource); } reader.NextResult(); while (reader.Read()) { Instrument instrument = new Instrument(); instrument.Id = (int)reader["Id"]; instrument.Code = (string)reader["Code"]; instrument.AdjustPoints = (int)reader["AdjustPoints"]; instrument.AdjustIncrement = (int)reader["AdjustIncrement"]; instrument.DecimalPlace = (int)reader["DecimalPlace"]; instrument.IsDerivative = (bool)reader["IsDerivative"]; instrument.InactiveTime = reader["InactiveTime"] == DBNull.Value ? null : (int?)reader["InactiveTime"]; instrument.UseWeightedPrice = reader["UseWeightedPrice"] == DBNull.Value ? null : (bool?)reader["UseWeightedPrice"]; instrument.IsSwitchUseAgio = reader["IsSwitchUseAgio"] == DBNull.Value ? null : (bool?)reader["IsSwitchUseAgio"]; instrument.AgioSeconds = reader["AgioSeconds"] == DBNull.Value ? null : (int?)reader["AgioSeconds"]; instrument.LeastTicks = reader["LeastTicks"] == DBNull.Value ? null : (int?)reader["LeastTicks"]; instrument.IsActive = true; instruments.Add(instrument.Id, instrument); } reader.NextResult(); while (reader.Read()) { InstrumentSourceRelation relation = new InstrumentSourceRelation(); relation.Id = (int)reader["Id"]; relation.SourceId = (int)reader["SourceId"]; relation.SourceSymbol = (string)reader["SourceSymbol"]; relation.InstrumentId = (int)reader["InstrumentId"]; relation.Inverted = (bool)reader["Inverted"]; relation.IsActive = (bool)reader["IsActive"]; relation.IsDefault = (bool)reader["IsDefault"]; relation.Priority = (int)reader["Priority"]; relation.SwitchTimeout = (int)reader["SwitchTimeout"]; relation.AdjustPoints = (int)reader["AdjustPoints"]; relation.AdjustIncrement = (int)reader["AdjustIncrement"]; //Dictionary<int, InstrumentSourceRelation> sources; //if (!instrumentSourceRelations.TryGetValue(relation.InstrumentId, out sources)) //{ // sources = new Dictionary<int, InstrumentSourceRelation>(); // instrumentSourceRelations.Add(relation.InstrumentId, sources); //} //sources.Add(relation.SourceId, relation); Dictionary<string, InstrumentSourceRelation> relations; if (!instrumentSourceRelations.TryGetValue(relation.SourceId, out relations)) { relations = new Dictionary<string, InstrumentSourceRelation>(); instrumentSourceRelations.Add(relation.SourceId, relations); } relations.Add(relation.SourceSymbol, relation); } reader.NextResult(); while (reader.Read()) { DerivativeRelation derivativeRelation = new DerivativeRelation(); derivativeRelation.Id = (int)reader["InstrumentId"]; derivativeRelation.UnderlyingInstrument1Id = (int)reader["UnderlyingInstrument1Id"]; derivativeRelation.UnderlyingInstrument1IdInverted = (bool)reader["UnderlyingInstrument1IdInverted"]; derivativeRelation.UnderlyingInstrument2Id = reader["UnderlyingInstrument2Id"] == DBNull.Value ? null : (int?)reader["UnderlyingInstrument2Id"]; derivativeRelation.AskOperand1Type = (OperandType)(byte)reader["AskOperand1Type"]; derivativeRelation.AskOperator1Type = reader["AskOperator1Type"] == DBNull.Value ? null : (OperatorType?)(byte)reader["AskOperator1Type"]; derivativeRelation.AskOperand2Type = reader["AskOperand2Type"] == DBNull.Value ? null : (OperandType?)(byte)reader["AskOperand2Type"]; derivativeRelation.AskOperator2Type = (OperatorType)(byte)reader["AskOperator2Type"]; derivativeRelation.AskOperand3 = (decimal)reader["AskOperand3"]; derivativeRelation.BidOperand1Type = (OperandType)(byte)reader["BidOperand1Type"]; derivativeRelation.BidOperator1Type = reader["BidOperator1Type"] == DBNull.Value ? null : (OperatorType?)(byte)reader["BidOperator1Type"]; derivativeRelation.BidOperand2Type = reader["BidOperand2Type"] == DBNull.Value ? null : (OperandType?)(byte)reader["BidOperand2Type"]; derivativeRelation.BidOperator2Type = (OperatorType)(byte)reader["BidOperator2Type"]; derivativeRelation.BidOperand3 = (decimal)reader["BidOperand3"]; derivativeRelation.LastOperand1Type = (OperandType)(byte)reader["LastOperand1Type"]; derivativeRelation.LastOperator1Type = reader["LastOperator1Type"] == DBNull.Value ? null : (OperatorType?)(byte)reader["LastOperator1Type"]; derivativeRelation.LastOperand2Type = reader["LastOperand2Type"] == DBNull.Value ? null : (OperandType?)(byte)reader["LastOperand2Type"]; derivativeRelation.LastOperator2Type = (OperatorType)(byte)reader["LastOperator2Type"]; derivativeRelation.LastOperand3 = (decimal)reader["LastOperand3"]; derivativeRelations.Add(derivativeRelation.Id, derivativeRelation); } reader.NextResult(); while (reader.Read()) { PriceRangeCheckRule priceRangeCheckRule = new PriceRangeCheckRule(); priceRangeCheckRule.Id = (int)reader["InstrumentId"]; priceRangeCheckRule.DiscardOutOfRangePrice = (bool)reader["DiscardOutOfRangePrice"]; priceRangeCheckRule.OutOfRangeType = (OutOfRangeType)(byte)reader["OutOfRangeType"]; priceRangeCheckRule.ValidVariation = (int)reader["ValidVariation"]; priceRangeCheckRule.OutOfRangeWaitTime = (int)reader["OutOfRangeWaitTime"]; priceRangeCheckRule.OutOfRangeCount = (int)reader["OutOfRangeCount"]; priceRangeCheckRules.Add(priceRangeCheckRule.Id, priceRangeCheckRule); } reader.NextResult(); while(reader.Read()) { WeightedPriceRule weightedPriceRule = new WeightedPriceRule(); weightedPriceRule.Id = (int)reader["InstrumentId"]; weightedPriceRule.Multiplier = (decimal)reader["Multiplier"]; weightedPriceRule.AskAskWeight = (int)reader["AskAskWeight"]; weightedPriceRule.AskBidWeight = (int)reader["AskBidWeight"]; weightedPriceRule.AskLastWeight = (int)reader["AskLastWeight"]; weightedPriceRule.BidAskWeight = (int)reader["BidAskWeight"]; weightedPriceRule.BidBidWeight = (int)reader["BidBidWeight"]; weightedPriceRule.BidLastWeight = (int)reader["BidLastWeight"]; weightedPriceRule.LastAskWeight = (int)reader["LastAskWeight"]; weightedPriceRule.LastBidWeight = (int)reader["LastBidWeight"]; weightedPriceRule.LastLastWeight = (int)reader["LastLastWeight"]; weightedPriceRule.AskAverageWeight = (int)reader["AskAverageWeight"]; weightedPriceRule.BidAverageWeight = (int)reader["BidAverageWeight"]; weightedPriceRule.LastAverageWeight = (int)reader["LastAverageWeight"]; weightedPriceRule.AskAdjust = (decimal)reader["AskAdjust"]; weightedPriceRule.BidAdjust = (decimal)reader["BidAdjust"]; weightedPriceRule.LastAdjust = (decimal)reader["LastAdjust"]; weightedPriceRules.Add(weightedPriceRule.Id, weightedPriceRule); } reader.NextResult(); while (reader.Read()) { GeneralQuotation lastQuotation = new GeneralQuotation(); lastQuotation.SourceId = (int)reader["SourceId"]; lastQuotation.InstrumentId = (int)reader["InstrumentId"]; lastQuotation.Timestamp = (DateTime)reader["Timestamp"]; lastQuotation.Ask = (double)reader["Ask"]; lastQuotation.Bid = (double)reader["Bid"]; lastQuotation.Last = reader["Last"] == DBNull.Value ? null : (double?)reader["Last"]; lastQuotation.High = reader["High"] == DBNull.Value ? null : (double?)reader["High"]; lastQuotation.Low = reader["Low"] == DBNull.Value ? null : (double?)reader["Low"]; lastQuotations.Add(lastQuotation.InstrumentId, lastQuotation); } }); }
public void AddMetadataObject(QuotationSource quotationSource) { this._ConfigMetadata.QuotationSources.Add(quotationSource.Name, quotationSource); }