초기커밋

This commit is contained in:
2025-05-01 07:20:41 +09:00
commit 98bb2e3c5c
2747 changed files with 646947 additions and 0 deletions

View File

@@ -0,0 +1,283 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Amazon.Util.Internal;
using Grpc.Core;
using Microsoft.AspNetCore.Mvc.TagHelpers;
using ServerCore; using ServerBase;
namespace ServerBase;
public static class DataCopyHelper
{
#region : Doc => Cache
public static async Task<Result> copyCacheFromDocs<TCacheType>(TCacheType toCacheBase, List<DynamoDbDocBase> fromDocBases)
where TCacheType : CacheBase
{
var result = new Result();
var err_msg = string.Empty;
var to_copy = toCacheBase as ICopyCacheFromDoc;
if (null == to_copy)
{
err_msg = $"Failed to cast ICopyCacheFromDoc !!! : {typeof(TCacheType).Name} !!!";
result.setFail(ServerErrorCode.ClassDoesNotImplementInterfaceInheritance, err_msg);
Log.getLogger().error(result.toBasicString());
return result;
}
foreach (var doc in fromDocBases)
{
if (false == to_copy.copyCacheFromDoc(doc))
{
err_msg = $"Failed to copyCacheFromDoc() !!!, to:{typeof(TCacheType).Name}, from:{doc.getTypeName()}";
result.setFail(ServerErrorCode.DynamoDbDocCopyToCacheFailed, err_msg);
Log.getLogger().error(result.toBasicString());
return result;
}
}
return await Task.FromResult(result);
}
#endregion
#region : Doc => EntityAttribute
public static async Task<Result> copyEntityAttributeFromDocs<TEntityAttributeType>(TEntityAttributeType toEntityAttributeBase, List<DynamoDbDocBase> fromDocBases)
where TEntityAttributeType : EntityAttributeBase
{
await Task.CompletedTask;
var result = new Result();
var err_msg = string.Empty;
var to_copy = toEntityAttributeBase as ICopyEntityAttributeFromDoc;
if (null == to_copy)
{
err_msg = $"Failed to cast ICopyEntityAttributeFromDoc !!! : {typeof(TEntityAttributeType).Name}";
result.setFail(ServerErrorCode.ClassDoesNotImplementInterfaceInheritance, err_msg);
Log.getLogger().error(result.toBasicString());
return result;
}
foreach(var doc in fromDocBases)
{
if (false == to_copy.copyEntityAttributeFromDoc(doc))
{
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, to:{typeof(TEntityAttributeType).Name}, from:{doc.getTypeName()}";
result.setFail(ServerErrorCode.DynamoDbDocCopyToEntityAttributeFailed, err_msg);
Log.getLogger().error(result.toBasicString());
return result;
}
}
return result;
}
#endregion
#region : Cache => EntityAttribute
public static async Task<Result> copyEntityAttributeFromCaches<TEntityAttributeType>(TEntityAttributeType toEntityAttribBase, List<CacheBase> fromCacheBases)
where TEntityAttributeType : EntityAttributeBase
{
var result = new Result();
var err_msg = string.Empty;
var to_copy = toEntityAttribBase as ICopyEntityAttributeFromCache;
if (null == to_copy)
{
err_msg = $"Failed to cast ICopyEntityAttributeFromCache !!! : {typeof(TEntityAttributeType).Name} !!!";
result.setFail(ServerErrorCode.ClassDoesNotImplementInterfaceInheritance, err_msg);
Log.getLogger().error(result.toBasicString());
return result;
}
foreach (var cache in fromCacheBases)
{
if (false == to_copy.copyEntityAttributeFromCache(cache))
{
err_msg = $"Failed to copyEntityAttributeFromCache() !!!, to:{typeof(TEntityAttributeType).Name}, from:{cache.getTypeName()}";
result.setFail(ServerErrorCode.CacheCopyToEntityAttributeFailed, err_msg);
Log.getLogger().error(result.toBasicString());
return result;
}
}
return await Task.FromResult(result);
}
#endregion
#region : Cache => Doc
public static async Task<Result> copyDocFromCache<TDoc>(TDoc toDoc, List<CacheBase> fromCacheBases)
where TDoc : DynamoDbDocBase
{
var result = new Result();
var err_msg = string.Empty;
var to_copy = toDoc as ICopyDocFromCache;
if (null == to_copy)
{
err_msg = $"Failed to cast ICopyDocFromCache !!! : {typeof(TDoc).Name}";
result.setFail(ServerErrorCode.ClassDoesNotImplementInterfaceInheritance, err_msg);
Log.getLogger().error(result.toBasicString());
return result;
}
foreach (var cache in fromCacheBases)
{
if (false == to_copy.copyDocFromCache(cache))
{
err_msg = $"Failed to copyDocFromCache() !!!, to:{typeof(TDoc).Name}, from:{cache.getTypeName()}";
result.setFail(ServerErrorCode.CacheCopyToEntityAttributeFailed, err_msg);
Log.getLogger().error(result.toBasicString());
return result;
}
}
return await Task.FromResult(result);
}
#endregion
#region : EntityAttribute => Cache
public static async Task<Result> copyCacheFromEntityAttributes<TCacheType>(TCacheType toCacheBase, List<EntityAttributeBase> fromEntityAttributeBases)
where TCacheType : CacheBase
{
var result = new Result();
var err_msg = string.Empty;
var to_copy = toCacheBase as ICopyCacheFromEntityAttribute;
if (null == to_copy)
{
err_msg = $"Failed to cast ICopyCacheFromEntityAttribute !!! : {typeof(TCacheType).Name} !!!";
result.setFail(ServerErrorCode.ClassDoesNotImplementInterfaceInheritance, err_msg);
Log.getLogger().error(result.toBasicString());
return result;
}
foreach(var attribute in fromEntityAttributeBases)
{
if (false == to_copy.copyCacheFromEntityAttribute(attribute))
{
err_msg = $"Failed to copyCacheFromEntityAttributes() !!!, to:{typeof(TCacheType).Name}, from:{fromEntityAttributeBases.getTypeName()}";
result.setFail(ServerErrorCode.EntityAttributeCopyToCacheFailed, err_msg);
Log.getLogger().error(result.toBasicString());
return result;
}
}
return await Task.FromResult(result);
}
#endregion
#region : EntityAttribute => Doc
public static async Task<Result> copyDocFromEntityAttributes<TDoc>(TDoc toDocBase, List<EntityAttributeBase> fromEntityAttributeBases)
where TDoc : DynamoDbDocBase
{
var result = new Result();
var err_msg = string.Empty;
var to_copy = toDocBase as ICopyDocFromEntityAttribute;
if (null == to_copy)
{
err_msg = $"Failed to cast ICopyDocFromEntityAttribute !!! : {fromEntityAttributeBases.getTypeName()}";
result.setFail(ServerErrorCode.ClassDoesNotImplementInterfaceInheritance, err_msg);
Log.getLogger().error(result.toBasicString());
return result;
}
foreach (var entity_attribute in fromEntityAttributeBases)
{
if (false == to_copy.copyDocFromEntityAttribute(entity_attribute))
{
err_msg = $"Failed to copyDocFromEntityAttribute() !!!, to:{typeof(TDoc).Name}, from:{fromEntityAttributeBases.getTypeName()}";
result.setFail(ServerErrorCode.EntityAttributeCopyToDynamoDbDocFailed, err_msg);
Log.getLogger().error(result.toBasicString());
return result;
}
}
return await Task.FromResult(result);
}
#endregion
#region : EntityAttribute => EntityAttributeTransactor
public static async Task<Result> copyEntityAttributeTransactorFromEntityAttribute<TEntityAttribute>(EntityAttributeTransactorBase<TEntityAttribute> toEntityAttributeTransactorBase, EntityAttributeBase fromEntityAttribute)
where TEntityAttribute : EntityAttributeBase
{
var result = new Result();
var err_msg = string.Empty;
var to_copy = toEntityAttributeTransactorBase as ICopyEntityAttributeTransactorFromEntityAttribute;
if (null == to_copy)
{
err_msg = $"Failed to cast ICopyEntityAttributeTransactorBaseFromEntityAttribute !!! : {fromEntityAttribute.getTypeName()}";
result.setFail(ServerErrorCode.ClassDoesNotImplementInterfaceInheritance, err_msg);
Log.getLogger().error(result.toBasicString());
return result;
}
if (false == to_copy.copyEntityAttributeTransactorFromEntityAttribute(fromEntityAttribute))
{
err_msg = $"Failed to copyEntityAttributeTransactorBaseFromEntityAttribute() !!!, to:{toEntityAttributeTransactorBase.getTypeName()}, from:{fromEntityAttribute.getTypeName()}";
result.setFail(ServerErrorCode.EntityAttributeCopyToEntityAttributeTransactorFailed, err_msg);
Log.getLogger().error(result.toBasicString());
return result;
}
return await Task.FromResult(result);
}
#endregion
#region : EntityAttributeTransactor => Doc
public static async Task<Result> copyDocFromEntityAttributeTransactor<TDynamoDbDocBase, TEntityAttribute>(TDynamoDbDocBase toDoc, EntityAttributeTransactorBase<TEntityAttribute> fromEntityAttributeTransactorBase)
where TDynamoDbDocBase : DynamoDbDocBase
where TEntityAttribute : EntityAttributeBase
{
var result = new Result();
var err_msg = string.Empty;
var to_copy = toDoc as ICopyDocFromEntityAttributeTransactor;
if (null == to_copy)
{
err_msg = $"Failed to cast ICopyDocFromEntityAttributeTransactor !!! : {fromEntityAttributeTransactorBase.getTypeName()}";
result.setFail(ServerErrorCode.ClassDoesNotImplementInterfaceInheritance, err_msg);
Log.getLogger().error(result.toBasicString());
return result;
}
if (false == to_copy.copyDocFromEntityAttributeTransactor(fromEntityAttributeTransactorBase))
{
err_msg = $"Failed to copyDocFromEntityAttributeTransactor() !!!, to:{typeof(TDynamoDbDocBase).Name}, from:{fromEntityAttributeTransactorBase.getTypeName()}";
result.setFail(ServerErrorCode.EntityAttributeTransactorCopyToDynamoDbDocFailed, err_msg);
Log.getLogger().error(result.toBasicString());
return result;
}
return await Task.FromResult(result);
}
#endregion
}