private void CheckAndLoadNotifications()
        {
            if (this.notificationsLoaded || this.Mode == ActionMode.Create)
            {
                return;
            }

            Job job = this.Job;

            if (this.Version.Major >= 9 || ((UserRole & UserRoles.SysAdmin) > 0))
            {
                // notifications
                this.operatorToEmail = job.OperatorToEmail;
                this.emailLevel      = job.EmailLevel;

                this.operatorToPage = job.OperatorToPage;
                this.pageLevel      = job.PageLevel;
            }
            else
            {
                this.operatorToEmail = String.Empty;
                this.emailLevel      = CompletionAction.Never;

                this.operatorToPage = String.Empty;
                this.pageLevel      = CompletionAction.Never;
            }

            this.eventLogLevel       = job.EventLogLevel;
            this.deleteLevel         = job.DeleteLevel;
            this.notificationsLoaded = true;
        }
        public void TestUrgentCompletion()
        {
            Analyzer analyzer = new Analyzer();

            analyzer.Actions.AddAction(new BasicSynthesis());
            analyzer.Actions.AddAction(new BasicTouch());
            analyzer.Actions.AddAction(new MastersMend());
            analyzer.Actions.AddAction(new SteadyHand());
            analyzer.Actions.AddAction(new Observe());

            State state = Utility.CreateDefaultState();

            state.CP         = 0;
            state.Durability = 10;
            state.Progress   = state.MaxProgress - 1;

            analyzer.Run(state);

            Ability bestAction = analyzer.OptimalAction(state);

            Assert.AreEqual <ActionType>(ActionType.Completion, bestAction.ActionType);
            CompletionAction completion = (CompletionAction)bestAction;

            Assert.AreNotEqual <uint>(0, (uint)(CompletionFlags.Progress & completion.CompletionFlags));
        }
        private void SaveNotifications(Job job, bool creating)
        {
            if (job == null)
            {
                throw new ArgumentNullException("job");
            }

            // nothing to do if this information has not been loaded
            if (this.notificationsLoaded == false)
            {
                return;
            }

            // notifications panel
            if (this.emailLevel == CompletionAction.Never)
            {
                this.emailLevel      = CompletionAction.OnFailure;
                this.operatorToEmail = String.Empty;
            }

            if (creating || this.emailLevel != job.EmailLevel)
            {
                job.EmailLevel = this.emailLevel;
            }

            if (creating || this.operatorToEmail != job.OperatorToEmail)
            {
                job.OperatorToEmail = this.operatorToEmail;
            }

            if (this.pageLevel == CompletionAction.Never)
            {
                this.pageLevel      = CompletionAction.OnFailure;
                this.operatorToPage = String.Empty;
            }

            if (creating || this.pageLevel != job.PageLevel)
            {
                job.PageLevel = this.pageLevel;
            }

            if (creating || this.operatorToPage != job.OperatorToPage)
            {
                job.OperatorToPage = this.operatorToPage;
            }

            if (creating || this.eventLogLevel != job.EventLogLevel)
            {
                job.EventLogLevel = this.eventLogLevel;
            }

            if (creating || this.deleteLevel != job.DeleteLevel)
            {
                job.DeleteLevel = this.deleteLevel;
            }
        }
Exemple #4
0
        private static void OnVCTaskCompletedEvent(Task task, CompletionAction completionAction)
        {
            WindowPending[] array  = Resources.FindObjectsOfTypeAll(typeof(WindowPending)) as WindowPending[];
            WindowPending[] array2 = array;
            for (int i = 0; i < array2.Length; i++)
            {
                WindowPending windowPending = array2[i];
                switch (completionAction)
                {
                case CompletionAction.UpdatePendingWindow:
                case CompletionAction.OnCheckoutCompleted:
                    windowPending.UpdateWindow();
                    break;

                case CompletionAction.OnChangeContentsPendingWindow:
                    windowPending.OnChangeContents(task);
                    break;

                case CompletionAction.OnIncomingPendingWindow:
                    windowPending.OnIncoming(task);
                    break;

                case CompletionAction.OnChangeSetsPendingWindow:
                    windowPending.OnChangeSets(task);
                    break;

                case CompletionAction.OnGotLatestPendingWindow:
                    windowPending.OnGotLatest(task);
                    break;
                }
            }
            if (completionAction != CompletionAction.OnSubmittedChangeWindow)
            {
                if (completionAction != CompletionAction.OnAddedChangeWindow)
                {
                    if (completionAction == CompletionAction.OnCheckoutCompleted)
                    {
                        if (EditorUserSettings.showFailedCheckout)
                        {
                            WindowCheckoutFailure.OpenIfCheckoutFailed(task.assetList);
                        }
                    }
                }
                else
                {
                    WindowChange.OnAdded(task);
                }
            }
            else
            {
                WindowChange.OnSubmitted(task);
            }
            task.Dispose();
        }
        static void OnVCTaskCompletedEvent(Task task, CompletionAction completionAction)
        {
            // inspector should re-calculate which VCS buttons it needs to show
            InspectorWindow.ClearVersionControlBarState();

            var wins = Resources.FindObjectsOfTypeAll(typeof(WindowPending)) as WindowPending[];

            foreach (WindowPending win in wins)
            {
                switch (completionAction)
                {
                case CompletionAction.UpdatePendingWindow:     // fallthrough
                case CompletionAction.OnCheckoutCompleted:
                    win.UpdateWindow();
                    break;

                case CompletionAction.OnChangeContentsPendingWindow:
                    win.OnChangeContents(task);
                    break;

                case CompletionAction.OnIncomingPendingWindow:
                    win.OnIncoming(task);
                    break;

                case CompletionAction.OnChangeSetsPendingWindow:
                    win.OnChangeSets(task);
                    break;

                case CompletionAction.OnGotLatestPendingWindow:
                    win.OnGotLatest(task);
                    break;
                }
            }

            switch (completionAction)
            {
            case CompletionAction.OnSubmittedChangeWindow:
                WindowChange.OnSubmitted(task);
                break;

            case CompletionAction.OnAddedChangeWindow:
                WindowChange.OnAdded(task);
                break;

            case CompletionAction.OnCheckoutCompleted:
                if (EditorUserSettings.showFailedCheckout)
                {
                    WindowCheckoutFailure.OpenIfCheckoutFailed(task.assetList);
                }
                break;
            }

            task.Dispose();
        }
 private static void OnVCTaskCompletedEvent(Task task, CompletionAction completionAction)
 {
     WindowPending[] array  = Resources.FindObjectsOfTypeAll(typeof(WindowPending)) as WindowPending[];
     WindowPending[] array2 = array;
     for (int i = 0; i < array2.Length; i++)
     {
         WindowPending windowPending = array2[i];
         if (completionAction == CompletionAction.UpdatePendingWindow)
         {
             windowPending.UpdateWindow();
         }
         else
         {
             if (completionAction == CompletionAction.OnChangeContentsPendingWindow)
             {
                 windowPending.OnChangeContents(task);
             }
             else
             {
                 if (completionAction == CompletionAction.OnIncomingPendingWindow)
                 {
                     windowPending.OnIncoming(task);
                 }
                 else
                 {
                     if (completionAction == CompletionAction.OnChangeSetsPendingWindow)
                     {
                         windowPending.OnChangeSets(task);
                     }
                     else
                     {
                         if (completionAction == CompletionAction.OnGotLatestPendingWindow)
                         {
                             windowPending.OnGotLatest(task);
                         }
                     }
                 }
             }
         }
     }
     if (completionAction == CompletionAction.OnSubmittedChangeWindow)
     {
         WindowChange.OnSubmitted(task);
     }
     else
     {
         if (completionAction == CompletionAction.OnAddedChangeWindow)
         {
             WindowChange.OnAdded(task);
         }
     }
     task.Dispose();
 }
Exemple #7
0
        private static void OnVCTaskCompletedEvent(Task task, CompletionAction completionAction)
        {
            foreach (WindowPending windowPending in Resources.FindObjectsOfTypeAll(typeof(WindowPending)) as WindowPending[])
            {
                switch (completionAction)
                {
                case CompletionAction.UpdatePendingWindow:
                case CompletionAction.OnCheckoutCompleted:
                    windowPending.UpdateWindow();
                    break;

                case CompletionAction.OnChangeContentsPendingWindow:
                    windowPending.OnChangeContents(task);
                    break;

                case CompletionAction.OnIncomingPendingWindow:
                    windowPending.OnIncoming(task);
                    break;

                case CompletionAction.OnChangeSetsPendingWindow:
                    windowPending.OnChangeSets(task);
                    break;

                case CompletionAction.OnGotLatestPendingWindow:
                    windowPending.OnGotLatest(task);
                    break;
                }
            }
            switch (completionAction)
            {
            case CompletionAction.OnSubmittedChangeWindow:
                WindowChange.OnSubmitted(task);
                break;

            case CompletionAction.OnAddedChangeWindow:
                WindowChange.OnAdded(task);
                break;

            case CompletionAction.OnCheckoutCompleted:
                if (EditorUserSettings.showFailedCheckout)
                {
                    WindowCheckoutFailure.OpenIfCheckoutFailed(task.assetList);
                    break;
                }
                break;
            }
            task.Dispose();
        }
Exemple #8
0
        private CompletionAction InvokeHandleMethod(Guid uuid, Type handlerType, object message)
        {
            object handler = _container.GetInstance(handlerType);

            _logger.Trace($"{nameof(MessageSubscriber)}.{nameof(ConsumeMessage)}",
                          new LogItem("Event", "Invoking Handler"), new LogItem("MessageId", uuid.ToString),
                          new LogItem("HandlerName", handlerType.Name));
            MethodInfo       handleMethod     = handlerType.GetMethod(nameof(IMessageHandler2 <object, object> .Handle));
            CompletionAction invocationResult = CompletionAction.DoNothing;

            if (handleMethod != null)
            {
                invocationResult = (CompletionAction)handleMethod.Invoke(handler, new[] { message });
            }

            return(invocationResult);
        }
        // loads default values for a new job.
        private void SetDefaults()
        {
            this.description = string.Empty;
            this.enabled     = true;
            this.source      = null;

            // notifications
            this.operatorToEmail = string.Empty;
            this.emailLevel      = CompletionAction.Never;

            this.operatorToPage = string.Empty;
            this.pageLevel      = CompletionAction.Never;
            this.eventLogLevel  = CompletionAction.Never;
            this.deleteLevel    = CompletionAction.Never;

            this.generalInfoLoaded    = true;
            this.notificationsLoaded  = true;
            this.msaInformationLoaded = true;

            this.originatingServer = string.Empty;
        }
Exemple #10
0
 public extern void SetCompletionAction(CompletionAction action);
 private static void OnVCTaskCompletedEvent(Task task, CompletionAction completionAction)
 {
   foreach (WindowPending windowPending in Resources.FindObjectsOfTypeAll(typeof (WindowPending)) as WindowPending[])
   {
     switch (completionAction)
     {
       case CompletionAction.UpdatePendingWindow:
       case CompletionAction.OnCheckoutCompleted:
         windowPending.UpdateWindow();
         break;
       case CompletionAction.OnChangeContentsPendingWindow:
         windowPending.OnChangeContents(task);
         break;
       case CompletionAction.OnIncomingPendingWindow:
         windowPending.OnIncoming(task);
         break;
       case CompletionAction.OnChangeSetsPendingWindow:
         windowPending.OnChangeSets(task);
         break;
       case CompletionAction.OnGotLatestPendingWindow:
         windowPending.OnGotLatest(task);
         break;
     }
   }
   switch (completionAction)
   {
     case CompletionAction.OnSubmittedChangeWindow:
       WindowChange.OnSubmitted(task);
       break;
     case CompletionAction.OnAddedChangeWindow:
       WindowChange.OnAdded(task);
       break;
     case CompletionAction.OnCheckoutCompleted:
       if (EditorUserSettings.showFailedCheckout)
       {
         WindowCheckoutFailure.OpenIfCheckoutFailed(task.assetList);
         break;
       }
       break;
   }
   task.Dispose();
 }
Exemple #12
0
 public void ContinueButtonClick()
 {
     Action = CompletionAction.Continue;
     Disappear();
 }
Exemple #13
0
 public void ReturnButtonClick()
 {
     Action = CompletionAction.Return;
     Disappear();
 }
		public void SetCompletionAction (CompletionAction action, string attNameForValue)
		{
			this.action = action;
			this.attNameForValue = attNameForValue;
		}
Exemple #15
0
 public void SetCompletionAction(CompletionAction action, string attNameForValue)
 {
     this.action          = action;
     this.attNameForValue = attNameForValue;
 }
Exemple #16
0
        public Task ConsumeMessage(object sender, BasicDeliverEventArgs eventDetails)
        {
            try
            {
                inProgressMessages++;

                if (eventDetails?.Body == null || eventDetails.Body.Length < 1)
                {
                    return(RejectMessageWith(DiscardedMessageReason.MissingMessageBody, eventDetails));
                }

                // Deserialise into a class containing only Method and UUID - this also generates a hash
                MethodInspector inspector = GetMethodInspector(eventDetails);
                if (inspector == null)
                {
                    return(RejectMessageWith(DiscardedMessageReason.MethodDeserialisationError, eventDetails));
                }

                _logger.Trace($"{nameof(MessageSubscriber)}.{nameof(ConsumeMessage)}",
                              new LogItem("Event", "Message routed"),
                              new LogItem("Calculated hashcode", inspector.Hash),
                              new LogItem("MessageId", inspector.Uuid.ToString),
                              new LogItem("MessageMethod", inspector.Method));

                if (MessageIsDuplicate(inspector))
                {
                    return(RejectMessageWith(DiscardedMessageReason.Duplicate, eventDetails));
                }

                Type handlerType = GetMessageHandlers(inspector);

                if (handlerType == null)
                {
                    _logger.Trace($"{nameof(MessageSubscriber)}.{nameof(ConsumeMessage)}", new LogItem("Event", "No suitable handler found for Method " + inspector.Method));
                    // We can't process this message, so we'll Ack it.
                    _methodInspectorManager.Register(inspector); // we don't want to see it again

                    return(RejectMessageWith(DiscardedMessageReason.NoHandler, eventDetails));
                }

                Type[] genericArguments = GetGenericArguments(handlerType, inspector.Uuid);

                if (handlerType.GetTypeInfo().ContainsGenericParameters)
                {
                    handlerType = handlerType.MakeGenericType(genericArguments);
                }

                string bodyAsString = Encoding.UTF8.GetString(eventDetails.Body);
                if (!ConstructMessage(out object message, genericArguments, bodyAsString, inspector.Uuid))
                {
                    _logger.Trace($"{nameof(MessageSubscriber)}.{nameof(ConsumeMessage)}",
                                  new LogItem("Event", "The Message could not be constructed, so it's been discarded."));

                    _methodInspectorManager.Register(inspector); // we don't want to see it again

                    // This is a Permanent Failure; if we couldn't construct the Message object now, processing it again won't help.
                    return(RejectMessageWith(DiscardedMessageReason.MessageDeserialisationError, eventDetails));
                }

                Type         messageType = message.GetType();
                PropertyInfo need;
                lock (NeedPropertyCache)
                {
                    if (!NeedPropertyCache.ContainsKey(messageType))
                    {
                        NeedPropertyCache.Add(messageType,
                                              messageType.GetProperty(nameof(Message <object, object> .Need)));
                    }
                    need = NeedPropertyCache[messageType];
                }

                if (need.GetValue(message) == null)
                {
                    _logger.Warn($"{nameof(MessageSubscriber)}.{nameof(ConsumeMessage)}",
                                 new LogItem("Event", "Message has no Need"), new LogItem("MessageId", inspector.Uuid.ToString));

                    _methodInspectorManager.Register(inspector); // we don't want to see it again

                    // This is a Permanent Failure; if there's no Need in the message now, processing it again won't change anything.
                    return(RejectMessageWith(DiscardedMessageReason.MissingNeed, eventDetails));
                }

                HandlerAttribute handlerAttribute = handlerType.GetTypeInfo().GetCustomAttributes <HandlerAttribute>().FirstOrDefault(a => a.Method == inspector.Method);

                if (!ProcessAcceptanceBehaviours(handlerAttribute, messageType, message))
                {
                    _methodInspectorManager.Register(inspector); // we don't want to see it again
                    return(RejectMessageWith(DiscardedMessageReason.AcceptanceBehaviourPrecondition, eventDetails));
                }

                _logger.Trace($"{nameof(MessageSubscriber)}.{nameof(ConsumeMessage)}",
                              new LogItem("Event", "Constructing handler"), new LogItem("MessageId", inspector.Uuid.ToString), new LogItem("HandlerName", handlerType.Name));

                var stopWatch = Stopwatch.StartNew();
                CompletionAction invocationResult = InvokeHandleMethod(inspector.Uuid, handlerType, message);
                stopWatch.Stop();

                _metrics.RecordProcessedMessage(handlerType.Name, stopWatch.Elapsed.TotalMilliseconds);

                if (invocationResult == CompletionAction.Republish)
                {
                    publishMethod = publishMethod ?? _queueWrapper.GetType().GetMethod(nameof(_queueWrapper.PublishMessage));
                    publishMethod.MakeGenericMethod(genericArguments).Invoke(_queueWrapper, new object[] { message, inspector.Uuid });
                }

                // Any exceptions thrown up to this point *are probably* Temporary Failures:
                // Permanent Failures will have been dealt with by local Exception Handling,
                // and the code will continue to this point.

                _methodInspectorManager.Register(inspector);

                _queueWrapper.AcknowledgeMessage(eventDetails);
            }
            catch (Exception e)
            {
                _logger.Exception($"{nameof(MessageSubscriber)}.{nameof(ConsumeMessage)}",
                                  "Failure during consuming of message",
                                  e);

                throw;
            }
            finally
            {
                inProgressMessages--;
            }

            return(Task.CompletedTask);
        }
Exemple #17
0
		public extern void SetCompletionAction(CompletionAction action);
 /// <summary>
 /// constructor
 /// </summary>
 /// <param name="name">job name</param>
 /// <param name="notifyEmail"></param>
 /// <param name="notifyPager"></param>
 public AgentJobNotificationHelper(string name, CompletionAction notifyEmail, CompletionAction notifyPager)
 {
     this.Name        = name;
     this.NotifyEmail = notifyEmail;
     this.NotifyPager = notifyPager;
 }
Exemple #19
0
 public void SetCompletionAction(CompletionAction action);
		private static void OnVCTaskCompletedEvent(Task task, CompletionAction completionAction)
		{
			WindowPending[] array = Resources.FindObjectsOfTypeAll(typeof(WindowPending)) as WindowPending[];
			WindowPending[] array2 = array;
			for (int i = 0; i < array2.Length; i++)
			{
				WindowPending windowPending = array2[i];
				if (completionAction == CompletionAction.UpdatePendingWindow)
				{
					windowPending.UpdateWindow();
				}
				else
				{
					if (completionAction == CompletionAction.OnChangeContentsPendingWindow)
					{
						windowPending.OnChangeContents(task);
					}
					else
					{
						if (completionAction == CompletionAction.OnIncomingPendingWindow)
						{
							windowPending.OnIncoming(task);
						}
						else
						{
							if (completionAction == CompletionAction.OnChangeSetsPendingWindow)
							{
								windowPending.OnChangeSets(task);
							}
							else
							{
								if (completionAction == CompletionAction.OnGotLatestPendingWindow)
								{
									windowPending.OnGotLatest(task);
								}
							}
						}
					}
				}
			}
			if (completionAction == CompletionAction.OnSubmittedChangeWindow)
			{
				WindowChange.OnSubmitted(task);
			}
			else
			{
				if (completionAction == CompletionAction.OnAddedChangeWindow)
				{
					WindowChange.OnAdded(task);
				}
			}
			task.Dispose();
		}
Exemple #21
0
 public void SetCompletionAction(CompletionAction action);