Exemplo n.º 1
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);
            }
        }
        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);
            }
        }