/// <summary> /// 提交问题 /// </summary> /// <param name="openID">用户微信ID</param> /// <param name="eventID">活动ID</param> /// <param name="questionID">问题ID</param> /// <param name="answerID">答案ID</param> public void SubmitQuestions(string openID, string eventID, string questionID, string answerID) { IWhereCondition[] whereCondition = new IWhereCondition[] { new EqualsCondition() { FieldName = "OpenID", Value = openID }, new EqualsCondition() { FieldName = "MarketEventID", Value = eventID }, new EqualsCondition() { FieldName = "QuestionID", Value = questionID } }; var vips = this.Query(whereCondition, null); //添加市场活动问题反馈 if (vips.Length == 0) { MarketQuesAnswerEntity entity = new MarketQuesAnswerEntity() { QuesAnswerID = this.NewGuid(), OpenID = openID, MarketEventID = eventID, QuestionID = questionID, AnswerID = answerID }; this.Create(entity); } }
/// <summary> /// 市场活动签到 /// </summary> /// <param name="openID">用户微信ID</param> /// <param name="eventID">活动ID</param> public void SignIn(string openID, string eventID) { IWhereCondition[] whereCondition = new IWhereCondition[] { new EqualsCondition() { FieldName = "OpenID", Value = openID }, new EqualsCondition() { FieldName = "EventID", Value = eventID } }; var vips = this.Query(whereCondition, null); //用户没有签到,添加签到信息 if (vips.Length == 0) { MarketSignInEntity entity = new MarketSignInEntity() { SignInID = this.NewGuid(), OpenID = openID, EventID = eventID }; this.Create(entity); } }
/// <summary> /// 市场活动购买 /// </summary> /// <param name="openID">用户微信ID</param> /// <param name="eventID">活动ID</param> /// <param name="productName">商品名称</param> /// <param name="purchaseAmount">购买金额</param> public void MarketEventPurchase(string openID, string eventID, string productName, string purchaseAmount) { //根据用户微信ID,获取VIPID IWhereCondition[] whereCondition = new IWhereCondition[] { new EqualsCondition() { FieldName = "WeiXinUserId", Value = openID } }; var vips = new VipBLL(this.CurrentUserInfo).Query(whereCondition, null); string vipID = string.Empty; if (vips.Length > 0) { vipID = vips.FirstOrDefault().VIPID; } //添加商品购买信息 MarketEventResponseEntity entity = new MarketEventResponseEntity() { ReponseID = this.NewGuid(), OpenID = openID, MarketEventID = eventID, VIPID = vipID, ProductName = productName, PurchaseAmount = ToDecimal(purchaseAmount), IsSales = 1 }; this.Create(entity); }
internal WhereCondition(ICondition condition, IWhereCondition andCondition = null, IWhereCondition orCondition = null) { if (condition == null) { throw new ArgumentNullException(nameof(condition)); } this.OrCondition = orCondition; this.Condition = condition; this.AndCondition = andCondition; }
/// <summary> /// Delete items. /// </summary> private void DeleteActivities(IWhereCondition whereCondition) { var activitiesToDelete = ActivityInfoProvider.GetActivities() .Columns("ActivityID", "ActivityType", "ActivityTitle") .Where(whereCondition); foreach (var activity in activitiesToDelete) { var safeLog = HTMLHelper.HTMLEncode(string.Format("{0} - {1}", activity.ActivityTitle, activity.ActivityType)); AddLog(safeLog); ActivityInfoProvider.DeleteActivityInfo(activity); } }
/// <summary> /// Delete items. /// </summary> private void DeleteActivities(IWhereCondition whereCondition) { var activitiesToDelete = ActivityInfoProvider.GetActivities() .Columns("ActivityID", "ActivityType", "ActivityTitle") .Where(whereCondition); foreach (var activity in activitiesToDelete) { LogContext.AppendLine(string.Format("{0} - {1}", activity.ActivityTitle, activity.ActivityType)); ActivityInfoProvider.DeleteActivityInfo(activity); } }
/// <summary> /// 市场活动响应 /// </summary> /// <param name="openID">用户微信ID</param> /// <param name="eventID">活动ID</param> public void MarketEventResponse(string openID, string eventID) { IWhereCondition[] whereCondition = new IWhereCondition[] { new EqualsCondition() { FieldName = "OpenID", Value = openID }, new EqualsCondition() { FieldName = "MarketEventID", Value = eventID } }; var responses = this.Query(whereCondition, null); //用户没有响应活动,添加活动响应信息 if (responses.Length == 0) { //根据用户微信ID,获取VIPID whereCondition = new IWhereCondition[] { new EqualsCondition() { FieldName = "WeiXinUserId", Value = openID } }; var vips = new VipBLL(this.CurrentUserInfo).Query(whereCondition, null); string vipID = string.Empty; if (vips.Length > 0) { vipID = vips.FirstOrDefault().VIPID; } MarketEventResponseEntity entity = new MarketEventResponseEntity() { ReponseID = this.NewGuid(), OpenID = openID, MarketEventID = eventID, VIPID = vipID }; this.Create(entity); } else { //更新活动响应信息 MarketEventResponseEntity entity = new MarketEventResponseEntity() { ReponseID = responses.FirstOrDefault().ReponseID, }; this.Update(entity, false); } }
private void RemoveContacts(What what, IWhereCondition where) { ContactGroupMemberInfoProvider.DeleteContactGroupMembers(where.ToString(true), cgi.ContactGroupID, false, false); switch (what) { case What.All: ShowConfirmation(GetString("om.contact.massaction.removedall")); break; case What.Selected: ShowConfirmation(GetString("om.contact.massaction.removed")); break; } }
public string GetListByOptionType(NameValueCollection rParams, int OptionType) { OptionsDefinedEntity entity = rParams["form"].DeserializeJSONTo <OptionsDefinedEntity>(); if (entity == null) { entity = new OptionsDefinedEntity(); } int pageSize = rParams["limit"].ToInt(); int pageIndex = rParams["page"].ToInt(); IWhereCondition[] pWhereConditions = new IWhereCondition[3]; if (entity != null) { if (entity.Title != null && entity.Title != "") { LikeCondition like = new LikeCondition(); like.FieldName = "Title"; like.HasLeftFuzzMatching = true; like.HasRightFuzzMathing = true; like.Value = entity.Title; pWhereConditions[0] = like; } } EqualsCondition equalCondition = new EqualsCondition(); equalCondition.FieldName = "OptionType"; equalCondition.Value = OptionType; pWhereConditions[1] = equalCondition; EqualsCondition equalCondition2 = new EqualsCondition(); equalCondition2.FieldName = "ClientID"; equalCondition2.Value = CurrentUserInfo.ClientID; pWhereConditions[2] = equalCondition2; OrderBy[] pOrderBys = new OrderBy[1]; OrderBy order = new OrderBy(); order.Direction = OrderByDirections.Asc; order.FieldName = "CreateTime"; pOrderBys[0] = order; PagedQueryResult <OptionsDefinedEntity> entitys = new OptionsDefinedBLL(CurrentUserInfo).PagedQuery(pWhereConditions, pOrderBys, pageSize, pageIndex); return(string.Format("{{\"totalCount\":{1},\"topics\":{0}}}", entitys.Entities.ToJSON(), entitys.RowCount)); }
/// <summary> /// 通过optionname 获取列表,其中 optionname 为必传参数 /// </summary> /// <param name="entity"></param> /// <returns></returns> public OptionsEntity[] GetOptionByName(OptionsEntity entity) { IWhereCondition[] whereCondition = new IWhereCondition[4]; if (!string.IsNullOrEmpty(entity.ClientID) && entity.ClientID != "0") { EqualsCondition Conditioin = new EqualsCondition(); Conditioin.FieldName = "ClientID"; Conditioin.Value = entity.ClientID; whereCondition[0] = Conditioin; } if (entity.OptionName != null && entity.OptionName != "") { EqualsCondition Conditioin = new EqualsCondition(); Conditioin.FieldName = "OptionName"; Conditioin.Value = entity.OptionName; whereCondition[1] = Conditioin; } if (entity.DefinedID > 0) { EqualsCondition Conditioin = new EqualsCondition(); Conditioin.FieldName = "DefinedID"; Conditioin.Value = entity.DefinedID; whereCondition[2] = Conditioin; } MoreThanCondition Conditioin1 = new MoreThanCondition(); Conditioin1.FieldName = "OptionValue"; Conditioin1.Value = 0; Conditioin1.IncludeEquals = false; whereCondition[3] = Conditioin1; OrderBy[] orderByCondition = new OrderBy[2]; OrderBy orderBy = new OrderBy(); orderBy.Direction = OrderByDirections.Asc; orderBy.FieldName = "OptionValue"; orderByCondition[0] = orderBy; OrderBy orderBy2 = new OrderBy(); orderBy2.Direction = OrderByDirections.Asc; orderBy2.FieldName = "CreateTime"; orderByCondition[1] = orderBy2; return(this.PagedQuery(whereCondition, orderByCondition, 1000, 1).Entities); }
/// <summary> /// Checks activity permissions. /// Returns restricted sites condition. /// </summary> private WhereCondition CheckSitePermissions(IWhereCondition whereCondition) { var restrictedSitesCondition = new WhereCondition(); var activitiesSites = ActivityInfoProvider.GetActivities() .Distinct() .Column("ActivitySiteID") .Where(whereCondition); foreach (var activity in activitiesSites) { if (!CurrentUser.IsAuthorizedPerObject(PermissionsEnum.Modify, "om.activity", SiteInfoProvider.GetSiteName(activity.ActivitySiteID))) { SiteInfo notAllowedSite = SiteInfoProvider.GetSiteInfo(activity.ActivitySiteID); AddError(String.Format(GetString("accessdeniedtopage.info"), ResHelper.LocalizeString(notAllowedSite.DisplayName))); restrictedSitesCondition.WhereNotEquals("ActivitySiteID", activity.ActivitySiteID); } } return restrictedSitesCondition; }
private string getSmallClassTermList() { var respObj = new RespData(); try { string reqContent = Request["ReqContent"]; var reqObj = reqContent.DeserializeJSONTo <ReqContent>(); var service = new ReservationServiceSmallClassTermStatusBLL(Default.GetLoggingSession()); IWhereCondition[] whereCondition = new IWhereCondition[] { new EqualsCondition() { FieldName = "reservationServiceId ", Value = reqObj.Special.reservationServiceId }, new EqualsCondition() { FieldName = "reservationServiceBigClassTermId ", Value = reqObj.Special.reservationBigClassTermId }, new EqualsCondition() { FieldName = "StatusID", Value = reqObj.Special.statusId } }; ReservationServiceSmallClassTermStatusEntity[] entities = service.Query(whereCondition, null); respObj.content = string.Format("DataItems:{{{0}}}", entities.ToJSON()); respObj.code = "200"; respObj.description = "操作成功"; ValidLogin(reqObj, respObj); } catch (Exception ex) { //throw ex; respObj.code = "103"; respObj.description = "数据库操作错误"; } string content = respObj.ToJSON(); return(content); }
private void StartNewProcess(What what, IWhereCondition where) { try { string error = String.Empty; int processId = ValidationHelper.GetInteger(hdnIdentifier.Value, 0); switch (what) { case What.All: // Get selected IDs based on where condition var contactIdsQuery = ContactGroupMemberInfo.Provider.Get().Where(where).Column("ContactGroupMemberRelatedID"); var contactsQuery = ContactInfo.Provider.Get().WhereIn("ContactId", contactIdsQuery); error = ExecuteProcess(processId, contactsQuery); break; case What.Selected: var contactIds = gridElem.SelectedItems; var query = ContactInfo.Provider.Get().WhereIn("ContactId", contactIds); error = ExecuteProcess(processId, query); break; } if (String.IsNullOrEmpty(error)) { string confirmation = GetString(what == What.All ? "ma.process.started" : "ma.process.startedselected"); ShowConfirmation(confirmation); } else { ShowError(GetString("ma.process.error"), error); } } catch (Exception ex) { LogAndShowError("Automation", "STARTPROCESS", ex); } }
private string getReservationList() { var respObj = new RespData(); try { string reqContent = Request["ReqContent"]; var reqObj = reqContent.DeserializeJSONTo <ReqContent>(); //TODO:判断登陆 var service = new ReservationServiceScheduleBLL(Default.GetLoggingSession()); IWhereCondition[] whereCondition = new IWhereCondition[] { new EqualsCondition() { FieldName = "a.VIPID", Value = reqObj.Common.userId }, //new EqualsCondition() { FieldName = "a.ReservationStoreID", Value = reqObj.Common.reservationStoreId }, //TODO:维护好状态数据字典 //new EqualsCondition() { FieldName = "a.StatusID", Value = reqObj.Special.statusId } }; ReservationServiceScheduleEntity[] entities = service.QueryAllField(whereCondition, null); respObj.content = string.Format("DataItems:{{{0}}}", entities.ToJSON()); respObj.code = "200"; respObj.description = "操作成功"; ValidLogin(reqObj, respObj); } catch (Exception ex) { //throw ex; respObj.code = "103"; respObj.description = "数据库操作错误"; } string content = respObj.ToJSON(); return(content); }
/// <summary> /// 通过optionname 获取列表,其中 optionname 为必传参数 /// </summary> /// <param name="entity"></param> /// <returns></returns> public VisitingParameterOptionsEntity[] GetOptionByName(VisitingParameterOptionsEntity entity) { IWhereCondition[] whereCondition = new IWhereCondition[2]; if (!string.IsNullOrEmpty(entity.ClientID) && entity.ClientID != "0") { EqualsCondition Conditioin = new EqualsCondition(); Conditioin.FieldName = "ClientID"; Conditioin.Value = entity.ClientID; whereCondition[0] = Conditioin; } EqualsCondition Conditioin1 = new EqualsCondition(); Conditioin1.FieldName = "OptionName"; Conditioin1.Value = entity.OptionName; whereCondition[1] = Conditioin1; OrderBy[] orderByCondition = new OrderBy[1]; OrderBy orderBy = new OrderBy(); orderBy.Direction = OrderByDirections.Asc; orderBy.FieldName = "Sequence"; orderByCondition[0] = orderBy; return(this.PagedQuery(whereCondition, orderByCondition, 1000, 1).Entities); }
/// <summary> /// 获取客户参数单位列表 /// </summary> /// <param name="entity"></param> /// <returns></returns> public UnitEntity[] GetList(UnitEntity entity) { IWhereCondition[] whereCondition = new IWhereCondition[2]; EqualsCondition Conditioin = new EqualsCondition(); Conditioin.FieldName = "ClientID"; Conditioin.Value = CurrentUserInfo.ClientID; whereCondition[0] = Conditioin; EqualsCondition Conditioin1 = new EqualsCondition(); Conditioin1.FieldName = "ClientDistributorID"; Conditioin1.Value = CurrentUserInfo.ClientDistributorID; whereCondition[1] = Conditioin1; OrderBy[] orderByCondition = new OrderBy[1]; OrderBy orderBy = new OrderBy(); orderBy.Direction = OrderByDirections.Asc; orderBy.FieldName = "CreateTime"; orderByCondition[0] = orderBy; return(this.PagedQuery(whereCondition, orderByCondition, 1000, 1).Entities); }
protected override UnitWeekReportRD ProcessRequest(APIRequest <UnitWeekReportRP> pRequest) { // var rd = new UnitWeekReportRD(); var rp = pRequest.Parameters; // var aggUnitDailyBLL = new Agg_UnitDailyBLL(CurrentUserInfo); var aggUnitWeeklyEmplBLL = new Agg_UnitWeekly_EmplBLL(CurrentUserInfo); var aggUnitWeeklyBLL = new Agg_UnitWeeklyBLL(CurrentUserInfo); var rUnitProductWeekSalesTopBLL = new R_UnitProductWeekSalesTopBLL(CurrentUserInfo); var aggUnitMonthlyEmplBLL = new Agg_UnitMonthly_EmplBLL(CurrentUserInfo); var t_UserBLL = new T_UserBLL(CurrentUserInfo); // var aggUnitWeeklyEntity = default(Agg_UnitWeeklyEntity); // 本周 var lastAggUnitWeeklyEntity = default(Agg_UnitWeeklyEntity); // 上周 var aggUnitDailyEntities = default(Agg_UnitDailyEntity[]); // 七天门店 var lastAggUnitDailyEntities = default(Agg_UnitDailyEntity[]); // 上七天门店 var rUnitProductWeekSalesTopEntities = default(R_UnitProductWeekSalesTopEntity[]); // 商品销量榜 var salesAggUnitWeeklyEmplEntities = default(Agg_UnitWeekly_EmplEntity[]); // 本周员工业绩 //var setoffAggUnitWeeklyEmplEntities = default(Agg_UnitWeekly_EmplEntity[]); // 本周员工集客 var aggUnitMonthlyEmplEntities = default(Agg_UnitMonthly_EmplEntity[]); // 本月员工 var t_UserEntities = default(T_UserEntity[]); //门店员工 // var tasks = new List <Task>(); tasks.Add(Task.Factory.StartNew(() => { aggUnitWeeklyEntity = aggUnitWeeklyBLL.QueryByEntity(new Agg_UnitWeeklyEntity { DateCode = Convert.ToDateTime(rp.Date), UnitId = rp.UnitID, CustomerId = rp.CustomerID }, null).FirstOrDefault(); })); tasks.Add(Task.Factory.StartNew(() => { lastAggUnitWeeklyEntity = aggUnitWeeklyBLL.QueryByEntity(new Agg_UnitWeeklyEntity { DateCode = Convert.ToDateTime(rp.Date).AddDays(-7), UnitId = rp.UnitID, CustomerId = rp.CustomerID }, null).FirstOrDefault(); })); tasks.Add(Task.Factory.StartNew(() => { var wheres = new IWhereCondition[] { new EqualsCondition { FieldName = "CustomerId", Value = rp.CustomerID }, new EqualsCondition { FieldName = "unitid", Value = rp.UnitID }, new DirectCondition("datecode>='" + Convert.ToDateTime(rp.Date).AddDays(-7).ToString("yyyy-MM-dd") + "' "), new DirectCondition("datecode<'" + Convert.ToDateTime(rp.Date).ToString("yyyy-MM-dd") + "' ") }; var orderbys = new OrderBy[] { new OrderBy { FieldName = "datecode", Direction = OrderByDirections.Asc } }; aggUnitDailyEntities = aggUnitDailyBLL.Query(wheres, orderbys); })); tasks.Add(Task.Factory.StartNew(() => { var lastWheres = new IWhereCondition[] { new EqualsCondition { FieldName = "CustomerId", Value = rp.CustomerID }, new EqualsCondition { FieldName = "unitid", Value = rp.UnitID }, new DirectCondition("datecode>='" + Convert.ToDateTime(rp.Date).AddDays(-14).ToString("yyyy-MM-dd") + "' "), new DirectCondition("datecode<'" + Convert.ToDateTime(rp.Date).AddDays(-7).ToString("yyyy-MM-dd") + "' ") }; var lastOrderBys = new OrderBy[] { new OrderBy { FieldName = "datecode", Direction = OrderByDirections.Asc } }; lastAggUnitDailyEntities = aggUnitDailyBLL.Query(lastWheres, lastOrderBys); })); tasks.Add(Task.Factory.StartNew(() => { rUnitProductWeekSalesTopEntities = rUnitProductWeekSalesTopBLL.PagedQueryByEntity(new R_UnitProductWeekSalesTopEntity { CustomerId = rp.CustomerID, UnitId = rp.UnitID, DateCode = Convert.ToDateTime(rp.Date) }, new OrderBy[] { new OrderBy { FieldName = "salesqty", Direction = OrderByDirections.Desc } }, 10, 1).Entities; })); tasks.Add(Task.Factory.StartNew(() => { salesAggUnitWeeklyEmplEntities = aggUnitWeeklyEmplBLL.QueryByEntity(new Agg_UnitWeekly_EmplEntity { CustomerId = rp.CustomerID, UnitId = rp.UnitID, DateCode = Convert.ToDateTime(rp.Date) }, null); })); //tasks.Add(Task.Factory.StartNew(() => //{ // setoffAggUnitWeeklyEmplEntities = aggUnitWeeklyEmplBLL.PagedQueryByEntity(new Agg_UnitWeekly_EmplEntity // { // CustomerId = rp.CustomerID, // UnitId = rp.UnitID, // DateCode = Convert.ToDateTime(rp.Date) // }, new OrderBy[] // { // new OrderBy // { // FieldName="setoffcount", // Direction= OrderByDirections.Desc // }, // new OrderBy // { // FieldName="EmplName", // Direction=OrderByDirections.Asc // } // }, 10, 1).Entities; //})); tasks.Add(Task.Factory.StartNew(() => { var date = Convert.ToDateTime(rp.Date); aggUnitMonthlyEmplEntities = aggUnitMonthlyEmplBLL.QueryByEntity(new Agg_UnitMonthly_EmplEntity { CustomerId = rp.CustomerID, UnitId = rp.UnitID, DateCode = Convert.ToDateTime(date.Year.ToString() + "-" + date.Month.ToString() + "-01") }, null); })); tasks.Add(Task.Factory.StartNew(() => { t_UserEntities = t_UserBLL.GetEntitiesByCustomerIdUnitId(rp.CustomerID, rp.UnitID); })); Task.WaitAll(tasks.ToArray()); // 本周 if (aggUnitWeeklyEntity != null) { rd.UnitCurrentWeekSalesAmount = aggUnitWeeklyEntity.SalesAmount; rd.UnitCurrentWeekNewVipCount = aggUnitWeeklyEntity.NewVipCount; rd.UnitCurrentWeekOldVipBackCount = aggUnitWeeklyEntity.OldVipBackCount; rd.UnitCurrentWeekUseCouponCount = aggUnitWeeklyEntity.UseCouponCount; } // 上周 if (lastAggUnitWeeklyEntity != null) { rd.UnitLastWeekSalesAmount = lastAggUnitWeeklyEntity.SalesAmount; rd.UnitLastWeekNewVipCount = lastAggUnitWeeklyEntity.NewVipCount; rd.UnitLastWeekOldVipBackCount = lastAggUnitWeeklyEntity.OldVipBackCount; rd.UnitLastWeekUseCouponCount = lastAggUnitWeeklyEntity.UseCouponCount; } // 增减 rd.UnitCurrentWeekSalesAmountWoW = ReportCommonBLL.Instance.CalcuDoD(lastAggUnitWeeklyEntity == null ? null : lastAggUnitWeeklyEntity.SalesAmount, aggUnitWeeklyEntity == null ? null : aggUnitWeeklyEntity.SalesAmount); rd.UnitCurrentWeekNewVipCountWoW = ReportCommonBLL.Instance.CalcuDoD(lastAggUnitWeeklyEntity == null ? null : lastAggUnitWeeklyEntity.NewVipCount, aggUnitWeeklyEntity == null ? null : aggUnitWeeklyEntity.NewVipCount); rd.UnitCurrentWeekOldVipBackCountWoW = ReportCommonBLL.Instance.CalcuDoD(lastAggUnitWeeklyEntity == null ? null : lastAggUnitWeeklyEntity.OldVipBackCount, aggUnitWeeklyEntity == null ? null : aggUnitWeeklyEntity.OldVipBackCount); rd.UnitCurrentWeekUseCouponCountWoW = ReportCommonBLL.Instance.CalcuDoD(lastAggUnitWeeklyEntity == null ? null : lastAggUnitWeeklyEntity.UseCouponCount, aggUnitWeeklyEntity == null ? null : aggUnitWeeklyEntity.UseCouponCount); // var startTime = Convert.ToDateTime(rp.Date).AddDays(-7); // 七天销售额 var unitCurrentWeekSalesAmountList = new List <UnitDaySalesAmount>(); ReportCommonBLL.Instance.FillReportDatasByTime(startTime, aggUnitDailyEntities, ref unitCurrentWeekSalesAmountList, (s, d) => { return(new UnitDaySalesAmount { Date = s.DateCode.ToString(), SalesAmount = s.SalesAmount }); }); rd.UnitCurrentWeekSalesAmountList = unitCurrentWeekSalesAmountList; // 七天新增会员 var unitCurrentWeekNewVipCountList = new List <UnitDayNewVipCount>(); ReportCommonBLL.Instance.FillReportDatasByTime(startTime, aggUnitDailyEntities, ref unitCurrentWeekNewVipCountList, (s, d) => { return(new UnitDayNewVipCount { Date = s.DateCode.ToString(), NewVipCount = s.NewVipCount }); }); rd.UnitCurrentWeekNewVipCountList = unitCurrentWeekNewVipCountList; // 七天老会员回店数 var unitCurrentWeekOldVipBackCountList = new List <UnitDayOldVipBackCount>(); ReportCommonBLL.Instance.FillReportDatasByTime(startTime, aggUnitDailyEntities, ref unitCurrentWeekOldVipBackCountList, (s, d) => { return(new UnitDayOldVipBackCount { Date = s.DateCode.ToString(), OldVipBackCount = s.OldVipBackCount }); }); rd.UnitCurrentWeekOldVipBackCountList = unitCurrentWeekOldVipBackCountList; // 七天优惠券使用数 var unitCurrentWeekUseCouponCountList = new List <UnitDayUseCouponCount>(); ReportCommonBLL.Instance.FillReportDatasByTime(startTime, aggUnitDailyEntities, ref unitCurrentWeekUseCouponCountList, (s, d) => { return(new UnitDayUseCouponCount { Date = s.DateCode.ToString(), UseCouponCount = s.OldVipBackCount }); }); rd.UnitCurrentWeekUseCouponCountList = unitCurrentWeekUseCouponCountList; // startTime = Convert.ToDateTime(rp.Date).AddDays(-14); // 上七天销售额 var unitLastWeekSalesAmountList = new List <UnitDaySalesAmount>(); ReportCommonBLL.Instance.FillReportDatasByTime(startTime, lastAggUnitDailyEntities, ref unitLastWeekSalesAmountList, (s, d) => { return(new UnitDaySalesAmount { Date = s.DateCode.ToString(), SalesAmount = s.SalesAmount }); }); rd.UnitLastWeekSalesAmountList = unitLastWeekSalesAmountList; // 上七天新增会员 var unitLastWeekNewVipCountList = new List <UnitDayNewVipCount>(); ReportCommonBLL.Instance.FillReportDatasByTime(startTime, lastAggUnitDailyEntities, ref unitLastWeekNewVipCountList, (s, d) => { return(new UnitDayNewVipCount { Date = s.DateCode.ToString(), NewVipCount = s.NewVipCount }); }); rd.UnitLastWeekNewVipCountList = unitLastWeekNewVipCountList; // 上七天老会员回店数 var unitLastWeekOldVipBackCountList = new List <UnitDayOldVipBackCount>(); ReportCommonBLL.Instance.FillReportDatasByTime(startTime, lastAggUnitDailyEntities, ref unitLastWeekOldVipBackCountList, (s, d) => { return(new UnitDayOldVipBackCount { Date = s.DateCode.ToString(), OldVipBackCount = s.OldVipBackCount }); }); rd.UnitLastWeekOldVipBackCountList = unitLastWeekOldVipBackCountList; // 上七天优惠券使用数 var unitLastWeekUseCouponCountList = new List <UnitDayUseCouponCount>(); ReportCommonBLL.Instance.FillReportDatasByTime(startTime, lastAggUnitDailyEntities, ref unitLastWeekUseCouponCountList, (s, d) => { return(new UnitDayUseCouponCount { Date = s.DateCode.ToString(), UseCouponCount = s.OldVipBackCount }); }); rd.UnitLastWeekUseCouponCountList = unitLastWeekUseCouponCountList; // 商品销量榜 rd.UnitCurrentWeekProductSalesTopList = new List <UnitProductSalesTop>(); if (rUnitProductWeekSalesTopEntities != null && rUnitProductWeekSalesTopEntities.Length > 0) { var list = rUnitProductWeekSalesTopEntities.ToList(); foreach (var item in list) { rd.UnitCurrentWeekProductSalesTopList.Add(new UnitProductSalesTop { TopIndex = item.TopIndex, ProductName = item.item_name, ProductSKU = item.SkuName, SalesAmount = item.SalesQty }); } } // rd.UnitCurrentWeekSalesAmountEmplTopList = new List <UnitSalesAmountEmplTop>(); // 员工业绩榜 if (salesAggUnitWeeklyEmplEntities != null && salesAggUnitWeeklyEmplEntities.Length > 0) { var list = salesAggUnitWeeklyEmplEntities.OrderByDescending(p => p.SalesAmount).ThenBy(p => p.EmplName).ToList(); var i = 1; foreach (var item in list) { var user = t_UserEntities.Where(p => p.user_id == item.EmplID).FirstOrDefault(); if (user == null) { continue; } rd.UnitCurrentWeekSalesAmountEmplTopList.Add(new UnitSalesAmountEmplTop { TopIndex = i, EmplName = item.EmplName, SalesAmount = item.SalesAmount }); i++; if (i > 10) { break; } } } // rd.UnitCurrentWeekSetoffEmplTopList = new List <UnitWeekSetoffEmplTop>(); // 员工集客榜 if (salesAggUnitWeeklyEmplEntities != null && salesAggUnitWeeklyEmplEntities.Length > 0) { var list = salesAggUnitWeeklyEmplEntities.OrderByDescending(p => p.SetoffCount).ThenBy(p => p.EmplName).ToList(); var i = 1; foreach (var item in list) { var user = t_UserEntities.Where(p => p.user_id == item.EmplID).FirstOrDefault(); if (user == null) { continue; } var empMothData = aggUnitMonthlyEmplEntities.FirstOrDefault(it => it.EmplID == item.EmplID); rd.UnitCurrentWeekSetoffEmplTopList.Add(new UnitWeekSetoffEmplTop { TopIndex = i, EmplName = item.EmplName, WeekSetoffCount = item.SetoffCount, MonthSetoffCount = empMothData != null ? empMothData.SetoffCount : 0 }); i++; if (i > 10) { break; } } } // return(rd); }
/// <summary>The add condition.</summary> /// <param name="condition">The condition.</param> public void AddCondition(ICondition condition) { this.FirstCondition = new WhereCondition(condition); }
/// <summary> /// 获取Mstr格式的Url /// </summary> /// <param name="pQueryParameter">提问回答对象</param> /// <param name="pDataRigthHierachy">用于处理数据权限的提问回答</param> /// <returns>Mstr格式的Url</returns> public string GetMstrUrl(PromptAnswerItem[] pQueryParameter, DataRigthHierachy pDataRigthHierachy) { //if (this._httpSessionState["MstrSSO_SessionID"] == null) // throw new Exception("会话超时,请重新登录。"); #region Mstr项目、报表等信息 //项目信息 MSTRProjectEntity mstrProjectQueryEntity = new MSTRProjectEntity(); //mstrProjectQueryEntity.ProjectID = reportInfo.ProjectID; mstrProjectQueryEntity.ClientID = this._currentUserInfo.ClientID;//一个客户仅允许一个项目 MSTRProjectBLL mstrProjectBLL = new MSTRProjectBLL(this._currentUserInfo, this._sqlHelper); MSTRProjectEntity[] mstrProjectEntities = mstrProjectBLL.QueryByEntity(mstrProjectQueryEntity, null); if (mstrProjectEntities == null || mstrProjectEntities.Length == 0) { return(null); throw new Exception("未找到客户标识为[" + this._currentUserInfo.ClientID + "]的报表项目。"); } var projectInfo = mstrProjectEntities[0]; //获取报表信息 MSTRReportEntity mstrReportQueryEntity = new MSTRReportEntity(); if (this._mstrReportGuid == null) {//用于刷新的报表 mstrReportQueryEntity.ProjectID = projectInfo.ProjectID; mstrReportQueryEntity.ReportType = 99; //mstrReportQueryEntity.ReportName = "KeepSession"; } else { mstrReportQueryEntity.ProjectID = projectInfo.ProjectID; mstrReportQueryEntity.ReportGUID = this._mstrReportGuid.ToString(); } MSTRReportBLL mstrReportBLL = new MSTRReportBLL(this._currentUserInfo, this._sqlHelper); MSTRReportEntity[] mstrReportEntities = mstrReportBLL.QueryByEntity(mstrReportQueryEntity, null); if (mstrReportEntities == null || mstrReportEntities.Length == 0) { throw new Exception("未找到标识为[" + this._mstrReportGuid + "]的报表。"); } var reportInfo = mstrReportEntities[0]; //取出当前报表所有Prompt MSTRReportPromptEntity mstrReportPromptQueryEntity = new MSTRReportPromptEntity(); mstrReportPromptQueryEntity.ReportID = reportInfo.ReportID; MSTRReportPromptBLL mstrReportPromptBLL = new MSTRReportPromptBLL(this._currentUserInfo, this._sqlHelper); MSTRReportPromptEntity[] mstrReportPromptEntities = mstrReportPromptBLL.QueryByEntity(mstrReportPromptQueryEntity, null); int mappintCount = (mstrReportPromptEntities == null ? 0 : mstrReportPromptEntities.Length); JIT.Utility.Log.Loggers.Debug(new JIT.Utility.Log.DebugLogInfo() { ClientID = this._currentUserInfo.ClientID, UserID = this._currentUserInfo.UserID, Message = string.Format("报表[{0}]所关联的提问数量为[{1}]", reportInfo.ReportName, mappintCount) }); #endregion #region 依次生成Mstr所需格式的PromptAnswer string mstrPromptAnswerUrl = string.Empty; if (mstrReportPromptEntities != null && mstrReportPromptEntities.Length > 0) { //取出每个Prompt的详情 int[] promptIds = new int[mstrReportPromptEntities.Length]; for (int i = 0; i < mstrReportPromptEntities.Length; i++) { promptIds[i] = mstrReportPromptEntities[i].PromptID.Value; } IWhereCondition[] whereCondition = new IWhereCondition[1]; JIT.Utility.DataAccess.Query.InCondition <int> promptIDsCondition = new JIT.Utility.DataAccess.Query.InCondition <int>(); promptIDsCondition.FieldName = "PromptID"; promptIDsCondition.Values = promptIds; whereCondition[0] = promptIDsCondition; MSTRPromptBLL mstrPromptBLL = new MSTRPromptBLL(this._currentUserInfo, this._sqlHelper); MSTRPromptEntity[] mstrPromptEntities = mstrPromptBLL.Query(whereCondition, null); //依次拼接Prompt //记录各个类型的提问答案 Dictionary <PromptAnswerType, string> dictPromptAnswers = new Dictionary <PromptAnswerType, string>(); dictPromptAnswers.Add(PromptAnswerType.ElementsPromptAnswer, string.Empty); dictPromptAnswers.Add(PromptAnswerType.ObjectsPromptAnswer, string.Empty); dictPromptAnswers.Add(PromptAnswerType.ValuePromptAnswer, string.Empty); //合并提问回答 List <PromptAnswerItem> lstAnswers = new List <PromptAnswerItem>(); lstAnswers.AddRange(pQueryParameter); if (pDataRigthHierachy != null) { lstAnswers.AddRange(pDataRigthHierachy.PromptAnswerItems); } //处理空回答 foreach (var promptItem in mstrPromptEntities) { var answeredItem = lstAnswers.ToArray().Where(answer => answer.PromptCode == promptItem.PromptCode).ToArray(); if (answeredItem.Length == 0) {//未回答项,准备空回答 PromptAnswerItem emptyPromptAnswerItem = new PromptAnswerItem(); emptyPromptAnswerItem.PromptCode = promptItem.PromptCode; emptyPromptAnswerItem.PromptType = (PromptAnswerType)promptItem.PromptType; emptyPromptAnswerItem.QueryCondition = new string[0] { }; lstAnswers.Add(emptyPromptAnswerItem); } } //List<int> lstAnsweredPromptId=new List<int>();//已提供回答的提问项标识 foreach (var answerItem in lstAnswers) { //根据代码查找Prompt var promptItems = mstrPromptEntities.Where(item => item.PromptCode == answerItem.PromptCode).ToArray(); if (promptItems == null || promptItems.Length == 0) { throw new Exception("配置表中未找到代码为[" + answerItem.PromptCode + "]的报表提问。"); } if (promptItems.Length > 1) { throw new Exception("配置表中代码为[" + answerItem.PromptCode + "]的报表提问出现多次(" + promptItems.Length.ToString() + "次)。"); } var promptItem = promptItems[0]; answerItem.PromptType = (PromptAnswerType)promptItem.PromptType; //拼接Mstr格式的URL string promptAnswerString = GetPromptAnswerString(answerItem.PromptType, promptItem.PromptGUID, answerItem.QueryCondition); switch (answerItem.PromptType) { case PromptAnswerType.ElementsPromptAnswer: dictPromptAnswers[PromptAnswerType.ElementsPromptAnswer] += promptItem.PromptGUID + ";" + promptAnswerString + ","; break; case PromptAnswerType.ValuePromptAnswer: dictPromptAnswers[PromptAnswerType.ValuePromptAnswer] += promptAnswerString + "^"; break; case PromptAnswerType.ObjectsPromptAnswer: dictPromptAnswers[PromptAnswerType.ObjectsPromptAnswer] += promptAnswerString + "^"; break; default: throw new Exception("未知的提问类型"); } } if (dictPromptAnswers[PromptAnswerType.ElementsPromptAnswer] != string.Empty) { if (dictPromptAnswers[PromptAnswerType.ElementsPromptAnswer].EndsWith(",")) { dictPromptAnswers[PromptAnswerType.ElementsPromptAnswer] = dictPromptAnswers[PromptAnswerType.ElementsPromptAnswer].Substring(0, dictPromptAnswers[PromptAnswerType.ElementsPromptAnswer].Length - 1); } mstrPromptAnswerUrl += "&elementsPromptAnswers=" + dictPromptAnswers[PromptAnswerType.ElementsPromptAnswer]; } if (dictPromptAnswers[PromptAnswerType.ObjectsPromptAnswer] != string.Empty) { if (dictPromptAnswers[PromptAnswerType.ObjectsPromptAnswer].EndsWith("^")) { dictPromptAnswers[PromptAnswerType.ObjectsPromptAnswer] = dictPromptAnswers[PromptAnswerType.ObjectsPromptAnswer].Substring(0, dictPromptAnswers[PromptAnswerType.ObjectsPromptAnswer].Length - 1); } mstrPromptAnswerUrl += "&objectsPromptAnswers=" + dictPromptAnswers[PromptAnswerType.ObjectsPromptAnswer]; } if (dictPromptAnswers[PromptAnswerType.ValuePromptAnswer] != string.Empty) { if (dictPromptAnswers[PromptAnswerType.ValuePromptAnswer].EndsWith("^")) { dictPromptAnswers[PromptAnswerType.ValuePromptAnswer] = dictPromptAnswers[PromptAnswerType.ValuePromptAnswer].Substring(0, dictPromptAnswers[PromptAnswerType.ValuePromptAnswer].Length - 1); } mstrPromptAnswerUrl += "&valuePromptAnswers=" + dictPromptAnswers[PromptAnswerType.ValuePromptAnswer]; } } #endregion 依次生成Mstr所需格式的PromptAnswer string reportUrl; switch ((ReportType)reportInfo.ReportType.Value) { case ReportType.Report: reportUrl = string.Format("{0}&port={1}&evt=4001&src=mstrWeb.4001&reportID={2}&ipclientid={4}&ipsessionid={5}&reportViewMode={6}{3}", projectInfo.WebServerBaseUrl, projectInfo.IServerPort, reportInfo.ReportGUID, mstrPromptAnswerUrl, this._currentUserInfo.ClientID, this._mstrIntegrationSessionID, reportInfo.ReportViewMode); //reportUrl = string.Format("{0}&port={1}&evt=4001&src=mstrWeb.4001&reportID={2}&reportViewMode={6}", projectInfo.WebServerBaseUrl, projectInfo.IServerPort, reportInfo.ReportGUID, mstrPromptAnswerUrl, this._currentUserInfo.ClientID, (int)this._httpSessionState["MstrSSO_SessionID"], reportInfo.ReportViewMode); break; case ReportType.Document: reportUrl = string.Format("{0}&port={1}&evt=2048001&src=mstrWeb.2048001&documentID={2}&ipclientid={4}&ipsessionid={5}&reportViewMode={6}{3}", projectInfo.WebServerBaseUrl, projectInfo.IServerPort, reportInfo.ReportGUID, mstrPromptAnswerUrl, this._currentUserInfo.ClientID, this._mstrIntegrationSessionID, reportInfo.ReportViewMode); //reportUrl = string.Format("{0}&port={1}&evt=2048001&src=mstrWeb.2048001&documentID={2}&reportViewMode={6}", projectInfo.WebServerBaseUrl, projectInfo.IServerPort, reportInfo.ReportGUID, mstrPromptAnswerUrl, this._currentUserInfo.ClientID, (int)this._httpSessionState["MstrSSO_SessionID"], reportInfo.ReportViewMode); break; case ReportType.KeepSesson: reportUrl = string.Format("{0}&port={1}&evt=4001&src=mstrWeb.4001&reportID={2}&ipclientid={4}&ipsessionid={5}&reportViewMode={6}{3}", projectInfo.WebServerBaseUrl, projectInfo.IServerPort, reportInfo.ReportGUID, mstrPromptAnswerUrl, this._currentUserInfo.ClientID, this._mstrIntegrationSessionID, reportInfo.ReportViewMode); break; default: throw new Exception("无效的报表类型."); break; } return(reportUrl); }