public void Serialize() { //CSharpCodeProvider.cre CSharpCodeProvider prov = new CSharpCodeProvider(new Dictionary <string, string>() { { "CompilerVersion", "v4.0" } }); CompilerParameters cp = new CompilerParameters(new [] { "mscorlib.dll", "System.dll", "System.IO.dll", "System.xml.dll", "System.Xml.Serializer.dll", "System.Runtime.dll", "System.ObjectModel.dll", "System.Collections.dll", "FileExplorer3.dll", "FileExplorer3.IO.dll", "FileExplorer3.WPF.dll", "Caliburn.Micro.dll", "Caliburn.Micro.Platform.dll" }); cp.GenerateExecutable = false; cp.GenerateInMemory = true; Progress.Clear(); CompilerResults cr = prov.CompileAssemblyFromSource(cp, Script); if (cr.Errors.HasErrors) { Progress.Add("Error when serializing:"); cr.Errors.Cast <CompilerError>().ToList().ForEach(err => Progress.Add(String.Format("{0} at line {1} column {2} ", err.ErrorText, err.Line, err.Column))); } }
/// <summary> /// Updates the engine's progress /// </summary> /// <param name="deltaTime"></param> public void Update(double deltaTime) { if (!Initialized) { return; } var keyframes = LayerProperty.UntypedKeyframes.ToList(); Progress = Progress.Add(TimeSpan.FromMilliseconds(deltaTime)); // The current keyframe is the last keyframe before the current time CurrentKeyframe = keyframes.LastOrDefault(k => k.Position <= Progress); // The next keyframe is the first keyframe that's after the current time NextKeyframe = keyframes.FirstOrDefault(k => k.Position > Progress); if (CurrentKeyframe == null) { KeyframeProgress = 0; KeyframeProgressEased = 0; } else if (NextKeyframe == null) { KeyframeProgress = 1; KeyframeProgressEased = 1; } else { var timeDiff = NextKeyframe.Position - CurrentKeyframe.Position; KeyframeProgress = (float)((Progress - CurrentKeyframe.Position).TotalMilliseconds / timeDiff.TotalMilliseconds); KeyframeProgressEased = (float)Easings.Interpolate(KeyframeProgress, CurrentKeyframe.EasingFunction); } // LayerProperty determines what's next: reset, stop, continue }
public void Update(IEnumerable <LevelProgressDto> collection) { Progress.Clear(); foreach (var model in collection) { Progress.Add(model); } }
public void WriteProgress(long sourceId, ProgressRecord progressRecord) { CheckForCancellation(); if (Progress.IsOpen && Progress.Count < MaxRecords) { Progress.Add(progressRecord); } }
/// <summary> /// Updates the progress for this task, a notification is sent to the client /// </summary> /// <param name="value">The value to add to the progress</param> /// <example> /// If the player were to obtain a certain amount of collectibles, <c>value</c> might be the item lot here. /// </example> protected void AddProgress(float value) { if (this.Mission.Player.TryGetComponent <MissionInventoryComponent>(out var missionInventoryComponent) && !MissionParser.CheckPrerequiredMissions(this.Mission.PrerequisiteMissions, missionInventoryComponent.AllMissions)) { return; } Progress.Add(value); MessageUpdateMissionTask(); }
private void LoadData() { foreach (string file in _files) { if (!File.Exists(file)) { continue; } DataGetter data = new DataGetter(file); Type t = data.GetTypeFromData(); if (t == typeof(CaseProgress)) { Progress.Add(file, (CaseProgress)data.ConvertToObject()); } if (t == typeof(CSIData)) { CSIData.Add(file, (CSIData)data.ConvertToObject()); } if (t == typeof(CurrentCaseData)) { CurrentData.Add(file, (CurrentCaseData)data.ConvertToObject()); } if (t == typeof(EntityData)) { EntityData.Add(file, (EntityData)data.ConvertToObject()); } if (t == typeof(EvidenceData)) { EvidenceData.Add(file, (EvidenceData)data.ConvertToObject()); } if (t == typeof(InterrogationData)) { InterrogationData.Add(file, (InterrogationData)data.ConvertToObject()); } if (t == typeof(SceneData)) { SceneData.Add(file, (SceneData)data.ConvertToObject()); } if (t == typeof(StageData)) { StageData.Add(file, (StageData)data.ConvertToObject()); } if (t == typeof(WrittenData)) { WrittenData.Add(file, (WrittenData)data.ConvertToObject()); } } }
Tuple <double[][], double[][]> PlayTrainingGame(ActivationNetwork net, bool aiX, bool fullAi) { TicTacToeGame game = new TicTacToeGame(); List <double[]> inputs = new List <double[]>(); List <double[]> outputs = new List <double[]>(); Model current = new Model(net); while (game.GetResult() == TicTacToeGame.Result.Unknown) { int playSquare; if (aiX == game.IsXTurn || fullAi) { playSquare = current.BestSquare(game); } else { int[] validSquares = game.ValidSquares().ToArray(); playSquare = validSquares[rand.Next(validSquares.Length)]; } game.Move(playSquare); inputs.Add(game.GetBoardAsDouble(!game.IsXTurn)); } double output; TicTacToeGame.Result result = game.GetResult(); if (result == TicTacToeGame.Result.XWins) { output = 1; } else if (result == TicTacToeGame.Result.OWins) { output = -1; } else { output = 0; } for (int i = 0; i < inputs.Count; i++) { outputs.Add(new double[] { output *(i % 2 == 0 ? 1 : -1) }); } Progress.Add(fullAi ? result == TicTacToeGame.Result.Tie : (aiX ? result == TicTacToeGame.Result.XWins : result == TicTacToeGame.Result.OWins)); return(new Tuple <double[][], double[][]>(inputs.ToArray(), outputs.ToArray())); }
private void TrackProgressExecute(object obj) { var progressModel = new ProgressModel { GoalId = SelectedGoal.GoalId, Date = DateTime.Now }; var newProgessViewModel = new AddProgressViewModel(progressModel, _client); var dialog = new TrackProgress(); dialog.DataContext = newProgessViewModel; var result = dialog.ShowDialog(); if (result.GetValueOrDefault()) { Progress.Add(new ProgressViewModel(SelectedGoal, newProgessViewModel.Progress)); } }
public void Set(int level, LevelProgressDto progress) { var current = Get(level); if (current != null) { if (current.Stars < progress.Stars) { current.Stars = progress.Stars; current.Seconds = progress.Seconds; current.ObjectsCollected = progress.ObjectsCollected; } } else { Progress.Add(progress); } }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadEncodedInt(); var count = reader.ReadInt(); for (int i = 0; i < count; i++) { Path.Add(reader.ReadInt()); } count = reader.ReadInt(); for (int i = 0; i < count; i++) { Progress.Add(reader.ReadInt()); } }
protected void btnSave_Click(object sender, System.EventArgs e) { string text = this.txtProgressName.Text.Trim(); string note = this.txtArea.Text.Trim(); string versionCode = this.txtVersionCode.Text.Trim(); bool @checked = this.chkIsMainPlan.Checked; if (this.action == "add") { Progress progress = Progress.Creat(System.Guid.NewGuid().ToString(), new System.Guid(this.prjId), text, versionCode, @checked, base.UserCode, System.DateTime.Now, note); progress.Add(progress); } else { if (this.action == "edit") { Progress.Update(this.planId, text, versionCode, @checked, note); } } base.RegisterScript("top.ui.winSuccess({ parentName: '_editplan' }); "); }
protected virtual void OnProgress(ProgressRecord progress) { Progress.Add(progress); }
public static async Task Move(Config config, TraceWriter log) { var metadata = await Timer.Time(() => MetadataReader.GetMetadata(config.ConnectionString, config.Period), "Fetching metadata", log); // Ignore duplicates until further var imsTagToId = metadata.ims.GroupBy(x => x.Tag).Where(x => x.Count() == 1).Select(x => x.First()).ToDictionary(x => x.Tag, x => x.Id); var calcTagToId = metadata.calc.Where(x => !string.IsNullOrWhiteSpace(x.Tag)).GroupBy(x => x.Tag).Where(x => x.Count() == 1).Select(x => x.First()).ToDictionary(x => x.Tag, x => x.Id); var imsMetas = metadata.ims.Where(i => imsTagToId.ContainsKey(i.Tag)).ToList(); var calcMetas = metadata.calc.Where(i => !string.IsNullOrWhiteSpace(i.Tag) && calcTagToId.ContainsKey(i.Tag)).ToList(); log.Info($"IMS Initial Tag Count: {imsMetas.Count}, Ignored: {metadata.ims.Count - imsMetas.Count}"); log.Info($"Calc Initial Tag Count: {calcMetas.Count}, Ignored: {metadata.calc.Count - calcMetas.Count}"); var influxQueryExecutor = new InfluxQueryExecutor(config.InfluxConfig); var imsEntityCreator = new EntityCreator(imsTagToId); var calcEntityCreator = new EntityCreator(calcTagToId); var imsFirstTimerMetas = imsMetas.Where(m => !m.Timestamp.HasValue).ToList(); var imsOldTimerMetas = imsMetas.Where(m => m.Timestamp.HasValue).ToList(); var calcFirstTimerMetas = calcMetas.Where(m => !m.Timestamp.HasValue).ToList(); var calcOldTimerMetas = calcMetas.Where(m => m.Timestamp.HasValue).ToList(); var imsTagsWithTimestampBeforeWatermarkTask = Timer.Time(() => GetOutliers(influxQueryExecutor, imsMetas, config.InfluxConfig.DbImsRetentionPolicy, config.InfluxConfig.DbImsMeasurement, TagTypes.Ims, config.InfluxConfig.DefaultTime, config.InfluxConfig.DoAdHocResampling, log, true), "Getting timestamp before watermark IMS tags", log); var calcTagsWithTimestampBeforeWatermarkTask = Timer.Time(() => GetOutliers(influxQueryExecutor, calcMetas, config.InfluxConfig.DbCalcRetentionPolicy, config.InfluxConfig.DbCalcMeasurement, TagTypes.Calc, config.InfluxConfig.DefaultTime, config.InfluxConfig.DoAdHocResampling, log, true), "Getting timestamp before watermark for Calc tags", log); var imsTagsWithLastTimestampTask = Timer.Time(() => GetOutliers(influxQueryExecutor, imsMetas, config.InfluxConfig.DbImsRetentionPolicy, config.InfluxConfig.DbImsMeasurement, TagTypes.Ims, config.InfluxConfig.DefaultTime, config.InfluxConfig.DoAdHocResampling, log, false), "Getting last timestamps for IMS tags", log); var calcTagsWithLastTimestampTask = Timer.Time(() => GetOutliers(influxQueryExecutor, calcMetas, config.InfluxConfig.DbCalcRetentionPolicy, config.InfluxConfig.DbCalcMeasurement, TagTypes.Calc, config.InfluxConfig.DefaultTime, config.InfluxConfig.DoAdHocResampling, log, false), "Getting last timestamps for Calc tags", log); await Task.WhenAll(imsTagsWithLastTimestampTask, calcTagsWithLastTimestampTask, imsTagsWithTimestampBeforeWatermarkTask, calcTagsWithTimestampBeforeWatermarkTask); var imsTagsWithLastTimestamp = imsTagsWithLastTimestampTask.Result; var calcTagsWithLastTimestamp = calcTagsWithLastTimestampTask.Result; var imsTagsWithTimestampBeforeWatermark = imsTagsWithTimestampBeforeWatermarkTask.Result; var calcTagsWithTimestampBeforeWatermark = calcTagsWithTimestampBeforeWatermarkTask.Result; var imsFirstTimers = imsFirstTimerMetas .Where(i => imsTagsWithLastTimestamp.ContainsKey(i.Tag)) .Select(m => new TsMetadata { Id = m.Id, LastTimestampAfterWatermark = imsTagsWithLastTimestamp[m.Tag].timestamp, LastValueAfterWatermark = imsTagsWithLastTimestamp[m.Tag].value, Tag = m.Tag }).ToList(); var calcFirstTimers = calcFirstTimerMetas .Where(c => calcTagsWithLastTimestamp.ContainsKey(c.Tag)) .Select(m => new TsMetadata { Id = m.Id, LastTimestampAfterWatermark = calcTagsWithLastTimestamp[m.Tag].timestamp, LastValueAfterWatermark = calcTagsWithLastTimestamp[m.Tag].value, Tag = m.Tag }).ToList(); var imsOldTimers = imsOldTimerMetas .Where(i => imsTagsWithLastTimestamp.ContainsKey(i.Tag)) .Select(i => new TsMetadata { Id = i.Id, LastTimestampAfterWatermark = imsTagsWithLastTimestamp[i.Tag].timestamp, LastValueAfterWatermark = imsTagsWithLastTimestamp[i.Tag].value, LastTimestampBeforeWatermark = imsTagsWithTimestampBeforeWatermark.ContainsKey(i.Tag) ? imsTagsWithTimestampBeforeWatermark[i.Tag].timestamp : default(DateTime?), LastValueBeforeWatermark = imsTagsWithTimestampBeforeWatermark.ContainsKey(i.Tag) ? imsTagsWithTimestampBeforeWatermark[i.Tag].value : default(double?), Tag = i.Tag, Watermark = i.Timestamp }).ToList(); var calcOldTimers = calcOldTimerMetas .Where(c => calcTagsWithLastTimestamp.ContainsKey(c.Tag)) .Select(c => new TsMetadata { Id = c.Id, LastTimestampAfterWatermark = calcTagsWithLastTimestamp[c.Tag].timestamp, LastValueAfterWatermark = calcTagsWithLastTimestamp[c.Tag].value, LastTimestampBeforeWatermark = calcTagsWithTimestampBeforeWatermark.ContainsKey(c.Tag) ? calcTagsWithTimestampBeforeWatermark[c.Tag].timestamp : default(DateTime?), LastValueBeforeWatermark = calcTagsWithTimestampBeforeWatermark.ContainsKey(c.Tag) ? calcTagsWithTimestampBeforeWatermark[c.Tag].value : default(double?), Tag = c.Tag, Watermark = c.Timestamp }).ToList(); var imsHasLastBeforeWatermark = imsOldTimers.Where(ot => ot.LastTimestampBeforeWatermark.HasValue).ToList(); var calcHasLastBeforeWatermark = calcOldTimers.Where(ot => ot.LastTimestampBeforeWatermark.HasValue).ToList(); log.Info($"IMS FirstTimer Data Filtered Count: {imsFirstTimers.Count}"); log.Info($"IMS OldTimer Data Filtered Count: {imsOldTimers.Count}"); log.Info($"Calc FirstTimer Data Filtered Count: {calcFirstTimers.Count}"); log.Info($"Calc OldTimer Data Filtered Count: {calcOldTimers.Count}"); int totalCount = imsOldTimers.Count + calcOldTimers.Count + imsFirstTimers.Count + calcFirstTimers.Count; log.Info($"Total Data Filtered Count: {totalCount}"); var progress = new Progress(); const string calcIdName = "CalculatedTag_ID"; const string calcTableName = "dbo.CalculatedTS"; const string imsIdName = "IMSTag_ID"; const string imsTableName = "dbo.IMSTS"; // Serve oldtimers first progress.Add(await ProcessMetas(config.ConnectionString, imsIdName, imsTableName, config.InfluxConfig.DbImsRetentionPolicy, config.InfluxConfig.DbImsMeasurement, TagTypes.Ims, config.InfluxConfig.DefaultTime, config.InfluxConfig.DoAdHocResampling, config.InfluxConfig.SkipLastPoint, config.Period, imsOldTimers, config.InfluxConfig.OldtimerBatchSize, config.InfluxConfig.Parallelism, influxQueryExecutor, imsEntityCreator, progress.ProcessedTags, "IMS Oldtimers", imsOldTimers.Count, totalCount, log)); progress.Add(await ProcessMetas(config.ConnectionString, calcIdName, calcTableName, config.InfluxConfig.DbCalcRetentionPolicy, config.InfluxConfig.DbCalcMeasurement, TagTypes.Calc, config.InfluxConfig.DefaultTime, config.InfluxConfig.DoAdHocResampling, config.InfluxConfig.SkipLastPoint, config.Period, calcOldTimers, config.InfluxConfig.OldtimerBatchSize, config.InfluxConfig.Parallelism, influxQueryExecutor, calcEntityCreator, progress.ProcessedTags, "Calc Oldtimers", calcOldTimers.Count, totalCount, log)); progress.Add(await ProcessMetas(config.ConnectionString, imsIdName, imsTableName, config.InfluxConfig.DbImsRetentionPolicy, config.InfluxConfig.DbImsMeasurement, TagTypes.Ims, config.InfluxConfig.DefaultTime, config.InfluxConfig.DoAdHocResampling, config.InfluxConfig.SkipLastPoint, config.Period, imsFirstTimers, config.InfluxConfig.FirsttimerBatchSize, config.InfluxConfig.Parallelism / 2, influxQueryExecutor, imsEntityCreator, progress.ProcessedTags, "IMS Firsttimers", imsFirstTimers.Count, totalCount, log)); progress.Add(await ProcessMetas(config.ConnectionString, calcIdName, calcTableName, config.InfluxConfig.DbCalcRetentionPolicy, config.InfluxConfig.DbCalcMeasurement, TagTypes.Calc, config.InfluxConfig.DefaultTime, config.InfluxConfig.DoAdHocResampling, config.InfluxConfig.SkipLastPoint, config.Period, calcFirstTimers, config.InfluxConfig.FirsttimerBatchSize, config.InfluxConfig.Parallelism / 2, influxQueryExecutor, calcEntityCreator, progress.ProcessedTags, "Calc Firsttimers", calcFirstTimers.Count, totalCount, log)); log.Info($"Processed points: {progress.ProcessedPoints}"); }
public Task OnProgressAsync(AssetUploadProgressEvent @event, CancellationToken ct) { Progress.Add(@event.Progress); return(Task.CompletedTask); }
protected void DoAddProgress(ProgressRecord progress) { Progress.Add(progress); }