计划任务配置管理页面

发表于:2018-8-16 11:31

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:哥屋恩0528    来源:CSDN

 
  @model CoronaDataCenter.Models.PlanModel
  @{
  ViewBag.Title = "编辑计划配置";
  if (ViewBag.ActionType == "View")
  {
  ViewBag.Title = "计划配置详情";
  }
  else if (ViewBag.ActionType == "Create")
  {
  ViewBag.Title = "添加计划配置";
  }
  else if (ViewBag.ActionType == "Edit")
  {
  ViewBag.Title = "编辑计划配置";
  }
  Layout = "~/Views/Shared/_LayoutB.cshtml";
  }
  @section Head{
  <script src="@Url.Content("~/Scripts/Validate/jquery-Lweight-validate-min.js")" type="text/javascript"></script>
  <link href="@Url.Content("~/Scripts/Validate/Lweight.css")" rel="stylesheet" type="text/css" />
  <script src="@Url.Content("~/Scripts/Common/commonTools.min.js")" type="text/javascript"></script>
  <script src="@Url.Content("~/Scripts/DatePicker/WdatePicker.js")" type="text/javascript"></script>
  <script src="../../Scripts/UI/jquery.easyui.min.js"></script>
  }
  <style type="text/css">
  .input_ContentCenter{
  line-height: 34px;
  height: 34px;
  }
  </style>
  <button class="btn btn-info btn-sm col-md-offset-1" type="button" style="margin-top: 10px;" onclick="javascript:history.back(-1);">
  <span class="glyphicon glyphicon-arrow-left col-md-offset-1 " style="color: white; font-size: 1.5em;"></span>
  </button>
  <div class="container">
  <div class="row">
  <div class="col-md-6 col-md-offset-3">
  <form id="EditData" class="form-horizontal" role="form" method="post" form-key="true" enctype="multipart/form-data">
  <div class="form-group">
  <label for="PlanName" class="col-md-2">计划名称</label>
  <div class="col-md-6">
  <input id="PlanName" name="PlanName" value="@Model.PlanName" class="form-control" placeholder = "请输入计划名称" check-type="required" required-message="请输入计划名称" />
  </div>
  <div class="col-md-3"><font color="red">*</font></div>
  </div>
  <div class="form-group">
  <label for="Sn" class="col-md-2">电站</label>
  <div class="col-md-6">
  <select id="selSn" name="Sn" class="form-control" check-type="required" required-message="请选择电站">
  <option></option>
  @foreach (var item in ViewBag.Stations as List<SelectListItem>)
  {
  if (Model.Sn == item.Value.Split(',')[0])
  {
  <option value="@item.Value" selected="selected">@item.Text</option>
  }
  else
  {
  <option value="@item.Value">@item.Text</option>
  }
  }
  </select>
  </div>
  <div class="col-md-3"><font color="red">*</font></div>
  </div>
  <div class="form-group">
  <label for="PlanBeginTime" class="col-md-2">开始时间</label>
  <div class="col-md-6">
  <input id="PlanBeginTime" name="PlanBeginTime" value="@Model.PlanBeginTime" class="form-control Wdate" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" check-type="required" required-message="请选择开始时间" />
  </div>
  <div class="col-md-3"><font color="red">*</font></div>
  </div>
  <div class="form-group">
  <label for="PlanEndTime" class="col-md-2">结束时间</label>
  <div class="col-md-6">
  <input id="PlanEndTime" name="PlanEndTime" value="@Model.PlanEndTime" class="form-control Wdate" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"/>
  </div>
  </div>
  <div class="form-group">
  <label for="PlanInterval" class="col-md-2">执行频率</label>
  <div class="col-md-6">
  <select id="PlanInterval" name="PlanInterval" class="form-control" val="@Model.PlanInterval" check-type="required" required-message="请选择时间间隔">
  @foreach (var item in ViewBag.PlanIntervalsList as List<SelectListItem>)
  {
  if (Model.PlanInterval == item.Value)
  {
  <option value="@item.Value" selected="selected">@item.Text</option>
  }
  else
  {
  <option value="@item.Value">@item.Text</option>
  }
  }
  </select>
  </div>
  <div class="col-md-3"><font color="red">*</font></div>
  </div>
  <!------------实时------------>
  <div class="form-group EveryInTime">
  <label for="EveryInTime" class="col-md-2">执行间隔</label>
  <div class="col-md-3">
  <input id="ExecutionInterval_InTime" name="ExecutionInterval_InTime" value="@Model.ExecutionInterval" class="form-control InTime" check-type="required" required-message="请输入执行间隔" />
  </div>
  <div class="col-md-2">
  <select id="ExecutionIntervalType_InTime" name="ExecutionIntervalType_InTime" class="form-control InTime" val="@Model.ExecutionIntervalType" check-type="required" required-message="请选择每天频率">
  @foreach (var item in ViewBag.ExecutionIntervalTypeSelectList as List<SelectListItem>)
  {
  if (Model.ExecutionIntervalType == item.Value)
  {
  <option value="@item.Value" selected="selected">@item.Text</option>
  }
  else
  {
  <option value="@item.Value">@item.Text</option>
  }
  }
  </select>
  </div>
  <div class="col-md-3"><font color="red">*</font></div>
  </div>
  <!------------实时------------>
  <!------------每天------------>
  <div class="form-group EveryDay">
  <div class="col-md-3">
  <input type="hidden" id="hidExecutionTime_EveryDayType" value="@Model.ExecutionTime_EveryDayType"/>
  <input type="radio" name="ExecutionTime_EveryDayType" value="OneTime" /> 执行一次
  </div>
  <div class="col-md-1">
  <input id="ExecutionTime_DayHours" value="@Model.ExecutionTime_Hours" class="form-control ExecutionTime_EveryDay OneTime" name="ExecutionTime_DayHours" />
  </div>
  <div class="col-md-1 input_ContentCenter">
  <label>时:</label>
  </div>
  <div class="col-md-1">
  <input id="ExecutionTime_DayMinutes" value="@Model.ExecutionTime_Minutes" class="form-control ExecutionTime_EveryDay OneTime" name="ExecutionTime_DayMinutes" />
  </div>
  <div class="col-md-1 input_ContentCenter">
  <label>分:</label>
  </div>
  <div class="col-md-1">
  <input id="ExecutionTime_DaySeconds" value="@Model.ExecutionTime_Seconds" class="form-control ExecutionTime_EveryDay OneTime" name="ExecutionTime_DaySeconds" />
  </div>
  <div class="col-md-1 input_ContentCenter">
  <label>秒</label>
  </div>
  <div class="col-md-2"><font color="red">*</font></div>
  </div>
  <div class="form-group EveryDay">
  <div class="col-md-3">
  <input type="radio" name="ExecutionTime_EveryDayType" value="Repeated" /> 执行间隔
  </div>
  <div class="col-md-3">
  <input id="ExecutionInterval" name="ExecutionInterval" value="@Model.ExecutionInterval" class="form-control Repeated" check-type="required" required-message="请输入执行间隔" />
  </div>
  <div class="col-md-2">
  <select id="ExecutionIntervalType" name="ExecutionIntervalType" class="form-control Repeated" val="@Model.ExecutionIntervalType" check-type="required" required-message="请选择每天频率">
  @foreach (var item in ViewBag.ExecutionIntervalTypeSelectList as List<SelectListItem>)
  {
  if (Model.ExecutionIntervalType == item.Value)
  {
  <option value="@item.Value" selected="selected">@item.Text</option>
  }
  else
  {
  <option value="@item.Value">@item.Text</option>
  }
  }
  </select>
  </div>
  <div class="col-md-3"><font color="red">*</font></div>
  </div>
  <!------------每天------------>
  <!------------每周------------>
  <div class="form-group EveryWeek">
  <label for="ExecutionWeek" class="col-md-2">执行星期</label>
  <div class="col-md-6">
  <select id="ExecutionWeek" name="ExecutionWeek" class="form-control" val="@Model.ExecutionWeek" check-type="required" required-message="请选择执行星期数">
  @foreach (var item in ViewBag.ExecutionWeekList)
  {
  if (Model.ExecutionWeek == item.Value)
  {
  <option value="@item.Value" selected="selected">@item.Text</option>
  }
  else
  {
  <option value="@item.Value">@item.Text</option>
  }
  }
  </select>
  </div>
  <div class="col-md-3"><font color="red">*</font></div>
  </div>
  <!------------每周------------>
  <!------------每月------------>
  <div class="form-group EveryMonth">
  <label for="ExecutionDay" class="col-md-2">执行日期</label>
  <div class="col-md-6">
  <select id="ExecutionDay" name="ExecutionDay" class="form-control" val="@Model.ExecutionDay" check-type="required" required-message="请选择执行日期">
  @foreach (var item in ViewBag.ExecutionDayList)
  {
  if (Model.ExecutionDay == item.Value)
  {
  <option value="@item.Value" selected="selected">@item.Text</option>
  }
  else
  {
  <option value="@item.Value">@item.Text</option>
  }
  }
  </select>
  </div>
  <div class="col-md-3"><font color="red">*</font></div>
  </div>
  <!------------每月------------>
  <!------------------执行时间------------------->
  <div class="form-group ExecutionTime">
  <label for="ExecutionTime_Hours" class="col-md-2">执行时间</label>
  <div class="col-md-1">
  <input id="ExecutionTime_Hours" value="@Model.ExecutionTime_Hours" class="form-control ExecutionTime_Common" name="ExecutionTime_Hours" />
  </div>
  <div class="col-md-1 input_ContentCenter">
  <label>时:</label>
  </div>
  <div class="col-md-1">
  <input id="ExecutionTime_Minutes" value="@Model.ExecutionTime_Minutes" class="form-control ExecutionTime_Common" name="ExecutionTime_Minutes" />
  </div>
  <div class="col-md-1 input_ContentCenter">
  <label>分:</label>
  </div>
  <div class="col-md-1">
  <input id="ExecutionTime_Seconds" value="@Model.ExecutionTime_Seconds" class="form-control ExecutionTime_Common" name="ExecutionTime_Seconds" />
  </div>
  <div class="col-md-1 input_ContentCenter">
  <label>秒</label>
  </div>
  <div class="col-md-3"><font color="red">*</font></div>
  </div>
  <!------------------执行时间------------------->
  <div class="form-group">
  <label for="PlanReceiver" class="col-md-2">接收人</label>
  <div class="col-md-6">
  <select id="selPlanReceiver" name="PlanReceiver" class="form-control" check-type="required" required-message="请选择接收人" multiple>
  @if (!string.IsNullOrEmpty(Model.PlanReceiver))
  {
  foreach (var item in ViewBag.PlanReceiverList as List<SelectListItem>)
  {
  if (@Model.PlanReceiver.Contains(item.Value))
  {
  <option value="@item.Value" selected="selected">@item.Text</option>
  }
  else
  {
  <option value="@item.Value">@item.Text</option>
  }
  }
  }
  </select>
  </div>
  <div class="col-md-3"><font color="red">*</font></div>
  </div>
  <div class="form-group">
  <label for="PlanReceiveMethod" class="col-md-2">接收方式</label>
  <div class="col-md-6">
  <select id="PlanReceiveMethod" name="PlanReceiveMethod" class="form-control" check-type="required" required-message="请选择接收方式" multiple>
  @if (!string.IsNullOrEmpty(Model.PlanReceiveMethod))
  {
  foreach (var item in ViewBag.PlanReceiveMethodsList as List<SelectListItem>)
  {
  if (@Model.PlanReceiveMethod.Contains(item.Value))
  {
  <option value="@item.Value" selected="selected">@item.Text</option>
  }
  else
  {
  <option value="@item.Value">@item.Text</option>
  }
  }
  }
  else
  {
  foreach (var item in ViewBag.PlanReceiveMethodsList as List<SelectListItem>)
  {
  <option value="@item.Value">@item.Text</option>
  }
  }
  </select>
  </div>
  <div class="col-md-3"><font color="red">*</font></div>
  </div>
  <div class="form-group">
  <div class="col-md-6 col-md-offset-3">
  @if (ViewBag.ActionType == "Edit" || ViewBag.ActionType == "Create")
  {
  <button id="btnSave" type="submit" class="btn btn-primary borderRadius">
  <span class="glyphicon glyphicon-ok"> 保存</span>
  </button>
  }
  <button id="btnCancel" type="button" class="btn btn-danger borderRadius" onclick="Cancel();">
  <span class="glyphicon glyphicon-remove"> 取消</span>
  </button>
  <input id="ActionType" type="hidden" name="ActionType" value="@ViewBag.ActionType" />
  <input id="PlanID" type="hidden" name="PlanID" value="@Model.PlanID" />
  <input id="TaskID" type="hidden" name="TaskID" value="@ViewBag.TaskID" />
  <input id="hidErrorMsg" type="hidden" value="@ViewBag.ErrorMsg" />
  <input id="btn" type="button" value="test" class="btn" onclick="GetPlanIntervalVal();" style="display:none;" />
  </div>
  </div>
  </form>
  </div>
  </div>
  </div>
  <!--Bootstrap Modal对话框框 -->
  <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
  <div class="modal-content">
  <div class="modal-header">
  <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
  <h4 class="modal-title" id="myModalLabel">提示信息</h4>
  </div>
  <div class="modal-body" id="modal-body" style="color: red; text-align: center;">
  </div>
  <div class="modal-footer">
  <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
  </div>
  </div>
  </div>
  </div>
  <script type="text/javascript">
  $(function () {
  //保存按钮
  SaveAlert(); //保存之后的错误提醒
  selectChange("selSn", "selPlanReceiver");   //联动下拉框
  $("#EditData").myValidate(
  {
  formCall: function () { $("#EditData").submit(); },
  isAlert: false,
  formKey: false,
  alterCall: function (msg) { }
  });
  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
  CheckRadio();                       //Radio单选取值
  CheckPlanInterval();                //首次加载,根据频率当前选择值初始化控件
  PlanIntervalChange();               //下拉框change事件
  EveryDayClick();                    //radio的click事件
  CheckExecutionTime_EveryDay();      //input中只能输入正整数
  CheckHours();                       //input中只能输入0-23的正整数
  CheckMinutesAndSeconds();           //input中只能输入0-59的正整数
  });
  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  //首次加载,根据频率当前选择值初始化控件
  function CheckPlanInterval() {
  //检测频率下拉框,初始化不同频率相关html控件
  var selPlanInterval = $("#PlanInterval option:selected").val(); //获取执行间隔(频率)下拉框当前选择值
  //alert(selPlanInterval);
  if (selPlanInterval == 0) {         //实时
  $(".EveryInTime").css("display", "block");
  $(".EveryDay").css("display", "none");
  $(".EveryWeek").css("display", "none");
  $(".EveryMonth").css("display", "none");
  $(".ExecutionTime").css("display", "none");
  }
  else if (selPlanInterval == 1) {    //每天
  $(".EveryInTime").css("display", "none");
  $(".EveryDay").css("display", "block");
  $(".EveryWeek").css("display", "none");
  $(".EveryMonth").css("display", "none");
  $(".ExecutionTime").css("display", "none");
  }
  else if (selPlanInterval == 2) {    //每周
  $(".EveryInTime").css("display", "none");
  $(".EveryDay").css("display", "none");
  $(".EveryWeek").css("display", "block");
  $(".EveryMonth").css("display", "none");
  $(".ExecutionTime").css("display", "block");
  }
  else if (selPlanInterval == 3) {    //每月
  $(".EveryInTime").css("display", "none");
  $(".EveryDay").css("display", "none");
  $(".EveryWeek").css("display", "none");
  $(".EveryMonth").css("display", "block");
  $(".ExecutionTime").css("display", "block");
  }
  //初始化频率为‘每天’的相关html控件
  var chkEveryDay = $("input[name='ExecutionTime_EveryDayType']:checked").val();  //获取CheckBox当前选择值
  //alert(chkEveryDay);
  if (chkEveryDay == "OneTime") {
  $('.OneTime').removeAttr("disabled");//去除input元素的disabled属性
  $('.Repeated').attr("disabled", "disabled");//将input元素设置为disabled
  $("#ExecutionInterval").val('');
  }
  else {
  $('.OneTime').attr("disabled", "disabled")//将input元素设置为disabled
  $('.Repeated').removeAttr("disabled");//去除input元素的disabled属性
  $(".ExecutionTime_EveryDay").val(''); //清空文本框
  }
  }
  //下拉框change事件
  function PlanIntervalChange() {
  $("#PlanInterval").on("change", function () {
  var selPlanInterval = $("#PlanInterval option:selected").val(); //获取执行间隔(频率)下拉框当前选择值
  //alert(selPlanInterval);
  if (selPlanInterval == 0) {         //实时
  $(".EveryInTime").css("display", "block");
  $(".EveryDay").css("display", "none");
  $(".EveryWeek").css("display", "none");
  $(".EveryMonth").css("display", "none");
  $(".ExecutionTime").css("display", "none");
  }
  else if (selPlanInterval == 1) {    //每天
  $(".EveryInTime").css("display", "none");
  $(".EveryDay").css("display", "block");
  $(".EveryWeek").css("display", "none");
  $(".EveryMonth").css("display", "none");
  $(".ExecutionTime").css("display", "none");
  }
  else if (selPlanInterval == 2) {    //每周
  $(".EveryInTime").css("display", "none");
  $(".EveryDay").css("display", "none");
  $(".EveryWeek").css("display", "block");
  $(".EveryMonth").css("display", "none");
  $(".ExecutionTime").css("display", "block");
  }
  else if (selPlanInterval == 3) {    //每月
  $(".EveryInTime").css("display", "none");
  $(".EveryDay").css("display", "none");
  $(".EveryWeek").css("display", "none");
  $(".EveryMonth").css("display", "block");
  $(".ExecutionTime").css("display", "block");
  }
  //清空执行时间文本框
  $(".ExecutionTime_Common").val(''); //执行时间的时分秒
  $(".ExecutionTime_EveryDay").val(''); //执行时间的时分秒
  $("#ExecutionInterval_InTime").val(''); //实时,执行间隔
  });
  }
  //radio的click事件,根据当前选择控制html控件是否可用,注:频率为‘每天’时,‘执行一次’与‘执行间隔’只能选一种
  function EveryDayClick() {
  $("input[name='ExecutionTime_EveryDayType']").on("click", function () {
  var chkEveryDay = $("input[name='ExecutionTime_EveryDayType']:checked").val();  //获取CheckBox当前选择值
  //alert(chkEveryDay);
  if (chkEveryDay == "OneTime") {
  $('.OneTime').removeAttr("disabled");//去除input元素的disabled属性
  $('.Repeated').attr("disabled", "disabled");//将input元素设置为disabled
  $("#ExecutionInterval").val('');
  }
  else {
  $('.OneTime').attr("disabled", "disabled");//将input元素设置为disabled
  $('.Repeated').removeAttr("disabled");//去除input元素的disabled属性
  $(".ExecutionTime_EveryDay").val(''); //清空文本框
  }
  });
  }
  //Radio单选取值
  function CheckRadio() {
  var hidRadio = $("#hidExecutionTime_EveryDayType").val();
  var radios = document.getElementsByName("ExecutionTime_EveryDayType");
  if (hidRadio.length > 0) {
  if (hidRadio == "OneTime") {
  radios[0].checked = true;
  } else {
  radios[1].checked = true;
  }
  }
  else {
  radios[0].checked = true;
  }
  }
  //input中只能输入正整数
  function CheckExecutionTime_EveryDay() {
  //限制键盘只能按数字键、小键盘数字键、退格键
  $("#ExecutionInterval,#ExecutionInterval_InTime").keyup(function (e) {
  if(this.value.length==1){
  this.value=this.value.replace(/[^1-9]/g,'')
  }else{
  this.value=this.value.replace(/\D/g,'')
  }
  }).bind("paste", function () {  //CTR+V事件处理
  if (this.value.length == 1) {
  this.value = this.value.replace(/[^1-9]/g, '')
  } else {
  this.value = this.value.replace(/\D/g, '')
  }
  });
  }
  //input中只能输入0-23的正整数
  function CheckHours() {
  //限制键盘只能按数字键、小键盘数字键、退格键
  $("#ExecutionTime_Hours,#ExecutionTime_DayHours").keyup(function (e) {
  //var reg = /^([1-9]|1\d|2[0-3])$/;
  var reg = /^(2[0-3]|[0-1]?\d)$/;
  var r = this.value.match(reg);
  if (r == null) {
  this.value = '';
  }
  }).bind("paste", function () {  //CTR+V事件处理
  //var reg = /^([1-9]|1\d|2[0-3])$/;
  var reg = /^(2[0-3]|[0-1]?\d)$/;
  var r = this.value.match(reg);
  if (r == null) {
  this.value = '';
  }
  });
  }
  //input中只能输入0-59的正整数
  function CheckMinutesAndSeconds() {
  //限制键盘只能按数字键、小键盘数字键、退格键
  $("#ExecutionTime_Minutes,#ExecutionTime_Seconds,#ExecutionTime_DayMinutes,#ExecutionTime_DaySeconds").keyup(function (e) {
  //var reg = /^([1-9]|[1-4]\d|5[0-9])$/;
  var reg = /^[0-5]?[0-9]$/;
  var r = this.value.match(reg);
  if (r == null) {
  this.value = '';
  }
  }).bind("paste", function () {  //CTR+V事件处理
  //var reg = /^([1-9]|[1-4]\d|5[0-9])$/;
  var reg = /^[0-5]?[0-9]$/;
  var r = this.value.match(reg);
  if (r == null) {
  this.value = '';
  }
  });
  }
  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  //取消按钮
  function Cancel() {
  window.location.href = "/SystemManager/PlanManager?id=@ViewBag.TaskID";
  }
  //保存之后的错误提醒
  function SaveAlert() {
  var ErMsg = $("#hidErrorMsg").val();
  if ($.trim(ErMsg).length > 0) {
  //alert(ErMsg);
  $('#modal-body').append(ErMsg);
  $('#myModal').modal();
  }
  }
  //获取多选框值,值类型为数组需转换为字符串便于保存
  function GetPlanIntervalVal() {
  var varStr = $("#PlanInterval").val();   //获取多选框值,值类型为数组
  varStr = varStr.join();   //将数组转换为字符串
  $("#PlanInterval").attr("value", varStr); //多选框赋值
  }
  //下拉框联动
  function selectChange(selSn, selPlanReceiver) {
  $("#" + selSn).change(function () {
  $("#" + selPlanReceiver + " option").remove();  //初始化下拉框
  $.ajax({
  type: "POST",
  dataType: "json",
  url: " @Url.Action("GetPlanReceiverBySN", "SystemManager")",
  data: { strSn: $(this).val() },
  success: function (data) {
  if (data.length > 0) {
  $.map(data, function (item, index) {
  $("#" + selPlanReceiver).append("<option value=" + item.Value + ">" + item.Text + "</option>");
  });
  }
  }
  });
  });
  }
  </script>
  #region 计划任务配置 add by lupeng on 20160506
  //计划任务配置页面
  public ActionResult PlanAndTaskManager(string PlanID)
  {
  Session[MyConst.StartTime] = DateTime.Now.ToString();
  SysLogModel sysModel = new SysLogModel()
  {
  Action = "计划任务配置",
  Content = "浏览",
  ModuleCode = "XTGL-XT-JHRW"
  };
  Syslog.InsertSYSLog(sysModel);
  ViewBag.startTime = "";
  ViewBag.endTime = "";
  List<TaskModel> model = new List<TaskModel>();
  model = SearchTaskData(ViewBag.startTime, ViewBag.endTime, PlanID, "", "");
  return View(model);
  }
  //计划任务配置页的提交,这里是“查询”,其参数是POST方式传递过来的,参数名是控件(input\select等)的name属性
  [HttpPost]
  public ActionResult PlanAndTaskManager(string startTime, string endTime, string PlanID, string TaskName, string TaskID)
  {
  SysLogModel sysModel = new SysLogModel()
  {
  Action = "计划任务配置",
  Content = "查询",
  ModuleCode = "XTGL-XT-JHRW"
  };
  Syslog.InsertSYSLog(sysModel);
  List<TaskModel> model = new List<TaskModel>();
  model = SearchTaskData(startTime, endTime, PlanID, TaskName, TaskID);
  return View(model);
  }
  [NonAction]
  private List<TaskModel> SearchTaskData(string startTime, string endTime, string PlanID, string TaskName, string TaskID)
  {
  SystemManager syMan = new SystemManager();
  if (!string.IsNullOrEmpty(startTime) && !string.IsNullOrEmpty(endTime)) //有起止日期
  {
  ViewBag.startTime = startTime;
  ViewBag.endTime = Convert.ToDateTime(endTime).AddDays(1).ToShortDateString().Replace("/", "-");
  }
  else if (!string.IsNullOrEmpty(startTime) && string.IsNullOrEmpty(endTime)) //有开始日期
  {
  ViewBag.startTime = startTime;
  ViewBag.endTime = Convert.ToDateTime(startTime).AddDays(1).ToShortDateString().Replace("/", "-");
  }
  else if (string.IsNullOrEmpty(startTime) && !string.IsNullOrEmpty(endTime)) //有结束日期
  {
  ViewBag.startTime = Convert.ToDateTime(startTime).AddDays(-1).ToShortDateString().Replace("/", "-");
  ViewBag.endTime = endTime;
  }
  List<TaskModel> List = syMan.GetTaskData(ViewBag.startTime, ViewBag.endTime, PlanID, TaskName, TaskID);
  ViewBag.PlanID = PlanID;    //任务ID
  ViewBag.PlanName = syMan.GetPlanDataByID(PlanID).PlanName;    //任务名称
  return List;
  }
  //编辑View
  public ActionResult EditPlanAndTask(string ActionType, string PlanID, string TaskID)
  {
  TaskModel model = new TaskModel();
  Session[MyConst.StartTime] = DateTime.Now;
  ViewBag.PlanID = PlanID;    //任务ID
  model.PlanID = PlanID;
  ViewBag.ActionType = ActionType;
  string ActionContent = string.Empty;
  if (ActionType == "Create")
  {
  ActionContent = "添加任务配置";
  ViewBag.TaskID = 0;
  }
  else if (ActionType == "Edit")
  {
  ActionContent = "编辑任务配置";
  model = syMan.GetTaskDataByID(TaskID);
  ViewBag.TaskID = model.TaskID;
  }
  else if (ActionType == "View")
  {
  ActionContent = "任务配置详情";
  model = syMan.GetTaskDataByID(TaskID);
  ViewBag.TaskID = model.TaskID;
  }
  //添加日志
  SysLogModel sysModel = new SysLogModel()
  {
  Action = "计划任务配置",
  Content = ActionContent,
  ModuleCode = "XTGL-XT-JHRW"
  };
  Syslog.InsertSYSLog(sysModel);
  List<PlanModel> planLists = syMan.GetPlanData("", "", "");
  ViewBag.PlanList = CommonTools.GetPlanSelectList(planLists); //计划下拉框数据源
  ViewBag.TaskTypesList = TaskTypesSelectList();    //任务类型下拉框数据源
  return View(model);
  }
  //编辑,Post方法
  [HttpPost]
  public ActionResult EditPlanAndTask(TaskModel model, string ActionType)
  {
  List<PlanModel> planLists = syMan.GetPlanData("", "", "");
  ViewBag.PlanList = CommonTools.GetPlanSelectList(planLists); //计划下拉框数据源
  ViewBag.TaskTypesList = TaskTypesSelectList();    //任务类型下拉框数据源
  string strContent = string.Empty;
  if (ActionType == "Create")
  {
  strContent = "添加";
  ViewBag.ActionType = "Create";
  }
  else
  {
  strContent = "修改";
  ViewBag.ActionType = "Edit";
  }
  if (ModelState.IsValid)
  {
  #region
  if (ActionType == "Create")   //新增操作
  {
  #region
  model.TaskCreateUser = (Session[MyConst.UserModel] as AccountModel).ID.ToString();
  List<TaskModel> list = syMan.GetTaskData("", "", model.PlanID, model.TaskName, "");
  if (list != null && list.Count > 0) //验证是否重复
  {
  ViewBag.ErrorMsg += "<label>任务配置名称已存在!</label></br> ";
  //插入系统日志
  SysLogModel sysModel = new SysLogModel()
  {
  Action = strContent + "任务配置",
  Content = strContent + "失败",
  ModuleCode = "XTGL-XT-JHRW"
  };
  Syslog.InsertSYSLog(sysModel);
  return View(model);
  }
  else
  {
  int result = syMan.InsertTaskData(model);   //新增数据
  //插入系统日志
  SysLogModel sysModel = new SysLogModel()
  {
  Action = strContent + "任务配置",
  Content = result > 0 ? strContent + "成功" : strContent + "失败",
  ModuleCode = "XTGL-XT-XWGG"
  };
  Syslog.InsertSYSLog(sysModel);
  if (result > 0)
  {
  return RedirectToAction("PlanAndTaskManager", "SystemManager", new { PlanID = model.PlanID });
  }
  else
  {
  ViewBag.ErrorMsg = strContent + "失败";
  return View(model);
  }
  }
  #endregion
  }
  else //修改操作
  {
  #region
  model.TaskModifyUser = (Session[MyConst.UserModel] as AccountModel).ID.ToString();
  int result = syMan.ModifyTaskData(model);   //修改数据
  //插入系统日志
  SysLogModel sysModel1 = new SysLogModel()
  {
  Action = strContent + "任务配置",
  Content = result > 0 ? strContent + "成功" : strContent + "失败",
  ModuleCode = "XTGL-XT-XWGG"
  };
  Syslog.InsertSYSLog(sysModel1);
  if (result > 0)
  {
  //this.TempData["PlanID"] = model.PlanID;
  return RedirectToAction("PlanAndTaskManager", "SystemManager", new { PlanID = model.PlanID });
  }
  else
  {
  ViewBag.ErrorMsg = strContent + "失败";
  return View(model);
  }
  #endregion
  }
  #endregion
  }
  else
  {
  ViewBag.ErrorMsg = strContent + "失败";
  //插入系统日志
  SysLogModel sysModel = new SysLogModel()
  {
  Action = strContent +"任务配置",
  Content = strContent + "失败",
  ModuleCode = "XTGL-XT-XWGG"
  };
  Syslog.InsertSYSLog(sysModel);
  return View(model);
  }
  }
  //删除任务配置
  [HttpPost]
  public ContentResult TaskDelete(int id)
  {
  int result = syMan.DeleteTask(id);
  SysLogModel sysModel = new SysLogModel()
  {
  Action = "删除任务配置",
  Content = result > 0 ? "删除成功" : "删除失败",
  ModuleCode = "XTGL-XT-XWGG"
  };
  Syslog.InsertSYSLog(sysModel);
  if (result > 0)
  {
  return Content("ok");
  }
  else
  {
  return Content("");
  }
  }


   上文内容不用于商业目的,如涉及知识产权问题,请权利人联系博为峰小编(021-64471599-8017),我们将立即处理。
21/212>
《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计 发展历程

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2024
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号