public static decimal createTask(tasks tasks)
        {
            using (var conn = new db_entities()) {
                try {
                    conn.SP_TASK_INSERT(tasks.name, tasks.description,
                                        tasks.process_id, tasks.father_taks_id,
                                        tasks.task_status, tasks.date_start,
                                        tasks.date_end, DateTime.Now,
                                        tasks.creator_user_id, tasks.assing_id);
                    var result = conn.tasks.Where(x => x.name == tasks.name &&
                                                  x.description == tasks.description &&
                                                  x.creator_user_id == tasks.creator_user_id).FirstOrDefault();

                    if (result != null)
                    {
                        log_task logTask = new log_task();
                        logTask.task_id          = result.id;
                        logTask.task_status_code = tasks.task_status;
                        conn.log_task.Add(logTask);
                        //conn.SaveChanges();

                        return(result.id);
                    }
                    else
                    {
                        return(-1);
                    }
                } catch (Exception e) {
                    throw e;
                }
            }
        }
Beispiel #2
0
        public tasks tasksGetByEventsDetectionId(int EventsDetectionId)
        {
            try
            {
                DataTable dt = SqlHelper.ExecuteDataset(SqlImplHelper.getConnectionString(), "tasksGetByIntrusionDetectionId",
                                                        EventsDetectionId).Tables[0];
                tasks NewEnt = new tasks();

                if (dt.Rows.Count > 0)
                {
                    DataRow dr = dt.Rows[0];
                    NewEnt.TaskId            = Int32.Parse(dr["TaskId"].ToString());
                    NewEnt.EventsDetectionId = Int32.Parse(dr["EventsDetectionId"].ToString());
                    NewEnt.TaskStatudId      = Int32.Parse(dr["TaskStatudId"].ToString());
                    NewEnt.UserId            = Int32.Parse(dr["UserId"].ToString());
                    NewEnt.TaskTittle        = dr["TaskTittle"].ToString();
                    NewEnt.DateTime          = DateTime.Parse(dr["DateTime"].ToString());
                }
                return(NewEnt);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #3
0
 private void btnRemoveTask_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         int taskId = Convert.ToInt32(taskTest[1].TrimStart(' '));
         MessageBoxResult result = MessageBox.Show($"Вы точно уверены, что хотите удалить проект {taskTest[3].TrimStart(' ')}?", "Delete", MessageBoxButton.YesNo);
         if (result == MessageBoxResult.Yes)
         {
             using (llblanca_lara1Entities db = new llblanca_lara1Entities())
             {
                 tasks     t   = db.tasks.Where(p => p.id == taskId).FirstOrDefault();
                 task_user tas = db.task_user.Where(ts => ts.id_task == t.id).FirstOrDefault();
                 if (tas != null)
                 {
                     db.task_user.Remove(tas);
                     db.SaveChanges();
                 }
                 db.tasks.Remove(t);
                 db.SaveChanges();
                 MessageBox.Show($"Task {taskTest[3].TrimStart(' ')} is delete");
             }
         }
         else
         {
             return;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Task is not selected");
     }
 }
Beispiel #4
0
        public List <tasks> tasksGetAll()
        {
            List <tasks> lsttasks = new List <tasks>();

            try
            {
                DataTable dt = SqlHelper.ExecuteDataset(SqlImplHelper.getConnectionString(), "tasksGetAll").Tables[0];
                if (dt.Rows.Count > 0)
                {
                    int colTaskId            = dt.Columns["TaskId"].Ordinal;
                    int colEventsDetectionId = dt.Columns["EventsDetectionId"].Ordinal;
                    int colTaskStatudId      = dt.Columns["TaskStatudId"].Ordinal;
                    int colUserId            = dt.Columns["UserId"].Ordinal;
                    int colTaskTittle        = dt.Columns["TaskTittle"].Ordinal;
                    int colDateTime          = dt.Columns["DateTime"].Ordinal;
                    for (int i = 0; dt.Rows.Count > i; i++)
                    {
                        tasks NewEnt = new tasks();
                        NewEnt.TaskId            = Int32.Parse(dt.Rows[i].ItemArray[colTaskId].ToString());
                        NewEnt.EventsDetectionId = Int32.Parse(dt.Rows[i].ItemArray[colEventsDetectionId].ToString());
                        NewEnt.TaskStatudId      = Int32.Parse(dt.Rows[i].ItemArray[colTaskStatudId].ToString());
                        NewEnt.UserId            = Int32.Parse(dt.Rows[i].ItemArray[colUserId].ToString());
                        NewEnt.TaskTittle        = dt.Rows[i].ItemArray[colTaskTittle].ToString();
                        NewEnt.DateTime          = DateTime.Parse(dt.Rows[i].ItemArray[colDateTime].ToString());
                        lsttasks.Add(NewEnt);
                    }
                }
                return(lsttasks);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public ActionResult GetTaskById(int idTask)
        {
            user.ValidateUser();

            try
            {
                var task = taskBusiness.GetTaskById(idTask);
                task.LastDescriptionReason = taskBusiness.GetLastReasonDescription(task.IdStep, idTask)?.Description ?? "";

                var newTask = new tasks
                {
                    IdTask                = task.IdTask,
                    Title                 = task.Title,
                    Description           = task.Description,
                    IdStep                = task.IdStep,
                    IdPriority            = task.IdPriority,
                    StartDate             = task.StartDate,
                    EndDate               = task.EndDate,
                    LastDescriptionReason = task.LastDescriptionReason
                };

                return(Json(JsonConvert.SerializeObject(newTask), JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(new HttpStatusCodeResult(404, ex.Message));
            }
        }
 // Selector wants only the first task that succeeds
 // try all tasks in order
 // stop and return true on the first task that succeeds
 // return false if all tasks fail
 public override void run()
 {
     //Debug.Log("selector running child task #" + currentTaskIndex);
     currentTask = children[currentTaskIndex];
     EventBus.StartListening(currentTask.TaskFinished, OnChildTaskFinished);
     currentTask.run();
 }
        private void btnStart_Click(object sender, RoutedEventArgs e)
        {
            using (llblanca_lara1Entities db = new llblanca_lara1Entities())
            {
                tasks task = new tasks
                {
                    project_id  = _projectId,
                    name        = txtName.Text,
                    description = txtDescription.Text,
                    created_at  = DateTime.Now,
                    status      = txtStatus.Text,
                    start       = Convert.ToDateTime(txtStart.Text),
                    end         = Convert.ToDateTime(txtEnd.Text)
                };

                try
                {
                    db.tasks.Add(task);
                    db.SaveChanges();
                    task_user taskUser = new task_user()
                    {
                        created_at = DateTime.Now,
                        id_task    = task.id,
                        id_user    = _userId
                    };
                    db.task_user.Add(taskUser);
                    db.SaveChanges();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            this.Close();
        }
 public List<tasks> tasksGetAll()
 {
     List<tasks> lsttasks = new List<tasks>();
     try
     {
         DataTable dt = SqlHelper.ExecuteDataset(SqlImplHelper.getConnectionString(), "tasksGetAll").Tables[0];
         if (dt.Rows.Count > 0)
         {
             int colTaskId =  dt.Columns["TaskId"].Ordinal;
             int colUserGroupId =  dt.Columns["UserGroupId"].Ordinal;
             int colTaskStatudId =  dt.Columns["TaskStatudId"].Ordinal;
             int colUserId =  dt.Columns["UserId"].Ordinal;
             int colTaskTittle =  dt.Columns["TaskTittle"].Ordinal;
             int colDateTime =  dt.Columns["DateTime"].Ordinal;
             for (int i = 0; dt.Rows.Count > i; i++)
             {
                 tasks NewEnt = new tasks();
                 NewEnt.TaskId = Int32.Parse(dt.Rows[i].ItemArray[colTaskId].ToString());
                 NewEnt.UserGroupId = dt.Rows[i].ItemArray[colUserGroupId].ToString();
                 NewEnt.TaskStatudId = Int32.Parse(dt.Rows[i].ItemArray[colTaskStatudId].ToString());
                 NewEnt.UserId = Int32.Parse(dt.Rows[i].ItemArray[colUserId].ToString());
                 NewEnt.TaskTittle = dt.Rows[i].ItemArray[colTaskTittle].ToString();
                 NewEnt.DateTime = DateTime.Parse(dt.Rows[i].ItemArray[colDateTime].ToString());
                 lsttasks.Add(NewEnt);
             }
         }
         return lsttasks;
     }
     catch(Exception ex)
     {
         throw ex;
     }
 }
Beispiel #9
0
 public bool tasksUpdate(tasks tasks)
 {
     try
     {
         int update = (int)SqlHelper.ExecuteScalar(SqlImplHelper.getConnectionString(), "tasksUpdate",
                                                   tasks.TaskId,
                                                   tasks.EventsDetectionId,
                                                   tasks.TaskStatudId,
                                                   tasks.UserId,
                                                   tasks.TaskTittle,
                                                   tasks.DateTime);
         if (update > 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #10
0
 public FileList(string title, IClient client, tasks task)
 {
     InitializeComponent();
     Title            = title;
     this.client      = client;
     jump.ItemsSource = jumps;
     this.task        = task;
     openDirectory("c:");
 }
Beispiel #11
0
 public FileList(List <listItem> source, string title, IClient client, tasks task = tasks.download)
 {
     InitializeComponent();
     fileSystem.ItemsSource = source;
     Title            = title;
     this.client      = client;
     jump.ItemsSource = jumps;
     this.task        = task;
 }
Beispiel #12
0
 public ActionResult Edit([Bind(Include = "ID,Nr,Title,Description,Worked,T_L,Test_Date,My_Time,Project_Name")] tasks tasks)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tasks).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index", new { tasks.Project_Name }));
     }
     return(View(tasks));
 }
Beispiel #13
0
        public ActionResult Create([Bind(Include = "ID,Nr,Title,Description,Worked,T_L,Test_Date,My_Time,Project_Name")] tasks tasks)
        {
            if (ModelState.IsValid)
            {
                db.Tasks.Add(tasks);
                db.SaveChanges();
                return(RedirectToAction("Index", new { tasks.Project_Name }));
            }

            return(View(tasks));
        }
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.G))
     {
         if (!executingBehavior)
         {
             myCurrentTask     = getCurrentTask();
             executingBehavior = true;
             myCurrentTask.run();
         }
     }
 }
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.G))
        {
            if (!executingBehavior)
            {
                executingBehavior = true;
                myCurrentTask     = BuildTask_GetTreasue();

                EventBus.StartListening(myCurrentTask.TaskFinished, OnTaskFinished);
                myCurrentTask.run();
            }
        }
    }
Beispiel #16
0
        // GET: Project/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tasks tasks = db.Tasks.Find(id);

            if (tasks == null)
            {
                return(HttpNotFound());
            }
            return(View(tasks));
        }
Beispiel #17
0
        // GET: Project/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tasks tasks = db.Tasks.Find(id);

            if (tasks == null)
            {
                return(HttpNotFound());
            }
            tasks.Test_Date = DateTime.Now;
            return(View(tasks));
        }
        public ActionResult Edit(tasks task)
        {
            user.ValidateUser();

            try
            {
                taskBusiness.EditTask(task);

                return(Json(task, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(new HttpStatusCodeResult(404, ex.Message));
            }
        }
        public tasks NewTask(tasks newTask)
        {
            if (string.IsNullOrEmpty(newTask.Title))
            {
                throw new Exception("Faltou o título da tarefa!");
            }

            if (string.IsNullOrEmpty(newTask.Description))
            {
                throw new Exception("Faltou a descrição da tarefa!");
            }

            if (newTask.StartDate == null)
            {
                throw new Exception("Faltou a data de início da tarefa!");
            }

            if (newTask.StartDate < DateTime.Now.Date)
            {
                throw new Exception("A data de ínicio não pode ser anterior à data de hoje!");
            }

            if (newTask.EndDate == null)
            {
                throw new Exception("Faltou a data de fim da tarefa!");
            }

            if (newTask.IdPriority == 0)
            {
                throw new Exception("A prioridade não foi informada!");
            }

            //Quando criada uma tarefa ela recebe o estado (Aguardando início)
            newTask.IdStep = 1;

            try
            {
                checkListDB.tasks.Add(newTask);

                checkListDB.SaveChanges();

                return(newTask);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        public static void createTask(Task task)
        {
            try {
                if (TaskDAL.exists(task.name))
                {
                    throw new ExistsException();
                }
                else
                {
                    tasks tasks = new tasks();
                    tasks.name        = task.name;
                    tasks.description = task.description;

                    if (task.processId != -1 && task.processId != 0)
                    {
                        tasks.process_id = int.Parse(task.processId + "");
                    }
                    if (task.assingId != -1 && task.processId != 0)
                    {
                        tasks.assing_id = int.Parse(task.assingId + "");
                    }
                    if (task.fatherTaksId != -1 && task.processId != 0)
                    {
                        tasks.father_taks_id = int.Parse(task.fatherTaksId + "");
                    }
                    tasks.task_status     = task.taskStatusId;
                    tasks.creator_user_id = task.creatorUserId;
                    tasks.created_at      = DateTime.Now;
                    tasks.date_end        = task.dateEnd;


                    var id = TaskDAL.createTask(tasks);

                    if (task.document != null)
                    {
                        files file = new files();
                        file.name    = task.document.name;
                        file.url     = task.document.url;
                        file.path    = task.document.path;
                        file.task_id = id;

                        DocumentDAL.createDocument(file);
                    }
                }
            } catch (Exception e) {
                throw e;
            }
        }
 public int tasksAdd( tasks tasks)
 {
     try
     {
         return (int)SqlHelper.ExecuteScalar(SqlImplHelper.getConnectionString(), "tasksAdd",
                                                                                 tasks.UserGroupId,
                                                                                 tasks.TaskStatudId,
                                                                                 tasks.UserId,
                                                                                 tasks.TaskTittle,
                                                                                 tasks.DateTime);
     }
     catch(Exception ex)
     {
         throw ex;
     }
 }
Beispiel #22
0
 public int tasksAdd(tasks tasks)
 {
     try
     {
         return((int)SqlHelper.ExecuteScalar(SqlImplHelper.getConnectionString(), "tasksAdd",
                                             tasks.EventsDetectionId,
                                             tasks.TaskStatudId,
                                             tasks.UserId,
                                             tasks.TaskTittle,
                                             tasks.DateTime));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public void RemoveAllDependencies(tasks task)
        {
            var reasonsList = checkListDB.reasons.Where(x => x.IdTask == task.IdTask).ToList();

            try
            {
                reasonsList.ForEach(reason =>
                                    checkListDB.reasons.Remove(reason)
                                    );

                checkListDB.SaveChanges();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        public ActionResult NewTask(tasks newTask)
        {
            user.ValidateUser();

            try
            {
                newTask.IdUser = int.Parse(Session["IdUser"].ToString());

                taskBusiness.NewTask(newTask);

                return(Json(newTask, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(new HttpStatusCodeResult(404, ex.Message));
            }
        }
Beispiel #25
0
        // GET: Project/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tasks tasks = db.Tasks.Find(id);

            if (tasks == null)
            {
                return(HttpNotFound());
            }
            else
            {
                db.Tasks.Remove(tasks);
                db.SaveChanges();
            }
            return(RedirectToAction("Index/" + tasks.Project_Name));
        }
        public tasks DeleteTask(tasks task)
        {
            checkListDB.Configuration.ProxyCreationEnabled = false;

            //Lambda para buscar uma tarefa pelo ID
            task = checkListDB.tasks.FirstOrDefault(c => c.IdTask == task.IdTask);

            try
            {
                RemoveAllDependencies(task);
                checkListDB.tasks.Attach(task);
                checkListDB.tasks.Remove(task);
                checkListDB.SaveChanges();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            return(task);
        }
        public tasks EditTask(tasks editTask)
        {
            //Lambda para buscar uma tarefa pelo ID
            var task = checkListDB.tasks.FirstOrDefault(c => c.IdTask == editTask.IdTask);

            if (string.IsNullOrEmpty(editTask.Title))
            {
                throw new Exception("Favor preencher o campo titúlo!");
            }

            if (string.IsNullOrEmpty(editTask.Description))
            {
                throw new Exception("Favor preencher o campo descrição!");
            }

            //Alterando a descrição
            task.Title       = editTask.Title;
            task.Description = editTask.Description;
            task.StartDate   = editTask.StartDate;
            task.EndDate     = editTask.EndDate;
            task.IdPriority  = editTask.IdPriority;

            try
            {
                checkListDB.tasks.Attach(task);
                checkListDB.Entry(task).Property(x => x.Title).IsModified       = true;
                checkListDB.Entry(task).Property(x => x.Description).IsModified = true;
                checkListDB.Entry(task).Property(x => x.StartDate).IsModified   = true;
                checkListDB.Entry(task).Property(x => x.EndDate).IsModified     = true;
                checkListDB.Entry(task).Property(x => x.IdPriority).IsModified  = true;
                checkListDB.SaveChanges();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            return(editTask);
        }
        public ActionResult DeleteTask(tasks task)
        {
            user.ValidateUser();

            try
            {
                taskBusiness.DeleteTask(task);

                var list = taskBusiness.GetTasksByIdUser(int.Parse(Session["IdUser"].ToString()));

                if (!list.Any())
                {
                    ModelState.AddModelError("notify", "Você ainda não possui tarefas. Adicione uma nova =)");
                }

                return(Json(task, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(new HttpStatusCodeResult(404, ex.Message));
            }
        }
        private void AddTask(object sender, RoutedEventArgs e)
        {
            if (UsersComboBox.SelectedValue == null)
            {
                MessageBox.Show("Выберите пользователя, для которого эта задача", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            String taskText   = TaskField.Text;
            String taskTheme  = TaskThemeField.Text;
            String taskToUser = (string)UsersComboBox.SelectedValue;
            tasks  t          = new tasks()
            {
                TaskText = taskText, TaskTheme = taskTheme, users = MainWindow.Database.users.FirstOrDefault(f => f.login == taskToUser)
            };
            tasks ct = MainWindow.Database.tasks.FirstOrDefault(f => f.TaskText == taskText);

            if (ct == null)
            {
                MainWindow.Database.tasks.Add(t);
            }
            MainWindow.Database.SaveChanges();
            MainWindow.Main.ControlView.Items.Remove(itemToDelete);
        }
Beispiel #30
0
        public static void start(decimal id, decimal userId)
        {
            try {
                var template = TemplateDAL.fetchAll().Where(x => x.id == id).FirstOrDefault();
                var tasks    = TemplateTaskDAL.fetchAll().Where(x => x.template_id == template.id).ToList();

                decimal processId = ProcessDAL.insert(template.name, template.description, DateTime.Now, userId);

                foreach (templates_tasks ts in tasks)
                {
                    tasks model = new tasks();
                    model.name            = ts.name;
                    model.description     = ts.description;
                    model.date_end        = ts.end_date;
                    model.task_status     = ts.task_status_code;
                    model.creator_user_id = decimal.Parse(userId + "");
                    model.process_id      = processId;

                    TaskDAL.createTask(model);
                }
            } catch (Exception e) {
                throw e;
            }
        }
Beispiel #31
0
        protected void getTaskData(int taskId)
        {
            DataTable dttTask = new DataTable();

            dttTask.Columns.Add(new DataColumn("taskId", System.Type.GetType("System.Int32")));
            dttTask.Columns.Add(new DataColumn("datetime", System.Type.GetType("System.DateTime")));
            dttTask.Columns.Add(new DataColumn("taskTittle", System.Type.GetType("System.String")));
            dttTask.Columns.Add(new DataColumn("eventsDetectionId", System.Type.GetType("System.Int32")));
            dttTask.Columns.Add(new DataColumn("taskStatusId", System.Type.GetType("System.Int32")));
            dttTask.Columns.Add(new DataColumn("statusDescription", System.Type.GetType("System.String")));
            dttTask.Columns.Add(new DataColumn("userId", System.Type.GetType("System.Int32")));
            dttTask.Columns.Add(new DataColumn("userName", System.Type.GetType("System.String")));
            dttTask.Columns.Add(new DataColumn("serverityId", System.Type.GetType("System.Int32")));
            dttTask.Columns.Add(new DataColumn("sererityDescription", System.Type.GetType("System.String")));
            dttTask.Columns.Add(new DataColumn("SLAStatus", System.Type.GetType("System.String")));

            tasks              auxtTasks        = new tasks();
            tasksBus           oTasks           = new tasksBus();
            eventsdetectionBus oEventsDetection = new eventsdetectionBus();
            idsBus             oIDPS            = new idsBus();
            eventsalarmBus     oEventsAlarm     = new eventsalarmBus();
            severityBus        oSeverity        = new severityBus();
            taskstatusBus      oTaskStatus      = new taskstatusBus();
            usersBus           oUsers           = new usersBus();

            auxtTasks = oTasks.tasksGetById(taskId);

            if (auxtTasks != null)
            {
                taskstatus      auxStatus         = new taskstatus();
                users           auxUser           = new users();
                eventsdetection auxEventDetection = new eventsdetection();
                eventsalarm     auxEventAlarm     = new eventsalarm();
                severity        auxSeverity       = new severity();
                string          SLASatus          = "";

                auxStatus         = oTaskStatus.taskstatusGetById(auxtTasks.TaskStatudId);
                auxUser           = oUsers.usersGetById(auxtTasks.UserId);
                auxEventDetection = oEventsDetection.eventsdetectionGetById(auxtTasks.EventsDetectionId);
                auxEventAlarm     = oEventsAlarm.eventsalarmGetById(auxEventDetection.EventsAlarmId);
                auxSeverity       = oSeverity.severityGetById(auxEventAlarm.Severity);

                DateTime deadTime = auxtTasks.DateTime;
                deadTime.AddMinutes(auxSeverity.SLATimeToResponse);
                if (DateTime.Now > deadTime)
                {
                    SLASatus = "Vencido";
                }
                if (DateTime.Now < deadTime)
                {
                    SLASatus = "En término";
                }

                dttTask.Rows.Add(auxtTasks.TaskId,
                                 auxtTasks.DateTime,
                                 auxtTasks.TaskTittle,
                                 auxtTasks.EventsDetectionId,
                                 auxtTasks.TaskStatudId,
                                 auxStatus.TaskStatusDescription,
                                 auxtTasks.UserId,
                                 auxUser.UserName,
                                 auxEventAlarm.Severity,
                                 auxSeverity.SeverityDescription,
                                 SLASatus);

                gvTask.DataSource = dttTask;
                gvTask.DataBind();
            }
        }
Beispiel #32
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            CultureInfo culture = (CultureInfo)CultureInfo.CurrentCulture.Clone();

            culture.DateTimeFormat.ShortDatePattern = "yyyy-MM-dd";
            culture.DateTimeFormat.LongTimePattern  = "";
            Thread.CurrentThread.CurrentCulture     = culture;

            taskdetails    auxNewTaskDetail = new taskdetails();
            taskdetailsBus oTaskDetail      = new taskdetailsBus();

            tasks    auxTasks = new tasks();
            tasksBus oTasks   = new tasksBus();

            users    auxUser = new users();
            usersBus oUser   = new usersBus();

            eventsdetectionBus oEventsDetection = new eventsdetectionBus();

            bool needRequiredFields = false;
            int  saveType           = 0;

            if (btnNew.Enabled)
            {
                saveType = 2;
            }
            if (!btnNew.Enabled)
            {
                saveType = 1;
            }

            if (String.IsNullOrEmpty(txtDateTime.Text))
            {
                needRequiredFields = true;
            }
            if (String.IsNullOrEmpty(txtEffortHours.Text))
            {
                needRequiredFields = true;
            }
            if (String.IsNullOrEmpty(txtDetail.Text))
            {
                needRequiredFields = true;
            }
            if (String.IsNullOrEmpty(txtTaskId.Text))
            {
                needRequiredFields = true;
            }

            if (!needRequiredFields)
            {
                auxUser = oUser.usersGetByUserName(HttpContext.Current.User.Identity.Name);

                DateTime dateTime = DateTime.ParseExact(txtDateTime.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                auxNewTaskDetail.DateTime    = dateTime;
                auxNewTaskDetail.EffortHours = Convert.ToDecimal(txtEffortHours.Text);
                auxNewTaskDetail.Details     = txtDetail.Text;
                auxNewTaskDetail.TaskId      = Convert.ToInt32(txtTaskId.Text);
                auxNewTaskDetail.UserId      = Convert.ToInt32(ddlUsers.SelectedValue);
                int auxTaskStatus   = Convert.ToInt32(ddlTaskStatus.SelectedValue);
                int auxUserAssigned = Convert.ToInt32(ddlUsers.SelectedValue);
                switch (saveType)
                {
                case 1:     //save
                    if (oTaskDetail.taskdetailsAdd(auxNewTaskDetail) > 0)
                    {
                        if (!oTasks.tasksUpdateStatus(Convert.ToInt32(txtTaskId.Text), auxTaskStatus))
                        {
                            lblMessage.Text = "Imposible actualizar nuevo Estado de Tarea...\n";
                        }

                        auxTasks = oTasks.tasksGetById(Convert.ToInt32(txtTaskId.Text));

                        if (!oEventsDetection.eventsdetectionUpdateStatus(auxTasks.EventsDetectionId, auxTaskStatus))
                        {
                            lblMessage.Text = "Imposible actualizar nuevo Estado del Evento de Intrusión...\n";
                        }

                        if (!oTasks.tasksUpdateUser(Convert.ToInt32(txtTaskId.Text), auxUserAssigned))
                        {
                            lblMessage.Text = "Imposible actualizar nuevo Usuario asignado a la Tarea...\n";
                        }

                        clearFields();
                        activateFields(false, true);
                        btnNew.Enabled = true;
                        getTaskDetailsData(TaskId);
                        lblMessage.Text = "Datos guardados correctamente!";
                    }
                    else
                    {
                        lblMessage.Text = "Error al guardar los datos!";
                    }
                    break;

                case 2:     //update

                    if (Convert.ToInt32(hfTaskStatusOrigin.Value) != auxTaskStatus)
                    {
                        if (!oTasks.tasksUpdateStatus(Convert.ToInt32(txtTaskId.Text), auxTaskStatus))
                        {
                            lblMessage.Text = "Imposible actualizar nuevo Estado de Tarea...\n";
                        }

                        if (!oEventsDetection.eventsdetectionUpdateStatus(auxTasks.EventsDetectionId, auxTaskStatus))
                        {
                            lblMessage.Text = "Imposible actualizar nuevo Estado del Evento de Intrusión...\n";
                        }
                    }

                    if (Convert.ToInt32(hfUserOrigin.Value) != auxUserAssigned)
                    {
                        if (!oTasks.tasksUpdateUser(Convert.ToInt32(txtTaskId.Text), auxUserAssigned))
                        {
                            lblMessage.Text = "Imposible actualizar nuevo Usuario asignado a la Tarea...\n";
                        }
                    }

                    auxNewTaskDetail.TaskDetailsId = Convert.ToInt32(txtTaskDetailId.Text);

                    if (oTaskDetail.taskdetailsUpdate(auxNewTaskDetail))
                    {
                        lblMessage.Text = "Datos actualizados correctamente!";
                        clearFields();
                        activateFields(false, true);
                        btnSave.Enabled = false;
                        getTaskDetailsData(TaskId);
                        lblMessage.Text = "Datos actualizados correctamente!";
                    }
                    else
                    {
                        lblMessage.Text = "Error al guardar los datos!";
                    }
                    break;
                }
            }
            else
            {
                lblMessage.Text = "Datos requeridos no cargados...";
            }
        }
 public bool tasksUpdate( tasks tasks)
 {
     try
     {
         int update = SqlHelper.ExecuteNonQuery(SqlImplHelper.getConnectionString(), "tasksUpdate",
                                                                                     tasks.TaskId,
                                                                                     tasks.UserGroupId,
                                                                                     tasks.TaskStatudId,
                                                                                     tasks.UserId,
                                                                                     tasks.TaskTittle,
                                                                                     tasks.DateTime);
         if (update > 0)
         {
             return true;
         }
         else
         {
             return false;
         }
     }
     catch(Exception ex)
     {
         throw ex;
     }
 }
        public tasks tasksGetById(int TaskId)
        {
            try
            {
                DataTable dt = SqlHelper.ExecuteDataset(SqlImplHelper.getConnectionString(), "tasksGetById",
                                                                                                    TaskId).Tables[0];
                tasks NewEnt = new tasks();

                if(dt.Rows.Count > 0)
                {
                    DataRow dr = dt.Rows[0];
                    NewEnt.TaskId = Int32.Parse(dr["TaskId"].ToString());
                    NewEnt.UserGroupId = dr["UserGroupId"].ToString();
                    NewEnt.TaskStatudId = Int32.Parse(dr["TaskStatudId"].ToString());
                    NewEnt.UserId = Int32.Parse(dr["UserId"].ToString());
                    NewEnt.TaskTittle = dr["TaskTittle"].ToString();
                    NewEnt.DateTime = DateTime.Parse(dr["DateTime"].ToString());
                }
                return NewEnt;
            }
            catch(Exception ex)
            {
                throw ex;
            }
        }
Beispiel #35
0
 public bool tasksUpdate(tasks tasks)
 {
     tasksImpl otasksImpl = new tasksImpl();
     return otasksImpl.tasksUpdate( tasks);
 }
Beispiel #36
0
 public int tasksAdd(tasks tasks)
 {
     tasksImpl otasksImpl = new tasksImpl();
     return otasksImpl.tasksAdd( tasks);
 }