public static void SelectDataForActivityFromZaConfigures() { string pkidStr = string.Empty; //获取活动表中已有的套餐信息 List <Tuhu.Provisioning.DataAccess.Entity.ActivityCalendar> listAc = new ActivityCalendarManager().SelectActivityByCondition(string.Format(" and DataFrom='{0}'", Tuhu.Provisioning.DataAccess.Entity.ActivityObject.TblZeroActivity.ToString())); //拼接已录入的活动信息,将来在套餐信息表中排除 if (listAc.Any()) { pkidStr = listAc.Where(_ => _.DataFromId != null).Aggregate(pkidStr, (current, item) => current + (item.DataFromId.ToString() + ',')); pkidStr = pkidStr.Substring(0, pkidStr.Length - 1); } //获取套餐信息表中新增的套餐信息 var listZaConfigue = SelectZeroActivityDetail().FindAll(delegate(ZeroActivityDetail info) { if (!pkidStr.Split(',').Contains(info.Period.ToString(CultureInfo.InvariantCulture))) { return(true); } return(false); }); #region 没有的数据要添加 //为更新准备字符穿 var dataFromIdStr = SelectZeroActivityDetail().Select(n => n.Period).ToList(); //向活动日历信息表添加数据 foreach (var item in listZaConfigue) { var modelAc = new Tuhu.Provisioning.DataAccess.Entity.ActivityCalendar(); modelAc.BeginDate = item.StartDateTime; modelAc.EndDate = item.EndDateTime; modelAc.ActivityTitle = "0元购"; modelAc.ActivityContent = item.ProductID + ",提供数量:" + item.Quantity; modelAc.CreateDate = item.CreateDateTime; modelAc.CreateBy = "SYSTEM"; modelAc.DataFrom = Tuhu.Provisioning.DataAccess.Entity.ActivityObject.TblZeroActivity.ToString(); modelAc.DataFromId = item.Period; modelAc.IsActive = true; new ActivityCalendarManager().AddActivityCalendar(modelAc); } #endregion #region 更新活动日历数据状态 var updateList = listAc.FindAll(delegate(Tuhu.Provisioning.DataAccess.Entity.ActivityCalendar model) { if (!dataFromIdStr.Contains(model.Pkid)) { return(true); } return(false); }); foreach (var item in updateList) { new ActivityCalendarManager().UpdateIsActivity(item.DataFromId.HasValue ? item.DataFromId.Value : 0, Tuhu.Provisioning.DataAccess.Entity.ActivityObject.TblZeroActivity.ToString(), false); } #endregion }
public void SelectDataForActivityFromCouponCatagory() { string pkidStr = string.Empty; //获取活动表中已有的套餐信息 List <DataAccess.Entity.ActivityCalendar> listAc = new ActivityCalendarManager().SelectActivityByCondition(string.Empty).Where(_ => _.DataFrom.EndsWith(ActivityObject.CouponCategory.ToString())).ToList(); //拼接已录入的活动信息,将来在套餐信息表中排除 if (listAc.Any()) { pkidStr = listAc.Where(_ => _.DataFromId != null).Aggregate(pkidStr, (current, item) => current + (item.DataFromId.ToString() + ',')); pkidStr = pkidStr.Substring(0, pkidStr.Length - 1); } #region 没有的数据要添加 //获取套餐信息表中新增的套餐信息 //获取套餐信息表中新增的套餐信息 List <CouponCategory> listZaConfigue; if (string.IsNullOrEmpty(pkidStr)) { listZaConfigue = GetAllCouponCategory(); } else { listZaConfigue = GetAllCouponCategory().FindAll(delegate(CouponCategory info) { if (!pkidStr.Split(',').Contains(info.PKID.ToString(CultureInfo.InvariantCulture))) { return(true); } return(false); }); } //向活动日历信息表添加数据 foreach (var item in listZaConfigue) { var modelAc = new DataAccess.Entity.ActivityCalendar { BeginDate = Convert.ToDateTime("1901-01-01"), ActivityTitle = item.Name, ActivityContent = item.Remark, CreateDate = DateTime.Now, CreateBy = "SYSTEM", DataFrom = ActivityObject.CouponCategory.ToString(), DataFromId = item.PKID, IsActive = true }; new ActivityCalendarManager().AddActivityCalendar(modelAc); } #endregion #region //获取套餐信息表中新增的套餐信息 var updateList = GetAllCouponCategory().FindAll(delegate(CouponCategory info) { if (pkidStr.Split(',').Contains(info.PKID.ToString(CultureInfo.InvariantCulture))) { return(true); } return(false); }); foreach (var item in updateList) { new ActivityCalendarManager().UpdateIsActivity(item.PKID, ActivityObject.CouponCategory.ToString(), item.IsActive == 1 ? true : false); } #endregion }
public void SelectDataForActivityFromNewAppSet() { string pkidStr = string.Empty; //获取活动表中已有的套餐信息 List <Tuhu.Provisioning.DataAccess.Entity.ActivityCalendar> listAc = new ActivityCalendarManager().SelectActivityByCondition(string.Empty).Where(_ => _.DataFrom.EndsWith(ActivityObject.NewAppSet.ToString())).ToList(); //拼接已录入的活动信息,将来在套餐信息表中排除 if (listAc.Any()) { //pkidStr = listAc.Where(_ => _.DataFromId != null).Aggregate(pkidStr, (current, item) => current + (item.DataFromId.ToString() + ',')); //pkidStr = pkidStr.Substring(0, pkidStr.Length - 1); listAc = listAc.Where(_ => _.CreateDate.Date == DateTime.Now.Date && _.DataFromId != null).ToList(); } #region 没有的数据要添加 //获取套餐信息表中新增的套餐信息 //获取套餐信息表中新增的套餐信息 List <NewAppSet> listZaConfigue; if (!listAc.Any()) { listZaConfigue = SelectNewAppSet(); } else { listZaConfigue = SelectNewAppSet().FindAll(delegate(NewAppSet info) { if (!listAc.Select(_ => _.DataFromId).Contains(Convert.ToInt32(info.Id)) || listAc.Any(_ => _.DataFromId == Convert.ToInt32(info.Id) && _.CreateDate.Date != DateTime.Now.Date)) { return(true); } return(false); }); } //向活动日历信息表添加数据 foreach (var item in listZaConfigue) { var modelAc = new DataAccess.Entity.ActivityCalendar { BeginDate = item.Starttime.GetValueOrDefault(), EndDate = item.Overtime.GetValueOrDefault(), ActivityTitle = item.Modelname, ActivityContent = item.Modelname, ActivityUrl = item.Jumph5url, CreateDate = DateTime.Now, CreateBy = "SYSTEM", DataFrom = ActivityObject.NewAppSet.ToString(), DataFromId = Convert.ToInt32(item.Id), IsActive = true, Owner = item.Apptype == 1 ? "安卓" : "IOS", OwnerType = item.Apptype.ToString() }; new ActivityCalendarManager().AddActivityCalendar(modelAc); } #endregion #region //获取套餐信息表中新增的套餐信息 var updateList = SelectNewAppSet().FindAll(delegate(NewAppSet info) { if (listAc.Any(_ => _.DataFromId == Convert.ToInt32(info.Id) && _.CreateDate.Date == DateTime.Now.Date)) { return(true); } return(false); }); foreach (var item in updateList) { new ActivityCalendarManager().UpdateIsActivity(Convert.ToInt32(item.Id), ActivityObject.NewAppSet.ToString(), item.Showstatic == 1 ? true : false); } #endregion #region 查询旧得网页资源,如果新的里面没有则添加 List <DataAccess.Entity.ActivityCalendar> listAc2 = new ActivityCalendarManager().SelectActivityByCondition(string.Empty).Where(_ => _.DataFrom.EndsWith(ActivityObject.Advertise.ToString())).ToList(); //拼接已录入的活动信息,将来在套餐信息表中排除 if (listAc2.Any()) { //pkidStr = listAc.Where(_ => _.DataFromId != null).Aggregate(pkidStr, (current, item) => current + (item.DataFromId.ToString() + ',')); //pkidStr = pkidStr.Substring(0, pkidStr.Length - 1); listAc2 = listAc2.Where(_ => _.CreateDate.Date == DateTime.Now.Date && _.DataFromId != null).ToList(); } List <Advertise> suppliesList; if (!listAc2.Any()) { suppliesList = GetSuppliesModule(); } else { suppliesList = GetSuppliesModule().FindAll(delegate(Advertise info) { if (!listAc2.Select(_ => _.DataFromId).Contains(Convert.ToInt32(info.PKID)) || listAc2.Any(_ => _.DataFromId == Convert.ToInt32(info.PKID) && _.CreateDate.Date != DateTime.Now.Date)) { return(true); } return(false); }); } suppliesList = suppliesList.Where(_ => _.AdColumnID.EndsWith("www-05")).ToList().FindAll(delegate(Advertise info) { if (!listZaConfigue.Select(_ => _.Modelname).Contains(info.Name)) { return(true); } return(false); }); //向活动日历信息表添加数据 foreach (var item in suppliesList) { var modelAc = new DataAccess.Entity.ActivityCalendar { BeginDate = item.BeginDateTime.GetValueOrDefault(), EndDate = item.EndDateTime.GetValueOrDefault(), ActivityTitle = item.Name, ActivityContent = item.Name, ActivityUrl = item.Url, CreateDate = DateTime.Now, CreateBy = "SYSTEM", DataFrom = ActivityObject.Advertise.ToString(), DataFromId = item.PKID, IsActive = true, Owner = "网站首页Banner" }; new ActivityCalendarManager().AddActivityCalendar(modelAc); } #endregion #region //获取套餐信息表中新增的套餐信息 var updateList2 = GetSuppliesModule().Where(_ => _.AdColumnID.EndsWith("www-05")).ToList().FindAll(delegate(Advertise info) { if (listAc2.Any(_ => _.DataFromId == Convert.ToInt32(info.PKID) && _.CreateDate.Date == DateTime.Now.Date)) { return(true); } return(false); }); foreach (var item in updateList2) { new ActivityCalendarManager().UpdateIsActivity(Convert.ToInt32(item.PKID), ActivityObject.Advertise.ToString(), item.State == 1 ? true : false); } #endregion }