public void checkJobs() { List<TaskData> lstTask = new TaskDa().getTasks(DateTime.Now); for (int i = 0; i < lstTask.Count;i++ ) { AddJob(lstTask[i], i); } }
private void loadData(DateTime date) { Session["date"] = date; renderWeek(date); //Get All Tasks TaskDa taskDa = new TaskDa(); List<TaskData> lstTasks = taskDa.getTaskByWeek(date); RenderWeekTable(lstTasks); }
protected void btnShowDevices_OnClick(int taskId) { btnAdd.Visible = false; btnSave.Visible = true; mpe.Show(); DeviceDa deviceDa = new DeviceDa(); TaskDa taskDa = new TaskDa(); TaskData taskData = taskDa.GetTask(taskId); Session["SelectedDevices"] = deviceDa.GetDevicesFromTask(taskId); Session["ActiveTask"] = taskData; grdDevices.DataSource = deviceDa.getDevices(); grdDevices.DataBind(); }
protected void btnAddDate_OnClick(object sender, EventArgs e) { if (EnumBackupTask.Procedure.immediately==(EnumBackupTask.Procedure)Session["BackupTask"]) { BackupServerClient serverClient = GlobalVariables.serverClient; if (serverClient != null) { //Check the selected devices List<TaskData> lstTaskData = new List<TaskData>(); DateTime taskDate = DateTime.Now; for (int i = 0; i < grdDevices.Rows.Count; i++) { CheckBox chkSelectDevice = (CheckBox)grdDevices.Rows[i].Cells[0].FindControl("ChbSelect"); if (chkSelectDevice.Checked) { TaskData taskData = new TaskData(); taskData.Id = -1; taskData.Date = taskDate; taskData.Repeat = (int)EnumSchedule.Task.Once; taskData.RepeatDay = -1; taskData.RepeatDayOftheWeek = -1; taskData.RepeatMonth = -1; lstTaskData.Add(taskData); } } if (lstTaskData.Count > 0) { SocketBackupTransportData socketTransportData = new SocketBackupTransportData(); socketTransportData.Date = taskDate; socketTransportData.Command = EnumSocketCommands.Command.FAST_BACKUP.ToString(); string sValue = ObjectSerializer.SerializeToString(socketTransportData); bool sended = serverClient.send(sValue); //List<SocketBackupTransportData> lstBackup = ObjectSerializer.SerializeFromString<List<SocketBackupTransportData>>(sValue); if (sended) { for (int i = 0; i < lstTaskData.Count; i++) { TaskDa taskDa = new TaskDa(); taskDa.Save(lstTaskData[i]); } } else { Page.RegisterClientScriptBlock("Alert Task", "<script language='javascript'>alert('Server Error: Task not executed!')</script>"); } } loadData(DateTime.Now); } else { Page.RegisterClientScriptBlock("Alert Task", "<script language='javascript'>alert('Error: Task not executed!')</script>"); } } else { TaskData taskData = new TaskData(); DateTime date = DateTime.Parse(txtDate.Text, new CultureInfo("en-US", false)); string[] time = txtHour.Text.Split(':'); taskData.Date = new DateTime(date.Year, date.Month, date.Day, int.Parse(time[0]), int.Parse(time[1]), 0); switch (drpSchedule.SelectedIndex) { case (int)EnumSchedule.Task.Once: taskData.Repeat = (int)EnumSchedule.Task.Once; taskData.RepeatDayOftheWeek = -1; taskData.RepeatDay = -1; taskData.RepeatMonth = -1; break; case (int)EnumSchedule.Task.Dailey: taskData.Repeat = (int)EnumSchedule.Task.Dailey; taskData.RepeatDayOftheWeek = -1; taskData.RepeatDay = -1; taskData.RepeatMonth = -1; break; case (int)EnumSchedule.Task.Weekley: taskData.Repeat = (int)EnumSchedule.Task.Weekley; taskData.RepeatDayOftheWeek = (int)date.DayOfWeek; taskData.RepeatDay = -1; taskData.RepeatMonth = -1; break; case (int)EnumSchedule.Task.Monthly: taskData.Repeat = (int)EnumSchedule.Task.Monthly; taskData.RepeatDayOftheWeek = (int)date.DayOfWeek; taskData.RepeatDay = -1; taskData.RepeatMonth = -1; break; case (int)EnumSchedule.Task.Annually: taskData.Repeat = (int)EnumSchedule.Task.Annually; break; } TaskDa taskDa = new TaskDa(); taskDa.Save(taskData); //Check the selected devices for (int i = 0; i < grdDevices.Rows.Count; i++) { CheckBox chkSelectDevice = (CheckBox)grdDevices.Rows[i].Cells[0].FindControl("ChbSelect"); if (chkSelectDevice.Checked) { TaskDeviceData taskDeviceData = new TaskDeviceData(); taskDeviceData.Bu_device_id = int.Parse(grdDevices.DataKeys[i].Value.ToString()); taskDeviceData.Bu_task_id = taskData.Id; } } loadData(taskData.Date); } }
protected void btnSaveDate_OnClick(object sender, EventArgs e) { TaskData taskData = (TaskData) Session["ActiveTask"]; List<Device> lstActiveDevices = new List<Device>(); for (int i = 0; i < grdDevices.Rows.Count; i++) { int id = (int) grdDevices.DataKeys[i].Value; DeviceDa deviceDa = new DeviceDa(); Device device = deviceDa.GetDevice(id); //Device device = (Device) ; CheckBox ChbSelect = (CheckBox) grdDevices.Rows[i].Cells[0].FindControl("ChbSelect"); if (ChbSelect.Checked) { lstActiveDevices.Add(device); } } TaskDa taskDa = new TaskDa(); taskDa.updateTask(taskData, lstActiveDevices); //Update loadData(taskData.Date); }