示例#1
0
        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 }));
            }
        }
示例#2
0
        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);
        }
示例#3
0
        public static DataPointDef GetDataItem(ProtocolDef protocolId, DataModelType identifier)
        {
            var dataPointItem = DataPointsBase.Instance(identifier).GetItem(protocolId);

            if (dataPointItem == null)
            {
                return(null);
            }
            return(dataPointItem);
        }
示例#4
0
        public static string GetDataPoint(ProtocolDef protocolId, DataModelType identifier)
        {
            var dataPointItem = DataPointsBase.Instance(identifier).GetItem(protocolId);

            if (dataPointItem == null)
            {
                return(string.Empty);
            }
            return(dataPointItem.DataPath);
        }
示例#5
0
        public static DataPointsBase Instance(int controllerType)
        {
            DataModelType identifier = DataModelType.EltekData;

            if (controllerType == 2)
            {
                identifier = DataModelType.DeltaData;
            }

            return(Instance(identifier));
        }
示例#6
0
        /// <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));
            }
        }
示例#7
0
        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);
        }
示例#8
0
        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);
        }
示例#9
0
        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;
        }
示例#10
0
 /// <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;
 }
示例#11
0
 public static ClaimValue CreateClaim(DataModelType dataModelType) => new ClaimValue
 {
     Uri   = ClaimUris.ModelType,
     Type  = ClaimValueType.STRING,
     Value = Enum.GetName(typeof(DataModelType), dataModelType)
 };