删除多余文件
This commit is contained in:
63
.gitattributes
vendored
63
.gitattributes
vendored
@@ -1,63 +0,0 @@
|
||||
###############################################################################
|
||||
# Set default behavior to automatically normalize line endings.
|
||||
###############################################################################
|
||||
* text=auto
|
||||
|
||||
###############################################################################
|
||||
# Set default behavior for command prompt diff.
|
||||
#
|
||||
# This is need for earlier builds of msysgit that does not have it on by
|
||||
# default for csharp files.
|
||||
# Note: This is only used by command line
|
||||
###############################################################################
|
||||
#*.cs diff=csharp
|
||||
|
||||
###############################################################################
|
||||
# Set the merge driver for project and solution files
|
||||
#
|
||||
# Merging from the command prompt will add diff markers to the files if there
|
||||
# are conflicts (Merging from VS is not affected by the settings below, in VS
|
||||
# the diff markers are never inserted). Diff markers may cause the following
|
||||
# file extensions to fail to load in VS. An alternative would be to treat
|
||||
# these files as binary and thus will always conflict and require user
|
||||
# intervention with every merge. To do so, just uncomment the entries below
|
||||
###############################################################################
|
||||
#*.sln merge=binary
|
||||
#*.csproj merge=binary
|
||||
#*.vbproj merge=binary
|
||||
#*.vcxproj merge=binary
|
||||
#*.vcproj merge=binary
|
||||
#*.dbproj merge=binary
|
||||
#*.fsproj merge=binary
|
||||
#*.lsproj merge=binary
|
||||
#*.wixproj merge=binary
|
||||
#*.modelproj merge=binary
|
||||
#*.sqlproj merge=binary
|
||||
#*.wwaproj merge=binary
|
||||
|
||||
###############################################################################
|
||||
# behavior for image files
|
||||
#
|
||||
# image files are treated as binary by default.
|
||||
###############################################################################
|
||||
#*.jpg binary
|
||||
#*.png binary
|
||||
#*.gif binary
|
||||
|
||||
###############################################################################
|
||||
# diff behavior for common document formats
|
||||
#
|
||||
# Convert binary document formats to text before diffing them. This feature
|
||||
# is only available from the command line. Turn it on by uncommenting the
|
||||
# entries below.
|
||||
###############################################################################
|
||||
#*.doc diff=astextplain
|
||||
#*.DOC diff=astextplain
|
||||
#*.docx diff=astextplain
|
||||
#*.DOCX diff=astextplain
|
||||
#*.dot diff=astextplain
|
||||
#*.DOT diff=astextplain
|
||||
#*.pdf diff=astextplain
|
||||
#*.PDF diff=astextplain
|
||||
#*.rtf diff=astextplain
|
||||
#*.RTF diff=astextplain
|
||||
Binary file not shown.
@@ -1,13 +0,0 @@
|
||||
using System.Data;
|
||||
|
||||
namespace Yi.Framework.Uow
|
||||
{
|
||||
public interface IUnitOfWork : IDisposable
|
||||
{
|
||||
public void Init(bool isTransactional, IsolationLevel? isolationLevel, int? timeout);
|
||||
public void BeginTran();
|
||||
|
||||
public void CommitTran();
|
||||
public void RollbackTran();
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Uow.Interceptors
|
||||
{
|
||||
public class UnitOfWorkAttribute : Attribute// : AbstractInterceptorAttribute
|
||||
{
|
||||
public UnitOfWorkAttribute(bool isTransactional = true)
|
||||
{
|
||||
IsTransactional = isTransactional;
|
||||
}
|
||||
public UnitOfWorkAttribute(IsolationLevel isolationLevel, bool isTransactional = true) : this(isTransactional)
|
||||
{
|
||||
IsolationLevel = isolationLevel;
|
||||
}
|
||||
public UnitOfWorkAttribute(IsolationLevel isolationLevel, int timeout, bool isTransactional = true) : this(isolationLevel, isTransactional)
|
||||
{
|
||||
Timeout = timeout;
|
||||
}
|
||||
|
||||
public bool IsTransactional { get; }
|
||||
|
||||
public IsolationLevel? IsolationLevel { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Milliseconds
|
||||
/// </summary>
|
||||
public int? Timeout { get; }
|
||||
public bool IsDisabled { get; }
|
||||
|
||||
|
||||
//public override Task Invoke(AspectContext context, AspectDelegate next)
|
||||
//{
|
||||
// if (IsTransactional)
|
||||
// {
|
||||
// ServiceLocator.in.getservice()
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
using Castle.DynamicProxy;
|
||||
using Nest;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Uow.Interceptors
|
||||
{
|
||||
public class UnitOfWorkInterceptor : IInterceptor
|
||||
{
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
public UnitOfWorkInterceptor(IUnitOfWork unitOfWork)
|
||||
{
|
||||
_unitOfWork = unitOfWork;
|
||||
}
|
||||
|
||||
public void Intercept(IInvocation invocation)
|
||||
{
|
||||
if (!IsUnitOfWorkMethod(invocation.Method, out var uowAttr))
|
||||
{
|
||||
invocation.Proceed();
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_unitOfWork.BeginTran();
|
||||
//执行被拦截的方法
|
||||
invocation.Proceed();
|
||||
_unitOfWork.CommitTran();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_unitOfWork.RollbackTran();
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static bool IsUnitOfWorkMethod( MethodInfo methodInfo,out UnitOfWorkAttribute unitOfWorkAttribute)
|
||||
{
|
||||
|
||||
//Method declaration
|
||||
var attrs = methodInfo.GetCustomAttributes(true).OfType<UnitOfWorkAttribute>().ToArray();
|
||||
if (attrs.Any())
|
||||
{
|
||||
unitOfWorkAttribute = attrs.First();
|
||||
return !unitOfWorkAttribute.IsDisabled;
|
||||
}
|
||||
|
||||
if (methodInfo.DeclaringType != null)
|
||||
{
|
||||
//Class declaration
|
||||
attrs = methodInfo.DeclaringType.GetTypeInfo().GetCustomAttributes(true).OfType<UnitOfWorkAttribute>().ToArray();
|
||||
if (attrs.Any())
|
||||
{
|
||||
unitOfWorkAttribute = attrs.First();
|
||||
return !unitOfWorkAttribute.IsDisabled;
|
||||
}
|
||||
|
||||
////Conventional classes
|
||||
//if (typeof(IUnitOfWorkEnabled).GetTypeInfo().IsAssignableFrom(methodInfo.DeclaringType))
|
||||
//{
|
||||
// unitOfWorkAttribute = null;
|
||||
// return true;
|
||||
//}
|
||||
}
|
||||
|
||||
unitOfWorkAttribute = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Uow;
|
||||
using Yi.Framework.Uow.Interceptors;
|
||||
|
||||
namespace Microsoft.Extensions.DependencyInjection
|
||||
{
|
||||
public static class UowIServiceCollectionExtensions
|
||||
{
|
||||
public static void AddUnitOfWork(this IServiceCollection services)
|
||||
{
|
||||
services.AddScoped(typeof(IUnitOfWork), typeof(UnitOfWork));
|
||||
|
||||
services.AddSingleton<UnitOfWorkInterceptor>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Uow
|
||||
{
|
||||
public class UnitOfWork : IUnitOfWork
|
||||
{
|
||||
|
||||
public bool IsTransactional { get; protected set; }
|
||||
|
||||
public IsolationLevel? IsolationLevel { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Milliseconds
|
||||
/// </summary>
|
||||
public int? Timeout { get; protected set; }
|
||||
|
||||
public void Init(bool isTransactional, IsolationLevel? isolationLevel, int? timeout)
|
||||
{
|
||||
IsTransactional = isTransactional;
|
||||
IsolationLevel = isolationLevel;
|
||||
Timeout = timeout;
|
||||
}
|
||||
|
||||
public ISqlSugarClient SugarClient { get; set; }
|
||||
/// <summary>
|
||||
/// 因为sqlsugarclient的生命周期是作用域的,也就是说一个请求线程内是共用一个client,暂时先直接注入
|
||||
/// </summary>
|
||||
/// <param name="sqlSugarClient"></param>
|
||||
public UnitOfWork(ISqlSugarClient sqlSugarClient)
|
||||
{
|
||||
this.SugarClient = sqlSugarClient;
|
||||
}
|
||||
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
SugarClient?.Dispose();
|
||||
SugarClient?.Close();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void BeginTran()
|
||||
{
|
||||
if (IsTransactional)
|
||||
{
|
||||
if (IsolationLevel.HasValue)
|
||||
{
|
||||
SugarClient.Ado.BeginTran(IsolationLevel.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
SugarClient.Ado.BeginTran();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void CommitTran()
|
||||
{
|
||||
if (IsTransactional)
|
||||
SugarClient.Ado.CommitTran();
|
||||
}
|
||||
public void RollbackTran()
|
||||
{
|
||||
if (IsTransactional)
|
||||
SugarClient.Ado.RollbackTran();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Castle.Core" Version="5.1.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Yi.Framework.Repository\Yi.Framework.Repository.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user