git_bsmd/bsmd.database/ValueMapping.cs

126 lines
3.2 KiB
C#

// Copyright (c) 2023-present schick Informatik
// Description: Container class for self-learning, volatile information that
// is added by parsing Excel sheets. Here common wrong/misspelled data fields
// are mapped to valid ones.
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace bsmd.database
{
public class ValueMapping : DatabaseEntityAsync
{
#region enums
public enum MappingType
{
UNKNOWN,
COUNTRY,
GENDER,
DOCUMENT_TYPE,
LOCODE,
INVALID
};
#endregion
#region Fields
private static Dictionary<MappingType, Dictionary<string, ValueMapping>> _dicts = new Dictionary<MappingType, Dictionary<string, ValueMapping>>();
#endregion
#region Properties
public static Dictionary<MappingType, Dictionary<string, ValueMapping>> Dicts
{
get { return _dicts; }
}
public MappingType EntryType { get; private set; }
public string Key { get; private set; }
public string Value { get; private set; }
#endregion
#region public funcs
/// <summary>
/// creates and saves a new entry and adds it to the internal dictionaries
/// </summary>
/// <returns>true if entry was actually created, false if already present</returns>
public static bool Create(MappingType type, string key, string value)
{
return false;
}
/// <summary>
/// deletes an entry and removes it from the database
/// </summary>
/// <returns>true if successful, false if value was not found</returns>
public static bool Delete(MappingType type, string key)
{
return false;
}
/// <summary>
/// updates an existing value and saves it
/// </summary>
/// <returns>true if successful</returns>
public bool Update(string newValue)
{
return false;
}
#endregion
#region DatabaseEntity implementation
public override void PrepareSave(System.Data.IDbCommand cmd)
{
throw new NotImplementedException();
}
public override void PrepareLoadCommand(System.Data.IDbCommand cmd, Message.LoadFilter filter, params object[] criteria)
{
throw new NotImplementedException();
}
public override List<DatabaseEntity> LoadList(System.Data.IDataReader reader)
{
throw new NotImplementedException();
}
protected override DatabaseEntityAsync ReadRowFromReader(System.Data.IDataReader reader)
{
ValueMapping vm = null;
if (reader != null)
{
vm = new ValueMapping();
vm.id = reader.GetGuid(0);
//if (!reader.IsDBNull(1)) md.MessageCoreId = reader.GetGuid(1);
//if (!reader.IsDBNull(2)) md.ColA = reader.GetString(2);
}
return vm;
}
#endregion
}
}