초기커밋
This commit is contained in:
82
ServerCommon/Helper/DataCopyHelper.cs
Normal file
82
ServerCommon/Helper/DataCopyHelper.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
using MetaAssets;
|
||||
|
||||
|
||||
namespace ServerCommon;
|
||||
|
||||
public static class DataCopyHelper
|
||||
{
|
||||
#region 데이터 복사 하기 : Meta => Doc
|
||||
public static async Task<Result> copyDocFromMetas<TDoc>(TDoc toDoc, List<MetaAssets.IMetaData> fromMetaDatas)
|
||||
where TDoc : DynamoDbDocBase
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_doc = toDoc as ICopyDocFromMeta;
|
||||
if (null == to_doc)
|
||||
{
|
||||
err_msg = $"Failed to cast ICopyDocFromMeta !!! : {typeof(TDoc).Name}";
|
||||
result.setFail(ServerErrorCode.ClassDoesNotImplementInterfaceInheritance, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
foreach (var meta_data in fromMetaDatas)
|
||||
{
|
||||
if (false == to_doc.copyDocFromMeta(meta_data))
|
||||
{
|
||||
err_msg = $"Failed to copyDocFromMeta() !!!, to:{typeof(TDoc).Name}, from:{meta_data.getTypeName()}";
|
||||
result.setFail(ServerErrorCode.MetaDataCopyToDynamoDbDocFailed, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
return await Task.FromResult(result);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 데이터 복사 하기 : Meta => EntityAttribute
|
||||
public static async Task<Result> copyEntityAttributeFromMetas<TEntityAttributeType>(TEntityAttributeType toDocBase, List<MetaAssets.IMetaData> metaDatas)
|
||||
where TEntityAttributeType : EntityAttributeBase
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_copy = toDocBase as ICopyEntityAttributeFromMeta;
|
||||
if (null == to_copy)
|
||||
{
|
||||
err_msg = $"Failed to cast ICopyEntityAttributeFromMeta !!! : {typeof(TEntityAttributeType).Name} !!!";
|
||||
result.setFail(ServerErrorCode.ClassDoesNotImplementInterfaceInheritance, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
foreach (var meta_data in metaDatas)
|
||||
{
|
||||
if (false == to_copy.copyEntityAttributeFromMeta(meta_data))
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromMeta() !!!, to:{typeof(TEntityAttributeType).Name}, from:{meta_data.getTypeName()}";
|
||||
result.setFail(ServerErrorCode.MetaDataCopyToEntityAttributeFailed, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
return await Task.FromResult(result);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
Reference in New Issue
Block a user