public ActionResult SaveAdertising(AdvertingInputModel model) { var bll = new AdvertisingBll(); Bas_Advertising dbModel = null; if (model.Bad_Id > 0) { dbModel = bll.GetAdvertisingById(model.Bad_Id); var modelByPos = bll.GetAdvertisingByPosId(model.Bad_PosId); if (dbModel == null || modelByPos == null || modelByPos.Bad_Id != dbModel.Bad_Id) { throw new AbhsException(ErrorCodeEnum.ParameterInvalid, AbhsErrorMsg.ConstParameterInvalid); } } //dbModel = model.ToAdvertisingDbModel(); //dbModel.Bad_Creator = CurrentUserID; dbModel = model.ConvertTo <Bas_Advertising>(dbModel); bool success = bll.SaveAdertising(dbModel); var msg = success ? "保存成功" : "保存失败"; return(Json(new JsonSimpleResponse() { State = success, ErrorMsg = msg })); }
public ActionResult Edit(int badPosId, int badId) { AdvertingInputModel viewModel; Bas_Advertising dbModel = null; if (badId > 0) { dbModel = new AdvertisingBll().GetAdvertisingById(badId); } if (dbModel == null) { viewModel = new AdvertingInputModel(badPosId); viewModel.Bad_Url = ""; } else { viewModel = new AdvertingInputModel(dbModel); } var bapModel = new AdvertisingBll().GetAdvertisingPosById(badPosId); if (bapModel != null) { viewModel.Bap_Code = bapModel.Bap_Code; } return(View(viewModel)); }
public ActionResult GetPagingAdvertisingHistory(AdvertisingSearch search) { var list = new AdvertisingBll().GetPagingAdvertisingHistory(search.Pagination, search.AdvPosId); var table = AbhsTableFactory.Create(list, search.Pagination.TotalCount); return(Json(table, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 课程中心-课程列表 /// </summary> /// <returns></returns> // GET: Course/Select public ActionResult Select() { CourseSearch search = new CourseSearch() { Grade = 0, CourseType = 0, OrderBy = 1, Pagination = new PagingObject() { PageIndex = 1, PageSize = 9 }, HasMore = true }; AdvertisingBll bll = new AdvertisingBll(); //广告列表 List <DtoAdvertisingIndex> AdvertisingList = bll.GetAdvertisingForIndex(); CourseSelectViewModel model = new CourseSelectViewModel() { StudentId = GetCurrentUser().StudentId, SearchInfo = JsonConvert.SerializeObject(search), AdvertisingList = AdvertisingList?.Select(a => new CourseSelectAdvertisingViewModel() { ImageUrl = a.Bad_ImageUrlShow, LinkUrl = a.Bad_ReferId == 0 ? a.Bad_Url : Url.Action("Detail", "Course", new { id = a.Bad_ReferId, aid = a.Bad_Id }), CourseId = a.Bad_ReferId, Ad_Id = a.Bad_Id }).ToList() }; return(View(model)); }
private void TestCommitSuccess() { using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew)) { AdvertisingBll bll = new AdvertisingBll(); bll.IncrementValidCount(10000, 10); scope.Complete(); } }
public ActionResult EditAdertisingPosStatus(int advPosId, int toStatus) { bool success = new AdvertisingBll().EditAdertisingPosStatus(advPosId, toStatus, CurrentUserID); var msg = success ? "保存成功" : "保存失败"; return(Json(new JsonSimpleResponse() { State = success, ErrorMsg = msg })); }
private void TestCommitFalse() { try { using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew)) { AdvertisingBll bll = new AdvertisingBll(); bll.IncrementValidCount(10001, 10); scope.Complete(); } } catch (Exception ex) { } }
public JsonResult HitMessage(int courseId = 0, int aid = 0) { try { System.Threading.Tasks.Task.Factory.StartNew(() => { AdvertisingBll advertisingBll = new AdvertisingBll(); advertisingBll.SendHitMessage(aid); }); } catch (Exception) { } return(new JsonResult() { Data = AjaxResponse.Success() }); }
public void TestRollBack() { AdvertisingBll bll = new AdvertisingBll(); try { using (TransactionScope scope = new TransactionScope()) { TestCommitSuccess(); TestCommitFalse(); bll.IncrementValidCount(10002, 10); scope.Complete(); } } catch (Exception ex) { throw; } }
/// <summary> /// 学生下单(课程详情页点击立即购买) /// </summary> /// <param name="id">课程Id</param> /// <returns></returns> public ActionResult MakeOrder(int id = 0, int aid = 0) { //生成订单,如果生成成功,跳转到订单页 int studentId = GetCurrentUser().StudentId; StudentOrderBll studentOrderBll = new StudentOrderBll(); int orderId = studentOrderBll.MakeOrder(studentId, id); try { System.Threading.Tasks.Task.Factory.StartNew(() => { AdvertisingBll advertisingBll = new AdvertisingBll(); advertisingBll.SendOrderMessage(aid); }); } catch (Exception) { } return(RedirectToAction("Payment", new { id = orderId })); }
public override void Run(DateTime now) { nextRunTime = new DateTime(1900, 1, 1); MessageBll messageBll = new MessageBll(); StudentPracticeBll practiceBll = new StudentPracticeBll(); Dictionary <int, AdvertisingNumber> dic = new Dictionary <int, AdvertisingNumber>(); int count = 1; while (count <= 100) { try { MessageBody body = messageBll.ReceiveMessageBody(MessageChannel.ADVERTISING_CHANNEL); if (body != null && !string.IsNullOrEmpty(body.Data)) { string message = body.Data; string[] array = message.Split(','); if (array.Length == 3) { int advertisingId = Convert.ToInt32(array[0]); if (!dic.ContainsKey(advertisingId)) { AdvertisingNumber action = new AdvertisingNumber(advertisingId, 0, 0); dic.Add(advertisingId, action); } dic[advertisingId].HitNumber += Convert.ToInt32(array[1]); dic[advertisingId].OrderNumber += Convert.ToInt32(array[2]); } } else { nextRunTime = DateTime.Now.AddSeconds(5); break; } } catch (Exception ex) { LogHelper.ErrorLog(this.JobName(), ex); } count++; } if (dic.Count > 0) { AdvertisingBll bll = new AdvertisingBll(); foreach (KeyValuePair <int, AdvertisingNumber> item in dic) { if (item.Value.HitNumber > 0) { bll.IncrementHitCount(item.Value.AdvertisingId, item.Value.HitNumber); } if (item.Value.OrderNumber > 0) { bll.IncrementValidCount(item.Value.AdvertisingId, item.Value.OrderNumber); } } } }