public async Task <JsonResult> Update(string Id, DataModelType dt = DataModelType.News) { switch (dt) { default: case DataModelType.News: var news = await MongoHelper.FindOne <News>(Id); if (news == null) { news = new News(); } UpdateModel(news); news.CreationDate = DateTime.Now; return(Json(new { result = MongoHelper.Save(news).Status })); case DataModelType.Topic: var topic = await MongoHelper.FindOne <Topic>(Id); if (topic == null) { topic = new Topic(); } UpdateModel(topic); topic.CreationDate = DateTime.Now; return(Json(new { result = MongoHelper.Save(topic).Status })); } }
public static object CreateByEnum(DataModelType modelType) { string enumText = modelType.ToString(); // will return for example "Company" Type classType = Type.GetType("MyNamespace." + enumText); // the Type for Company class object t = Activator.CreateInstance(classType); // create an instance of Company class return(t); }
public static DataPointDef GetDataItem(ProtocolDef protocolId, DataModelType identifier) { var dataPointItem = DataPointsBase.Instance(identifier).GetItem(protocolId); if (dataPointItem == null) { return(null); } return(dataPointItem); }
public static string GetDataPoint(ProtocolDef protocolId, DataModelType identifier) { var dataPointItem = DataPointsBase.Instance(identifier).GetItem(protocolId); if (dataPointItem == null) { return(string.Empty); } return(dataPointItem.DataPath); }
public static DataPointsBase Instance(int controllerType) { DataModelType identifier = DataModelType.EltekData; if (controllerType == 2) { identifier = DataModelType.DeltaData; } return(Instance(identifier)); }
/// <summary> /// 详情页 /// </summary> public async Task <ActionResult> Details(string id, DataModelType dt = DataModelType.News) { switch (dt) { default: case DataModelType.News: return(await Details <News>(id)); case DataModelType.Topic: return(await Details <Topic>(id)); } }
public static ProtocolDef GetProtocolId(ref PathAndType item, DataModelType identifier) { var dataPointItem = DataPointsBase.Instance(identifier).GetItem(item.Path); if (dataPointItem == null) { return(0); } if (item.Type == "") { item.Type = dataPointItem.DataType; } return(dataPointItem.ProtocolId); }
public static DataPointsBase Instance(DataModelType identifier) { if (dataPoints == null) { dataPoints = new List <DataPointsBase>(); } var dataPointList = dataPoints.Where(s => s.Identifier == identifier).FirstOrDefault(); if (dataPointList == null) { dataPoints.Add(new DataPointsBase(identifier)); return(dataPoints[dataPoints.Count - 1]); } return(dataPointList); }
public DataPointsBase(DataModelType identifier) { Identifier = identifier; IDataPoint dataModelType; switch (identifier) { default: case DataModelType.EltekData: dataModelType = new EltekDataPoints(); break; case DataModelType.DeltaData: dataModelType = new DeltaDataPoints(); break; } Items = dataModelType.Items; }
/// <summary> /// NoTest /// </summary> /// <param name="strategyHeader">strategyHeader</param> /// <param name="symbol">symbol</param> /// <param name="interval">Длительность бара</param> /// <param name="period">Количество баров</param> /// <param name="barType">Тип бара</param> public BarSettings(StrategyHeader strategyHeader, string symbol, int interval, int period, DataModelType barType) { this.Id = SerialIntegerFactory.Make(); this.Symbol = symbol; this.Interval = interval; this.Period = period; this.StrategyId = strategyHeader.Id; this.Strategy = strategyHeader; this.BarType = barType; }
public static ClaimValue CreateClaim(DataModelType dataModelType) => new ClaimValue { Uri = ClaimUris.ModelType, Type = ClaimValueType.STRING, Value = Enum.GetName(typeof(DataModelType), dataModelType) };