コード例 #1
0
        private IProcessItem GetItemProcess(Item item)
        {
            IProcessItem process = null;

            if (item.Name.Contains("Brie"))
            {
                return(process = new BrieItem());
            }
            else if (item.Name.Contains("Dexterity"))
            {
                return(process = new DexterityItem());
            }
            else if (item.Name.Contains("Elixir"))
            {
                return(process = new ElixirItem());
            }
            else if (item.Name.Contains("Sulfuras"))
            {
                return(process = new SulfurasItem());
            }
            else if (item.Name.Contains("Backstage"))
            {
                return(process = new BackstageItem());
            }
            else if (item.Name.Contains("Conjured"))
            {
                return(process = new ConjuredItem());
            }
            else
            {
                return(process = new OtherItem());
            }
        }
コード例 #2
0
        public void KillProcessById(int processId)
        {
            IProcessItem processItem = processItems.First(p => p.ProcessId == processId);
            string       processName = processItem.ProcessName;

            processItems.Remove(processItem);
            mockProcessWatcher.ProcessDeleted(processId, processName);
        }
コード例 #3
0
ファイル: FrmSerialPort.cs プロジェクト: ssor/LogisTechBase
 public FrmSerialPort(IProcessItem ProcessItem, ISerialPortConfigItem portcfg)
 {
     this.ispci        = portcfg;
     this._ProcessItem = ProcessItem;
     InitializeComponent();
     this.FormClosing += new FormClosingEventHandler(FrmSerialPort_FormClosing);
     this.btn_opencom.EnabledChanged += new EventHandler(btn_opencom_EnabledChanged);
     InitialiseControlValues();
     comport.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);
 }
 public void Validate(IEngineTask task, IProcessItem processItem)
 {
     if (processItem.Lock == null || processItem.Lock.LockExpirationUtc < DateTime.UtcNow)
     {
         return;
     }
     if (!Equals(processItem.Lock.LockedToPrincipalId, task.PrincipalId))
     {
         throw new ProcessItemLockedException(processItem.ProcessItemId, task.PrincipalId, processItem.Lock.LockExpirationUtc);
     }
 }
コード例 #5
0
 public void Validate(IEngineTask task, IProcessItem processItem)
 {
     if (!(task is IActionTask actionTask))
     {
         // don't validate a non-action task
         return;
     }
     if (!actionTask.ExpectedLastMutationId.Equals(processItem.ItemState?.ProcessItemMutationId))
     {
         throw new ProcessItemStateChangedException(processItem.ProcessItemId, actionTask.ExpectedLastMutationId, processItem.ItemState.ProcessItemMutationId);
     }
 }
コード例 #6
0
        public void DeleteProcessFromList(int processId)
        {
            IProcessItem processItem = processList.FirstOrDefault(t => t.ProcessId == processId);

            if (processItem != null)
            {
                processList.Remove(processList.First(t => t.ProcessId == processId));
            }
            else
            {
                simpleLoger.Log($"{processId} is not a valid process Id.");
            }
        }
コード例 #7
0
        /// <summary>
        /// ctor
        /// </summary>
        /// <param name="logger"><see cref="ILogger{InventoryService}"/></param>
        /// <param name="processInvalidItem"><see cref="IProcessInvalidItem"/></param>
        /// <param name="processAgedBrie"><see cref="IProcessAgedBrie"/></param>
        /// <param name="processBackStagePass"><see cref="IProcessBackStagePass"/></param>
        /// <param name="processConjuredItem"><see cref="IProcessConjuredItem"/></param>
        /// <param name="processNormalItem"><see cref="IProcessNormalItem"/></param>
        /// <param name="processSulfurasItem"><see cref="IProcessSulfurasItem"/></param>
        public InventoryService(
            ILogger <InventoryService> logger,
            IProcessInvalidItem processInvalidItem,
            IProcessAgedBrie processAgedBrie,
            IProcessBackStagePass processBackStagePass,
            IProcessConjuredItem processConjuredItem,
            IProcessNormalItem processNormalItem,
            IProcessSulfurasItem processSulfurasItem
            )
        {
            _logger = logger ?? throw new ArgumentNullException(nameof(logger));

            // Item processors
            _processInvalidItem   = processInvalidItem ?? throw new ArgumentNullException(nameof(processInvalidItem));
            _processAgedBrie      = processAgedBrie ?? throw new ArgumentNullException(nameof(processAgedBrie));
            _processBackStagePass = processBackStagePass ?? throw new ArgumentNullException(nameof(processBackStagePass));
            _processConjuredItem  = processConjuredItem ?? throw new ArgumentNullException(nameof(processConjuredItem));
            _processNormalItem    = processNormalItem ?? throw new ArgumentNullException(nameof(processNormalItem));
            _processSulfurasItem  = processSulfurasItem ?? throw new ArgumentNullException(nameof(processSulfurasItem));
        }
コード例 #8
0
        private void ProcessThread()
        {
            List <IProcessItem> processQueue = ProcessHelper.GenerateProcessQueue(matrix, rectangle, handle, settings);
            ResultItem          rs           = new ResultItem(ResultItem.States.ThreadStart, "开始执行操作");

            NotifyAllResultItemObservers(rs);
            isThreadRunning = true;
            for (int i = 0, wrongCount = 0; i < processQueue.Count && wrongCount < settings.MaximumNumberOfRetries; i++)
            {
                try
                {
                    IProcessItem item   = processQueue[i];
                    ResultItem   result = item.Execute();
                    wrongCount = 0;
                    Thread.Sleep(settings.StepDelay);
                    NotifyAllResultItemObservers(result);
                }
                catch (ProcessException e)
                {
                    i--;
                    wrongCount++;
                    if (wrongCount == settings.MaximumNumberOfRetries)
                    {
                        rs = new ResultItem(ResultItem.States.ERROR, "该操作无法完成");
                    }
                    else
                    {
                        rs = new ResultItem(ResultItem.States.WARNING, e.Message + " 正在重试……");
                    }
#if DEBUG
                    Console.WriteLine(rs);
#endif
                    Thread.Sleep(settings.RetryStepDelay);
                    NotifyAllResultItemObservers(rs);
                }
            }
            rs = new ResultItem(ResultItem.States.ThreadFinish, "操作执行完成");
            NotifyAllResultItemObservers(rs);
            isThreadRunning = false;
        }