public void UpdateCutRoll(CutRoll cutRoll) { using (var connection = this.GetOpenConnection()) { connection.Update(cutRoll); } }
public void AddCutRoll(CutRoll cutRoll) { using (var connection = this.GetOpenConnection()) { connection.Insert(cutRoll); } }
/// <summary> /// Make a best effort to assign a SAP roll number to the cut roll /// and update the database. /// </summary> /// <param name="cutRoll">The </param> /// <returns></returns> public void AssignSapRollTo(CutRoll cutRoll) { if (this.cutRoll != null) { // No SAP roll number was assigned // The next roll needs it, so we just have update without a SAP roll number this.dbLocal.UpdateCutRoll(this.cutRoll); } // Make the new roll available to be assigned a SAP rull number this.cutRoll = cutRoll; }
public void FirstRollWrittenWithoutChangeIfSecondRollIsPresentedBeforeNewSapRollAvailable() { CutRoll cutRoll1 = new CutRoll(); CutRoll cutRoll2 = new CutRoll(); this.target.AssignSapRollTo(cutRoll1); this.scheduler.AdvanceBy(this.target.TryInterval.Ticks); this.target.AssignSapRollTo(cutRoll2); this.dbMfg.GetCutRollFromHostAsync().Returns(Task.FromResult <decimal?>(2)); this.scheduler.AdvanceBy(this.target.TryInterval.Ticks); Assert.Equal(string.Empty, cutRoll1.SapRoll); Assert.Equal("2", cutRoll2.SapRoll); this.dbLocal.Received(1).UpdateCutRoll(cutRoll2); this.dbLocal.Received(1).UpdateCutRoll(cutRoll1); }
public void NoRollAssignedUntilSapRollChanges() { CutRoll cutRoll = new CutRoll(); this.target.AssignSapRollTo(cutRoll); Assert.Equal(string.Empty, cutRoll.SapRoll); this.scheduler.AdvanceBy(this.target.TryInterval.Ticks); Assert.Equal(string.Empty, cutRoll.SapRoll); this.dbLocal.DidNotReceiveWithAnyArgs().UpdateCutRoll(Arg.Any <CutRoll>()); this.dbMfg.GetCutRollFromHostAsync().Returns(Task.FromResult <decimal?>(2)); this.scheduler.AdvanceBy(this.target.TryInterval.Ticks); Assert.Equal("2", cutRoll.SapRoll); this.dbLocal.Received(1).UpdateCutRoll(cutRoll); }
private async Task AssignSapRollAsync() { if (!this.busy) { this.busy = true; decimal?sapRoll = await this.dbMfg.GetCutRollFromHostAsync(); if (sapRoll != null && sapRoll.Value != this.priorSapRoll) { this.priorSapRoll = sapRoll.Value; this.cutRoll.SapRoll = sapRoll.Value.ToString(CultureInfo.InvariantCulture); this.dbLocal.UpdateCutRoll(this.cutRoll); this.cutRoll = null; } this.busy = false; } }