Lernende Umsetzungsliste Part 1

This commit is contained in:
Daniel Schick 2023-05-09 08:36:05 +02:00
parent f6316e52dc
commit 2058161c79
5 changed files with 172 additions and 7 deletions

View File

@ -1,7 +1,5 @@
// Copyright (c) 2020-present schick Informatik
// Description: The new and mighty DB manager that uses async methods and
// connection pooling.. will try it out in Maersk/PO numbers and expand over the whole
// app later
// Copyright (c) 2023-present schick Informatik
// Description: Variant of DBManager that uses async calls
using log4net;
using System;
@ -81,6 +79,14 @@ namespace bsmd.database
return result;
}
public static async Task<List<ValueMapping>> LoadValuesForType(ValueMapping.MappingType mappingType)
{
SqlCommand cmd = new SqlCommand();
ValueMapping vm = new ValueMapping();
vm.PrepareLoadCommand(cmd, Message.LoadFilter.BY_TYPE, mappingType);
SqlDataReader reader = await PerformCommandAsync(cmd);
return await vm.LoadListAsync(reader);
}
#endregion

View File

@ -0,0 +1,33 @@
// Copyright (c) 2023-present schick Informatik
// Description: Async variant of DatabaseEntity
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace bsmd.database
{
public abstract class DatabaseEntityAsync : DatabaseEntity
{
protected abstract DatabaseEntityAsync ReadRowFromReader(IDataReader reader);
public async Task<List<DatabaseEntityAsync>> LoadListAsync(SqlDataReader reader)
{
List<DatabaseEntityAsync> result = new List<DatabaseEntityAsync>();
if (reader != null)
{
while (await reader.ReadAsync())
{
result.Add(ReadRowFromReader(reader));
}
reader.Close();
}
return result;
}
}
}

View File

@ -143,7 +143,8 @@ namespace bsmd.database
BY_CORE_AND_CLASS,
BY_AGE,
WASRCPT_ID,
BY_FILE_SEQ_NUM
BY_FILE_SEQ_NUM,
BY_TYPE
}
/// <summary>

View File

@ -0,0 +1,125 @@
// 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
}
}

View File

@ -1,11 +1,11 @@
extensions: designer.cs generated.cs
extensions: .cs .cpp .h
// Copyright (c) 2020-present schick Informatik
// Copyright (c) 2023-present schick Informatik
// Description:
extensions: .aspx .ascx
<%--
Copyright (c) 2020-present schick Informatik
Copyright (c) 2023-present schick Informatik
--%>
extensions: .vb
'Sample license text.