private long Schedule(TKey key, TData data) { if (data == null) { return(0); } var state = new ScheduleState(data); var scheduleId = _mapping.GetOrAdd(key, (_, state) => state.Id = this.Schedule(this.GetHandler(state.Data), this.GetTrigger(state.Data), state.Data), state); //如果新增的调度失败,则需要将失败的调度项删除 if (scheduleId == 0) { if (_mapping.TryRemove(key, out var id) && id != 0) { _mapping.TryAdd(key, id); } } //如果上面的新增调度成功,则返回该新增的调度项编号 if (state.Id > 0) { return(scheduleId); } return(this.Reschedule(scheduleId, this.GetTrigger(data), data) ? scheduleId : 0); }
public IEnumerator DelayedAIAction(DecayingDev.Action _AIAction, string[] args, float delayTime) { yield return(new WaitForSeconds(delayTime)); _AIAction.Execute(args, gameObject); state = ScheduleState.RunningAction; }
public void ExecuteAction(int index, bool Secondary = false, bool started = false) { state = ScheduleState.WaitingForNextAction; ActionIndex = index; PeriodSlot period; DecayingDev.Action _AIAction; if (index < schedule.Periods.Count) { period = schedule.Periods[index]; _AIAction = period.action; } else { ActionIndex = 0; period = schedule.Periods[0]; _AIAction = period.action; } if (started) { StartCoroutine(DelayedAIAction(_AIAction, period.args.ToArray(), 0)); } else { StartCoroutine(DelayedAIAction(_AIAction, period.args.ToArray(), PreviousIndex(schedule.Periods))); } //action.Execute(period.args.ToArray(), gameObject); CurAction = _AIAction; }
public async Task ShouldPassDatesProperly() { // arrange var state = new ScheduleState(); var StartDate = new DateTime(2019, 8, 25, 14, 0, 0); var EndDate = new DateTime(2019, 8, 25, 16, 0, 0); // Act var sut = new AvailabilityViewModel() { MyScheduleState = state, ScheduleRepository = _ScheduleRepository.Object }; sut.MySchedule = new Schedule { Id = 1 }; sut.NewScheduleItem.StartDateTime = StartDate; sut.NewScheduleItem.EndDateTime = EndDate; sut.NewScheduleItem.Name = "Interview with Emma"; var results = await sut.AddNewScheduleItem(); // Assert results.Should().BeEmpty(); _ScheduleRepository.Verify(r => r.AddNewScheduleItem(It.IsAny <Schedule>(), It.Is <ScheduleItem>(i => i.StartDateTime == StartDate && i.EndDateTime == EndDate)), Times.Once, "Did not load the schedule item properly"); }
public void ExecuteSecondAction(List <string> args) { PauseAction(); state = ScheduleState.SecondaryAction; CurSecondaryAction.Execute(args.ToArray(), gameObject); CurAction = null; }
public void End() { Debug.Log("End School"); GameManager.Instance.ChangeBackground("RabbitRoom"); state = ScheduleState.Finish; PlayingManager.PlusCurrentScheduleIndex(); gameObject.SetActive(false); DialogueManager.Instance.ReceiveCommandsFile("EndSchedule"); }
public static ScheduleState GetScheduleState(this IScheduleService s, string Token) { s.InitializeGuard(); ScheduleState r = null; s.Test.RunStep(() => r = s.ServiceClient.Port.GetScheduleState(Token), "Get ScheduleState"); return(r); }
public object Convert(object value, Type targetType, object parameter, string language) { ScheduleState state = (ScheduleState)value; return(state switch { ScheduleState.Normal => GreenBrush, // doesn't matter, the UI isn't visble when in a normal state ScheduleState.Ahead => GreenBrush, ScheduleState.Delayed => RedBrush, _ => throw new ArgumentException() });
public override void Stop() { if (m_timer != null) { m_timer.Stop(); m_timer.Dispose(); m_timer = null; m_syncContext.Post(PostEvent, false); m_scheduleState = ScheduleState.None; } }
public void ResumeAction() { if (CurAction is MoveTo) { animator.SetBool("Moving", true); agent.isStopped = false; state = ScheduleState.RunningAction; } if (CurAction is Idle) { } }
public IActionResult GetScheduleStatus(int deviceId) { try { _logger.LogInformation($"POST /v1/Device/{deviceId}/Schedule/Status called"); ScheduleState scheduleState = _aquariumService.GetDeviceScheduleStatus(deviceId); return(new OkObjectResult(scheduleState)); } catch (Exception ex) { _logger.LogError($"POST /v1/Device/{deviceId}/Schedule/Status: { ex.Message } Details: { ex.ToString() }"); return(BadRequest()); } }
public ActionResult ChangeIssueState(long id, ScheduleState state) { Issue issue; if (!ProjectContext.Issues.TryGetById(id, out issue)) throw new ApplicationException("issue with id = " + id + " was not found!"); if (issue.Assignee == null || issue.Assignee.Id != WebSecurity.CurrentUserId) return JsonError("You can't change issue status because its unnasigned or assigned to another user"); issue.State = state; ProjectContext.TrackIssueProgress(issue, IssueProgressType.StatusChanged); Context.SaveChanges(); return JsonSuccess(); }
public async Task ShouldReturnAppropriateValidationMessages() { // arrange var state = new ScheduleState(); // Act var sut = new AvailabilityViewModel() { MyScheduleState = state, ScheduleRepository = _ScheduleRepository.Object }; await sut.AddNewScheduleItem(); // Assert _ScheduleRepository.Verify(r => r.AddNewScheduleItem(It.IsAny <Schedule>(), It.IsAny <ScheduleItem>()), Times.Never, "Should not have attempted to save the schedule"); }
public void Save(int nLoanID, ScheduleState nStatus, AConnection oDB) { if (IsAlreadyProcessed) { if (!Loan.Step2.Contains(nLoanID)) { return; } } if (!Loan.Step2.Contains(nLoanID)) { return; } var os = new StringBuilder(); int nIsBad = 0; if (nStatus == ScheduleState.DiffCount) { nIsBad = 1; } os.AppendFormat( "INSERT INTO LoanScheduleTransaction" + "(LoanID, ScheduleID, TransactionID, Date, PrincipalDelta, FeesDelta, InterestDelta, StatusBefore, StatusAfter)" + "VALUES ({0}, {1}, {2}, '{3}', {4}, {5}, {6},'{7}','{7}')\n" + "INSERT INTO LoanScheduleTransactionBackfilled (LoanScheduleTransactionID, IsBad, Step) VALUES (@@IDENTITY, {8}, {9})", nLoanID, Schedule.ID, Transaction.ID, Transaction.Date.ToString("MMMM dd yyyy HH:mm:ss", Schedule.Culture), PrincipalDelta, InterestDelta, FeesDelta, Status, nIsBad, 2 ); string sQuery = os.ToString(); oDB.ExecuteNonQuery(sQuery); } // Save
private void DoAction() { // 执行Unity的Build_All try { // 关闭所有的Unity程序 CloseUnityProcess(); string targetDir = Path.GetDirectoryName(m_batFilePath); //这是bat存放的目录 Process proc = new Process(); proc.StartInfo.WorkingDirectory = targetDir; proc.StartInfo.FileName = Path.GetFileName(m_batFilePath); //bat文件名称 proc.StartInfo.CreateNoWindow = true; proc.Start(); proc.WaitForExit(); string output = proc.StandardOutput.ReadToEnd();//读取进程的输出 Logger.ProcessCmdLog(output); m_scheduleState = ScheduleState.Done; } catch (Exception ex) { Logger.Error(string.Format("Exception Occurred :{0},{1}", ex.Message, ex.StackTrace.ToString())); } }
public void BuildWorkingSet() { if (Planned.Count == Actual.Count) { Schedule[] aryPlanned = Planned.ToArray(); Schedule[] aryActual = Actual.ToArray(); for (int i = 0; i < Planned.Count; i++) { Schedule oCurPlanned = aryPlanned[i]; Schedule oCurActual = aryActual[i]; if (oCurActual.Date != oCurPlanned.Date) { ScheduleState = ScheduleState.SameCountDiffDates; } WorkingSet.Add(new Schedule(this) { ID = oCurActual.ID, Date = oCurPlanned.Date, Principal = oCurPlanned.Principal }); } // for if (ScheduleState == ScheduleState.Unknown) { ScheduleState = ScheduleState.Match; } } else { ScheduleState = ScheduleState.DiffCount; BuildBadWorkingSet(); } // if } // BuildWorkingSet
public override void Start() { if (string.IsNullOrEmpty(m_batFilePath)) { System.Windows.Forms.MessageBox.Show("请先选择Bat文件"); return; } if (m_scheduleState == ScheduleState.Doing) { System.Windows.Forms.MessageBox.Show("当前任务正在执行"); return; } DateTime dateTime = m_dateTime; DateTime nowTime = DateTime.Now; if (DateTime.Compare(dateTime, nowTime) < 0) { // 添加24个小时 dateTime = dateTime.AddHours(24); } Logger.Debug("下一个任务的时间点: " + dateTime.ToString()); TimeSpan timeSpan = dateTime.Subtract(nowTime); Interval = (long)timeSpan.TotalMilliseconds; Logger.Debug("距离下一个任务的时间点,还需要毫秒数: " + Interval); m_timer = new Timer(); m_timer.Enabled = true; m_timer.Interval = Interval; //执行间隔时间,单位为毫秒 m_timer.Start(); m_timer.AutoReset = false; m_timer.Elapsed += new ElapsedEventHandler(Timer_Elapsed); PostEvent(true); m_scheduleState = ScheduleState.Doing; }
public FixedTimePointSchedule() { //获取UI线程同步上下文 m_syncContext = System.Threading.SynchronizationContext.Current; m_scheduleState = ScheduleState.None; }
/// <summary> /// Default constructor /// </summary> public GXScheduleEventArgs(GXSchedule schedule, ScheduleState status) : base(schedule) { Status = status; }
public void Awake() { count = 0; workTime = 0.0f; state = ScheduleState.Waiting; }
public void Begin() { Debug.Log("Begin School"); GameManager.Instance.ChangeBackground("School"); state = ScheduleState.Progressing; }
internal void NotifyChange(ScheduleState status) { GXScheduleEventArgs e = new GXScheduleEventArgs(this, status); if (OnScheduleItemStateChanged != null) { OnScheduleItemStateChanged(this, e); } if (Parent != null) { Parent.NotifyChange(this, e); } }
/// <summary> /// Пометить запись в ITS как отправленную, либо не отправленную (ошибка). /// </summary> /// <param name="aCastSchedule">Запись.</param> /// <param name="aState">Состояние отправки.</param> private void MarkCastScheduleAsSended(CastSchedule aCastSchedule, ScheduleState aState) { try { oracleConnection.LockConnection(); Logger.Debug(string.Format("Изменение состояния записи на '{0}'", aState)); updateCastState.Connection = oracleConnection.GetOracleConnection(); updateCastState.Parameters["State"].Value = (int) aState; updateCastState.Parameters["Id"].Value = aCastSchedule.Id; updateCastState.ExecuteNonQuery(); oracleConnection.UpdateLastOperationTime(); Logger.Debug("Изменение состояния успешно"); } catch (Exception ex) { oracleConnection.ProcessError(ex); } finally { oracleConnection.ReleaseConnection(); } }
public void Progress() { state = ScheduleState.Progressing; }
void UpdateScheduleImage(ListViewItem li, ScheduleState status) { switch (status) { case ScheduleState.TaskStart: case ScheduleState.TaskRun: li.ImageIndex = (int)ScheduleImages.ScheduleItemExecute; break; case ScheduleState.TaskFinish: li.ImageIndex = (int)ScheduleImages.ScheduleItemStart; //Update next schedule date. // Schedules.Sort(); break; case ScheduleState.Start: case ScheduleState.Run: li.ImageIndex = (int)ScheduleImages.ScheduleItemStart; break; case ScheduleState.End: case ScheduleState.None: li.ImageIndex = (int)ScheduleImages.ScheduleItemStop; break; default: //Unknown state. System.Diagnostics.Debug.Assert(false); break; } (li.Tag as GXAmiSchedule).Status = status; }
public ActionResult GetIterationIssues(long iterationId, ScheduleState state, int iDisplayStart, int iDisplayLength, string sEcho) { var query = ProjectContext.Issues .AsPredicateTrue() .And(x => x.IterationId == iterationId) .And(x => x.StateValue == (int)state) .And(x => !x.Deleted) .Evaluate() .OrderByDescending(x => x.CreatedDate); var page = query.GetPage(iDisplayStart, iDisplayLength); var model = new DataTablePage { sEcho = sEcho, iTotalRecords = page.TotalItems, iTotalDisplayRecords = page.TotalItems }; foreach (var issue in page.Items) { var item = new Dictionary<string, string> { {"Summary", issue.Summary}, {"Reporter", issue.Reporter.Name}, {"Type", issue.Type.GetDescription()}, {"StoryPoints", issue.StoryPoints.ToString()}, {"Priority", issue.Priority.ToString()}, {"DT_RowId", "issue_" + issue.Id}, {"DT_RowClass", "row-" + issue.Type.ToString().ToLower()} }; model.aaData.Add(item); } return Json(model, JsonRequestBehavior.AllowGet); }
public void ScheduleFetchAndCreateTests() { //cover all lists on the server - there must be at least one List <Schedule> oSchedules; WebCallResult res = Schedule.GetSchedules(_connectionServer, out oSchedules, 1, 2, null); Assert.IsTrue(res.Success, "Failed to fetch schedule list:" + res.ToString()); string strObjectId = ""; foreach (var oSchedule in oSchedules) { Console.WriteLine(oSchedule.ToString()); Console.WriteLine(oSchedule.DumpAllProps()); List <ScheduleDetail> oDetails; oSchedule.GetScheduleDetails(out oDetails); Console.WriteLine(oSchedule.GetScheduleState(DateTime.Now)); strObjectId = oSchedule.ObjectId; } //create a new schedule instance from objectId Schedule oNewSchedule; try { oNewSchedule = new Schedule(_connectionServer, strObjectId); ScheduleState oState = oNewSchedule.GetScheduleState(DateTime.Now); Assert.IsNotNull(oState, "Failed to fetch schedule state from schedule objectId:" + strObjectId); } catch (Exception ex) { Assert.IsTrue(false, "Failed to create new schedule instance from ObjectId:" + ex); } Schedule oTempSchedule; res = Schedule.GetSchedule(out oTempSchedule, _connectionServer, "", oSchedules[0].DisplayName); Assert.IsTrue(res.Success, "Failed to fetch schedule by valid name:" + res); try { oNewSchedule = new Schedule(_connectionServer, "", "blah"); Assert.IsTrue(false, "Creating schedule class with invalid schedule name should throw an exception"); Console.WriteLine(oNewSchedule); } catch (Exception) { Console.WriteLine("Expected error for creation failure"); } res = Schedule.GetSchedule(out oNewSchedule, _connectionServer, "", "bogus"); Assert.IsFalse(res.Success, "Fetching schedule by invalid name did not fail"); res = Schedule.GetSchedules(_connectionServer, out oSchedules, 1, 2, "query=(ObjectId is Bogus)"); Assert.IsTrue(res.Success, "fetching schedules with invalid query should not fail:" + res); Assert.IsTrue(oSchedules.Count == 0, "Invalid query string should return an empty schedules list:" + oSchedules.Count); }
public void StartIdle(float time) { Idling = true; StartCoroutine(Idle(time)); state = ScheduleState.RunningAction; }
public override string ToString() { var os = new StringBuilder(); os.AppendFormat( "Summary for Loan {0} ({3}) - {1} ({5}) - {2} - {4}paid - begin\n", ID, LoanType.ToString(), ScheduleState.ToString(), DeclaredLoanAmount.ToString("C2", Schedule.Culture), TotalPrincipalPaid == DeclaredLoanAmount ? "" : "not ", Actual.Count ); os.AppendFormat("\tPlanned vs Actual: {0} - {1}\n", Planned.Count, Actual.Count); os.AppendFormat( "\tRemaining + Paid = Issued: {0} - {1} + {2} <=> {3}\n", TotalPrincipalPaid + RemainingPrincipal == DeclaredLoanAmount ? "yes" : "no", RemainingPrincipal, TotalPrincipalPaid, DeclaredLoanAmount ); os.AppendFormat("\tPlanned schedule ({0}):\n", Planned.Count); Planned.ForEach(x => os.AppendFormat("\t\t{0}\n", x)); os.AppendFormat("\t\t{0}\n", new string('-', 38)); os.AppendFormat("\t\t{0,27} {1,10}\n", " ", Planned.Sum(x => x.Principal).ToString("C2", Schedule.Culture)); os.AppendFormat("\tActual schedule ({0}):\n", Actual.Count); Actual.ForEach(x => os.AppendFormat("\t\t{0}\n", x)); os.AppendFormat("\t\t{0}\n", new string('-', 38)); os.AppendFormat("\t\t{0,27} {1,10}\n", " ", RemainingPrincipal.ToString("C2", Schedule.Culture)); os.AppendFormat("\tWorking set ({0}):\n", WorkingSet.Count); WorkingSet.ForEach(x => os.AppendFormat("\t\t{0}\n", x)); os.AppendFormat("\tTransactions ({0} - {1}):\n", Transactions.Count, ProcessedTransactionCount); Transactions.ForEach(x => os.AppendFormat("\t\t{0}\n", x)); os.AppendFormat("\t\t{0}\n", new string('-', 38)); os.AppendFormat("\t\t{0,27} {1,10}\n", " ", TotalPrincipalPaid.ToString("C2", Schedule.Culture)); os.AppendFormat("\tSchedule-transactions ({0}):\n", ScheduleTransactions.Count); ScheduleTransactions.ForEach(x => os.AppendFormat("\t\t{0}\n", x)); var nExpected = WorkingSet.Sum(x => x.Principal); var nActual = ScheduleTransactions.Sum(x => x.PrincipalDelta); os.AppendFormat( "\tTotal working set + schedule transactions\n\t\t{0,10} + {1,10} = {2,10}\n", nExpected.ToString("C2", Schedule.Culture), nActual.ToString("C2", Schedule.Culture), (nExpected + nActual).ToString("C2", Schedule.Culture) ); os.AppendFormat("Loan {0} - end\n", ID); return(os.ToString()); } // ToString