Esempio n. 1
0
        /// <summary>
        /// 月销售情况报表
        /// </summary>
        /// <param name="filter">条件</param>
        /// <returns></returns>
        public static StatementResult <ArrayList> MonthSalesData(MonthSalesFilter filter)
        {
            StatementResult <ArrayList> result = new StatementResult <ArrayList>();

            result.ServicePageIndex = filter.ServicePageIndex;
            result.PageSize         = filter.PageSize;

            PagingInfoEntity  page = DataAccessUtil.ToPagingInfo(filter);
            CustomDataCommand cmd  = DataCommandManager.CreateCustomDataCommandFromConfig("MonthSalesData");

            using (var sqlBuilder = new DynamicQuerySqlBuilder(cmd.CommandText, cmd, page, "LogDate DESC"))
            {
                DateTime beginDate = DateTime.Parse(string.Format("{0}-{1}-01", filter.Year, filter.Month));
                sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "LogDate", DbType.DateTime,
                                                             "@BeginLogDate", QueryConditionOperatorType.MoreThanOrEqual, beginDate);
                DateTime endDate = beginDate.AddMonths(1);
                sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "LogDate", DbType.DateTime,
                                                             "@EndLogDate", QueryConditionOperatorType.LessThan, endDate);

                cmd.CommandText   = sqlBuilder.BuildQuerySql();
                result.Result     = DbHelper.DatatableConvertArrayList(cmd.ExecuteDataTable());
                result.TotalCount = Convert.ToInt32(cmd.GetParameterValue("@TotalCount"));
                result.TotalValue = Convert.ToDecimal(cmd.GetParameterValue("@TotalAmount"));

                return(result);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 月销售情况报表
        /// </summary>
        /// <param name="filter">条件</param>
        /// <returns></returns>
        public static StatementResult<ArrayList> MonthSalesData(MonthSalesFilter filter)
        {
            StatementResult<ArrayList> result = new StatementResult<ArrayList>();
            result.ServicePageIndex = filter.ServicePageIndex;
            result.PageSize = filter.PageSize;

            PagingInfoEntity page = DataAccessUtil.ToPagingInfo(filter);
            CustomDataCommand cmd = DataCommandManager.CreateCustomDataCommandFromConfig("MonthSalesData");
            using (var sqlBuilder = new DynamicQuerySqlBuilder(cmd.CommandText, cmd, page, "LogDate DESC"))
            {
                DateTime beginDate = DateTime.Parse(string.Format("{0}-{1}-01", filter.Year, filter.Month));
                sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "LogDate", DbType.DateTime,
                    "@BeginLogDate", QueryConditionOperatorType.MoreThanOrEqual, beginDate);
                DateTime endDate = beginDate.AddMonths(1);
                sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "LogDate", DbType.DateTime,
                    "@EndLogDate", QueryConditionOperatorType.LessThan, endDate);

                cmd.CommandText = sqlBuilder.BuildQuerySql();
                result.Result = DbHelper.DatatableConvertArrayList(cmd.ExecuteDataTable());
                result.TotalCount = Convert.ToInt32(cmd.GetParameterValue("@TotalCount"));
                result.TotalValue = Convert.ToDecimal(cmd.GetParameterValue("@TotalAmount"));

                return result;
            }
        }
 public void ShouldReturnRecords()
 {
     var recordYielder = new TestRecordYielder(5, 10, _output);
     var cursor = new StatementResult( TestRecordYielder.Keys, new FuncBasedRecordSet(() => recordYielder.RecordsWithAutoLoad));
     var records = cursor.ToList();
     records.Count.Should().Be(10);
 }
Esempio n. 4
0
        /// <summary>
        /// Test creates a situation where streaming of a node fails when accessing node labels/properties.
        /// It fails because transaction is terminated. Bolt server should not send half-written message.
        /// Driver should receive a regular FAILURE message saying that transaction has been terminated.
        /// </summary>
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldTransmitStreamingFailure()
        public virtual void ShouldTransmitStreamingFailure()
        {
            using (Session session = _driver.session())
            {
                IDictionary <string, object> @params = new Dictionary <string, object>();
                @params["name1"] = RandomLongString();
                @params["name2"] = RandomLongString();
                session.run("CREATE (n1 :Person {name: $name1}), (n2 :Person {name: $name2}) RETURN n1, n2", @params).consume();

                StatementResult result = session.run("CALL test.readNodesReturnThemAndTerminateTheTransaction() YIELD node");

                assertTrue(result.hasNext());
                Record record = result.next();
                assertEquals("Person", Iterables.single(record.get(0).asNode().labels()));
                assertNotNull(record.get(0).asNode().get("name"));

                try
                {
                    result.hasNext();
                    fail("Exception expected");
                }
                catch (TransientException e)
                {
                    assertEquals(Org.Neo4j.Kernel.Api.Exceptions.Status_Transaction.Terminated.code().serialize(), e.code());
                }
            }
        }
Esempio n. 5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void mixingPeriodicCommitAndLoadCSVShouldWorkWithMapsWithinMaps() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void MixingPeriodicCommitAndLoadCSVShouldWorkWithMapsWithinMaps()
        {
            using (Driver driver = GraphDatabase.driver(GraphDb.boltURI(), Configuration()), Session session = driver.session())
            {
                StatementResult result       = session.run("USING PERIODIC COMMIT " + (_lineCountInCSV - 1) + "\n" + "LOAD CSV FROM \"" + _url + "\" as row fieldterminator \" \"\n" + "MERGE (currentnode:Label5 {uuid:row[0]})\n" + "RETURN {outer:{node:currentnode}};");
                int             countOfNodes = 0;
                while (result.hasNext())
                {
                    IEnumerator <KeyValuePair <string, object> > iterator = result.next().get(0).asMap().entrySet().GetEnumerator();
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                    assertTrue(iterator.hasNext());
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                    iterator = ((IDictionary <string, object>)iterator.next().Value).SetOfKeyValuePairs().GetEnumerator();
                    while (iterator.MoveNext())
                    {
                        KeyValuePair <string, object> entry = iterator.Current;
                        assertEquals("node", entry.Key);
                        Node node = ( Node )entry.Value;
                        assertTrue(node.hasLabel("Label5"));
                        assertEquals(countOfNodes.ToString(), node.get("uuid").asString());
                        countOfNodes++;
                    }
                }

                assertEquals(_lineCountInCSV, countOfNodes);
            }
        }
Esempio n. 6
0
        private StatementResult CreateRandomSingersResults(int count)
        {
            var rows = new List <object[]>(count);

            for (int row = 0; row < count; row++)
            {
                var date    = new SpannerDate(_random.Next(1900, 2020), _random.Next(1, 13), _random.Next(1, 29));
                var picture = new byte[_random.Next(1, 4097)];
                _random.NextBytes(picture);
                rows.Add(new object[] { 1L, date.ToString(), "Alice", "Alice Morrison", "Morrison", ByteString.CopyFrom(picture).ToBase64() });
            }

            return(StatementResult.CreateResultSet(
                       new List <Tuple <V1.TypeCode, string> >
            {
                Tuple.Create(V1.TypeCode.Int64, "SingerId"),
                Tuple.Create(V1.TypeCode.Date, "BirthDate"),
                Tuple.Create(V1.TypeCode.String, "FirstName"),
                Tuple.Create(V1.TypeCode.String, "FullName"),
                Tuple.Create(V1.TypeCode.String, "LastName"),
                Tuple.Create(V1.TypeCode.Bytes, "Picture"),
            },
                       rows
                       ));
        }
            public void ShouldSetKeysProperlyIfKeysNotNull()
            {
                var result = new StatementResult(new string[] { "test" }, new ListBasedRecordSet(new List <IRecord>()));

                result.Keys.Should().HaveCount(1);
                result.Keys.Should().Contain("test");
            }
 public void ShouldReturnRecordsImmediatelyWhenReady()
 {
     var recordYielder = new TestRecordYielder(5, 10, _output);
     var result = new StatementResult(TestRecordYielder.Keys, new FuncBasedRecordSet(() => recordYielder.Records));
     var temp = result.Take(5);
     var records = temp.ToList();
     records.Count.Should().Be(5);
 }
Esempio n. 9
0
 internal virtual void AssertWriteSucceeds(Driver driver)
 {
     using (Session session = driver.session())
     {
         StatementResult result = session.run("CREATE ()");
         assertThat(result.summary().counters().nodesCreated(), CoreMatchers.equalTo(1));
     }
 }
Esempio n. 10
0
 private static object SendAndReceive(object value)
 {
     using (Session session = _driver.session())
     {
         StatementResult result = session.run("RETURN $value", parameters("value", value));
         Record          record = result.single();
         return(record.get(0).asObject());
     }
 }
Esempio n. 11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void calls_simplistic_procedure()
        public virtual void CallsSimplisticProcedure()
        {
            using (Driver driver = GraphDatabase.driver(GraphDb.boltURI(), Configuration()), Session session = driver.session())
            {
                StatementResult result = session.run("CALL " + _procedureNamespace + ".theAnswer()");

                assertThat(result.single().get("value").asLong()).isEqualTo(42L);
            }
        }
        /// <summary>
        /// 给分类查询出的用户发送邮件
        /// </summary>
        /// <param name="entity">邮件内容</param>
        public void SendMail(CategoryCustomersSendMail entity)
        {
            if (string.IsNullOrWhiteSpace(entity.MailTitle))
            {
                throw new BusinessException("请输入邮件标题!");
            }
            if (string.IsNullOrWhiteSpace(entity.MailBody))
            {
                throw new BusinessException("请输入邮件内容!");
            }

            QueryCategoryCustomersFilter filter = new QueryCategoryCustomersFilter()
            {
                PageIndex = 1,
                PageSize  = 100000000,
                Category  = entity.Category
            };
            StatementResult <ArrayList> queryUsers = QueryCategoryCustomers(filter);

            if (queryUsers != null && queryUsers.Result != null && queryUsers.Result.Count > 0)
            {
                Soho.EmailAndSMS.Service.Entity.EmailEntity mailEntity = new Soho.EmailAndSMS.Service.Entity.EmailEntity();
                mailEntity.Status        = Soho.EmailAndSMS.Service.Entity.EmailStatus.AuditPassed;
                mailEntity.IsBodyHtml    = entity.IsHtmlMail;
                mailEntity.InDate        = DateTime.Now.ToString();
                mailEntity.EmailTitle    = entity.MailTitle;
                mailEntity.EmailPriority = System.Net.Mail.MailPriority.Normal;
                mailEntity.EmailBody     = entity.MailBody;
                List <Soho.EmailAndSMS.Service.Entity.EmailEntity> sendMailList = new List <Soho.EmailAndSMS.Service.Entity.EmailEntity>();

                ArrayList users = queryUsers.Result;
                for (int i = 0; i < users.Count; i++)
                {
                    Dictionary <string, object> item = users[i] as Dictionary <string, object>;
                    foreach (var obj in item)
                    {
                        if (obj.Key.Equals("CustomerID"))
                        {
                            mailEntity.UserSysNo = int.Parse(obj.Value.ToString());
                        }
                        if (obj.Key.Equals("TrueName"))
                        {
                            mailEntity.ReceiveName = obj.Value.ToString();
                        }
                        if (obj.Key.Equals("Email"))
                        {
                            mailEntity.ReceiveAddress = obj.Value.ToString();
                        }
                    }
                    if (!string.IsNullOrEmpty(mailEntity.ReceiveAddress))
                    {
                        sendMailList.Add(mailEntity);
                    }
                }
                EmailAndSMSService.Instance.BatchInsertMail(sendMailList);
            }
        }
            public void ShouldThrowInvalidOperationExceptionIfNoRecordFound()
            {
                var result = new StatementResult(new [] { "test" }, new ListBasedRecordSet(new List <IRecord>()));
                var ex     = Xunit.Record.Exception(() => result.Single());

                ex.Should().BeOfType <InvalidOperationException>();
                // INFO: Changed message because use of Enumerable.Single for simpler implementation
                ex.Message.Should().Be("Sequence contains no elements");
            }
Esempio n. 14
0
        public IEnumerable <T> ExecuteQuery <T>(StatementResult <T> statementList)
        {
            foreach (var query in statementList.StatementList.RootScope.Queries)
            {
                WriteStatement(query);
            }

            return(lastResult.Cast <T>());
        }
Esempio n. 15
0
 private StatementResult CreateFullNameResultSet(string fullName)
 => StatementResult.CreateResultSet(
     new List <Tuple <V1.TypeCode, string> >
 {
     Tuple.Create(V1.TypeCode.String, "FullName"),
 },
     new List <object[]>
 {
     new object[] { fullName },
 }
     );
        private static void Result(StatementResult result)
        {
            if (result.Type == StatementResultType.Exception)
            {
                throw result.Error;
            }

            if (result.Type != StatementResultType.Result)
            {
                throw new InvalidOperationException("Invalid response from statement");
            }
        }
Esempio n. 17
0
        internal QueryResult(SqlQuery query, StatementResult result, bool readAll)
        {
            Query  = query;
            Result = result;

            FormColumns(Result);

            if (readAll && Result.Type == StatementResultType.CursorRef)
            {
                ReadAll();
            }
        }
        private static int GetResult(StatementResult result)
        {
            if (result.Type == StatementResultType.Exception)
            {
                throw result.Error;
            }
            if (result.Type != StatementResultType.Result)
            {
                throw new InvalidOperationException();
            }

            return(GetResult(result.Result));
        }
        /// <summary>
        /// 给分类查询出的用户发送短信
        /// </summary>
        /// <param name="entity">短信内容</param>
        public void SendSMS(CategoryCustomersSendSMS entity)
        {
            if (string.IsNullOrWhiteSpace(entity.SMSBody))
            {
                throw new BusinessException("请输入短信内容!");
            }

            QueryCategoryCustomersFilter filter = new QueryCategoryCustomersFilter()
            {
                PageIndex = 1,
                PageSize  = 100000000,
                Category  = entity.Category
            };
            StatementResult <ArrayList> queryUsers = QueryCategoryCustomers(filter);

            if (queryUsers != null && queryUsers.Result != null && queryUsers.Result.Count > 0)
            {
                Soho.EmailAndSMS.Service.Entity.SMSEntity smsEntity = new Soho.EmailAndSMS.Service.Entity.SMSEntity();
                smsEntity.Status  = Soho.EmailAndSMS.Service.Entity.SMSStatus.AuditPassed;
                smsEntity.InDate  = DateTime.Now.ToString();
                smsEntity.SMSBody = entity.SMSBody;
                List <Soho.EmailAndSMS.Service.Entity.SMSEntity> sendSMSList = new List <Soho.EmailAndSMS.Service.Entity.SMSEntity>();

                ArrayList users = queryUsers.Result;
                for (int i = 0; i < users.Count; i++)
                {
                    Dictionary <string, object> item = users[i] as Dictionary <string, object>;
                    foreach (var obj in item)
                    {
                        if (obj.Key.Equals("CustomerID"))
                        {
                            smsEntity.UserSysNo = int.Parse(obj.Value.ToString());
                        }
                        if (obj.Key.Equals("TrueName"))
                        {
                            smsEntity.ReceiveName = obj.Value.ToString();
                        }
                        if (obj.Key.Equals("ComMobile"))
                        {
                            smsEntity.ReceivePhoneNumber = obj.Value.ToString();
                        }
                    }
                    if (!string.IsNullOrEmpty(smsEntity.ReceivePhoneNumber))
                    {
                        sendSMSList.Add(smsEntity);
                    }
                }
                EmailAndSMSService.Instance.BatchInsertSMS(sendSMSList);
            }
        }
Esempio n. 20
0
        public static Variable NizkCombineFunctionResult(StatementResult result, NType resultNType)
        {
            switch (result)
            {
            case StatementResultOneCase ret:
                switch (ret.ExecutionResultType)
                {
                case StatementResultType.Continue:
                case StatementResultType.Break:
                    throw new Exception($"Unexpected \"{ ret.ExecutionResultType.ToString()}\" statement.");

                case StatementResultType.Normal:
                case StatementResultType.Return:

                    Debug.Assert((ret.ExecutionResultType != StatementResultType.Normal) || ret.ReturnVariable == null);
                    if (ret.ReturnVariable != null)
                    {
                        return(ret.ReturnVariable.Assign(resultNType));
                    }

                    if (resultNType == NType.Void)
                    {
                        return(NType.Void.GetEmptyVariable());
                    }
                    else
                    {
                        throw new Exception("Missing \"return\" statement.");
                    }

                default:
                    throw CommonException.AssertFailedException();
                }

            case StatementResultTwoCase ret:
                if (resultNType == NType.Void)
                {
                    return(NType.Void.GetEmptyVariable());
                }

                var trueVar  = NizkCombineFunctionResult(ret.TrueCase, resultNType);
                var falseVar = NizkCombineFunctionResult(ret.FalseCase, resultNType);



                return(NizkConditionVariable(ret.Condition, trueVar, falseVar));

            default:
                throw CommonException.AssertFailedException();
            }
        }
        private static Field GetSingle(StatementResult result)
        {
            if (result.Type == StatementResultType.Exception)
            {
                throw result.Error;
            }

            if (result.Type != StatementResultType.Result)
            {
                throw new InvalidOperationException("The statement has returned a cursor.");
            }

            return(GetSingle(result.Result));
        }
Esempio n. 22
0
        private void InitializeStatementResults(List <VotingByHand> votingByHands)
        {
            this.StatementResults = new List <StatementResult>();
            var firstVotingByHand = votingByHands.FirstOrDefault();

            foreach (var item in firstVotingByHand.VotingByHandLines)
            {
                var lineResult = new StatementResult()
                {
                    Id          = item.StatementId,
                    Description = item.StatementDesc
                };
                StatementResults.Add(lineResult);
            }
        }
Esempio n. 23
0
        public async Task can_get_many_statements_without_attachments()
        {
            // Arrange
            var request = new GetStatementsRequest()
            {
                Agent = new Agent()
                {
                    Name = AGENT_NAME,
                    MBox = new Uri(AGENT_MBOX)
                },
                Verb              = new Uri(VERB),
                ActivityId        = new Uri(ACTIVITY_ID),
                Registration      = REGISTRATION,
                RelatedActivities = true,
                RelatedAgents     = true,
                Since             = DateTimeOffset.Parse(SINCE),
                Until             = DateTimeOffset.Parse(UNTIL),
                Limit             = LIMIT,
                Format            = StatementFormat.Canonical,
                Attachments       = false,
                Ascending         = true
            };

            this._mockHttp
            .When(HttpMethod.Get, this.GetApiUrl("statements"))
            .WithQueryString("agent", AGENT_QS)
            .WithQueryString("verb", VERB)
            .WithQueryString("activity", ACTIVITY_ID)
            .WithQueryString("registration", REGISTRATION.ToString())
            .WithQueryString("related_activities", "true")
            .WithQueryString("related_agents", "true")
            .WithQueryString("since", SINCE)
            .WithQueryString("until", UNTIL)
            .WithQueryString("limit", LIMIT.ToString())
            .WithQueryString("format", "canonical")
            .WithQueryString("ascending", "true")
            .WithHeaders("Accept-Language", "*")
            .Respond(this.GetStatementsResponseMessage());

            // Act
            StatementResult result = await this._client.Statements.GetMany(request);

            // Assert
            result.Should().NotBeNull();
            result.Statements.Should().NotBeNullOrEmpty();
            result.More.Should().Be(new Uri(MORE, UriKind.Relative));
            result.ConsistentThrough.Should().Be(DateTimeOffset.Parse(XAPI_CONSISTENT_THROUGH_VALUE));
        }
Esempio n. 24
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void mixingPeriodicCommitAndLoadCSVShouldWork2()
        public virtual void MixingPeriodicCommitAndLoadCSVShouldWork2()
        {
            using (Driver driver = GraphDatabase.driver(GraphDb.boltURI(), Configuration()), Session session = driver.session())
            {
                StatementResult result       = session.run("USING PERIODIC COMMIT " + (_lineCountInCSV + 1) + "\n" + "LOAD CSV FROM \"" + _url + "\" as row fieldterminator \" \"\n" + "MERGE (currentnode:Label1 {uuid:row[0]})\n" + "RETURN currentnode;");
                int             countOfNodes = 0;
                while (result.hasNext())
                {
                    Node node = result.next().get(0).asNode();
                    assertTrue(node.hasLabel("Label1"));
                    assertEquals(countOfNodes.ToString(), node.get("uuid").asString());
                    countOfNodes++;
                }
                assertEquals(_lineCountInCSV, countOfNodes);
            }
        }
Esempio n. 25
0
        public override IList <StatementResultViewModel> GetResults(IEnumerable <string> columns, IEnumerable <StatementResult> statementResults)
        {
            var type       = StatementViewModelTypeBuilder.BuildTypeForFields(columns.Where(c => c != "StudentFullName"));
            var result     = new List <StatementResultViewModel>();
            var distinctor = new DistinctByStudent();// :D

            if (statementResults != null)
            {
                foreach (var current in statementResults.Distinct(distinctor))
                {
                    var obj = (StatementResultViewModel)Activator.CreateInstance(type);
                    obj.StudentID       = current.StudentID;
                    obj.StudentFullName = current.StudentFullName;
                    result.Add(obj);
                }
                //Get all results.
                //For each column, what is subject and contains subject ID set it's string value, store it in first 'result', that is for current student.
                foreach (var currentResult in statementResults)
                {
                    foreach (var currentColumn in columns.Where(c => c.StartsWith("subject")))
                    {
                        if (currentResult.SubjectID.ToString() == currentColumn.Split(new[] { "subject" }, StringSplitOptions.RemoveEmptyEntries)[0])
                        {
                            type.GetProperty(currentColumn)
                            .SetValue(result.First(c => c.StudentID == currentResult.StudentID), currentResult.MarkValueStringTotal);
                        }
                    }
                }
                //Get all results for this student.
                //If has any 'Blanks' - result will blank.
                //If has any absents or unpasseds(does this word exist, btw? :D ) then result will be 'Unpassed'
                //Else result is average of all subject marks.
                //Aaaand we don't count "Passed".
                foreach (var current in result)
                {
                    var currentStudentResults = statementResults.Where(c => c.StudentID == current.StudentID && c.MarkValue != (sbyte)TechnicalMarkValue.Passed);
                    type.GetProperty("average")
                    .SetValue(current, currentStudentResults.Any(c => c.MarkValue == (sbyte)TechnicalMarkValue.Blank) ?
                              StatementResult.GetMarkValueStringTotal((sbyte)TechnicalMarkValue.Blank) :
                              currentStudentResults.Any(c => c.MarkValue == (sbyte)TechnicalMarkValue.Absent || c.MarkValue == (sbyte)TechnicalMarkValue.Unpassed) ?
                              StatementResult.GetMarkValueStringTotal((sbyte)TechnicalMarkValue.Unpassed) :
                              StatementResult.GetMarkValueStringTotal((sbyte)currentStudentResults.Average(c => c.MarkValue)));
                }
            }
            return(result);
        }
Esempio n. 26
0
        /// <summary>
        /// 查询大于等于30天没登录过的用户
        /// </summary>
        /// <param name="filter">查询条件</param>
        /// <returns></returns>
        public static StatementResult<ArrayList> QueryThirtyDayNotLoginCustomers(QueryCategoryCustomersFilter filter)
        {
            StatementResult<ArrayList> result = new StatementResult<ArrayList>();
            result.ServicePageIndex = filter.ServicePageIndex;
            result.PageSize = filter.PageSize;

            PagingInfoEntity page = DataAccessUtil.ToPagingInfo(filter);
            CustomDataCommand cmd = DataCommandManager.CreateCustomDataCommandFromConfig("QueryThirtyDayNotLoginCustomers");
            using (var sqlBuilder = new DynamicQuerySqlBuilder(cmd.CommandText, cmd, page, "CustomerID DESC"))
            {
                cmd.CommandText = sqlBuilder.BuildQuerySql();
                result.Result = DbHelper.DatatableConvertArrayList(cmd.ExecuteDataTable());
                result.TotalCount = Convert.ToInt32(cmd.GetParameterValue("@TotalCount"));

                return result;
            }
        }
Esempio n. 27
0
        /// <summary>
        /// 查询近7天未下过订单的用户
        /// </summary>
        /// <param name="filter">查询条件</param>
        /// <returns></returns>
        public static StatementResult <ArrayList> QuerySevenDayNotHaveOrder(QueryCategoryCustomersFilter filter)
        {
            StatementResult <ArrayList> result = new StatementResult <ArrayList>();

            result.ServicePageIndex = filter.ServicePageIndex;
            result.PageSize         = filter.PageSize;

            PagingInfoEntity  page = DataAccessUtil.ToPagingInfo(filter);
            CustomDataCommand cmd  = DataCommandManager.CreateCustomDataCommandFromConfig("QuerySevenDayNotHaveOrder");

            using (var sqlBuilder = new DynamicQuerySqlBuilder(cmd.CommandText, cmd, page, "CustomerID DESC"))
            {
                cmd.CommandText   = sqlBuilder.BuildQuerySql();
                result.Result     = DbHelper.DatatableConvertArrayList(cmd.ExecuteDataTable());
                result.TotalCount = Convert.ToInt32(cmd.GetParameterValue("@TotalCount"));

                return(result);
            }
        }
Esempio n. 28
0
 private string AddFindSingerResult(string sql)
 {
     SpannerMock.AddOrUpdateStatementResult(sql, StatementResult.CreateResultSet(
                                                new List <Tuple <V1.TypeCode, string> >
     {
         Tuple.Create(V1.TypeCode.Int64, "SingerId"),
         Tuple.Create(V1.TypeCode.Date, "BirthDate"),
         Tuple.Create(V1.TypeCode.String, "FirstName"),
         Tuple.Create(V1.TypeCode.String, "FullName"),
         Tuple.Create(V1.TypeCode.String, "LastName"),
         Tuple.Create(V1.TypeCode.Bytes, "Picture"),
     },
                                                new List <object[]>
     {
         new object[] { 1L, null, "Alice", "Alice Morrison", "Morrison", null },
     }
                                                ));
     return(sql);
 }
Esempio n. 29
0
        async Task <StatementResult> IStatementsApi.GetMany(GetStatementsRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }
            request.Validate();

            var options = new RequestOptions(ENDPOINT);

            this.CompleteOptions(options, request);

            HttpResponseMessage response = await this._client.GetJson(options);

            StatementResult content = await response.Content.ReadAsAsync <StatementResult>(new[] { new StrictJsonMediaTypeFormatter() });

            content.ConsistentThrough = this.GetConsistentThroughHeader(response.Headers);
            return(content);
        }
Esempio n. 30
0
        private static Task AssertGetExpectResults(StatementResult result, int numberExpected, List <object> expectedRecordsValues = null)
        {
            int count = 0;
            var t     = Task.Factory.StartNew(() =>
            {
                // ReSharper disable once LoopCanBeConvertedToQuery
                foreach (var item in result)
                {
                    if (expectedRecordsValues != null)
                    {
                        item.Values.First().Value.Should().Be(expectedRecordsValues[count]);
                    }
                    count++;
                }
                count.Should().Be(numberExpected);
            });

            return(t);
        }
Esempio n. 31
0
        /// <summary>
        /// 用户流失分析报表
        /// </summary>
        /// <param name="filter">条件</param>
        /// <returns></returns>
        public static StatementResult<ArrayList> CustomersLoseAnalyze(CustomersLoseAnalyzeFilter filter)
        {
            StatementResult<ArrayList> result = new StatementResult<ArrayList>();
            result.ServicePageIndex = filter.ServicePageIndex;
            result.PageSize = filter.PageSize;

            PagingInfoEntity page = DataAccessUtil.ToPagingInfo(filter);
            CustomDataCommand cmd = DataCommandManager.CreateCustomDataCommandFromConfig("CustomersLoseAnalyze");
            using (var sqlBuilder = new DynamicQuerySqlBuilder(cmd.CommandText, cmd, page, "LogDate ASC"))
            {
                sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "LogDate", DbType.DateTime,
                    "@LogDate", QueryConditionOperatorType.LessThan, DateTime.Parse(DateTime.Now.AddDays(-1 * filter.Day).ToShortDateString()));

                cmd.CommandText = sqlBuilder.BuildQuerySql();
                result.Result = DbHelper.DatatableConvertArrayList(cmd.ExecuteDataTable());
                result.TotalCount = Convert.ToInt32(cmd.GetParameterValue("@TotalCount"));

                return result;
            }
        }
Esempio n. 32
0
        public async Task can_get_more_statements()
        {
            // Arrange
            var more            = new Uri(MORE, UriKind.Relative);
            var endpointUrl     = new Uri(ENDPOINT_URI);
            var hostUrl         = new Uri(endpointUrl.GetLeftPart(UriPartial.Authority));
            var moreAbsoluteUrl = new Uri(hostUrl, more);

            this._mockHttp
            .When(HttpMethod.Get, moreAbsoluteUrl.ToString())
            .Respond(this.GetStatementsResponseMessage());

            // Act
            StatementResult result = await this._client.Statements.GetMore(more);

            // Assert
            result.Should().NotBeNull();
            result.Statements.Should().NotBeNullOrEmpty();
            result.ConsistentThrough.Should().Be(DateTimeOffset.Parse(XAPI_CONSISTENT_THROUGH_VALUE));
        }
Esempio n. 33
0
        async Task <StatementResult> IStatementsApi.GetMore(Uri more)
        {
            if (more == null)
            {
                throw new ArgumentNullException(nameof(more));
            }
            if (more.IsAbsoluteUri)
            {
                throw new ArgumentException("The URI must be relative", nameof(more));
            }

            string endpoint = $"/{more.ToString().TrimStart('/')}";
            var    options  = new RequestOptions(endpoint);

            HttpResponseMessage response = await this._client.GetJson(options);

            StatementResult content = await response.Content.ReadAsAsync <StatementResult>(new[] { new StrictJsonMediaTypeFormatter() });

            content.ConsistentThrough = this.GetConsistentThroughHeader(response.Headers);
            return(content);
        }