init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
73
Framework/Util/EntityUtils.cs
Normal file
73
Framework/Util/EntityUtils.cs
Normal file
|
@ -0,0 +1,73 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Xml.Linq;
|
||||
using Kreta.Framework.Entities;
|
||||
|
||||
namespace Kreta.Framework.Util
|
||||
{
|
||||
public static class EntityUtils
|
||||
{
|
||||
/// <summary>
|
||||
/// Visszaadja az entitásokhoz tartozó aktív kapcsolatokat.
|
||||
/// </summary>
|
||||
/// <param name="entityIds"></param>
|
||||
/// <param name="entitasNevek"></param>
|
||||
/// <returns></returns>
|
||||
public static Dictionary<int, List<EntityConnectionModel>> GetEntitiesConnections(List<int> entityIds, List<string> entitasNevek)
|
||||
{
|
||||
|
||||
// entityhistory szures
|
||||
XDocument xmlDoc = new XDocument(new XElement("EntitasNevek"));
|
||||
foreach (var entitasNev in entitasNevek)
|
||||
{
|
||||
xmlDoc.Root.Add(new XElement("Entitas", entitasNev));
|
||||
}
|
||||
|
||||
var EntitasNevek = xmlDoc.ToString();
|
||||
|
||||
xmlDoc = new XDocument(new XElement("Entitasok"));
|
||||
foreach (var entitasId in entityIds)
|
||||
{
|
||||
xmlDoc.Root.Add(new XElement("EntitasId", entitasId));
|
||||
}
|
||||
|
||||
var EntitasIdk = xmlDoc.ToString();
|
||||
|
||||
var result = new Dictionary<int, List<EntityConnectionModel>>();
|
||||
|
||||
using (SDA.DataProvider.SDACommand command = UserContext.Instance.SDAConnection.CreateCommand())
|
||||
{
|
||||
command.Connection = UserContext.Instance.SDAConnection;
|
||||
command.Transaction = UserContext.Instance.SDATransaction;
|
||||
command.CommandText = @"sp_GetEntitasAktivKapcsolatai";
|
||||
command.CommandType = System.Data.CommandType.StoredProcedure;
|
||||
command.Parameters.Add("EntitasIDk", EntitasIdk);
|
||||
command.Parameters.Add("EntitasNevek", EntitasNevek);
|
||||
|
||||
using (SDA.DataProvider.SDADataReader reader = command.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
var entitasId = reader.GetInt32(0);
|
||||
var targetTableName = reader.GetString(1);
|
||||
var targetColumnName = reader.GetString(2);
|
||||
var sorokSzama = reader.GetInt32(3);
|
||||
|
||||
if (!result.ContainsKey(entitasId))
|
||||
{
|
||||
result.Add(entitasId, new List<EntityConnectionModel>());
|
||||
}
|
||||
|
||||
result[entitasId].Add(new EntityConnectionModel
|
||||
{
|
||||
TargetTableName = targetTableName,
|
||||
TargetColumnName = targetColumnName,
|
||||
RowsCount = sorokSzama
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue