Пример #1
0
        public ActionResult Create(TaskListViewModel taskList)
        {
            taskList.mainTaskID = taskList.ID;

            try
            {
                if (ModelState.IsValid)
                {

                    if (taskList.dependency == taskList.requeriment)
                    {
                        ModelState.AddModelError("", "Favor selecionar dependência OU pré-requisito. ");
                    }
                    else
                    {
                        var newTaskList = Mapper.Map<TaskListViewModel, TB_TaskList>(taskList);
                        _taskListService.Add(newTaskList);

                        return RedirectToAction("Index", new { id = taskList.mainTaskID });
                    }
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", "Erro ao cadastrar usuário. ERRO: " + ex.Message);
            }

            ViewBag.taskID = new SelectList(_taskService.GetAll(), "ID", "description", taskList.taskID);
            ViewBag.mainTaskID = taskList.mainTaskID;
            return View(taskList);
        }
Пример #2
0
 public ActionResult CreateNew(TaskList taskItem)
 {
     if (ModelState.IsValid)
     {
         _taskListService.Add(taskItem);
         return(RedirectToAction("Index"));
     }
     return(View(taskItem));
 }
Пример #3
0
        private void AddErrorsToVSErrorList(Window window, string[] errors)
        {
            ErrorList errorList = this.ApplicationObject.ToolWindows.ErrorList;
            Window2   errorWin2 = (Window2)(errorList.Parent);

            if (errors.Length > 0)
            {
                if (!errorWin2.Visible)
                {
                    this.ApplicationObject.ExecuteCommand("View.ErrorList", " ");
                }
                errorWin2.SetFocus();
            }

            IDesignerHost    designer = (IDesignerHost)window.Object;
            ITaskListService service  = designer.GetService(typeof(ITaskListService)) as ITaskListService;

            //remove old task items from this document and BIDS Helper class
            System.Collections.Generic.List <ITaskItem> tasksToRemove = new System.Collections.Generic.List <ITaskItem>();
            foreach (ITaskItem ti in service.GetTaskItems())
            {
                ICustomTaskItem task = ti as ICustomTaskItem;
                if (task != null && task.CustomInfo == this && task.Document == window.ProjectItem.get_FileNames(0))
                {
                    tasksToRemove.Add(ti);
                }
            }
            foreach (ITaskItem ti in tasksToRemove)
            {
                service.Remove(ti);
            }


            foreach (string s in errors)
            {
                ICustomTaskItem item = (ICustomTaskItem)service.CreateTaskItem(TaskItemType.Custom, s);
                item.Category   = TaskItemCategory.Misc;
                item.Appearance = TaskItemAppearance.Squiggle;
                item.Priority   = TaskItemPriority.High;
                item.Document   = window.ProjectItem.get_FileNames(0);
                item.CustomInfo = this;
                service.Add(item);
            }
        }
 public ActionResult SubmitTask(RTC_TaskList task)
 {
     try
     {
         if (task.id == 0)
         {
             task.DateCreated = DateTime.Now;
             taskListService.Add(task);
             taskListService.SaveChanges();
             return(AjaxResult(true));
         }
         else
         {
             task.DateModified = DateTime.Now;
             taskListService.Update(task);
             taskListService.SaveChanges();
             return(AjaxResult(true));
         }
     }
     catch (Exception e)
     {
         return(AjaxResult(false, "Lỗi hệ thống", null, e.Message));
     }
 }
        private void AddErrorsToVSErrorList(Window window, Results errors)
        {
            ErrorList errorList = this.ApplicationObject.ToolWindows.ErrorList;
            Window2   errorWin2 = (Window2)(errorList.Parent);

            if (errors.Count > 0)
            {
                if (!errorWin2.Visible)
                {
                    this.ApplicationObject.ExecuteCommand("View.ErrorList", " ");
                }
                errorWin2.SetFocus();
            }

            IDesignerHost    designer = (IDesignerHost)window.Object;
            ITaskListService service  = designer.GetService(typeof(ITaskListService)) as ITaskListService;

            //remove old task items from this document and BIDS Helper class
            System.Collections.Generic.List <ITaskItem> tasksToRemove = new System.Collections.Generic.List <ITaskItem>();
            foreach (ITaskItem ti in service.GetTaskItems())
            {
                ICustomTaskItem task = ti as ICustomTaskItem;
                if (task != null && task.CustomInfo == this && task.Document == window.ProjectItem.Name)
                {
                    tasksToRemove.Add(ti);
                }
            }
            foreach (ITaskItem ti in tasksToRemove)
            {
                service.Remove(ti);
            }


            foreach (Result result in errors)
            {
                if (result.Passed)
                {
                    continue;
                }
                ICustomTaskItem item = (ICustomTaskItem)service.CreateTaskItem(TaskItemType.Custom, result.ResultExplanation);
                item.Category   = TaskItemCategory.Misc;
                item.Appearance = TaskItemAppearance.Squiggle;
                switch (result.Severity)
                {
                case ResultSeverity.Low:
                    item.Priority = TaskItemPriority.Low;
                    break;

                case ResultSeverity.Normal:
                    item.Priority = TaskItemPriority.Normal;
                    break;

                case ResultSeverity.High:
                    item.Priority = TaskItemPriority.High;
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                item.Document   = window.ProjectItem.Name;
                item.CustomInfo = this;
                service.Add(item);
            }
        }
        private void AddWarningsToVSErrorList(ITaskListService taskListService, string sFilename, string[] warnings)
        {
            ErrorList errorList = this.ApplicationObject.ToolWindows.ErrorList;
            Window2 errorWin2 = (Window2)(errorList.Parent);

            if (warnings.Length > 0)
            {
                if (!errorWin2.Visible)
                {
                    this.ApplicationObject.ExecuteCommand("View.ErrorList", " ");
                }
                //errorWin2.SetFocus(); //don't focus the error window because the Expression Highlighter pays attention to window focusing
            }

            //remove old task items from this document and BIDS Helper class
            System.Collections.Generic.List<ITaskItem> tasksToRemove = new System.Collections.Generic.List<ITaskItem>();
            foreach (ITaskItem ti in taskListService.GetTaskItems())
            {
                ICustomTaskItem task = ti as ICustomTaskItem;
                if (task != null && task.CustomInfo == this && task.Document == sFilename)
                {
                    tasksToRemove.Add(ti);
                }
            }
            foreach (ITaskItem ti in tasksToRemove)
            {
                taskListService.Remove(ti);
            }

            //add new task items
            foreach (string s in warnings)
            {
                ICustomTaskItem item = (ICustomTaskItem)taskListService.CreateTaskItem(TaskItemType.Custom, s);
                item.Category = TaskItemCategory.Misc;
                item.Appearance = TaskItemAppearance.Squiggle;
                item.Priority = TaskItemPriority.Normal;
                item.Document = sFilename;
                item.CustomInfo = this;
                taskListService.Add(item);
            }
        }