internal void CarToReturn(OrderVM carToReturn) { var orderReturned = context.Orders.First(x => x.BookingNr == carToReturn.BookingNr); var car = context.Cars.First(c => c.Id == orderReturned.CarId); orderReturned.MileageOnReturn = carToReturn.MileageOnReturn; orderReturned.DrivenMiles = carToReturn.MileageOnReturn - orderReturned.CurrentMileage; orderReturned.IsReturned = true; orderReturned.IsActive = false; car.ToBeCleaned = true; car.IsAvailable = true; car.Mileage += orderReturned.DrivenMiles; if (car.TimesRented == 3) { car.NeedService = true; car.TimesRented = 0; } if (car.Mileage >= 2000) { car.ToBeRemoved = true; } HistoryLog y = new HistoryLog { OrderId = carToReturn.BookingNr, CustomerId = orderReturned.CustomerId, CarId = car.Id, Activity = $"Kund {orderReturned.CustomerId} Lämnade tillbaka bil {car.Id}" }; context.HistoryLog.Add(y); context.SaveChanges(); }
internal void BookCar(OrderVM newOrder) { var carToBook = context.Cars.First(c => c.Id == newOrder.CarId); Orders x = new Orders { CustomerId = context.Customers .Where(c => c.Ssn == newOrder.Ssn) .Select(c => c.CustomerId) .FirstOrDefault(), CarId = newOrder.CarId, PickUpDate = newOrder.PickUpDate, ReturnDate = newOrder.ReturnDate, CurrentMileage = carToBook.Mileage, IsReturned = false, IsActive = true, }; carToBook.IsAvailable = false; carToBook.TimesRented += 1; context.Orders.Add(x); HistoryLog y = new HistoryLog { CustomerId = x.CustomerId, CarId = newOrder.CarId, Activity = $"Kund {x.CustomerId} hyrde bil {newOrder.CarId}" }; context.HistoryLog.Add(y); context.SaveChanges(); }
public async Task <IActionResult> Edit(int id, [Bind("Id,EventDescription,EventDateTime")] HistoryLog historyLog) { if (id != historyLog.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(historyLog); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!HistoryLogExists(historyLog.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(historyLog)); }
public void HistoryLogService_Create_CallsInsertAndSaveChanges() { #region Arrange var historyLog = new HistoryLog { Frequency = TaskFrequencyNames.OneTime, Handler = TaskHandlerNames.OperationsHandler, Name = TaskNames.AllocateCase, CompletedDate = DateTime.Now.AddMinutes(-10), InsertedBy = UserName, InsertedDate = _dateTime.AddDays(-1), UpdatedBy = UserName, UpdatedDate = _dateTime.AddDays(-1), }; #endregion #region Act _historyLogService.Create(historyLog); #endregion #region Assert _mockHistoryLogRepository.Verify(x => x.Insert(It.IsAny <HistoryLog>()), Times.Once()); _mockUnitOfWork.Verify(x => x.Save(), Times.Once); #endregion }
public override void Initialize() { HistoryLog.Initialize(_assetManager.Font, 400, _assetManager); HistoryLog.Instance.SortOrder = Camera2D.SortUI + 100; HistoryLog.Instance.Hidden = false; AddAndInitializeRootEntity(HistoryLog.Instance, _assetManager); var cursorSprite = _assetManager[AssetManager.CrosshairCursor]; var crosshairCursor = CreateRootEntity(Camera2D.SortUI + 10000); crosshairCursor.Renderer = new SpriteRenderer(cursorSprite); crosshairCursor.AddComponent(() => { crosshairCursor.Position = InputManager.Instance.MousePosition.ToVector2() - cursorSprite.Bounds.Size.ToVector2() / 2; }); Camera2D.Instance.Translate = new Vector3(600, 400, 0); var gameBoardEntity = CreateRootEntity(Camera2D.SortBackground); gameBoardEntity.AddComponent(() => { if (InputManager.Instance.IsKeyJustPressed(Keys.P)) { Terminate(); } }); _gameBoardController = new GameBoardController(_game, crosshairCursor, this, _replay); _gameBoardController.GameFinishedCallback = () => GameFinishedCallback?.Invoke(); gameBoardEntity.AddComponent(_gameBoardController); gameBoardEntity.CustomBatch = true; BuildUi(); foreach (var mobId in _game.MobManager.Mobs) { var mobAnimationController = new MobAnimationController(_game); var mobEntity = new MobEntity(mobId, _game) { SortOrder = Camera2D.SortMobs, Renderer = new MobRenderer(_game, mobId, mobAnimationController), Transform = () => Camera2D.Instance.Transform }; mobEntity.AddComponent(mobAnimationController); AddAndInitializeRootEntity(mobEntity, _assetManager); MobEntities[mobId] = mobEntity; } }
public async Task <IActionResult> Create([Bind("Id,EventDescription,EventDateTime")] HistoryLog historyLog) { if (ModelState.IsValid) { _context.Add(historyLog); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(historyLog)); }
public static void AddEscalationListItem(this Web value, string listName, HistoryLog historyLog) { var list = value.Lists.GetByTitle(listName); var dictionary = new Dictionary <string, object> { { "Title", historyLog.Name }, { "Comment", historyLog.EventDetail }, // This is in fact the Description field! { "Category", historyLog.Handler } }; list.AddListItem(dictionary); }
public override int SaveChanges() { this.ChangeTracker.DetectChanges(); var modifiedBooks = this.ChangeTracker.Entries <Book>() .Where(t => t.State == EntityState.Modified) .Select(t => t.Entity) .ToList(); modifiedBooks.ForEach(e => { var currentBook = (Book)this.Entry(e).CurrentValues.ToObject(); var originalBook = (Book)this.Entry(e).OriginalValues.ToObject(); var currentLanguages = this.ChangeTracker.Entries <BookLanguage>() .Where(t => ((t.State == EntityState.Added) || (t.State == EntityState.Modified)) && t.Entity.BookId == currentBook.Id) .Select(t => t.Entity) .ToList(); currentBook.BookLanguages = new List <BookLanguage>(); currentLanguages.ForEach(bl => { currentBook.BookLanguages.Add((BookLanguage)this.Entry(bl).CurrentValues.ToObject()); }); var originalLanguages = this.ChangeTracker.Entries <BookLanguage>() .Where(t => ((t.State == EntityState.Deleted) || (t.State == EntityState.Modified)) && t.Entity.BookId == currentBook.Id) .Select(t => t.Entity) .ToList(); originalBook.BookLanguages = new List <BookLanguage>(); originalLanguages.ForEach(bl => { originalBook.BookLanguages.Add((BookLanguage)this.Entry(bl).OriginalValues.ToObject()); }); var currentBookJson = historyLogHandler.Serialize(currentBook); var originalBookJson = historyLogHandler.Serialize(originalBook); var historyLog = new HistoryLog() { Origin = originalBookJson, Actually = currentBookJson, EntityId = e.Id.ToString(), EntityType = e.GetType().ToString(), UpdateTime = DateTime.UtcNow, }; Set <HistoryLog>().Add(historyLog); }); return(base.SaveChanges()); }
void Start() { historyLog = GameObject.Find("HistoryLog").GetComponent <HistoryLog>(); inputField = GameObject.Find("InputField").GetComponent <InputField>(); navigator = GetComponent <Navigator>(); LoadScenario(startingScenario); inputField.onEndEdit.AddListener(delegate { HandleOnEditEnd(inputField.text); }); }
internal void UpdateCarCleaning(CarVM update) { var carToUpdate = context.Cars.First(c => c.Id == update.Id); carToUpdate.ToBeCleaned = update.ToBeCleaned; HistoryLog y = new HistoryLog { CarId = carToUpdate.Id, Activity = $"Bil {carToUpdate.Id} städades." }; context.HistoryLog.Add(y); context.SaveChanges(); }
internal void UpdateCarService(CarVM update) { var carToUpdate = context.Cars.First(c => c.Id == update.Id); carToUpdate.NeedService = update.NeedService; HistoryLog y = new HistoryLog { CarId = carToUpdate.Id, Activity = $"Bil {carToUpdate.Id} Lämnades in på service." }; context.HistoryLog.Add(y); context.SaveChanges(); }
public async Task <IActionResult> OnGetAsync(long?id) { if (id == null) { return(NotFound()); } HistoryLog = await _context.history_log.FirstOrDefaultAsync(m => m.idx == id); if (HistoryLog == null) { return(NotFound()); } return(Page()); }
/// <summary> /// 紀錄歷程 /// </summary> /// <param name="servicename">服務功能名稱</param> /// <param name="projectcode">專案名稱</param> /// <param name="userid">使用者Id</param> /// <param name="param"></param> public async void logHistory(string servicename, string projectcode, Guid userid, string param = "") { await Task.Run(() => { HistoryLog hl = new HistoryLog() { Id = Guid.NewGuid(), ServiceName = servicename, ProjectCode = projectcode, User_Id = userid, ActionTime = DateTime.Now, Params = param }; TableEntity <HistoryLog> historyEntity = new TableEntity <HistoryLog>(DBType, DBConnStr, DBTimeout); historyEntity.Insert(hl); }); }
/// <summary> /// Instantiates a prompt object. This object can be re-used for multiple invocations of <see cref="ReadLineAsync()"/>. /// </summary> /// <param name="persistentHistoryFilepath">The filepath of where to store history entries. If null, persistent history is disabled.</param> /// <param name="callbacks">A collection of callbacks for modifying and intercepting the prompt's behavior</param> /// <param name="console">The implementation of the console to use. This is mainly for ease of unit testing</param> /// <param name="configuration">If null, default configuration is used.</param> public Prompt( string?persistentHistoryFilepath = null, PromptCallbacks?callbacks = null, IConsole?console = null, PromptConfiguration?configuration = null) { this.console = console ?? new SystemConsole(); this.console.InitVirtualTerminalProcessing(); this.configuration = configuration ?? new PromptConfiguration(); this.history = new HistoryLog(persistentHistoryFilepath, this.configuration.KeyBindings); this.cancellationManager = new CancellationManager(this.console); this.clipboard = (console is IConsoleWithClipboard consoleWithClipboard) ? consoleWithClipboard.Clipboard : new Clipboard(); promptCallbacks = callbacks ?? new PromptCallbacks(); this.highlighter = new SyntaxHighlighter(promptCallbacks, PromptConfiguration.HasUserOptedOutFromColor); }
public async Task <IActionResult> OnPostAsync(long?id) { if (id == null) { return(NotFound()); } HistoryLog = await _context.history_log.FindAsync(id); if (HistoryLog != null) { _context.history_log.Remove(HistoryLog); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> DeleteConfirmed(int id) { var employee = await _context.Employee.FindAsync(id); _context.Employee.Remove(employee); await _context.SaveChangesAsync(); //Create a record in the HistoryLog table about the delete of the current employee HistoryLog newlog = new HistoryLog(); newlog.EventDescription = "Employee " + employee.Name + " " + employee.Surname + " deleted."; newlog.EventDateTime = DateTime.Now; _context.Add(newlog); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
//Method that exports the Skill Data Set to .xlsx file //When the scheduler clicks the button "Export to .xlsx file" //the following method will run and a Skills.xlsx file will be downloaded from the scheduler's browser //the file is saved by default in the "Downloads" folder public async Task <IActionResult> Excel() { using (var workbook = new XLWorkbook()) { var worksheet = workbook.Worksheets.Add("Skills"); var currentRow = 1; worksheet.Cell(currentRow, 1).Value = "Id"; worksheet.Cell(currentRow, 2).Value = "Name"; worksheet.Cell(currentRow, 3).Value = "Description"; worksheet.Cell(currentRow, 4).Value = "Creation Date"; foreach (var skill in _context.Skill) { currentRow++; worksheet.Cell(currentRow, 1).Value = skill.ID; worksheet.Cell(currentRow, 2).Value = skill.Name; worksheet.Cell(currentRow, 3).Value = skill.Description; worksheet.Cell(currentRow, 4).Value = skill.CreationDate; } using (var stream = new System.IO.MemoryStream()) { workbook.SaveAs(stream); var content = stream.ToArray(); HistoryLog newlog = new HistoryLog(); newlog.EventDescription = "Skills DataSet exported to Skills.xlsx file."; newlog.EventDateTime = DateTime.Now; _context.Add(newlog); await _context.SaveChangesAsync(); return(File( content, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "Skills.xlsx")); } } }
public async Task <IActionResult> Edit(int id, [Bind("ID,Name,Description,CreationDate")] Skill skill) { if (id != skill.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(skill); await _context.SaveChangesAsync(); //Create a record in the HistoryLog table about the data change of the current skill HistoryLog newlog = new HistoryLog(); newlog.EventDescription = "Skill " + skill.Name + " data changed."; newlog.EventDateTime = DateTime.Now; _context.Add(newlog); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SkillExists(skill.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(skill)); }
public async Task <IActionResult> Create([Bind("ID,Name,Description,CreationDate")] Skill skill) { if (ModelState.IsValid) { _context.Add(skill); await _context.SaveChangesAsync(); //Create a record in the HistoryLog table about the creation of the current skill HistoryLog newlog = new HistoryLog(); newlog.EventDescription = "Skill " + skill.Name + " created."; newlog.EventDateTime = DateTime.Now; _context.Add(newlog); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(skill)); }
public void EscalateErrorEvent(HistoryLog historyLog) { using (var context = new ClientContext(SupportSiteCollectionUrl())) { // Assign Credentials context.Credentials = Credentials; context.Web.AddEscalationListItem(SupportEscalationListName, historyLog); context.ExecuteQuery(); } RetryableOperation.Invoke(ExceptionPolicies.General, () => { // Mark the dead task as escalated historyLog.Escalated = true; historyLog.UpdatedDate = DateTime.Now; historyLog.UpdatedBy = _userIdentity.Name; _historyLogRepository.Update(historyLog); _unitOfWork.Save(); }); }
private void UpdateVipStatus(Customers customer) { if (customer.TimesRented == 3) { customer.Vipstatus += 1; HistoryLog y = new HistoryLog { CustomerId = customer.CustomerId, Activity = $"Kund {customer.CustomerId} uppgraderas till VIP nivå Brons" }; context.HistoryLog.Add(y); context.SaveChanges(); } if (customer.TimesRented == 5) { customer.Vipstatus += 1; HistoryLog y = new HistoryLog { CustomerId = customer.CustomerId, Activity = $"Kund {customer.CustomerId} uppgraderas till VIP nivå Silver" }; context.HistoryLog.Add(y); context.SaveChanges(); } if (customer.TimesRented > 4 && customer.MilesDriven > 1000) { customer.Vipstatus += 1; HistoryLog y = new HistoryLog { CustomerId = customer.CustomerId, Activity = $"Kund {customer.CustomerId} uppgraderas till VIP nivå Guld" }; context.HistoryLog.Add(y); context.SaveChanges(); } }
public void AddMessage(PlayerMessage e) { var desc = e.Desc; if (HistoryLog.Count == 0) { var entry = new HistoryEntry(desc); HistoryLog.Add(entry); HistoryRecent.Add(entry); } else { var last = HistoryLog.Last(); if (last._desc.ToString() == desc.ToString()) { last.times++; last.SetScreenTime(); if (HistoryRecent.Any()) { if (HistoryRecent.Last() != last) { HistoryRecent.Remove(last); HistoryRecent.Add(last); } } else { HistoryRecent.Add(last); } } else { var entry = new HistoryEntry(desc); HistoryLog.Add(entry); HistoryRecent.Add(entry); } } }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Surname,Country,City,Address,HiringDate,Department,Skillset,JobTitle,MonthlySalary")] Employee employee) { if (id != employee.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(employee); await _context.SaveChangesAsync(); //Create a record in the HistoryLog table about the data change of the current employee HistoryLog newlog = new HistoryLog(); newlog.EventDescription = "Employee " + employee.Name + " " + employee.Surname + " data changed."; newlog.EventDateTime = DateTime.Now; _context.Add(newlog); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmployeeExists(employee.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(employee)); }
public async Task <IActionResult> Create([Bind("Id,Name,Surname,Country,City,Address,HiringDate,Department,Skillset,JobTitle,MonthlySalary")] Employee employee) { if (ModelState.IsValid) { _context.Add(employee); await _context.SaveChangesAsync(); //Create a record in the HistoryLog table about the creation of the current employee HistoryLog newlog = new HistoryLog(); newlog.EventDescription = "Employee " + employee.Name + " " + employee.Surname + " created."; newlog.EventDateTime = DateTime.Now; _context.Add(newlog); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(employee)); }
/// <summary> /// Bei einem Klick auf einen Header wird die Liste sortiert. Abwechselnd ASC und DESC. /// </summary> /// <param name="sortBy">Das HistoryLogEntry Property nach dem sortiert werden soll</param> private void HistoryLogHeaderClick(string sortBy) { // Falls nach einer neuen Spalte sortiert wird, wird die Richtung nicht beachtet if (SortedHeader != sortBy) { SortedDirection = 0; } // Sortiert ASC if (SortedDirection != 1) { HistoryLog = new ObservableCollection <HistoryLogEntry>(HistoryLog.OrderBy(x => x.GetType().GetProperty(sortBy).GetValue(x, null))); SortedDirection = 1; } // Sortiert DESC else { HistoryLog = new ObservableCollection <HistoryLogEntry>(HistoryLog.OrderByDescending(x => x.GetType().GetProperty(sortBy).GetValue(x, null))); SortedDirection = -1; } // Speichert den Header nach dem Sortiert ist SortedHeader = sortBy; }
public void HistoryLogService_Delete_ByEntity_CallsDeleteAndUnitOfWorkSave() { #region Arrange var historyLog = new HistoryLog { Id = 1 }; #endregion #region Act _historyLogService.Delete(historyLog); #endregion #region Assert _mockHistoryLogRepository.Verify(x => x.Delete(It.IsAny <HistoryLog>()), Times.Once()); _mockUnitOfWork.Verify(x => x.Save(), Times.Once); #endregion }
private void ManagerAllThreadsCompleted() { this.Manager.AllThreadsCompleted -= ManagerAllThreadsCompleted; this.Manager.RecordCompleted -= ManagerRecordCompleted; JobStatistics stats = new JobStatistics(this.Manager.ExecutionData.Values); bool hasErrors = (this.Statistics.FailureCount > 0); HistoryLog.RecordHistory( this.Context, String.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9}", this.Statistics.ExecutionCount, this.Context.Execution.TestCountPerThreadStep, this.Context.Execution.ThreadCount, this.Statistics.RecordsInRun, this.Statistics.FailureCount, this.Statistics.AverageAITime(), stats.TotalExecutionTime, (this.Statistics.RecordsInRun / stats.TotalExecutionTime), stats.MaxProcessedRecords, stats.MinProcessedRecords) ); this.StatusUpdate?.Invoke(String.Format("Finished job with {0} threads", this.Context.Execution.ThreadCount)); // Reset AI times and failure counts for next run this.Statistics.AITimes.Clear(); this.Statistics.FailureCount = 0; if (this.Context.Execution.AutoScaling) { if (++this.Statistics.ExecutionCount < this.Context.Execution.TestCountPerThreadStep) { String errorText = String.Format("INTERNAL - Scaling up but no more threads left -> {0}.", this.Context.Execution.ThreadCount); if (!hasErrors) { this.ErrorTrackingAutoScale[SUCCESS] = this.Context.Execution.ThreadCount; if (this.ErrorTrackingAutoScale[FAILURE] != -1) { errorText = String.Format("INTERNAL - Previous errors detected, not moving up thread count."); } else if (this.Context.Execution.ThreadCount < this.Context.Execution.MaxThreadCount) { this.Context.Execution.ThreadCount += this.Context.Execution.AutoScaleIncrement; errorText = String.Format("INTERNAL - Scaling up thread count"); ClientScalingLog.RecordScalingChange(this.Context, this.Context.Execution.ThreadCount); } } else // Something is wrong, scale back { this.StatusUpdate?.Invoke("Errors detected, scaling back"); this.ErrorTrackingAutoScale[FAILURE] = this.Context.Execution.ThreadCount; errorText = String.Format("INTERNAL - Scaled back to a single thread already"); if (this.Context.Execution.ThreadCount > 1) { this.Context.Execution.ThreadCount -= 1; errorText = String.Format("INTERNAL - Scaling back thread count with errors"); } ClientScalingLog.RecordScalingChange(this.Context, this.Context.Execution.ThreadCount); } EventHubUtility.ProcessOneOff(this.Context.HubConfiguration, this.Context.Execution.ClientName, 2, errorText); this.StartExecution(); } else { // Let caller know we're done. this.AllThreadsCompleted?.Invoke(); } } else { if (++this.Statistics.ExecutionCount < this.Context.Execution.TestCountPerThreadStep) { this.StartExecution(); } else { // Increase thread count until max if (this.Context.Execution.ThreadStep > 0 && this.Context.Execution.ThreadCount + this.Context.Execution.ThreadStep <= this.Context.Execution.MaxThreadCount) { this.Statistics.ExecutionCount = 0; this.Context.Execution.ThreadCount += this.Context.Execution.ThreadStep; this.StartExecution(); } else { this.AllThreadsCompleted?.Invoke(); } } } }
public void UpdateHistoryLog(HistoryLog log) { _dapper.Execute(_configuration.RdssqlServerConnection, _fileReader.GetFile(_configuration.UpdateHistoryLog), new { ACRONYMName = log.AcronymName, AppearTimes = log.AppearTimes + 1 }); }
public HistoryLogViewForm(HistoryLog _log) { InitializeComponent(); ParsePolynomial(_log.firstPolynomial, polynomial1TextBox); if (twoPolynomials.Contains(_log.Operation)) { ParsePolynomial(_log.secondPolynomial, polynomial2TextBox); ParsePolynomial(_log.resultPolynomial, resultPolynomialTextBox); } else if (onePolynomial.Contains(_log.Operation)) { splitContainer2.Panel1Collapsed = true; if (_log.Operation == '=') { showRoots(_log.firstPolynomial, _log.roots); } else { ParsePolynomial(_log.resultPolynomial, resultPolynomialTextBox); } } else if (oneWithParameters.Contains(_log.Operation)) { groupBox2.Text = "Parameters"; showParameter(_log.parameters, polynomial2TextBox); ParsePolynomial(_log.resultPolynomial, resultPolynomialTextBox); } else { throw new ArgumentException("Operation is not supported"); } this.Text = DateTime.Parse(_log._timeStamp).ToShortTimeString() + " "; switch (_log.Operation) { case '+': this.Text += " Addition"; break; case '-': this.Text += " Subtraction"; break; case '*': this.Text += " Multiplication"; break; case '=': this.Text += " Finding Roots"; break; case '/': this.Text += " Division"; break; case '%': this.Text += " Modulus"; break; case 'g': this.Text += " GCD"; break; case 's': this.Text += " Substitution"; break; case 'd': this.Text += " Definite Integral"; break; case '^': this.Text = " Derivative"; break; } }