private void Bind() { Ernie bll = new Ernie(); if (!Id.Equals(Guid.Empty)) { Page.Title = "编辑摇奖设定"; var model = bll.GetModel(Id); if (model == null) { return; } hErnieId.Value = model.Id.ToString(); txtStartTime.Value = model.StartTime.ToString("yyyy-MM-dd HH:mm"); txtEndTime.Value = model.EndTime.ToString("yyyy-MM-dd HH:mm"); txtUserBetMaxCount.Value = model.UserBetMaxCount.ToString(); var li = rdIsDisable.Items.FindByValue(model.IsDisable.ToString().ToLower()); if (li != null) { li.Selected = true; } } else { if (bll.IsExistLatest()) { abtnSaveErnie.Visible = false; lbMsg.InnerText = "系统提示:已存在摇奖设置且未结束,无法再添加摇奖设置!"; } } }
//private static readonly int ernieTimeout = 0; public static IList <ErnieAllInfo> GetLatest() { Ernie bll = new Ernie(); if (!enableCaching) { return(bll.GetLatest()); } string key = "ernie_latest"; IList <ErnieAllInfo> data = (IList <ErnieAllInfo>)HttpRuntime.Cache[key]; if (data == null) { double timeOut = 0; data = bll.GetLatest(); if (data.Count > 0) { var model = data[0]; timeOut = (int)(model.EndTime - model.StartTime).TotalMilliseconds; } AggregateCacheDependency cd = DependencyFacade.GetErnieDependency(); HttpRuntime.Cache.Add(key, data, cd, DateTime.Now.AddMilliseconds(timeOut), Cache.NoSlidingExpiration, CacheItemPriority.High, null); } return(data); }
private void Bind() { //查询条件 GetSearchItem(); int totalRecords = 0; Ernie bll = new Ernie(); rpData.DataSource = bll.GetList(pageIndex, pageSize, out totalRecords, sqlWhere, parms == null ? null : parms.ToArray()); rpData.DataBind(); myDataAppend.Append("<div id=\"myDataForPage\" style=\"display:none;\">[{\"PageIndex\":\"" + pageIndex + "\",\"PageSize\":\"" + pageSize + "\",\"TotalRecord\":\"" + totalRecords + "\",\"QueryStr\":\"" + queryStr + "\"}]</div>"); }
private void SaveErnie(HttpContext context) { context.Response.ContentType = "text/plain"; Guid Id = Guid.Empty; if (!string.IsNullOrWhiteSpace(context.Request.Form["Id"])) { Guid.TryParse(context.Request.Form["Id"], out Id); } if (string.IsNullOrWhiteSpace(context.Request.Form["startTime"])) { context.Response.Write("{\"success\": false,\"message\": \"" + MessageContent.Submit_Params_InvalidError + "\"}"); return; } DateTime startTime = DateTime.MinValue; if (!string.IsNullOrWhiteSpace(context.Request.Form["startTime"])) { DateTime.TryParse(context.Request.Form["startTime"], out startTime); } if (startTime == DateTime.MinValue) { context.Response.Write("{\"success\": false,\"message\": \"" + MessageContent.Submit_Params_InvalidError + "\"}"); return; } DateTime endTime = DateTime.MinValue; if (!string.IsNullOrWhiteSpace(context.Request.Form["endTime"])) { DateTime.TryParse(context.Request.Form["endTime"], out endTime); } if (endTime == DateTime.MinValue) { context.Response.Write("{\"success\": false,\"message\": \"" + MessageContent.Submit_Params_InvalidError + "\"}"); return; } if (startTime >= endTime) { context.Response.Write("{\"success\": false,\"message\": \"结束时间必须大于开始时间,请正确操作\"}"); return; } int userBetMaxCount = 0; if (!string.IsNullOrWhiteSpace(context.Request.Form["userBetMaxCount"])) { int.TryParse(context.Request.Form["userBetMaxCount"], out userBetMaxCount); } bool isDisable = false; bool.TryParse(context.Request.Form["isDisable"], out isDisable); ErnieInfo model = new ErnieInfo(); model.Id = Id; model.LastUpdatedDate = DateTime.Now; model.StartTime = startTime; model.UserBetMaxCount = userBetMaxCount; model.EndTime = endTime; model.IsDisable = isDisable; Ernie bll = new Ernie(); int effect = -1; if (!Id.Equals(Guid.Empty)) { var oldModel = bll.GetModel(Id); if (oldModel == null) { throw new ArgumentException(MessageContent.Submit_Data_NotExists); } model.IsOver = oldModel.IsOver; effect = bll.Update(model); } else { using (TransactionScope scope = new TransactionScope()) { if (bll.IsExistLatest()) { throw new ArgumentException("已存在摇奖设置且未结束,无法再添加摇奖设置!"); } else { model.IsOver = false; Id = Guid.NewGuid(); model.Id = Id; effect = bll.Insert(model); } scope.Complete(); } } context.Response.Write("{\"success\": true,\"message\": \"" + Id + "\"}"); }