public QueryPageModel <AccountMetaModel> GetAccountMeta(AccountQuery query) { var result = DbFactory.Default.Get <AccountInfo>().LeftJoin <AccountMetaInfo>((ai, ami) => ai.Id == ami.AccountId).Where(a => a.Id == query.AccountId); if (query.StartDate.HasValue) { result.Where(a => a.StartDate >= query.StartDate); } if (query.EndDate.HasValue) { result.Where(a => a.EndDate < query.EndDate); } result = result.Select <AccountMetaInfo>(p => new { AccountId = p.AccountId, Id = p.Id, EndDate = p.ServiceEndTime, StartDate = p.ServiceStartTime, MetaKey = p.MetaKey, MetaValue = p.MetaValue }); var metaInfo = result.ToPagedList <AccountMetaModel>(query.PageNo, query.PageSize); return(new QueryPageModel <AccountMetaModel>() { Models = metaInfo, Total = metaInfo.TotalRecordCount }); }
public QueryPageModel <AccountInfo> GetAccounts(AccountQuery query) { //IQueryable<AccountInfo> complaints = Context.AccountInfo.AsQueryable(); var complaints = DbFactory.Default.Get <AccountInfo>(); #region 条件组合 if (query.Status.HasValue) { complaints.Where(item => query.Status == item.Status); } if (query.ShopId.HasValue) { complaints.Where(item => query.ShopId == item.ShopId); } if (!string.IsNullOrEmpty(query.ShopName)) { complaints.Where(item => item.ShopName.Contains(query.ShopName)); } #endregion //int total; //complaints = complaints.GetPage(d => d.OrderByDescending(o => o.Id), out total, query.PageNo, query.PageSize); var models = complaints.OrderByDescending(o => o.Id).ToPagedList(query.PageNo, query.PageSize); QueryPageModel <AccountInfo> pageModel = new QueryPageModel <AccountInfo>() { Models = models, Total = models.TotalRecordCount }; return(pageModel); }
public async Task GetAccountCachesAccountReturnedFromStoreTest() { var provider = Guid.NewGuid().ToString(); var username = Guid.NewGuid().ToString(); var user = Model.CreateWith <User>(provider + "|" + username); var expected = Model.Create <AccountResult>().Set(x => x.IsNewAccount = false); var accountStore = Substitute.For <IAccountStore>(); var profileStore = Substitute.For <IProfileStore>(); var accountCache = Substitute.For <IAccountCache>(); var profileCache = Substitute.For <IProfileCache>(); var sut = new AccountQuery(accountStore, profileStore, accountCache, profileCache); using (var tokenSource = new CancellationTokenSource()) { accountStore.GetAccount(provider, username, tokenSource.Token).Returns(expected); await sut.GetAccount(user, tokenSource.Token).ConfigureAwait(false); accountCache.Received().StoreAccount(expected); profileCache.DidNotReceive().StoreProfile(Arg.Any <Profile>()); await profileStore.DidNotReceive().StoreProfile(Arg.Any <Profile>(), Arg.Any <CancellationToken>()) .ConfigureAwait(false); } }
public async Task GetAccountCachesCreatedProfileWhenNewAccountCreatedTest() { var provider = Guid.NewGuid().ToString(); var username = Guid.NewGuid().ToString(); var user = Model.CreateWith <User>(provider + "|" + username); var account = Model.Create <AccountResult>().Set(x => x.IsNewAccount = true); var accountStore = Substitute.For <IAccountStore>(); var profileStore = Substitute.For <IProfileStore>(); var accountCache = Substitute.For <IAccountCache>(); var profileCache = Substitute.For <IProfileCache>(); var sut = new AccountQuery(accountStore, profileStore, accountCache, profileCache); using (var tokenSource = new CancellationTokenSource()) { accountStore.GetAccount(provider, username, tokenSource.Token).Returns(account); var actual = await sut.GetAccount(user, tokenSource.Token).ConfigureAwait(false); profileCache.Received(1).StoreProfile(Arg.Any <Profile>()); profileCache.Received().StoreProfile(Arg.Is <Profile>(x => x.Id == actual.Id)); profileCache.Received().StoreProfile(Arg.Is <Profile>(x => x.Email == user.Email)); profileCache.Received().StoreProfile(Arg.Is <Profile>(x => x.FirstName == user.FirstName)); profileCache.Received().StoreProfile(Arg.Is <Profile>(x => x.LastName == user.LastName)); } }
public PageModel <AccountPurchaseAgreementInfo> GetAccountPurchaseAgreements(AccountQuery query) { int num; IQueryable <AccountPurchaseAgreementInfo> accountPurchaseAgreementInfo = from item in context.AccountPurchaseAgreementInfo where item.AccountId == query.AccountId select item; if (query.StartDate.HasValue) { accountPurchaseAgreementInfo = from item in accountPurchaseAgreementInfo where item.Date >= query.StartDate select item; } if (query.EndDate.HasValue) { accountPurchaseAgreementInfo = from item in accountPurchaseAgreementInfo where item.Date < query.EndDate select item; } accountPurchaseAgreementInfo = accountPurchaseAgreementInfo.GetPage(out num, query.PageNo, query.PageSize, null); return(new PageModel <AccountPurchaseAgreementInfo>() { Models = accountPurchaseAgreementInfo, Total = num }); }
public static DataTable TransactionSelectedDataControl(int a) { int selectedIndex = a; DataTable dt = AccountQuery.TransactionTable(selectedIndex); return(dt); }
public void AccountQueryConstructorTest() { const string baseUri = "http://www.test.com/"; AccountQuery target = new AccountQuery(baseUri); Assert.AreEqual(target.Uri, new Uri(baseUri)); }
public ObsoletePageModel <AccountMetaModel> GetAccountMeta(AccountQuery query) { var result = (from a in Context.AccountInfo join b in Context.AccountMetaInfo on a.Id equals b.AccountId where (!query.StartDate.HasValue || a.StartDate >= query.StartDate) && (!query.EndDate.HasValue || a.EndDate < query.EndDate) && a.Id == query.AccountId select new AccountMetaModel { AccountId = a.Id, Id = b.Id, EndDate = b.ServiceEndTime, StartDate = b.ServiceStartTime, MetaKey = b.MetaKey, MetaValue = b.MetaValue }); int total; var metaInfo = result.FindBy(item => true, query.PageNo, query.PageSize, out total, item => item.Id, false); ObsoletePageModel <AccountMetaModel> pageModel = new ObsoletePageModel <AccountMetaModel>() { Models = metaInfo, Total = total }; return(pageModel); }
public JsonResult MetaDetailList(long accountId, int enumOrderTypeId, DateTime?startDate, DateTime?endDate, int page, int rows) { AccountQuery accountQuery = new AccountQuery() { StartDate = startDate, EndDate = (endDate.HasValue ? new DateTime?(endDate.Value.AddDays(1)) : endDate), AccountId = accountId, PageSize = rows, PageNo = page }; PageModel <AccountMetaModel> accountMeta = ServiceHelper.Create <IAccountService>().GetAccountMeta(accountQuery); IEnumerable <AccountMetaModel> list = from e in accountMeta.Models.ToList() select new AccountMetaModel() { AccountId = e.Id, Id = e.Id, EndDate = e.EndDate, StartDate = e.StartDate, MetaKey = e.MetaKey, MetaValue = e.MetaValue, DateRange = string.Concat(e.StartDate.ToString("yyyy-MM-dd"), " 至 ", e.EndDate.ToString("yyyy-MM-dd")) }; return(Json(new { rows = list, total = accountMeta.Total })); }
public PageModel <AccountDetailInfo> GetAccountDetails(AccountQuery query) { int num; IQueryable <AccountDetailInfo> accountDetailInfo = from item in context.AccountDetailInfo where (int)item.OrderType == (int)query.EnumOrderType && item.AccountId == query.AccountId select item; if (query.StartDate.HasValue) { accountDetailInfo = from item in accountDetailInfo where item.Date >= query.StartDate select item; } if (query.EndDate.HasValue) { accountDetailInfo = from item in accountDetailInfo where item.Date < query.EndDate select item; } accountDetailInfo = accountDetailInfo.GetPage(out num, query.PageNo, query.PageSize, null); return(new PageModel <AccountDetailInfo>() { Models = accountDetailInfo, Total = num }); }
public JsonResult DetailList(long accountId, int enumOrderTypeId, DateTime?startDate, DateTime?endDate, int page, int rows) { var queryModel = new AccountQuery() { StartDate = startDate, EndDate = endDate.HasValue ? endDate.Value.AddDays(1) : endDate, AccountId = accountId, PageSize = rows, EnumOrderType = (Entities.AccountDetailInfo.EnumOrderType)enumOrderTypeId, PageNo = page }; var accountDetails = AccountApplication.GetAccountDetails(queryModel); var result = (from p in accountDetails.Models select new { p.Id, p.OrderType, OrderTypeDescription = p.OrderType.ToDescription(), p.OrderId, p.ProductActualPaidAmount, p.FreightAmount, p.CommissionAmount, p.RefundCommisAmount, p.BrokerageAmount, p.ReturnBrokerageAmount, p.RefundTotalAmount, Date = p.Date.ToString(), OrderDate = p.OrderDate.ToString(), p.OrderRefundsDates }).ToList(); return(Json(new { rows = result, total = accountDetails.Total })); }
public JsonResult DetailList(long accountId, int enumOrderTypeId, DateTime?startDate, DateTime?endDate, int page, int rows) { var queryModel = new AccountQuery() { StartDate = startDate, EndDate = endDate.HasValue ? endDate.Value.AddDays(1) : endDate, AccountId = accountId, PageSize = rows, EnumOrderType = (AccountDetailInfo.EnumOrderType)enumOrderTypeId, PageNo = page, ShopId = CurrentSellerManager.ShopId }; ObsoletePageModel <AccountDetailInfo> accountDetails = _iAccountService.GetAccountDetails(queryModel); var accountDetailsModel = (from p in accountDetails.Models.ToList() select new { p.Id, p.OrderType, OrderTypeDescription = p.OrderType.ToDescription(), p.OrderId, p.ProductActualPaidAmount, p.FreightAmount, p.CommissionAmount, p.RefundCommisAmount, p.RefundTotalAmount, Date = p.Date.ToString(), OrderDate = p.OrderDate.ToString(), p.OrderRefundsDates }); return(Json(new { rows = accountDetailsModel, total = accountDetails.Total })); }
private void query_QueryResponse(object sender, QueryResponseEventArgs e) { if (e.ResponseEventType.Equals(QueryResponseEventType.Error)) { Error(e.Errors[0]); } else { AccountQuery query = sender as AccountQuery; // Request more data if (query != null) { if (query.State == QueryState.MoreImagesAvailable) { query.RequestMoreData(); } } // Consume data BindingList <Account> list = this.query.GetList(); foreach (Account account in list) { this.Output += account.AccountCode; } OnPropertyChanged(new PropertyChangedEventArgs("Output")); } }
public ObsoletePageModel <AccountInfo> GetAccounts(AccountQuery query) { IQueryable <AccountInfo> complaints = Context.AccountInfo.AsQueryable(); #region 条件组合 if (query.Status.HasValue) { complaints = complaints.Where(item => query.Status == item.Status); } if (query.ShopId.HasValue) { complaints = complaints.Where(item => query.ShopId == item.ShopId); } if (!string.IsNullOrEmpty(query.ShopName)) { complaints = complaints.Where(item => item.ShopName.Contains(query.ShopName)); } #endregion int total; complaints = complaints.GetPage(out total, query.PageNo, query.PageSize); ObsoletePageModel <AccountInfo> pageModel = new ObsoletePageModel <AccountInfo>() { Models = complaints, Total = total }; return(pageModel); }
public PageModel <AccountInfo> GetAccounts(AccountQuery query) { int num; IQueryable <AccountInfo> status = context.AccountInfo.AsQueryable <AccountInfo>(); if (query.Status.HasValue) { status = from item in status where (int?)query.Status == (int?)item.Status select item; } if (query.ShopId.HasValue) { status = from item in status where query.ShopId == item.ShopId select item; } if (!string.IsNullOrEmpty(query.ShopName)) { status = from item in status where item.ShopName.Contains(query.ShopName) select item; } status = status.GetPage(out num, query.PageNo, query.PageSize, null); return(new PageModel <AccountInfo>() { Models = status, Total = num }); }
/// <summary> /// Test Find using the Query class /// </summary> private void Step_30_TestFindByQuery_Generated() { using (TransactionManager tm = CreateTransaction()) { //Insert Mock Instance Account mock = CreateMockInstance(tm); bool result = DataRepository.AccountProvider.Insert(tm, mock); Assert.IsTrue(result, "Could Not Test FindByQuery, Insert Failed"); AccountQuery query = new AccountQuery(); query.AppendEquals(AccountColumn.Branch, mock.Branch.ToString()); query.AppendEquals(AccountColumn.AccountId, mock.AccountId.ToString()); query.AppendEquals(AccountColumn.Abbreviat, mock.Abbreviat.ToString()); query.AppendEquals(AccountColumn.MofGl, mock.MofGl.ToString()); query.AppendEquals(AccountColumn.CustId, mock.CustId.ToString()); query.AppendEquals(AccountColumn.Name, mock.Name.ToString()); query.AppendEquals(AccountColumn.OpenDate, mock.OpenDate.ToString()); query.AppendEquals(AccountColumn.PrevDate, mock.PrevDate.ToString()); query.AppendEquals(AccountColumn.LastDate, mock.LastDate.ToString()); query.AppendEquals(AccountColumn.Creamt, mock.Creamt.ToString()); query.AppendEquals(AccountColumn.Debamt, mock.Debamt.ToString()); query.AppendEquals(AccountColumn.Status, mock.Status.ToString()); TList <Account> results = DataRepository.AccountProvider.Find(tm, query); Assert.IsTrue(results.Count == 1, "Find is not working correctly. Failed to find the mock instance"); } }
void BindData() { List <ViewItem> items = new List <ViewItem>(); List <Department> dts = null; List <Account> acts = null; AccountQuery aq = new AccountQuery(); aq.KeyWord = Keyword; aq.SiteID = SiteID; aq.UserType = (int)CurrentState; UPager.PageIndex = PageNumber; UPager.ItemCount = AccountHelper.QueryAccountCountByQuery(aq); UPager.UrlFormat = We7Helper.AddParamToUrl(Request.RawUrl, Keys.QRYSTR_PAGEINDEX, "{0}"); UPager.PrefixText = "共 " + UPager.MaxPages + " 页 · 第 " + UPager.PageIndex + " 页 · "; acts = AccountHelper.QueryAccountsByQuery(aq, UPager.Begin - 1, UPager.Count, new string[] { "ID", "LoginName", "Email", "CreatedNoteTime", "EmailValidate", "ModelState", "ModelName", "State", "Created", "UserType", "Department" }); if (acts != null) { foreach (Account act in acts) { ViewItem vi = new ViewItem(); vi.Text = "<b>" + act.LoginName + "</b> " + act.LastName + ""; vi.Summary = act.Department; vi.Mode = "User"; vi.State = act.TypeText; vi.Url = String.Format("AccountEdit.aspx?id={0}", act.ID); vi.DeleteUrl = String.Format("javascript:DeleteConfirm('{0}','{1}','Account');", act.ID, act.LoginName); vi.EditUrl = String.Format("AccountEdit.aspx?id={0}", act.ID); string mng = @"<a href=""AccountEdit.aspx?id={0}&tab=2""> 角色设置</a> <a href=""AccountEdit.aspx?id={0}&tab=6""> 模块权限</a> "; vi.ManageLinks = string.Format(mng, act.ID); vi.ID = act.ID; vi.RegisterDate = act.Created.ToLongDateString(); if (DepartmentID != We7Helper.EmptyGUID) { if (act.DepartmentID == DepartmentID) { items.Add(vi); } } else { if (act.DepartmentID == We7Helper.EmptyGUID) { items.Add(vi); } } } } AccountsGridView.DataSource = items; AccountsGridView.DataBind(); }
public FileResult AgreementDetailListExportExcel(long accountId, int enumOrderTypeId, DateTime?startDate, DateTime?endDate) { var queryModel = new AccountQuery() { StartDate = startDate, EndDate = endDate.HasValue ? endDate.Value.AddDays(1) : endDate, AccountId = accountId, PageSize = int.MaxValue, PageNo = 1 }; QueryPageModel <DTO.AccountMetaModel> pageModelMetaInfo = AccountApplication.GetAccountMeta(queryModel); var mode = pageModelMetaInfo.Models.ToList().Select(e => new DTO.AccountMetaModel { AccountId = e.Id, Id = e.Id, EndDate = e.EndDate, StartDate = e.StartDate, MetaKey = e.MetaKey, MetaValue = e.MetaValue, DateRange = e.StartDate.ToString("yyyy-MM-dd") + " 至 " + e.EndDate.ToString("yyyy-MM-dd") }).ToList(); //创建Excel文件的对象 NPOI.HSSF.UserModel.HSSFWorkbook book = new NPOI.HSSF.UserModel.HSSFWorkbook(); //添加一个sheet ISheet sheet1 = book.CreateSheet("Sheet1"); //获取list数据 //给sheet1添加第一行的头部标题 IRow row1 = sheet1.CreateRow(0); row1.CreateCell(0).SetCellValue("类型"); row1.CreateCell(1).SetCellValue("营销类型"); row1.CreateCell(2).SetCellValue("费用"); row1.CreateCell(3).SetCellValue("服务周期"); sheet1.SetColumnWidth(0, 550 * 5); sheet1.SetColumnWidth(1, 550 * 20); sheet1.SetColumnWidth(2, 550 * 8); sheet1.SetColumnWidth(3, 550 * 15); //将数据逐步写入sheet1各个行 for (int i = 0; i < mode.Count(); i++) { IRow rowtemp = sheet1.CreateRow(i + 1); rowtemp.CreateCell(0).SetCellValue("营销服务费"); rowtemp.CreateCell(1).SetCellValue(mode[i].MetaKey); rowtemp.CreateCell(2).SetCellValue(mode[i].MetaValue); rowtemp.CreateCell(3).SetCellValue(mode[i].DateRange); } // 写入到客户端 System.IO.MemoryStream ms = new System.IO.MemoryStream(); book.Write(ms); ms.Seek(0, SeekOrigin.Begin); return(File(ms, "application/vnd.ms-excel", "结算详情-营销服务费列表.xls")); }
public AccountsReadModel Search(AccountQuery accountQuery) { return(new AccountsReadModel( _items .Skip(accountQuery.Skip) .Take(accountQuery.Take) .Select(f => new AccountReadModel(f)))); }
public void EmptyQueryTest() { const string result = "http://www.test.com/"; AccountQuery target = new AccountQuery(); target.BaseAddress = result; Assert.AreEqual(new Uri(result), target.Uri); }
public async Task <ActionResult> GetAccount(string id, [FromQuery] AccountQuery accountQuery) { var accounts = await _accountService.GetAccount(id); var selectedAccountData = _accountPropertySelector.SelectPropertiesToReturn(accounts, accountQuery.Fields, accountQuery.IncludeFields); return(Ok(selectedAccountData.FirstOrDefault())); }
public FrmOrderAccount(long deptId, string chineseName, string belongSystem) { InitializeComponent(); _deptId = (int)deptId; _belongSystem = belongSystem; _accountQuery = AccountFactory.GetQuery(belongSystem); this.Text = chineseName; }
public ActionResult List(AccountQuery query) { var list = this.AccountRepository.GetList(query); var data = list.Data.Select(c => AccountModel.From(c)).ToList(); var result = new { total = list.RecordCount, rows = data }; return(Json(result)); }
public JsonResult GetAccounts(AccountQuery q) { //string sqlWhere = $"Name like '%{q.Name}%'"; string sqlWhere = q.Name == null ? "" : $"Name like '%{ q.Name}%'"; var accounts = _accountsRepository.GetPage(q.PageIndex, q.PageSize, null, sqlWhere); return(JsonToDataTables(accounts)); }
public bool Matches(AccountQuery query) { return((!string.IsNullOrEmpty(query.CheckNumber) && query.CheckNumber == CheckNumber) || (!string.IsNullOrEmpty(query.BankAccount) && query.BankAccount == BankAccount) || (!string.IsNullOrEmpty(query.Description) && query.Description == Description) || (query.ClearedDate.HasValue && query.ClearedDate == ClearedDate) || (query.SentDate.HasValue && query.SentDate == SentDate) || (query.CheckAmount.HasValue && query.CheckAmount == CheckAmount)); }
public FrmMonthAccount(string belongSystem, long currentUser, long currentDept) { _belongSystem = belongSystem; _monthAccount = AccountFactory.GetMonthBalancer(belongSystem); _accountQuery = AccountFactory.GetQuery(belongSystem); _currentUser = currentUser; _currentDept = currentDept; InitializeComponent(); }
public FrmIOSQuery(long currentUser, long currentDept, string chineseName, string belongSystem) { _currentUser = currentUser; _currentDept = currentDept; _chineseName = chineseName; _belongSystem = belongSystem; _accountQuery = AccountFactory.GetQuery(belongSystem); InitializeComponent(); }
public void StartDateTest() { AccountQuery target = new AccountQuery(); DateTime expected = DateTime.Now; DateTime actual; target.StartDate = expected; actual = target.StartDate; Assert.AreEqual(expected, actual); }
public static void ClassInit(TestContext testContext) { CreateOrg(); query = new AccountQuery(context); easyJet = context.Accounts.Single(a => a.Name == "easyJet"); deleteAllTestAccounts(); }
public void QueryTest() { AccountQuery target = new AccountQuery(); string expected = "TestValue"; string actual; target.Query = expected; actual = target.Query; Assert.AreEqual(expected, actual); }
/// <summary> /// Bind grid /// </summary> public void Bind() { AccountService accountService = new AccountService(); AccountQuery filters = new AccountQuery(); //check Login id if (UserID.Text.Trim().Length > 0) { MembershipUser user = Membership.GetUser(UserID.Text.Trim()); if (user != null) { filters.AppendEquals(AccountColumn.UserID, user.ProviderUserKey.ToString()); } else { filters.AppendEquals(AccountColumn.UserID, UserID.Text.Trim()); } } //check OrderID if (OrderID.Text.Trim().Length > 0) { int orderID = int.Parse(OrderID.Text.Trim()); OrderService _orderService = new OrderService(); Order entity = _orderService.GetByOrderID(orderID); if (entity != null) { filters.AppendEquals(AccountColumn.AccountID, entity.AccountID.Value.ToString()); } else { filters.AppendEquals(AccountColumn.AccountID, "0"); } } //Filter query filters.Append(AccountColumn.BillingFirstName,"%" + FirstName.Text.Trim() + "%"); filters.Append(AccountColumn.BillingLastName, "%" + LastName.Text.Trim() + "%"); filters.Append(AccountColumn.BillingPostalCode, "%" + ZipCode.Text.Trim() + "%"); filters.Append(AccountColumn.BillingCompanyName, "%" + CompanyName.Text.Trim() + "%"); //get account list TList<Account> accountList = accountService.Find(filters.GetParameters()); if (accountList != null) { if (accountList.Count == 0) { lblSearhError.Text = "No users found."; } } else { lblSearhError.Text = "No users found."; } //Bind account list grid ui_FoundUsers.DataSource = accountList; ui_FoundUsers.DataBind(); }
public AccountQueryTest() { TestEnvironment.Init(); query = new AccountQuery(); }
public IHttpActionResult Get(AccountQuery query) { return Ok(_cardAccountService.GetCardAccounts(query)); }
public IPagedList<CardAccountBriefModel> GetCardAccounts(AccountQuery query) { EnsureIsValid(query); try { var accounts = _deps.CardAccounts.QueryPage(query.ToDbQuery<CardAccount>()); return accounts.Map<CardAccountBriefModel>(); } catch (Exception ex) { throw new ServiceException("Cannot get card accounts.", ex); } }