Exemplo n.º 1
0
        public void Init()
        {
            IoCInitializer.Init();

            var taskRepository = IoCContainer.Resolve <ITaskRepository>();
            var taskExecutionItemRepository = IoCContainer.Resolve <ITaskExecutionItemRepository>();

            taskService = new TaskService(taskRepository, taskExecutionItemRepository);

            topic           = "123";
            deal            = new Mock <Deal>();
            contractor      = new Mock <Contractor>();
            productionOrder = new Mock <ProductionOrder>();
            taskType        = new TaskType("Type_1");
            state           = new TaskExecutionState("State_1", TaskExecutionStateType.New, 1);
            taskType.AddState(state);
            taskPriority = new TaskPriority("Priority_1", 1);
            currentDate  = DateTime.Now;

            user = new User(new Employee("Иван", "Иванов", "Иванович", new EmployeePost("Менеджер"), null), "Иванов Иван", "ivanov", "pa$$w0rd", new Team("Тестовая команда", null), null);
            var role = new Role("Администратор");

            role.AddPermissionDistribution(new PermissionDistribution(Permission.Task_Create, PermissionDistributionType.All));
            user.AddRole(role);
        }
Exemplo n.º 2
0
 private Process(ILogger logger, System.Diagnostics.Process process)
 {
     m_process       = process;
     m_logger        = logger;
     m_state         = TaskExecutionState.Started;
     process.Exited += Process_Exited;
     //process.ErrorDataReceived += Process_ErrorDataReceived;
     //process.OutputDataReceived += Process_OutputDataReceived;
 }
Exemplo n.º 3
0
 private void SetState(TaskExecutionState state)
 {
     lock (m_sync)
     {
         if (state != m_state)
         {
             m_state = state;
             this.CurrentStateChanged?.Invoke(this, EventArgs.Empty);
         }
     }
 }
Exemplo n.º 4
0
 private void SetState(TaskExecutionState state)
 {
     lock (m_sync)
     {
         if (state != m_currentState)
         {
             System.Diagnostics.Debug.WriteLine($"Script execution changed to {state} state");
             m_currentState = state;
             this.CurrentStateChanged?.Invoke(this, EventArgs.Empty);
         }
     }
 }
Exemplo n.º 5
0
        private void UpdateState(TaskExecutionState state)
        {
            var temp = TaskState;

            _taskState = state;

            if (TaskExecutionStateChanged != null)
            {
                TaskExecutionStateChanged(
                    this, new TaskExecutionStateEventArgs {
                    OldState = temp
                });
            }
        }
            protected void ChangeState(TaskExecutionState state)
            {
                bool changed = false;

                lock (m_sync)
                {
                    if (m_state != state)
                    {
                        m_state = state;
                        changed = true;
                    }
                }
                if (changed)
                {
                    this.CurrentStateChanged?.Invoke(this, EventArgs.Empty);
                }
            }
Exemplo n.º 7
0
 /// <summary>
 /// Restituisce la descrizione in formato stringa dello stato specificato.
 /// </summary>
 /// <param name="state">lo stato di cui si richiede la descrizione</param>
 /// <returns>la descrizione in formato stringa dello stato specificato</returns>
 public static string GetStateDescription(TaskExecutionState state)
 {
     string description;
     if (m_InternalTable_1.TryGetValue(state, out description))
         return description;
     return string.Empty;
 }
Exemplo n.º 8
0
 /// <summary>
 /// Получение типа задачи по статусу исполнения
 /// </summary>
 /// <param name="state">Статус исполнения</param>
 /// <returns></returns>
 public TaskType GetTaskTypeByExecutionState(TaskExecutionState state)
 {
     return(taskTypeRepository.GetTaskTypeByExecutionState(state.Id));
 }
Exemplo n.º 9
0
 /// <summary>
 /// Istanzia un nuovo oggetto della classe TaskExecutionProgressEventArgs con i parametri specificati.
 /// </summary>
 /// <param name="state">lo stato relativo alla richiesta di elaborazione</param>
 /// <param name="error">l'eventuale errore verificatosi durante la comunicazione col servizio</param>
 /// <param name="id">l'identificativo del task assegnato dal servizio di elaborazione</param>
 /// <remarks>
 /// Se non si è verificato alcun errore durante la comunicazione col servizio, il parametro corrispondente
 /// va impostato a null. In modo analogo, se i risultati dell'elaborazione di un task non sono disponibili
 /// a causa di un errore o perché l'operazione è stata annullata, il parametro corrispondente dovrà essere
 /// impostato a null.
 /// </remarks>
 public TaskExecutionProgressEventArgs(TaskExecutionState state, Exception error, string id)
 {
     State = state;
     Error = error;
     Id = id;
 }
 private bool HasExpired(TaskExecutionState taskExecutionState)
 {
     return(_commonTokenRepository.HasExpired(taskExecutionState));
 }
 /// <summary>
 /// Genera un nuovo evento per notificare il cambiamento di stato della richiesta di elaborazione del task.
 /// </summary>
 /// <param name="state">lo stato relativo alla richiesta di elaborazione</param>
 /// <param name="error">l'eventuale errore verificatosi durante la comunicazione col servizio</param>
 /// <remarks>
 /// Se non si è verificato alcun errore durante la comunicazione col servizio, il parametro corrispondente
 /// va impostato a null. In modo analogo, se i risultati dell'elaborazione di un task non sono disponibili
 /// a causa di un errore o perché l'operazione è stata annullata, il parametro corrispondente dovrà essere
 /// impostato a null.
 /// </remarks>
 private void RaiseTaskExecutionProgress(TaskExecutionState state, Exception error)
 {
     TaskExecutionProgressHandler handler = OnTaskExecutionProgress;
     if (handler != null)
     {
         TaskExecutionProgressEventArgs args =
             new TaskExecutionProgressEventArgs(state, error, m_TaskRequestId);
         OnTaskExecutionProgress(this, args);
     }
 }
 private bool HasCriticalSectionExpired(TaskExecutionState taskExecutionState)
 {
     return _commonTokenRepository.HasExpired(taskExecutionState);
 }
Exemplo n.º 13
0
        public void Init()
        {
            topic  = "123";
            topic2 = "456";

            description = "qwerty";

            completionPercentage  = 0;
            completionPercentage2 = 42;

            deal = new Mock <Deal>();
            deal.Setup(x => x.Id).Returns(711);

            contractor = new Mock <Contractor>();
            contractor.Setup(x => x.Id).Returns(71);

            productionOrder = new Mock <ProductionOrder>();
            productionOrder.Setup(x => x.Id).Returns(productionOrderId);

            taskType  = new TaskType("Type_1");
            taskType2 = new TaskType("Type_2");
            var taskExecutionState = new Mock <TaskExecutionState>();

            taskExecutionState.Setup(x => x.Id).Returns(1);
            taskExecutionState.Setup(x => x.ExecutionStateType).Returns(TaskExecutionStateType.New);
            taskExecutionState.Setup(x => x.Equals(It.Is <TaskExecutionState>(y => y.Id == 1))).Returns(true);

            var taskExecutionState2 = new Mock <TaskExecutionState>();

            taskExecutionState2.Setup(x => x.Id).Returns(2);
            taskExecutionState2.Setup(x => x.ExecutionStateType).Returns(TaskExecutionStateType.Executing);
            taskExecutionState2.Setup(x => x.Equals(It.Is <TaskExecutionState>(y => y.Id == 2))).Returns(true);
            var taskExecutionState3 = new Mock <TaskExecutionState>();

            taskExecutionState3.Setup(x => x.Id).Returns(3);
            taskExecutionState3.Setup(x => x.ExecutionStateType).Returns(TaskExecutionStateType.Completed);
            taskExecutionState3.Setup(x => x.Equals(It.Is <TaskExecutionState>(y => y.Id == 3))).Returns(true);

            var taskExecutionState4 = new Mock <TaskExecutionState>();

            taskExecutionState4.Setup(x => x.Id).Returns(4);
            taskExecutionState4.Setup(x => x.ExecutionStateType).Returns(TaskExecutionStateType.New);
            taskExecutionState4.Setup(x => x.Equals(It.Is <TaskExecutionState>(y => y.Id == 4))).Returns(true);
            taskExecutionState4.Setup(x => x.Name).Returns("State_4");

            state1 = taskExecutionState.Object;
            state2 = taskExecutionState2.Object;
            state3 = taskExecutionState3.Object;
            state4 = taskExecutionState4.Object;

            taskType.AddState(state1);
            taskType.AddState(state2);
            taskType.AddState(state3);
            taskType2.AddState(state4);

            taskPriority  = new TaskPriority("Priority_1", 1);
            taskPriority2 = new TaskPriority("Priority_2", 2);

            currentDate = DateTime.Now;

            user = new Mock <User>();
            user.Setup(x => x.Id).Returns(1);
        }