public static bool WithCourseError(this DataLock dataLockStatus) { return(dataLockStatus.ErrorCode.HasFlag(DataLockErrorCode.Dlock03) || dataLockStatus.ErrorCode.HasFlag(DataLockErrorCode.Dlock04) || dataLockStatus.ErrorCode.HasFlag(DataLockErrorCode.Dlock05) || dataLockStatus.ErrorCode.HasFlag(DataLockErrorCode.Dlock06)); }
public IEnumerable<Command> Process(DataLock dataLock, IEnumerable<Notification> notifications) { List<Command> commands = new List<Command>(); commands.AddRange(dataLock.AiRead<List<Command>>(ProcessFleets)); DebugConsole.WriteLine("IA calculations done for " + _realm); return commands; }
public static void SaveDataLock(Apprenticeship apprenticeship, DataLock datalock) { var connection = GetConnection(); var query = "insert into DataLockStatus (DataLockEventId, DataLockEventDatetime, PriceEpisodeIdentifier," + "ApprenticeshipId, IlrTrainingCourseCode, IlrTrainingType, IlrActualStartDate, IlrEffectiveFromDate, " + "IlrTotalCost, ErrorCode, Status, TriageStatus, IsResolved, EventStatus) " + "VALUES (@DataLockEventId, @DataLockEventDatetime, @PriceEpisodeIdentifier," + "@ApprenticeshipId, @IlrTrainingCourseCode, @IlType, @IlrActualStartDate, @IlrEffectiveFromDate," + "@IlrTotalCost, @ErrorCode, @Status, @TriageStatus, @IsResolved, @EventStatus)"; var result = connection.Execute(query, new { DataLockEventId = IdentityHelpers.GetNextDataLockStatusId(), DataLockEventDatetime = DateTime.Now, PriceEpisodeIdentifier = datalock.PriceEpisodeIdentifier, ApprenticeshipId = apprenticeship.Id, IlrTrainingCourseCode = datalock.IlrTrainingCourseCode, IlType = datalock.IlrTrainingType, IlrActualStartDate = apprenticeship.StartDate.Value, IlrEffectiveFromDate = datalock.IlrEffectiveFromDate, IlrTotalCost = datalock.IlrTotalCost, ErrorCode = datalock.ErrorCode, Status = datalock.Status, TriageStatus = 0, IsResolved = false, EventStatus = 1 }); }
public static void DayUpdate(this IEnumerable <IDailyUpdatableItem> items, DataLock dataLock) { foreach (IDailyUpdatableItem item in items) { dataLock.Write(item.DayUpdate); } }
public IEnumerable <Command> Process(DataLock dataLock, IEnumerable <Notification> notifications) { List <Command> commands = new List <Command>(); commands.AddRange(dataLock.AiRead <List <Command> >(ProcessFleets)); DebugConsole.WriteLine("IA calculations done for " + _realm); return(commands); }
public void DayUpdate(DataLock dataLock) { dataLock.Write(() => { _tags.OfType <IDailyUpdatableItem>().DayUpdate(); _tags.RemoveWhere(t => !t.IsValid()); }); }
public static bool HasCourseDataLock(this DataLock dataLock) { var result = dataLock.ErrorCode.HasFlag(DataLockErrorCode.Dlock03) || dataLock.ErrorCode.HasFlag(DataLockErrorCode.Dlock04) || dataLock.ErrorCode.HasFlag(DataLockErrorCode.Dlock05) || dataLock.ErrorCode.HasFlag(DataLockErrorCode.Dlock06); return(result); }
public void StartRenderLoop(DataLock dataLock) { Initialize(dataLock); RenderLoop.Run(_form, () => { dataLock.UiRead(()=> Update(_timer.Tick())); Draw(); }); _game.Exit(); }
public void StartRenderLoop(DataLock dataLock) { Initialize(dataLock); RenderLoop.Run(_form, () => { dataLock.UiRead(() => Update(_timer.Tick())); Draw(); }); _game.Exit(); }
internal override void DayUpdate(DataLock dataLock) { dataLock.Write(() => { CurrentDate = NextDay(CurrentDate); CurrentSeason = Season.CurrentSeason(_seasons, this); CurrentSeasonLength++; }); Tags.DayUpdate(dataLock); TryTriggerEvents(_events, this.Yield(), dataLock); }
public PauseDateDataLockRowModel( CollectionPeriod period, DataLock dataLock, string heading) { Heading = heading; IsLocked = period.DataLocks.Contains(dataLock); ActiveDataLock = IsLocked ? dataLock.ToString() : "-"; PausedOnDate = period.Apprenticeship?.PausedOn?.ToShortDateString(); ResumedOnDate = period.Apprenticeship?.ResumedOn?.ToShortDateString() ?? "Present"; }
private void Initialize(DataLock dataLock) { CreateWindow(); _directX = new Dx11(_form); _uiManager = new UiManager(); _input = new Input.Input(); _camera = new Camera(new Vector3(0, 200, 0), new Vector3(0, 0.7f, 0)); _context = new Context(_form, _directX, _game, _worldContainer, _uiManager, _input, _camera, _notificationResolver, dataLock); _camera.Initialize(_context); _input.Initialize(_context); _uiManager.Initialize(_context); _uiManager.AddScreen(new WorldParametersScreen(_context)); }
internal World(List<Notification> dailyNotifications, List<Notification> liveNotifications, DataLock dataLock) { _dailyNotifications = dailyNotifications; _liveNotifications = liveNotifications; _datalock = dataLock; EventManager = new EventManager(this); RealmManager = new RealmManager(this); FleetManager = new FleetManager(this); ProvinceManager = new ProvinceManager(this); CharacterManager = new CharacterManager(this); Calendar = new Calendars.Calendar(this); Managers = new List<Manager> { Calendar, FleetManager, RealmManager, ProvinceManager, CharacterManager }; Managers.ForEach(m=>m.Initialize()); }
public void HasCourseDataLock_Returns_Correct_Value(DataLockErrorCode errorCode, bool expectedResult) { //Arrange _dataLock = new DataLock() { ErrorCode = errorCode }; //Act var actualResult = _dataLock.WithCourseError(); //Assert Assert.AreEqual(expectedResult, actualResult); }
public DataLockRowModel( CollectionPeriod period, DataLock dataLock, string heading, Func <DataMatch, object?> valueExtractor) { Heading = heading; this.period = period ?? throw new ArgumentNullException(nameof(period)); this.valueExtractor = valueExtractor ?? throw new ArgumentNullException(nameof(valueExtractor)); IsLocked = this.period.DataLocks.Contains(dataLock); ActiveDataLock = IsLocked ? dataLock.ToString() : "-"; }
public void Run() { Thread.CurrentThread.Name = "Main thread"; //Create ReadWrite lock for world data access DataLock dataLock = new DataLock(); //Create UI Thread Thread uiThread = new Thread(() => _ui.StartRenderLoop(dataLock)); uiThread.SetApartmentState(ApartmentState.STA); uiThread.Name = "UiThread"; uiThread.Start(); //Wait for the user to press on "Generate World" bool ready; do { ready = GenerateWorldEvent.WaitOne(50); } while (_continue && !ready); if (!_continue) { return; } //Generate the world DebugConsole.WriteLine("Generation begin"); _world = (World)((IWorldGenerator)(new WorldGenerator(_dailyNotifications, _liveNotifications, dataLock))) .Generate(s => _loadingMessage = s); DebugConsole.WriteLine("Generation is done"); _world.SetNewRealmHandler(NewRealm); //Choose one of the realms as the UI realm _worldContainer.PlayerRealm = _tokens.First(); _ais.Remove(_ais.Single(ai => ai.Realm == _tokens.First().Realm)); _world.RegisterInteractiveRealm(_tokens.First()); _worldContainer.World = _world; _isWorldGenerationDone = true; _dayTimer.Start(); while (_continue) { _dailyNotifications.Clear(); ((IProcessableWorld)_world).Process(); Parallel.ForEach(_ais, new ParallelOptions { MaxDegreeOfParallelism = 4 }, ai => _world.RegisterCommands(ai.RealmToken, ai.Process(dataLock, _dailyNotifications))); DebugConsole.WriteLine("Computations done"); _dayTimer.WaitForNextDay(_continue); DebugConsole.WriteLine("Day end"); } }
public Context(RenderForm form, Dx11 directX, IGame game, WorldContainer worldContainer, IUiManager uiManager, IInput input, Camera camera, NotificationResolver notificationResolver, DataLock datalock) { _worldContainer = worldContainer; NotificationResolver = notificationResolver; Form = form; DirectX = directX; Game = game; TextureManager = new TextureManager(DirectX.Device); TextManager = new TextManager(this); Shaders = new ShaderManager(DirectX.Device); Camera = camera; UiManager = uiManager; Input = input; DataLock = datalock; }
internal World(List <Notification> dailyNotifications, List <Notification> liveNotifications, DataLock dataLock) { _dailyNotifications = dailyNotifications; _liveNotifications = liveNotifications; _datalock = dataLock; EventManager = new EventManager(this); RealmManager = new RealmManager(this); FleetManager = new FleetManager(this); ProvinceManager = new ProvinceManager(this); CharacterManager = new CharacterManager(this); Calendar = new Calendars.Calendar(this); Managers = new List <Manager> { Calendar, FleetManager, RealmManager, ProvinceManager, CharacterManager }; Managers.ForEach(m => m.Initialize()); }
private static DataLockViewModel MapDataLockStatus(DataLock dataLock, TrainingProgramme training) { return(new DataLockViewModel { DataLockEventDatetime = dataLock.DataLockEventDatetime, PriceEpisodeIdentifier = dataLock.PriceEpisodeIdentifier, ApprenticeshipId = dataLock.ApprenticeshipId, IlrTrainingCourseCode = dataLock.IlrTrainingCourseCode, IlrTrainingCourseName = training.Name, IlrActualStartDate = dataLock.IlrActualStartDate, IlrEffectiveFromDate = dataLock.IlrEffectiveFromDate, IlrPriceEffectiveToDate = dataLock.IlrPriceEffectiveToDate, IlrTotalCost = dataLock.IlrTotalCost, DataLockErrorCode = dataLock.ErrorCode }); }
private void AddRemove() { DataLock.WaitOne(); foreach (InstanceData t in Additions) { Data.Add(t); } foreach (InstanceData t in Removals) { Data.Remove(t); } Additions.Clear(); Removals.Clear(); DataLock.ReleaseMutex(); }
public void Run() { Thread.CurrentThread.Name = "Main thread"; //Create ReadWrite lock for world data access DataLock dataLock = new DataLock(); //Create UI Thread Thread uiThread = new Thread(()=>_ui.StartRenderLoop(dataLock)); uiThread.SetApartmentState(ApartmentState.STA); uiThread.Name = "UiThread"; uiThread.Start(); //Wait for the user to press on "Generate World" bool ready; do { ready = GenerateWorldEvent.WaitOne(50); } while (_continue && ! ready); if(!_continue) return; //Generate the world DebugConsole.WriteLine("Generation begin"); _world = (World)((IWorldGenerator)(new WorldGenerator(_dailyNotifications, _liveNotifications, dataLock))) .Generate(s => _loadingMessage = s); DebugConsole.WriteLine("Generation is done"); _world.SetNewRealmHandler(NewRealm); //Choose one of the realms as the UI realm _worldContainer.PlayerRealm = _tokens.First(); _ais.Remove(_ais.Single(ai => ai.Realm == _tokens.First().Realm)); _world.RegisterInteractiveRealm(_tokens.First()); _worldContainer.World = _world; _isWorldGenerationDone = true; _dayTimer.Start(); while (_continue) { _dailyNotifications.Clear(); ((IProcessableWorld)_world).Process(); Parallel.ForEach(_ais, new ParallelOptions { MaxDegreeOfParallelism = 4 }, ai => _world.RegisterCommands(ai.RealmToken, ai.Process(dataLock, _dailyNotifications))); DebugConsole.WriteLine("Computations done"); _dayTimer.WaitForNextDay(_continue); DebugConsole.WriteLine("Day end"); } }
internal override void DayUpdate(DataLock dataLock) { _realms.DayUpdate(dataLock); }
internal override void DayUpdate(DataLock dataLock) { }
public async Task GenerateReport() { DateTime dateTime = DateTime.UtcNow; int ukPrn = 10036143; string filename = $"R01_10036143_10036143 Learner Level View Report {dateTime:yyyyMMdd-HHmmss}"; int academicYear = 2021; Mock <IReportServiceContext> reportServiceContextMock = new Mock <IReportServiceContext>(); reportServiceContextMock.SetupGet(x => x.JobId).Returns(1); reportServiceContextMock.SetupGet(x => x.SubmissionDateTimeUtc).Returns(DateTime.UtcNow); reportServiceContextMock.SetupGet(x => x.Ukprn).Returns(10036143); reportServiceContextMock.SetupGet(x => x.ReturnPeriod).Returns(1); reportServiceContextMock.SetupGet(x => x.ReturnPeriodName).Returns("R01"); Mock <ILogger> loggerMock = new Mock <ILogger>(); Mock <ICsvFileService> csvFileServiceMock = new Mock <ICsvFileService>(); Mock <IFileNameService> fileNameServiceMock = new Mock <IFileNameService>(); Mock <IUYPSummaryViewDataProvider> uypSummaryViewDataProviderMock = new Mock <IUYPSummaryViewDataProvider>(); Mock <IUYPSummaryViewModelBuilder> uypSummaryViewModelBuilderMock = new Mock <IUYPSummaryViewModelBuilder>(); Mock <IJsonSerializationService> jsonSerializationServiceMock = new Mock <IJsonSerializationService>(); IJsonSerializationService jsonSerializationService = new JsonSerializationService(); Mock <IFileService> fileServiceMock = new Mock <IFileService>(); Mock <IReportDataPersistanceService <LearnerLevelViewReport> > reportDataPersistanceServiceMock = new Mock <IReportDataPersistanceService <LearnerLevelViewReport> >(); Mock <IUYPSummaryViewPersistenceMapper> uypSummaryViewPersistenceMapper = new Mock <IUYPSummaryViewPersistenceMapper>(); var summaryReportDataPersistanceServiceMock = new Mock <IReportDataPersistanceService <UYPSummaryViewReport> >(); var zipServiceMock = new Mock <IReportZipService>(); uypSummaryViewPersistenceMapper.Setup(x => x.Map( It.IsAny <IReportServiceContext>(), It.IsAny <IEnumerable <LearnerLevelViewModel> >(), It.IsAny <CancellationToken>())).Returns(new List <LearnerLevelViewReport>()); uypSummaryViewPersistenceMapper.Setup(x => x.Map( It.IsAny <IReportServiceContext>(), It.IsAny <IEnumerable <LearnerLevelViewSummaryModel> >())).Returns(new List <UYPSummaryViewReport>()); reportDataPersistanceServiceMock.Setup(x => x.PersistAsync( It.IsAny <IReportServiceContext>(), It.IsAny <IEnumerable <LearnerLevelViewReport> >(), It.IsAny <CancellationToken>())); summaryReportDataPersistanceServiceMock.Setup(x => x.PersistAsync( It.IsAny <IReportServiceContext>(), It.IsAny <IEnumerable <UYPSummaryViewReport> >(), It.IsAny <CancellationToken>())); jsonSerializationServiceMock.Setup(x => x.Serialize <IEnumerable <LearnerLevelViewSummaryModel> >( It.IsAny <IEnumerable <LearnerLevelViewSummaryModel> >())).Returns(string.Empty); // We need three streams FileStream[] fs = new FileStream[3] { new FileStream("1.json", FileMode.Create), new FileStream("2.csv", FileMode.Create), new FileStream("3.csv", FileMode.Create) }; var index = 0; fileServiceMock.Setup(x => x.OpenWriteStreamAsync( It.IsAny <string>(), It.IsAny <string>(), It.IsAny <CancellationToken>())).ReturnsAsync(() => fs[index++]); // Return filenames fileNameServiceMock.Setup(x => x.GetFilename(It.IsAny <IReportServiceContext>(), It.IsAny <string>(), It.IsAny <OutputTypes>(), It.IsAny <bool>(), It.IsAny <bool>())).Returns(filename); // Setup data return objects ICollection <CoInvestmentInfo> coInvestmentInfo = new CoInvestmentInfo[1] { BuildILRCoInvestModel(ukPrn) }; uypSummaryViewDataProviderMock.Setup(x => x.GetCoinvestmentsAsync(It.IsAny <int>(), It.IsAny <CancellationToken>())).ReturnsAsync(coInvestmentInfo); ICollection <Payment> payments = BuildDasPaymentsModel(ukPrn, academicYear); uypSummaryViewDataProviderMock.Setup(x => x.GetDASPaymentsAsync(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <CancellationToken>())).ReturnsAsync(payments); ICollection <DataLock> dataLocks = new DataLock[1] { new DataLock() { DataLockFailureId = 1, CollectionPeriod = 1, LearnerReferenceNumber = "A12345" } }; uypSummaryViewDataProviderMock.Setup(x => x.GetDASDataLockAsync(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <CancellationToken>())).ReturnsAsync(dataLocks); ICollection <HBCPInfo> hbcpInfo = new HBCPInfo[1] { new HBCPInfo() { LearnerReferenceNumber = "A12345", CollectionPeriod = 1, NonPaymentReason = 1 } }; uypSummaryViewDataProviderMock.Setup(x => x.GetHBCPInfoAsync(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <CancellationToken>())).ReturnsAsync(hbcpInfo); ICollection <Learner> learners = BuildILRModel(ukPrn); uypSummaryViewDataProviderMock.Setup(x => x.GetILRLearnerInfoAsync(It.IsAny <int>(), It.IsAny <CancellationToken>())).ReturnsAsync(learners); ICollection <LearningDeliveryEarning> ldEarnings = BuildLDEarningsModel(ukPrn); uypSummaryViewDataProviderMock.Setup(x => x.GetLearnerDeliveryEarningsAsync(It.IsAny <int>(), It.IsAny <CancellationToken>())).ReturnsAsync(ldEarnings); IDictionary <long, string> legalEntityNames = BuildLegalEntityNames(); uypSummaryViewDataProviderMock.Setup(x => x.GetLegalEntityNameAsync(It.IsAny <int>(), It.IsAny <IEnumerable <long> >(), It.IsAny <CancellationToken>())).ReturnsAsync(legalEntityNames); ICollection <PriceEpisodeEarning> peEarnings = BuildPEEarningsModel(ukPrn); uypSummaryViewDataProviderMock.Setup(x => x.GetPriceEpisodeEarningsAsync(It.IsAny <int>(), It.IsAny <CancellationToken>())).ReturnsAsync(peEarnings); ICollection <LearnerLevelViewModel> results = new LearnerLevelViewModel[1] { new LearnerLevelViewModel() { Ukprn = ukPrn, PaymentLearnerReferenceNumber = "A12345", PaymentUniqueLearnerNumbers = "12345", FamilyName = "Banner", GivenNames = "Bruce", LearnerEmploymentStatusEmployerId = 1, EmployerName = "Employer Name", TotalEarningsToDate = 1m, PlannedPaymentsToYouToDate = 2m, TotalCoInvestmentCollectedToDate = 3m, CoInvestmentOutstandingFromEmplToDate = 4m, TotalEarningsForPeriod = 5m, ESFAPlannedPaymentsThisPeriod = 6m, CoInvestmentPaymentsToCollectThisPeriod = 7m, IssuesAmount = 8m, ReasonForIssues = "Borked", PaymentFundingLineType = "12345", RuleDescription = "Rule X" } }; uypSummaryViewModelBuilderMock.Setup(x => x.Build( It.IsAny <ICollection <Payment> >(), It.IsAny <ICollection <Learner> >(), It.IsAny <ICollection <LearningDeliveryEarning> >(), It.IsAny <ICollection <PriceEpisodeEarning> >(), It.IsAny <ICollection <CoInvestmentInfo> >(), It.IsAny <ICollection <DataLock> >(), It.IsAny <ICollection <HBCPInfo> >(), It.IsAny <IDictionary <long, string> >(), It.IsAny <int>(), It.IsAny <int>())).Returns(results); // Create and invoke the view Reports.UYPSummaryView.UYPSummaryView report = new Reports.UYPSummaryView.UYPSummaryView( csvFileServiceMock.Object, fileNameServiceMock.Object, uypSummaryViewDataProviderMock.Object, uypSummaryViewModelBuilderMock.Object, jsonSerializationService, fileServiceMock.Object, zipServiceMock.Object, reportDataPersistanceServiceMock.Object, summaryReportDataPersistanceServiceMock.Object, uypSummaryViewPersistenceMapper.Object, loggerMock.Object); await report.GenerateReport(reportServiceContextMock.Object, CancellationToken.None); List <LearnerLevelViewSummaryModel> result; using (var reader = new StreamReader(fs[0].Name)) { string fileData = reader.ReadToEnd(); result = jsonSerializationService.Deserialize <IEnumerable <LearnerLevelViewSummaryModel> >(fileData).ToList(); } result.Should().NotBeNullOrEmpty(); result.Count().Should().Be(1); result[0].CoInvestmentPaymentsToCollectForThisPeriod.Should().Be(7); result[0].ESFAPlannedPaymentsForThisPeriod.Should().Be(6); result[0].NumberofLearners.Should().Be(1); result[0].TotalCoInvestmentCollectedToDate.Should().Be(3); result[0].NumberofClawbacks.Should().Be(0); }
internal override void DayUpdate(DataLock dataLock) { TryTriggerEvents(_events, LivingCharacters, dataLock); }
internal override void DayUpdate(DataLock dataLock) { Provinces.DayUpdate(dataLock); TryTriggerEvents(_buildingsEvents, LandProvinces.SelectMany(p=>p.Capital.Buildings), dataLock); }
public static bool IsCourseAndPrice(this DataLock dataLock) { return(dataLock.HasCourseDataLock() && dataLock.HasPrice()); }
public static bool IsCourseOrPrice(this DataLock dataLock) { return(dataLock.IsCourse() || dataLock.IsPrice()); }
public void Arrange() { _dataLock = new DataLock(); }
//BEGIN Update public void Update(NameValueCollection clientData = null) { IsModeList = false; IsModeAdd = false; IsModeUpdate = true; IsModeDelete = false; if (clientData != null) { ClientData = clientData; } if (ClientData == null) { IsError = true; IdError = "Data.Update.E.100"; ErrorInfo = IdError; } else { if (ClientData["IsProcess"] == "y") { IsProcess = true; } Id = ClientData["IdData"]; } //BEGIN Check if (!IsError) { bool isError = true; int atNum = 3; //Проверить доступ на чтение if (IsProcess) { atNum = 4; } //Если процесс, то проверить доступ на обновление int q1 = db.NewQuery(); db.Query[q1].AddParameter(DatabaseParameterType.Number, "@p_iddata", Id); db.Query[q1].AddParameter(DatabaseParameterType.Number, "@p_iduser", IdUser); db.Query[q1].AddParameter(DatabaseParameterType.Number, "@p_access", atNum); db.Query[q1].CmdType = DatabaseCommandType.Procedure; db.Query[q1].Open("dbo.pr_data_check"); if (!db.Query[q1].IsError) { if (db.Query[q1].RowAmount == 1) { string f_iserror = db.Query[q1].Table.Rows[0]["f_iserror"].ToString(); string f_idtype = db.Query[q1].Table.Rows[0]["f_idtype"].ToString(); string f_typename = db.Query[q1].Table.Rows[0]["f_typename"].ToString(); string f_typeview = db.Query[q1].Table.Rows[0]["f_typeview"].ToString(); if (f_iserror == "n") { isError = false; IdType = f_idtype; TypeName = f_typename; if (!string.IsNullOrWhiteSpace(f_typeview)) { IsView = true; View = f_typeview; } } } } if (isError) { IsError = true; IdError = "Data.Update.E.200"; ErrorInfo = IdError; } } //END Check //BEGIN ColList if (!IsError) { GetColList(); if (ColList.Count < 1) { IsError = true; IdError = "Data.Update.E.300"; ErrorInfo = IdError; } } //END ColList //BEGIN IsProcess if (IsProcess) { if (!IsError) { bool isLock = false; //Для блокировки записи по Id //BEGIN try try { //BEGIN Пытаемся заблокировать запись if (!DataLock.Add(Id)) { IsError = true; IdError = "Data.Update.E.500"; ErrorInfo = IdError; } else { isLock = true; } //END Пытаемся заблокировать запись //BEGIN Data Lock if (!IsError) { if (!GetCurrentData()) { IsError = true; IdError = "Data.Update.E.600"; ErrorInfo = IdError; } else { if (!CheckView(CurrentData)) { IsError = true; IdError = "Data.Update.E.650"; ErrorInfo = IdError; } } //BEGIN Preparing to update data if (!IsError) { SetEditData(); if (!CheckEditData()) { IsError = true; IdError = "Data.Update.E.700"; ErrorInfo = IdError; } //BEGIN Check Step else { if (!CheckStep()) { IsError = true; IdError = "Data.Update.E.800"; ErrorInfo = IdError; } } //END Check Step } //END Preparing to update data //BEGIN Update Data if (!IsError) { ................................ } //END Update Data } //END Data Lock }
public void Remove(InstanceData data) { DataLock.WaitOne(); Removals.Add(data); DataLock.ReleaseMutex(); }
public WorldGenerator(List <Notification> dailyNotifications, List <Notification> liveNotifications, DataLock dataLock) { _dailyNotifications = dailyNotifications; _liveNotifications = liveNotifications; _dataLock = dataLock; }
internal override void DayUpdate(DataLock dataLock) { TryTriggerEvents(_events, _fleets, dataLock); _fleets.ForEach(fleet => dataLock.Write(() => (fleet as IDailyUpdatableItem).DayUpdate())); }
public void Add(InstanceData data) { DataLock.WaitOne(); Additions.Add(data); DataLock.ReleaseMutex(); }
internal override void DayUpdate(DataLock dataLock) { Provinces.DayUpdate(dataLock); TryTriggerEvents(_buildingsEvents, LandProvinces.SelectMany(p => p.Capital.Buildings), dataLock); }
public static void DayUpdate(this IEnumerable<IDailyUpdatableItem> items, DataLock dataLock) { foreach (IDailyUpdatableItem item in items) dataLock.Write(item.DayUpdate); }