/// <summary> /// Converts the current <see cref="TrackRecordsEntity"/> into a <see cref="TrackRecords"/>. /// </summary> /// <returns>The <see cref="TrackRecords"/>.</returns> /// <param name="entity">The current <see cref="TrackRecordsEntity"/>.</param> internal static TrackRecords ToDomainModel(this TrackRecordsEntity entity) { TrackRecords model = new TrackRecords { BestLapRecord = entity.LapRecords[0].ToDomainModel(), RecordsFor2Laps = entity.LapRecords.Skip(1).Take(10).ToDomainModels().ToList(), RecordsFor4Laps = entity.LapRecords.Skip(11).Take(10).ToDomainModels().ToList(), RecordsFor8Laps = entity.LapRecords.Skip(21).Take(10).ToDomainModels().ToList(), }; return(model); }
/// <summary> /// Converts the current <see cref="TrackRecords"/> into a <see cref="TrackRecordsEntity"/>. /// </summary> /// <returns>The <see cref="TrackRecordsEntity"/>.</returns> /// <param name="model">The current <see cref="TrackRecords"/>.</param> internal static TrackRecordsEntity ToEntity(this TrackRecords model) { TrackRecordsEntity entity = new TrackRecordsEntity { LapRecords = new LapRecord[] { model.BestLapRecord } .Concat(model.RecordsFor2Laps) .Concat(model.RecordsFor4Laps) .Concat(model.RecordsFor8Laps) .ToEntities().ToArray() }; return(entity); }
private void LoadRecords() { if (!File.Exists(recordFile)) { Debug.LogWarning("Record file does not exist"); trackRecords = new TrackRecords(); } else { FileStream fs = File.OpenRead(recordFile); var ser = new DataContractJsonSerializer(typeof(TrackRecords)); trackRecords = (TrackRecords)ser.ReadObject(fs); fs.Close(); } trackRecords.Init(); return; }
public virtual void DeleteTrackRecord() { if (SelectedTrackRecord == null) { XtraMessageBox.Show("请选中要删除的行", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else { string sqlStr = $"DELETE [db_SFI].[dbo].[tb_track_record] WHERE int_id={SelectedTrackRecord.int_id}"; if (XtraMessageBox.Show("删除后不可恢复,是否继续?", "错误信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { if (SQLHelper.UpDateSQL(sqlStr)) { TrackRecords.Remove(SelectedTrackRecord); } } } }
/// <summary> /// Converts an XML into an STF. /// </summary> /// <param name="xmlPath">XML path.</param> /// <param name="stfPath">STF path.</param> public void ConvertToSTF(string xmlPath, string stfPath) { TrackRecords records = xmlManager.Read(xmlPath); stf.Write(stfPath, records.ToEntity()); }
/// <summary> /// Converts an STF into an XML. /// </summary> /// <param name="stfPath">STF path.</param> /// <param name="xmlPath">XML path.</param> public void ConvertToXML(string stfPath, string xmlPath) { TrackRecords records = stf.Read(stfPath).ToDomainModel(); xmlManager.Write(xmlPath, records); }