예제 #1
0
        private static void WriteTaskInfo(TaskInfo ti)
        {
            DocumentTask dt = apiClient.GetDocumentTask(ti.ID, DocumentTaskScope.Triggering);

            string startAt = "";
            string hourly = "", daily = "", weekly = "", monthly = "";

            foreach (Trigger t in dt.Triggering.Triggers)
            {
                try
                {
                    startAt = ((RecurrenceTrigger)t).StartAt.ToString("HH:mm:ss");
                    hourly  = ((RecurrenceTrigger)t).Hourly != null ? ((RecurrenceTrigger)t).Hourly.RecurEvery.ToString() : "N/A";
                    daily   = ((RecurrenceTrigger)t).Daily != null ? ((RecurrenceTrigger)t).Daily.RecurEvery.ToString() : "N/A";
                    weekly  = ((RecurrenceTrigger)t).Weekly != null ? ((RecurrenceTrigger)t).Weekly.RecurEvery.ToString() : "N/A";
                    //monthly = ((RecurrenceTrigger)t).Monthly.DayConstraints.ToString();
                }
                catch (System.Exception)
                {
                }

                Console.WriteLine(ti.Name + "\t" +
                                  apiClient.GetTaskStatus(ti.ID, TaskStatusScope.All).General.Status.ToString() + "\t" +
                                  ti.Enabled.ToString() + "\t" + ti.ID.ToString() + "\t" + startAt + "\t" + hourly
                                  + "\t" + daily + "\t" + weekly);
            }
        }
예제 #2
0
 public static DocumentTaskViewModel ConvertToViewModel(DocumentTask item)
 => new DocumentTaskViewModel
 {
     DateAdded      = item.DateAdded,
     LastModified   = item.LastModified,
     IdDocumentTask = item.IdDocumentTask,
     Name           = item.DocumentTaskType.DocumentTaskTemplate.Name,
     DocumentStatus = item.DocumentTaskStates.Last().DocumentTaskStatus,
     CreatedBy      = item.User.UserName
 };
예제 #3
0
 private static void ForEachDocumentTask(Action <DocumentTask> action, Func <DocumentTask, bool> breakAction)
 {
     foreach (Microsoft.VisualStudio.Shell.Task t in errorListProvider.Value.Tasks)
     {
         DocumentTask docTask = t as DocumentTask;
         if (docTask != null)
         {
             action.Call(docTask);
             if (breakAction != null && breakAction.Call(docTask))
             {
                 break;
             }
         }
     }
 }
예제 #4
0
        public static DocumentTaskDetailViewModel ConvertToDetailViewModel(DocumentTask item, int?userGroupId)
        {
            var lastState = item.DocumentTaskStates.Last();

            return(new DocumentTaskDetailViewModel
            {
                IdDocumentTask = item.IdDocumentTask,
                CurrentUserGroupId = userGroupId,
                Name = item.DocumentTaskType.DocumentTaskTemplate.Name,
                CreatedBy = item.User.UserName,
                DateAdded = item.DateAdded,
                LastModified = item.LastModified,
                Type = item.DocumentTaskType.Name,
                Status = lastState.DocumentTaskStatus,
                Documents = ConvertToViewModel(item.Documents),
                RequireActionUserGroupId = lastState.DocumentTaskTypePath?.IdUserGroup ?? default(int),
                Progress = lastState.DocumentTaskTypePath == null ? "Terminat" : $"{lastState.DocumentTaskTypePath.Index} / {item.DocumentTaskType.Paths.Count}"
            });
        }
예제 #5
0
        public async Task Add(string userId, int idDocumentTaskType, IEnumerable <int> idDocuments)
        {
            var now  = DateTime.Now;
            var task = new DocumentTask
            {
                UserId             = userId,
                DateAdded          = now,
                LastModified       = now,
                IdDocumentTaskType = idDocumentTaskType,
                Documents          = await dbContext.Documents.Where(it => idDocuments.Contains(it.IdDocument)).ToListAsync()
            };

            var taskType = await dbContext.DocumentTaskTypes.Include(it => it.Paths).FirstAsync(it => it.IdDocumentTaskType == idDocumentTaskType);

            var state = new DocumentTaskState
            {
                StateDate              = now,
                DocumentTaskStatus     = DocumentTaskStatus.RequireAction,
                IdDocumentTaskTypePath = taskType.Paths.First(it => it.Index == 0).IdDocumentTaskTypePath
            };

            task.DocumentTaskStates.Add(state);
            dbContext.DocumentTasks.Add(task);
        }
예제 #6
0
        /// <summary>
        /// Add the error/warning to the error list and potentially to the output window.
        /// </summary>
        private void AddToErrorList(
            BuildEventArgs errorEvent,
            string subcategory,
            string errorCode,
            string file,
            int startLine,
            int startColumn,
            int endLine,
            int endColumn)
        {
            if (file == null)
            {
                file = String.Empty;
            }

            bool         isWarning = errorEvent is BuildWarningEventArgs;
            TaskPriority priority  = isWarning ? TaskPriority.Normal : TaskPriority.High;

            TextSpan span;

            span.iStartLine  = startLine;
            span.iStartIndex = startColumn;
            span.iEndLine    = endLine < startLine ? span.iStartLine : endLine;
            span.iEndIndex   = (endColumn < startColumn) && (span.iStartLine == span.iEndLine) ? span.iStartIndex : endColumn;

            if (OutputWindowPane != null &&
                (this.Verbosity != LoggerVerbosity.Quiet || errorEvent is BuildErrorEventArgs))
            {
                // Format error and output it to the output window
                string message         = this.FormatMessage(errorEvent.Message);
                DefaultCompilerError e = new DefaultCompilerError(file,
                                                                  span.iStartLine,
                                                                  span.iStartIndex,
                                                                  span.iEndLine,
                                                                  span.iEndIndex,
                                                                  errorCode,
                                                                  message);
                e.IsWarning = isWarning;

                Output(GetFormattedErrorMessage(e));
            }

            UIThread.Run(delegate()
            {
                IVsUIShellOpenDocument openDoc = serviceProvider.GetService(typeof(IVsUIShellOpenDocument)) as IVsUIShellOpenDocument;
                if (openDoc == null)
                {
                    return;
                }

                IVsWindowFrame frame;
                IOleServiceProvider sp;
                IVsUIHierarchy hier;
                uint itemid;
                Guid logicalView = VSConstants.LOGVIEWID_Code;

                IVsTextLines buffer = null;
                // JAF
                // Notes about acquiring the buffer:
                // If the file physically exists then this will open the document in the current project. It doesn't matter if the file is a member of the project.
                // Also, it doesn't matter if this is an F# file. For example, an error in Microsoft.Common.targets will cause a file to be opened here.
                // However, opening the document does not mean it will be shown in VS.
                if (!Microsoft.VisualStudio.ErrorHandler.Failed(openDoc.OpenDocumentViaProject(file, ref logicalView, out sp, out hier, out itemid, out frame)) && frame != null)
                {
                    object docData;
                    frame.GetProperty((int)__VSFPROPID.VSFPROPID_DocData, out docData);

                    // Get the text lines
                    buffer = docData as IVsTextLines;

                    if (buffer == null)
                    {
                        IVsTextBufferProvider bufferProvider = docData as IVsTextBufferProvider;
                        if (bufferProvider != null)
                        {
                            bufferProvider.GetTextBuffer(out buffer);
                        }
                    }
                }

                // Need to adjust line and column indexing for the task window, which assumes zero-based values
                if (span.iStartLine > 0 && span.iStartIndex > 0)
                {
                    span.iStartLine  -= 1;
                    span.iEndLine    -= 1;
                    span.iStartIndex -= 1;
                    span.iEndIndex   -= 1;
                }

                // Add new document task to task list
                DocumentTask task = new DocumentTask(serviceProvider,
                                                     buffer, // May be null
                                                             // This seems weird. Why would warning status make this a 'compile error'?
                                                             // The “code sense” errors produce red squiggles, whereas the “compile” errors produce blue squiggles.  (This is in line with C#’s pre-VS2008-SP1 behavior.)  Swapping these two gives us a look consistent with that of the language service.
                                                     isWarning ? MARKERTYPE.MARKER_COMPILE_ERROR : MARKERTYPE.MARKER_CODESENSE_ERROR,
                                                     span,
                                                     file,
                                                     subcategory);

                // Add error to task list
                task.Text          = Microsoft.FSharp.Compiler.ErrorLogger.NewlineifyErrorString(errorEvent.Message);
                task.Priority      = priority;
                task.ErrorCategory = isWarning ? TaskErrorCategory.Warning : TaskErrorCategory.Error;
                task.Category      = TaskCategory.BuildCompile;
                task.HierarchyItem = hierarchy;
                task.Navigate     += new EventHandler(NavigateTo);

                if (null != this.TaskReporter)
                {
                    this.taskReporter.AddTask(task);
                }
                else
                {
                    this.taskProvider.Tasks.Add(task);
                }
            });
        }
예제 #7
0
		/// <summary>
		/// Add the error/warning to the error list and potentially to the output window.
		/// </summary>
		private void AddToErrorList(
			BuildEventArgs errorEvent,
            string subcategory,
			string errorCode,
			string file,
			int startLine,
			int startColumn,
            int endLine,
            int endColumn)
		{
            if (file == null)
                file = String.Empty;
            
            bool isWarning = errorEvent is BuildWarningEventArgs;
            TaskPriority priority = isWarning ? TaskPriority.Normal : TaskPriority.High;
            
            TextSpan span;
            span.iStartLine = startLine;
            span.iStartIndex = startColumn;
            span.iEndLine = endLine < startLine ? span.iStartLine : endLine;
            span.iEndIndex = (endColumn < startColumn) && (span.iStartLine == span.iEndLine) ? span.iStartIndex : endColumn;

			if (OutputWindowPane != null
				&& (this.Verbosity != LoggerVerbosity.Quiet || errorEvent is BuildErrorEventArgs))
			{
				// Format error and output it to the output window
				string message = this.FormatMessage(errorEvent.Message);
                DefaultCompilerError e = new DefaultCompilerError(file,
                                                span.iStartLine,
                                                span.iStartIndex,
                                                span.iEndLine,
                                                span.iEndIndex,
                                                errorCode,
					                            message);
				e.IsWarning = isWarning;

				Output(GetFormattedErrorMessage(e));
			}

            UIThread.Run(delegate()
            {
                IVsUIShellOpenDocument openDoc = serviceProvider.GetService(typeof(IVsUIShellOpenDocument)) as IVsUIShellOpenDocument;
                if (openDoc == null)
                    return;

                IVsWindowFrame frame;
                IOleServiceProvider sp;
                IVsUIHierarchy hier;
                uint itemid;
                Guid logicalView = VSConstants.LOGVIEWID_Code;

                IVsTextLines buffer = null;
                // JAF 
                // Notes about acquiring the buffer:
                // If the file physically exists then this will open the document in the current project. It doesn't matter if the file is a member of the project.
                // Also, it doesn't matter if this is an F# file. For example, an error in Microsoft.Common.targets will cause a file to be opened here.
                // However, opening the document does not mean it will be shown in VS. 
                if (!Microsoft.VisualStudio.ErrorHandler.Failed(openDoc.OpenDocumentViaProject(file, ref logicalView, out sp, out hier, out itemid, out frame)) && frame != null) {
                    object docData;
                    frame.GetProperty((int)__VSFPROPID.VSFPROPID_DocData, out docData);

                    // Get the text lines
                    buffer = docData as IVsTextLines;

                    if (buffer == null) {
                        IVsTextBufferProvider bufferProvider = docData as IVsTextBufferProvider;
                        if (bufferProvider != null) {
                            bufferProvider.GetTextBuffer(out buffer);
                        }
                    }
                }

                // Need to adjust line and column indexing for the task window, which assumes zero-based values
                if (span.iStartLine > 0 && span.iStartIndex > 0)
                {
                    span.iStartLine -= 1;
                    span.iEndLine -= 1;
                    span.iStartIndex -= 1;
                    span.iEndIndex -= 1;
                }

                // Add new document task to task list
                DocumentTask task = new DocumentTask(serviceProvider,
                    buffer, // May be null
                    // This seems weird. Why would warning status make this a 'compile error'? 
                    // The “code sense” errors produce red squiggles, whereas the “compile” errors produce blue squiggles.  (This is in line with C#’s pre-VS2008-SP1 behavior.)  Swapping these two gives us a look consistent with that of the language service.
                    isWarning ? MARKERTYPE.MARKER_COMPILE_ERROR : MARKERTYPE.MARKER_CODESENSE_ERROR, 
                    span,
                    file,
                    subcategory);

                // Add error to task list
                task.Text = Microsoft.FSharp.Compiler.ErrorLogger.NewlineifyErrorString(errorEvent.Message);
                task.Priority = priority;
                task.ErrorCategory = isWarning ? TaskErrorCategory.Warning : TaskErrorCategory.Error;
                task.Category = TaskCategory.BuildCompile;
                task.HierarchyItem = hierarchy;
                task.Navigate += new EventHandler(NavigateTo);

                if (null != this.TaskReporter)
                {
                    this.taskReporter.AddTask(task);
                }
                else
                {
                    this.taskProvider.Tasks.Add(task);
                }
            });
		}
예제 #8
0
        // helper methods.
        public DocumentTask CreateErrorTaskItem(TextSpan span, string filename, string subcategory, string message, TaskPriority priority, TaskCategory category, MARKERTYPE markerType, TaskErrorCategory errorCategory)
        {
            // create task item

            //TODO this src obj may not be the one matching filename.
            //find the src for the filename only then call ValidSpan.
            //Debug.Assert(TextSpanHelper.ValidSpan(this, span)); 

            DocumentTask taskItem = new DocumentTask(this.service.Site, this.textLines, markerType, span, filename, subcategory);
            taskItem.Priority = priority;
            taskItem.Category = category;
            taskItem.ErrorCategory = errorCategory;
            message = NewlineifyErrorString(message);
            taskItem.Text = message;
            taskItem.IsTextEditable = false;
            taskItem.IsCheckedEditable = false;
            return taskItem;
        }
예제 #9
0
 public void RemoveTask(DocumentTask task)
 {
     for (int i = 0, n = this.taskProvider.Tasks.Count; i < n; i++)
     {
         Task current = this.taskProvider.Tasks[i];
         if (current == task)
         {
             this.taskProvider.Tasks.RemoveAt(i); return;
         }
     }
 }
예제 #10
0
        protected void QueueTaskEvent(BuildEventArgs errorEvent)
        {
            // This enqueues a function that will later be run on the main (UI) thread
            this.taskQueue.Enqueue(() => {
                TextSpan span;
                string file;
                MARKERTYPE marker;
                TaskErrorCategory category;

                if (errorEvent is BuildErrorEventArgs)
                {
                    BuildErrorEventArgs errorArgs = (BuildErrorEventArgs)errorEvent;
                    span = new TextSpan();
                    // spans require zero-based indices
                    span.iStartLine  = errorArgs.LineNumber - 1;
                    span.iEndLine    = errorArgs.EndLineNumber - 1;
                    span.iStartIndex = errorArgs.ColumnNumber - 1;
                    span.iEndIndex   = errorArgs.EndColumnNumber - 1;
                    file             = Path.Combine(Path.GetDirectoryName(errorArgs.ProjectFile), errorArgs.File);
                    marker           = MARKERTYPE.MARKER_CODESENSE_ERROR; // red squiggles
                    category         = TaskErrorCategory.Error;
                }
                else if (errorEvent is BuildWarningEventArgs)
                {
                    BuildWarningEventArgs warningArgs = (BuildWarningEventArgs)errorEvent;
                    span = new TextSpan();
                    // spans require zero-based indices
                    span.iStartLine  = warningArgs.LineNumber - 1;
                    span.iEndLine    = warningArgs.EndLineNumber - 1;
                    span.iStartIndex = warningArgs.ColumnNumber - 1;
                    span.iEndIndex   = warningArgs.EndColumnNumber - 1;
                    file             = Path.Combine(Path.GetDirectoryName(warningArgs.ProjectFile), warningArgs.File);
                    marker           = MARKERTYPE.MARKER_COMPILE_ERROR; // red squiggles
                    category         = TaskErrorCategory.Warning;
                }
                else
                {
                    throw new NotImplementedException();
                }

                if (span.iEndLine == -1)
                {
                    span.iEndLine = span.iStartLine;
                }
                if (span.iEndIndex == -1)
                {
                    span.iEndIndex = span.iStartIndex;
                }

                IVsUIShellOpenDocument openDoc = serviceProvider.GetService(typeof(IVsUIShellOpenDocument)) as IVsUIShellOpenDocument;
                if (openDoc == null)
                {
                    throw new NotImplementedException(); // TODO
                }
                IVsWindowFrame frame;
                IOleServiceProvider sp;
                IVsUIHierarchy hier;
                uint itemid;
                Guid logicalView = VSConstants.LOGVIEWID_Code;

                IVsTextLines buffer = null;

                // Notes about acquiring the buffer:
                // If the file physically exists then this will open the document in the current project. It doesn't matter if the file is a member of the project.
                // Also, it doesn't matter if this is a Rust file. For example, an error in Microsoft.Common.targets will cause a file to be opened here.
                // However, opening the document does not mean it will be shown in VS.
                if (!Microsoft.VisualStudio.ErrorHandler.Failed(openDoc.OpenDocumentViaProject(file, ref logicalView, out sp, out hier, out itemid, out frame)) && frame != null)
                {
                    object docData;
                    frame.GetProperty((int)__VSFPROPID.VSFPROPID_DocData, out docData);

                    // Get the text lines
                    buffer = docData as IVsTextLines;

                    if (buffer == null)
                    {
                        IVsTextBufferProvider bufferProvider = docData as IVsTextBufferProvider;
                        if (bufferProvider != null)
                        {
                            bufferProvider.GetTextBuffer(out buffer);
                        }
                    }
                }

                DocumentTask task  = new DocumentTask(serviceProvider, buffer, marker, span, file);
                task.ErrorCategory = category;
                task.Document      = file;
                task.Line          = span.iStartLine;
                task.Column        = span.iStartIndex;
                task.Priority      = category == TaskErrorCategory.Error ? TaskPriority.High : TaskPriority.Normal;
                task.Text          = errorEvent.Message;
                task.Category      = TaskCategory.BuildCompile;
                task.HierarchyItem = hierarchy;

                return(task);
            });

            // NOTE: Unlike output we dont want to interactively report the tasks. So we never queue
            // call ReportQueuedTasks here. We do this when the build finishes.
        }
예제 #11
0
        protected void QueueTaskEvent(BuildEventArgs errorEvent)
        {
            // This enqueues a function that will later be run on the main (UI) thread
            this.taskQueue.Enqueue(() => {
                TextSpan span;
                string file;
                MARKERTYPE marker;
                TaskErrorCategory category;

                if (errorEvent is BuildErrorEventArgs) {
                    BuildErrorEventArgs errorArgs = (BuildErrorEventArgs)errorEvent;
                    span = new TextSpan();
                    // spans require zero-based indices
                    span.iStartLine = errorArgs.LineNumber - 1;
                    span.iEndLine = errorArgs.EndLineNumber - 1;
                    span.iStartIndex = errorArgs.ColumnNumber - 1;
                    span.iEndIndex = errorArgs.EndColumnNumber - 1;
                    file = Path.Combine(Path.GetDirectoryName(errorArgs.ProjectFile), errorArgs.File);
                    marker = MARKERTYPE.MARKER_CODESENSE_ERROR; // red squiggles
                    category = TaskErrorCategory.Error;
                } else if (errorEvent is BuildWarningEventArgs) {
                    BuildWarningEventArgs warningArgs = (BuildWarningEventArgs)errorEvent;
                    span = new TextSpan();
                    // spans require zero-based indices
                    span.iStartLine = warningArgs.LineNumber - 1;
                    span.iEndLine = warningArgs.EndLineNumber - 1;
                    span.iStartIndex = warningArgs.ColumnNumber - 1;
                    span.iEndIndex = warningArgs.EndColumnNumber - 1;
                    file = Path.Combine(Path.GetDirectoryName(warningArgs.ProjectFile), warningArgs.File);
                    marker = MARKERTYPE.MARKER_COMPILE_ERROR; // red squiggles
                    category = TaskErrorCategory.Warning;
                }
                else {
                    throw new NotImplementedException();
                }

                if (span.iEndLine == -1) span.iEndLine = span.iStartLine;
                if (span.iEndIndex == -1) span.iEndIndex = span.iStartIndex;

                IVsUIShellOpenDocument openDoc = serviceProvider.GetService(typeof(IVsUIShellOpenDocument)) as IVsUIShellOpenDocument;
                if (openDoc == null)
                    throw new NotImplementedException(); // TODO

                IVsWindowFrame frame;
                IOleServiceProvider sp;
                IVsUIHierarchy hier;
                uint itemid;
                Guid logicalView = VSConstants.LOGVIEWID_Code;

                IVsTextLines buffer = null;

                // Notes about acquiring the buffer:
                // If the file physically exists then this will open the document in the current project. It doesn't matter if the file is a member of the project.
                // Also, it doesn't matter if this is a Rust file. For example, an error in Microsoft.Common.targets will cause a file to be opened here.
                // However, opening the document does not mean it will be shown in VS.
                if (!Microsoft.VisualStudio.ErrorHandler.Failed(openDoc.OpenDocumentViaProject(file, ref logicalView, out sp, out hier, out itemid, out frame)) && frame != null)
                {
                    object docData;
                    frame.GetProperty((int)__VSFPROPID.VSFPROPID_DocData, out docData);

                    // Get the text lines
                    buffer = docData as IVsTextLines;

                    if (buffer == null)
                    {
                        IVsTextBufferProvider bufferProvider = docData as IVsTextBufferProvider;
                        if (bufferProvider != null)
                        {
                            bufferProvider.GetTextBuffer(out buffer);
                        }
                    }
                }

                DocumentTask task = new DocumentTask(serviceProvider, buffer, marker, span, file);
                task.ErrorCategory = category;
                task.Document = file;
                task.Line = span.iStartLine;
                task.Column = span.iStartIndex;
                task.Priority = category == TaskErrorCategory.Error ? TaskPriority.High : TaskPriority.Normal;
                task.Text = errorEvent.Message;
                task.Category = TaskCategory.BuildCompile;
                task.HierarchyItem = hierarchy;

                return task;
            });

            // NOTE: Unlike output we dont want to interactively report the tasks. So we never queue
            // call ReportQueuedTasks here. We do this when the build finishes.
        }
예제 #12
0
        public static void QueueMessage(
            string subCategory,
            string errorCode,
            string file, string msg,
            int line, int column, int endLine, int endColumn,
            IVsHierarchy hierarchy,
            bool isError       = true,
            string helpKeyword = "",
            string senderName  = "",
            bool refresh       = true)
        {
            if (Contains(subCategory, errorCode, file, msg, line, column, hierarchy, isError, helpKeyword, senderName))
            {
                return;
            }

            // This enqueues a function that will later be run on the main (UI) thread
            TextSpan          span;
            string            filePath;
            MARKERTYPE        marker;
            TaskErrorCategory category;

            VisualRust.Project.RustProjectNode rustProject = hierarchy as VisualRust.Project.RustProjectNode;
            var ivsSolution = (IVsSolution)Package.GetGlobalService(typeof(IVsSolution));
            var dte         = (EnvDTE80.DTE2)Package.GetGlobalService(typeof(EnvDTE.DTE));

            span = new TextSpan();
            // spans require zero-based indices
            span.iStartLine  = line - 1;
            span.iEndLine    = endLine - 1;
            span.iStartIndex = column - 1;
            span.iEndIndex   = endColumn - 1;
            filePath         = Path.Combine(Path.GetDirectoryName(rustProject.GetCanonicalName()), file);

            if (isError)
            {
                marker   = MARKERTYPE.MARKER_CODESENSE_ERROR; // red squiggles
                category = TaskErrorCategory.Error;
            }
            else
            {
                marker   = MARKERTYPE.MARKER_COMPILE_ERROR; // red squiggles
                category = TaskErrorCategory.Warning;
            }

            if (span.iEndLine == -1)
            {
                span.iEndLine = span.iStartLine;
            }
            if (span.iEndIndex == -1)
            {
                span.iEndIndex = span.iStartIndex;
            }

            IVsUIShellOpenDocument openDoc = serviceProvider.GetService(typeof(IVsUIShellOpenDocument)) as IVsUIShellOpenDocument;

            if (openDoc == null)
            {
                throw new NotImplementedException(); // TODO
            }
            IVsWindowFrame      frame;
            IOleServiceProvider sp;
            IVsUIHierarchy      hier;
            uint itemid;
            Guid logicalView = Microsoft.VisualStudio.VSConstants.LOGVIEWID_Code;

            IVsTextLines buffer = null;

            // Notes about acquiring the buffer:
            // If the file physically exists then this will open the document in the current project. It doesn't matter if the file is a member of the project.
            // Also, it doesn't matter if this is a Rust file. For example, an error in Microsoft.Common.targets will cause a file to be opened here.
            // However, opening the document does not mean it will be shown in VS.
            if (!Microsoft.VisualStudio.ErrorHandler.Failed(openDoc.OpenDocumentViaProject(file, ref logicalView, out sp, out hier, out itemid, out frame)) && frame != null)
            {
                object docData;
                frame.GetProperty((int)__VSFPROPID.VSFPROPID_DocData, out docData);

                // Get the text lines
                buffer = docData as IVsTextLines;
                if (buffer == null)
                {
                    IVsTextBufferProvider bufferProvider = docData as IVsTextBufferProvider;
                    if (bufferProvider != null)
                    {
                        bufferProvider.GetTextBuffer(out buffer);
                    }
                }
            }

            if (span.iEndLine > span.iStartLine)
            {
                span.iEndLine = span.iStartLine;
                int lineLength = 0;
                if (buffer.GetLengthOfLine(span.iStartLine, out lineLength) == Microsoft.VisualStudio.VSConstants.S_OK)
                {
                    span.iEndIndex = lineLength - 1;
                }
            }
            DocumentTask task = new DocumentTask(serviceProvider, buffer, marker, span, file);

            task.ErrorCategory = category;
            task.Document      = file;
            task.Line          = span.iStartLine;
            task.Column        = span.iStartIndex;
            task.Priority      = category == TaskErrorCategory.Error ? TaskPriority.High : TaskPriority.Normal;
            task.Text          = msg;
            task.Category      = TaskCategory.BuildCompile;
            task.HierarchyItem = hierarchy;
            Add(task);
            if (refresh)
            {
                Refresh();
            }

            // NOTE: Unlike output we dont want to interactively report the tasks. So we never queue
            // call ReportQueuedTasks here. We do this when the build finishes.
        }
예제 #13
0
 private static bool IsInitiated(DocumentTask task, int?idUserGroup)
 {
     return(task.DocumentTaskStates.Last().DocumentTaskStatus != DocumentTaskStatus.RequireModifications &&
            task.DocumentTaskStates.Last().IdDocumentTaskTypePath.HasValue&&
            task.DocumentTaskStates.Last().DocumentTaskTypePath.IdUserGroup == idUserGroup);
 }
예제 #14
0
 private static bool IsFinalized(DocumentTask task)
 {
     return(task.DocumentTaskStates.Last().DocumentTaskStatus == DocumentTaskStatus.Accepted ||
            task.DocumentTaskStates.Last().DocumentTaskStatus == DocumentTaskStatus.Denied);
 }
예제 #15
0
        void createTaskEDX()
        {
            //connect to the QDS
            ServiceInfo[] MyQDS = Client.GetServices(ServiceTypes.QlikViewDistributionService);

            //get a list of source docs
            DocumentNode[] SourceDocs;
            SourceDocs = Client.GetSourceDocuments(MyQDS[0].ID);

            //Create the new task object
            DocumentTask myTask = new DocumentTask();

            //find the ID for the doc we created above
            for (int i = 0; i < SourceDocs.Length; i++)
            {
                if (SourceDocs[i].Name == targetDoc + ".qvw")
                {
                    myTask.Document = SourceDocs[i];
                }
            }

            //set some basic settings
            myTask.QDSID = MyQDS[0].ID;
            myTask.Scope = DocumentTaskScope.All;
            myTask.Reload = new DocumentTask.TaskReload();
            myTask.Reload.Mode = TaskReloadMode.Full;

            //apply some category data to the task
            myTask.DocumentInfo = new DocumentTask.TaskDocumentInfo();
            myTask.DocumentInfo.Category = "OnDemand Reload task";
            DocumentAttribute[] attribs = new DocumentAttribute[1];
            attribs[0] = new DocumentAttribute();
            attribs[0].Name = "OnDemandApp";
            attribs[0].Value = "OnDemandApp";
            myTask.DocumentInfo.Attributes = attribs;

            //add a task name and enable it
            myTask.General = new DocumentTask.TaskGeneral();
            myTask.General.TaskName = "OnDemand Reload Task for - " + targetDoc;
            myTask.General.Enabled = true;

            //create the tasks EDX trigger
            ExternalEventTrigger eet = new ExternalEventTrigger();
            eet.Type = TaskTriggerType.ExternalEventTrigger;
            eet.ID = Guid.NewGuid();
            eet.Password = "";
            eet.Enabled = true;

            List<Trigger> TrigList = new List<Trigger>();
            TrigList.Add(new Trigger());
            TrigList[0] = eet;

            myTask.Triggering = new DocumentTask.TaskTriggering();
            myTask.Triggering.Triggers = TrigList.ToArray();
            myTask.Triggering.ExecutionAttempts = 1;
            myTask.Triggering.ExecutionTimeout = 1000;
            myTask.Triggering.TaskDependencies = new TaskInfo[0];

            //Set up distribution
            TaskDistributionDestination taskDestination = new TaskDistributionDestination();
            taskDestination.Type = TaskDistributionDestinationType.QlikViewServer;
            taskDestination.QlikViewServer = new TaskDistributionDestination.TaskDistributionDestinationQlikViewServer();
            taskDestination.QlikViewServer.ID = Client.GetServices(ServiceTypes.QlikViewServer)[0].ID;
            taskDestination.QlikViewServer.Name = Client.GetServices(ServiceTypes.QlikViewServer)[0].Name;
            taskDestination.QlikViewServer.Mount = "";

            DirectoryServiceObject[] recipients = new DirectoryServiceObject[1];
            recipients[0] = new DirectoryServiceObject();
            recipients[0].Type = DirectoryServiceObjectType.Authenticated;
            TaskDistributionEntry[] taskDistributionEntry = new TaskDistributionEntry[1];
            taskDistributionEntry[0] = new TaskDistributionEntry();
            taskDistributionEntry[0].Destination = taskDestination;
            taskDistributionEntry[0].Recipients = recipients;

            myTask.Distribute = new DocumentTask.TaskDistribute();
            myTask.Distribute.Static = new DocumentTask.TaskDistribute.TaskDistributeStatic();
            myTask.Distribute.Static.DistributionEntries = taskDistributionEntry;
            myTask.Distribute.Output = new DocumentTask.TaskDistribute.TaskDistributeOutput();
            myTask.Distribute.Output.Type = TaskDistributionOutputType.QlikViewDocument;

            myTask.Distribute.Dynamic = new DocumentTask.TaskDistribute.TaskDistributeDynamic();
            myTask.Distribute.Dynamic.IdentityType = UserIdentityValueType.SAMAccountName;
            myTask.Distribute.Dynamic.Destinations = new TaskDistributionDestination[0];

            myTask.Distribute.Notification = new DocumentTask.TaskDistribute.TaskDistributeNotification();
            myTask.Distribute.Notification.SendNotificationEmail = false;

            //Set output name
            myTask.Reduce = new DocumentTask.TaskReduce();
            myTask.Reduce.DocumentNameTemplate = targetDoc;
            myTask.Reduce.Static = new DocumentTask.TaskReduce.TaskReduceStatic();
            myTask.Reduce.Static.Reductions = new TaskReduction[0];

            myTask.Reduce.Dynamic = new DocumentTask.TaskReduce.TaskReduceDynamic();

            // Fill out server tab defaults
            myTask.Server = new DocumentTask.TaskServer();
            myTask.Server.Access = new DocumentTask.TaskServer.TaskServerAccess();
            myTask.Server.Access.Download = DocumentDownloadAccess.None;
            myTask.Server.Access.DownloadUsers = new string[0];
            myTask.Server.Access.Export = DocumentDownloadAccess.All;
            myTask.Server.Access.ExportUsers = new string[0];
            myTask.Server.Access.Methods = DocumentAccessMethods.All;
            myTask.Server.Access.MaxConcurrentSessions = 1000;
            myTask.Server.Access.DocumentTimeout = 0;
            myTask.Server.Access.SessionTimeout = 0;
            myTask.Server.Access.ZeroFootprintClientURL = "";
            myTask.Server.DocumentLoading = new DocumentTask.TaskServer.TaskServerDocumentLoading();
            myTask.Server.DocumentLoading.ServerSettings = new DocumentTask.TaskServer.TaskServerDocumentLoading.TaskServerDocumentLoadServerSetting[0];
            myTask.Server.Collaboration = new DocumentTask.TaskServer.TaskServerCollaboration();
            myTask.Server.Collaboration.CreatorUserNames = new string[1];
            myTask.Server.Collaboration.CreationMode = DocumentCollaborationCreationMode.All;

            //Finished the object so save it to the server
            Client.SaveDocumentTask(myTask);

            //Wait 5 seconds for it to catch up, then get the object back for use later on
            System.Threading.Thread.Sleep(5000);
            TaskInfo[] alltasksfordoc = Client.GetTasksForDocument(myTask.Document.ID);
            targetTask = Client.GetDocumentTask(alltasksfordoc[alltasksfordoc.Count() - 1].ID, DocumentTaskScope.All);
        }
예제 #16
0
        public void CreateAggregateTask(string sysname, out Guid taskId)
        {
            ServiceInfo qds = Client.GetServices(ServiceTypes.QlikViewDistributionService).FirstOrDefault();

            if (qds == null)
            {
                throw new System.Exception("No QDS found.");
            }

            List <DocumentNode> sourceDocuments = Client.GetSourceDocuments(qds.ID);

            DocumentNode templateDocument = sourceDocuments.FirstOrDefault(t =>
                                                                           t.Name.Equals("Aggregator.qvw", StringComparison.InvariantCultureIgnoreCase) &&
                                                                           t.RelativePath.Equals("_TEMPLATE", StringComparison.InvariantCultureIgnoreCase));

            if (templateDocument == null)
            {
                throw new System.Exception("Template \"Aggregator.qvw\" not found.");
            }

            DocumentNode customerDocument = sourceDocuments.FirstOrDefault(t =>
                                                                           t.Name.Equals("Aggregator.qvw", StringComparison.InvariantCultureIgnoreCase) &&
                                                                           t.RelativePath.Equals(sysname, StringComparison.InvariantCultureIgnoreCase));

            if (customerDocument == null)
            {
                throw new System.Exception("Customer \"Aggregator.qvw\" not found.");
            }

            TaskInfo templateTaskInfo = Client.GetTasksForDocument(templateDocument.ID).FirstOrDefault(x => x.Type == TaskType.DocumentTask);

            if (templateTaskInfo == null)
            {
                throw new System.Exception("Document task for the template \"Aggregator.qvw\" not found.");
            }

            string   taskName         = GetCustomerAggregatorTaskName(sysname);
            TaskInfo existingTaskInfo = Client.FindTask(qds.ID, TaskType.DocumentTask, taskName);

            if (existingTaskInfo != null)
            {
                taskId = existingTaskInfo.ID;
                return;
            }

            DocumentTask task = Client.GetDocumentTask(templateTaskInfo.ID, DocumentTaskScope.All);

            task.ID                          = Guid.NewGuid();
            task.Document                    = customerDocument;
            task.General.Enabled             = true;
            task.General.TaskName            = taskName;
            task.DocumentInfo.Category       = "Data aggregators";
            task.Reload.ScriptParameterValue = sysname;
            task.Triggering.Triggers.Clear();
            Client.SaveDocumentTask(task);

            task = Client.GetDocumentTask(task.ID, DocumentTaskScope.All);
            var recurrenceTrigger = new RecurrenceTrigger
            {
                Hourly = new RecurrenceTrigger.RecurrenceTriggerHourly
                {
                    DayOfWeekConstraints = new List <DayOfWeek>
                    {
                        DayOfWeek.Monday,
                        DayOfWeek.Tuesday,
                        DayOfWeek.Wednesday,
                        DayOfWeek.Thursday,
                        DayOfWeek.Friday,
                        DayOfWeek.Saturday,
                        DayOfWeek.Sunday
                    },
                    RecurEvery         = 20,
                    TimeConstraintFrom = DateTime.MinValue,
                    TimeConstraintTo   = DateTime.MaxValue
                },
                Enabled = true,
                Type    = TaskTriggerType.HourlyTrigger
            };

            task.Triggering.Triggers.Add(recurrenceTrigger);
            Client.SaveDocumentTask(task);

            taskId = task.ID;
        }