Beispiel #1
0
        public GetDataPiontHistoryDataResponse GetDataPiontHistoryData(GetDataPointHistoryDataRequest request)
        {
            GetDataPiontHistoryDataResponse response = new GetDataPiontHistoryDataResponse();

            try
            {
                Query query = new Query();
                query.AddCriterion(Criterion.Create <DataPointHistoryData>(p => p.DataPoint.Id, request.DataPointId, CriteriaOperator.Equal));
                query.AddCriterion(Criterion.Create <DataPointHistoryData>(p => p.DateTime, request.BeginTime, CriteriaOperator.GreaterThanOrEqual));
                query.AddCriterion(Criterion.Create <DataPointHistoryData>(p => p.DateTime, request.EndTime, CriteriaOperator.LesserThanOrEqual));
                query.QueryOperator   = QueryOperator.And;
                query.OrderByProperty = OrderByClause.Create <DataPointHistoryData>(p => p.DateTime, false);

                IEnumerable <DataPointHistoryData> dataPointHistoryDatas =
                    dataPointHistoryDataRepository.FindBy(query);

                response.DataPointHistoryDataView =
                    dataPointHistoryDatas.ConvetToDataPointHistoryDataView();
            }
            catch (Exception ex)
            {
                string message = "查询失败!错误信息:/n" + ex.Message;
                response = new GetDataPiontHistoryDataResponse()
                {
                    ResponseSucceed = false,
                    Message         = "查询失败"
                };
                LoggingFactory.GetLogger().WriteDebugLogger(message);

                return(response);
            }

            return(response);
        }
        public void TestAliasesAggregationOM()
        {
            var model = new EPStatementObjectModel();

            model.SelectClause      = SelectClause.Create("Symbol", "Volume").Add(Expressions.Sum("Price"), "mySum");
            model.FromClause        = FromClause.Create(FilterStream.Create(typeof(SupportMarketDataBean).FullName).AddView(View.Create("length", Expressions.Constant(20))));
            model.GroupByClause     = GroupByClause.Create("Symbol");
            model.OutputLimitClause = OutputLimitClause.Create(6);
            model.OrderByClause     = OrderByClause.Create(Expressions.Sum("Price")).Add("Symbol", false);
            model = (EPStatementObjectModel)SerializableObjectCopier.Copy(model);

            var statementString = "select Symbol, Volume, sum(Price) as mySum from " +
                                  typeof(SupportMarketDataBean).FullName + "#length(20) " +
                                  "group by Symbol " +
                                  "output every 6 events " +
                                  "order by sum(Price), Symbol";

            Assert.AreEqual(statementString, model.ToEPL());

            _testListener = new SupportUpdateListener();
            var statement = _epService.EPAdministrator.Create(model);

            statement.AddListener(_testListener);

            RunAssertionDefault();
        }
        public GetDataPointByModuleResponse GetDataPointInfoByModule(GetDataPointByModuleRequest request)
        {
            GetDataPointByModuleResponse response = new GetDataPointByModuleResponse();

            try
            {
                Query query = new Query();
                query.AddCriterion(Criterion.Create <DataPoint>(p => p.ModuleBelongTo.Id, request.ModuleId, CriteriaOperator.Equal));
                query.OrderByProperty = OrderByClause.Create <DataPoint>(p => p.Number, false);

                IEnumerable <DataPoint> dataPoints = _dataPointRepository.FindBy(query);
                response.DataPointInfoViews = dataPoints.ConverToDataPointInfoViews();
            }
            catch (Exception ex)
            {
                string message = "查询失败!错误信息:/n" + ex.Message;
                response = new GetDataPointByModuleResponse()
                {
                    ResponseSucceed = false,
                    Message         = "查询失败"
                };
                LoggingFactory.GetLogger().WriteDebugLogger(message);

                return(response);
            }

            return(response);
        }
Beispiel #4
0
            public void Run(RegressionEnvironment env)
            {
                var model = new EPStatementObjectModel();
                model.SelectClause = SelectClause.Create("Symbol", "Volume").Add(Expressions.Sum("Price"), "mySum");
                model.FromClause = FromClause.Create(
                    FilterStream.Create(typeof(SupportMarketDataBean).Name)
                        .AddView(View.Create("length", Expressions.Constant(20))));
                model.GroupByClause = GroupByClause.Create("Symbol");
                model.OutputLimitClause = OutputLimitClause.Create(6);
                model.OrderByClause = OrderByClause.Create(Expressions.Sum("Price")).Add("Symbol", false);
                model = env.CopyMayFail(model);

                var epl = "select Symbol, Volume, sum(Price) as mySum from " +
                          "SupportMarketDataBean#length(20) " +
                          "group by Symbol " +
                          "output every 6 events " +
                          "order by sum(Price), Symbol";
                Assert.AreEqual(epl, model.ToEPL());

                model.Annotations = Collections.SingletonList(AnnotationPart.NameAnnotation("s0"));
                env.CompileDeploy(model).AddListener("s0");

                TryAssertionDefault(env);

                env.UndeployAll();
            }
Beispiel #5
0
        private void RunAssertionAliasesAggregationOM(EPServiceProvider epService)
        {
            var model = new EPStatementObjectModel();

            model.SelectClause      = SelectClause.Create("symbol", "volume").Add(Expressions.Sum("price"), "mySum");
            model.FromClause        = FromClause.Create(FilterStream.Create(typeof(SupportMarketDataBean).FullName).AddView(View.Create("length", Expressions.Constant(20))));
            model.GroupByClause     = GroupByClause.Create("symbol");
            model.OutputLimitClause = OutputLimitClause.Create(6);
            model.OrderByClause     = OrderByClause.Create(Expressions.Sum("price")).Add("symbol", false);
            model = (EPStatementObjectModel)SerializableObjectCopier.Copy(epService.Container, model);

            string statementString = "select symbol, volume, sum(price) as mySum from " +
                                     typeof(SupportMarketDataBean).FullName + "#length(20) " +
                                     "group by symbol " +
                                     "output every 6 events " +
                                     "order by sum(price), symbol";

            Assert.AreEqual(statementString, model.ToEPL());

            var         testListener = new SupportUpdateListener();
            EPStatement statement    = epService.EPAdministrator.Create(model);

            statement.Events += testListener.Update;

            TryAssertionDefault(epService, testListener);

            statement.Dispose();
        }
        public void TestCreatQuery()
        {
            Query query = new Query();

            query.AddCriterion(Criterion.Create <DataPoint>(p => p.Number, 10, CriteriaOperator.LesserThanOrEqual));
            query.AddCriterion(Criterion.Create <DataPoint>(p => p.ModuleBelongTo.Id, 2, CriteriaOperator.Equal));
            query.OrderByProperty = OrderByClause.Create <DataPoint>(p => p.Name, true);
        }
Beispiel #7
0
        public void TestFindByQueryAndCount()
        {
            AdoUnitOfWork       unitOfWork          = new AdoUnitOfWork();
            DataPointRepository dataPointRepository = new DataPointRepository(unitOfWork);

            Query query = new Query();

            query.AddCriterion(Criterion.Create <DataPoint>(p => p.Number, 10, CriteriaOperator.LesserThanOrEqual));
            query.AddCriterion(Criterion.Create <DataPoint>(p => p.ModuleBelongTo.Id, 2, CriteriaOperator.Equal));
            query.OrderByProperty = OrderByClause.Create <DataPoint>(p => p.Name, true);

            IEnumerable <DataPoint> result = dataPointRepository.FindBy(query, 1, 1);
        }
Beispiel #8
0
        public IEnumerable <Order> FindAllCustomersOrdersBy(Guid customerId)
        {
            IEnumerable <Order> customerOrders = new List <Order>();

            Query query = new Query();

            query.Add(new Criterion(nameof(Order.CustomerId), customerId, CriteriaOperator.Equal));
            //query.OrderByProperty = new OrderByClause { PropertyName = "CustomerId", Desc = true };
            query.OrderByProperty = OrderByClause.Create(nameof(Order.Id), true);

            customerOrders = _orderRepository.FindBy(query);

            return(customerOrders);
        }
        public void TestFindByQuery()
        {
            AdoUnitOfWork unitOfWork = new AdoUnitOfWork();
            DataPointHistoryDataRepository dataPointHistoryDataRepository = new DataPointHistoryDataRepository(unitOfWork);

            Query query = new Query();

            query.AddCriterion(Criterion.Create <DataPointHistoryData>(p => p.DataPoint.Id, 1, CriteriaOperator.Equal));
            query.AddCriterion(Criterion.Create <DataPointHistoryData>(p => p.DateTime, new DateTime(2013, 5, 1), CriteriaOperator.GreaterThanOrEqual));
            query.AddCriterion(Criterion.Create <DataPointHistoryData>(p => p.DateTime, DateTime.Now, CriteriaOperator.LesserThanOrEqual));
            query.QueryOperator   = QueryOperator.And;
            query.OrderByProperty = OrderByClause.Create <DataPointHistoryData>(p => p.DateTime, false);

            IEnumerable <DataPointHistoryData> result = dataPointHistoryDataRepository.FindBy(query);

            Assert.IsTrue(result.Count() > 0);
        }
        public void TestDatapiontRepositoryFindByQueryMethod()
        {
            NHUnitOfWork        nhUnitOfWork        = new NHUnitOfWork();
            DataPointRepository dataPointRepository = new DataPointRepository(nhUnitOfWork);

            Query query = new Query();

            query.AddCriterion(Criterion.Create <DataPoint>(p => p.DataType, DataType.S32, CriteriaOperator.Equal));
            query.QueryOperator = QueryOperator.And;

            //query.OrderByProperty = new OrderByClause() { PropertyName = "Number" ,Desc = true};
            query.OrderByProperty = OrderByClause.Create <DataPoint>(p => p.Number, false);

            List <DataPoint> dataPoints = (List <DataPoint>)dataPointRepository.FindBy(query);

            Assert.NotNull(dataPoints);
        }
Beispiel #11
0
        public void TestCreateFromOMComplete()
        {
            var model = new EPStatementObjectModel();

            model.InsertInto   = InsertIntoClause.Create("ReadyStreamAvg", "line", "avgAge");
            model.SelectClause = SelectClause.Create()
                                 .Add("line")
                                 .Add(Expressions.Avg("age"), "avgAge");
            var filter = Filter.Create(typeof(SupportBean).FullName, Expressions.In("line", 1, 8, 10));

            model.FromClause        = FromClause.Create(FilterStream.Create(filter, "RS").AddView("win", "time", Expressions.Constant(10)));
            model.WhereClause       = Expressions.IsNotNull("waverId");
            model.GroupByClause     = GroupByClause.Create("line");
            model.HavingClause      = Expressions.Lt(Expressions.Avg("age"), Expressions.Constant(0));
            model.OutputLimitClause = OutputLimitClause.Create(Expressions.TimePeriod(null, null, null, 10, null));
            model.OrderByClause     = OrderByClause.Create("line");

            Assert.AreEqual("insert into ReadyStreamAvg(line, avgAge) select line, avg(age) as avgAge from com.espertech.esper.support.bean.SupportBean(line in (1,8,10)).win:time(10) as RS where waverId is not null group by line having avg(age)<0 output every 10 seconds order by line", model.ToEPL());
            SerializableObjectCopier.Copy(model);
        }
Beispiel #12
0
            public void Run(RegressionEnvironment env)
            {
                EPStatementObjectModel model = new EPStatementObjectModel();
                model.SetInsertInto(InsertIntoClause.Create("ReadyStreamAvg", "line", "avgAge"));
                model.SetSelect(SelectClause.Create().Add("line").Add(Expressions.Avg("age"), "avgAge"));
                Filter filter = Filter.Create(typeof(SupportBean).FullName, Expressions.In("line", 1, 8, 10));
                model.SetFrom(FromClause.Create(FilterStream.Create(filter, "RS").AddView("time", Expressions.Constant(10))));
                model.SetWhere(Expressions.IsNotNull("waverId"));
                model.SetGroupBy(GroupByClause.Create("line"));
                model.SetHaving(Expressions.Lt(Expressions.Avg("age"), Expressions.Constant(0)));
                model.SetOutputLimit(OutputLimitClause.Create(Expressions.TimePeriod(null, null, null, 10, null)));
                model.SetOrderBy(OrderByClause.Create("line"));

                Assert.AreEqual(
                    "insert into ReadyStreamAvg(line, avgAge) select line, avg(age) as avgAge from " +
                    typeof(SupportBean).CleanName() +
                    "(line in (1,8,10))#time(10) as RS where waverId is not null group by line having avg(age)<0 output every 10.0d seconds order by line",
                    model.ToEPL());
                SerializableObjectCopier.CopyMayFail(env.Container, model);
            }
Beispiel #13
0
        public void DelecteDataPointHistoryValueBefore(int dayAgo)
        {
            if (null != this.dataPointHistoryDataRepository)
            {
                try
                {
                    Query query = new Query();
                    query.AddCriterion(Criterion.Create <DataPointHistoryData>(p => p.DateTime, DateTime.Now.AddDays(-dayAgo), CriteriaOperator.LessThan));
                    query.OrderByProperty = OrderByClause.Create <DataPointHistoryData>(p => p.DateTime, false);

                    this.dataPointHistoryDataRepository.Remove(query);

                    var uwRepository = this.dataPointHistoryDataRepository as IUnitOfWorkRepository;
                    if (uwRepository != null)
                    {
                        uwRepository.UnitOfWork.Commit();
                    }
                }
                catch (Exception)
                {
                    return;
                }
            }
        }