protected bool PermitStaticRequest() { BizParams paramDayofWeek = BizParamsList.FirstOrDefault(p => string.Equals(p.ParamKey, "NoStAppDay")); BizParams paramTimeStart = BizParamsList.FirstOrDefault(p => string.Equals(p.ParamKey, "NoStAppTimeStart")); BizParams paramTimeEnd = BizParamsList.FirstOrDefault(p => string.Equals(p.ParamKey, "NoStAppTimeEnd")); if (int.Parse(paramDayofWeek.ParamValue) == (int)DateTime.Now.DayOfWeek) { DateTime timeStart = DateTime.Parse(DateTime.Now.ToShortDateString() + " " + paramTimeStart.ParamValue); DateTime timeEnd = DateTime.Parse(DateTime.Now.ToShortDateString() + " " + paramTimeEnd.ParamValue); if (DateTime.Now >= timeStart && DateTime.Now <= timeEnd) { return(false); } } return(true); }
protected void Save() { string errorMessage = ""; CacheHelper.RemoveCache(Consts.CACHE_KEY_BIZ_PARAMS); List <BizParams> updateList = new List <BizParams>(); //if (bizParamsList == null) // bizParamsList = Service.GetBizParamsList(); foreach (GridViewRow row in this.GridView1.Rows) { GridView gvParams = (GridView)row.FindControl("gvBizParams"); if (gvParams != null) { foreach (GridViewRow bpRow in gvParams.Rows) { //save each parameter string istr = gvParams.DataKeys[bpRow.DataItemIndex].Value.ToString(); if (!string.IsNullOrEmpty(istr)) { int paramId = Convert.ToInt32(istr); BizParams param = BizParamsList.FirstOrDefault(o => o.ParamID == paramId); BizParams model = new BizParams { DataType = param.DataType, GroupName = param.GroupName, ParamDesc = param.ParamDesc, ParamID = param.ParamID, ParamKey = param.ParamKey, ParamValue = param.ParamValue, ReadOnly = param.ReadOnly, Sequence = param.Sequence }; //TextBox tbValue = (TextBox)row.Cells[1].FindControl("paramValue"); try { TextBox textBox = (TextBox)bpRow.FindControl("paramValue"); CheckBox chkBox = (CheckBox)bpRow.FindControl("checkStatus"); DropDownList ddlList = (DropDownList)bpRow.FindControl("ddlList"); Label lblError = (Label)bpRow.FindControl("lblError"); lblError.Text = ""; string value = textBox.Text; if (model.DataType.ToLower() == TYPE_BOOL)//"bool") { value = chkBox.Checked.ToString(); } else if (model.DataType.ToLower() == TYPE_DAYOFWEEK) //"dayofweek") { value = ddlList.SelectedValue; } if (model.ParamValue.Trim() == value.Trim() || model.ReadOnly == true) { continue; //没有更改,不需要更新 } // value validation if (ValidateParamValue(model, value)) { model.ParamValue = value; } else { lblError.Text = "请输入正确格式"; // errorMessage += model.ParamDesc + "数据格式不正确,请按照要求输入\\n"; continue; } } catch { continue;//获取文本失败,跳过? } try { updateList.Add(model); //Service.UpdateBizParams(model); } catch { errorMessage += "更新参数" + model.ParamDesc + "失败\\n"; } } } } } if (updateList.Count > 0) { Service.UpdateBizParamsList(updateList); } CacheHelper.RemoveCache(Consts.CACHE_KEY_BIZ_PARAMS); ////if(!string.IsNullOrEmpty(errorMessage)) //// RegisterStartupScript("Message", "<script>alert('" +errorMessage + "');</script>"); }