master
xiaochanghai 3 weeks ago
parent e4a8a590b5
commit 3932d785ca
  1. 15
      Tiobon.Core.IServices/IGuestbookServices.cs
  2. 47
      Tiobon.Core.Model/Models/Guestbook.cs
  3. 49
      Tiobon.Core.Model/ViewModels/GuestbookViewModels.cs
  4. 202
      Tiobon.Core.Services/GuestbookServices.cs
  5. 80
      Tiobon.Core/Tiobon.Core.Model.xml

@ -1,15 +0,0 @@
using Tiobon.Core.Model;
namespace Tiobon.Core.IServices;
public partial interface IGuestbookServices : IBaseServices<Guestbook>
{
Task<ServiceResult<string>> TestTranInRepository();
Task<bool> TestTranInRepositoryAOP();
Task<bool> TestTranPropagation();
Task<bool> TestTranPropagationNoTran();
Task<bool> TestTranPropagationTran();
}

@ -1,47 +0,0 @@
namespace Tiobon.Core.Model.Models;
public class Guestbook : RootEntityTkey<long>
{
/// <summary>博客ID
///
/// </summary>
public long? TiobonId { get; set; }
/// <summary>创建时间
///
/// </summary>
public DateTime createdate { get; set; }
[SugarColumn(Length = 2000, IsNullable = true)]
public string username { get; set; }
/// <summary>手机
///
/// </summary>
[SugarColumn(Length = 2000, IsNullable = true)]
public string phone { get; set; }
/// <summary>qq
///
/// </summary>
[SugarColumn(Length = 2000, IsNullable = true)]
public string QQ { get; set; }
/// <summary>留言内容
///
/// </summary>
[SugarColumn(Length = 2000, IsNullable = true)]
public string body { get; set; }
/// <summary>ip地址
///
/// </summary>
[SugarColumn(Length = 2000, IsNullable = true)]
public string ip { get; set; }
/// <summary>是否显示在前台,0否1是
///
/// </summary>
public bool isshow { get; set; }
[SugarColumn(IsIgnore = true)]
public TiobonArticle Tiobonarticle { get; set; }
}

@ -1,49 +0,0 @@
using Tiobon.Core.Model.Models;
namespace Tiobon.Core.Model.ViewModels;
/// <summary>
/// 留言信息展示类
/// </summary>
public class GuestbookViewModels
{
/// <summary>留言表
///
/// </summary>
public int id { get; set; }
/// <summary>博客ID
///
/// </summary>
public int? TiobonId { get; set; }
/// <summary>创建时间
///
/// </summary>
public DateTime createdate { get; set; }
public string username { get; set; }
/// <summary>手机
///
/// </summary>
public string phone { get; set; }
/// <summary>qq
///
/// </summary>
public string QQ { get; set; }
/// <summary>留言内容
///
/// </summary>
public string body { get; set; }
/// <summary>ip地址
///
/// </summary>
public string ip { get; set; }
/// <summary>是否显示在前台,0否1是
///
/// </summary>
public bool isshow { get; set; }
public TiobonArticle Tiobonarticle { get; set; }
}

@ -1,202 +0,0 @@
using Tiobon.Core.Common.DB;
using Tiobon.Core.Repository.UnitOfWorks;
namespace Tiobon.Core.Services;
public class GuestbookServices : BaseServices<Guestbook>, IGuestbookServices
{
private readonly IUnitOfWorkManage _unitOfWorkManage;
private readonly IBaseRepository<PasswordLib> _passwordLibRepository;
private readonly IPasswordLibServices _passwordLibServices;
public GuestbookServices(IUnitOfWorkManage unitOfWorkManage, IBaseRepository<Guestbook> dal, IBaseRepository<PasswordLib> passwordLibRepository, IPasswordLibServices passwordLibServices)
{
_unitOfWorkManage = unitOfWorkManage;
_passwordLibRepository = passwordLibRepository;
_passwordLibServices = passwordLibServices;
}
public async Task<ServiceResult<string>> TestTranInRepository()
{
try
{
Console.WriteLine($"");
Console.WriteLine($"事务操作开始");
using (var uow = _unitOfWorkManage.CreateUnitOfWork())
{
Console.WriteLine($"");
Console.WriteLine($"insert a data into the table PasswordLib now.");
var insertPassword = await _passwordLibRepository.Add(new PasswordLib()
{
IsDeleted = false,
plAccountName = "aaa",
plCreateTime = DateTime.Now
});
var passwords = await _passwordLibRepository.Query(d => d.IsDeleted == false);
Console.WriteLine($"second time : the count of passwords is :{passwords.Count}");
//......
Console.WriteLine($"");
var guestbooks = await BaseDal.Query();
Console.WriteLine($"first time : the count of guestbooks is :{guestbooks.Count}");
int ex = 0;
Console.WriteLine($"\nThere's an exception!!");
int throwEx = 1 / ex;
Console.WriteLine($"insert a data into the table Guestbook now.");
var insertGuestbook = await BaseDal.Add(new Guestbook()
{
username = "bbb",
TiobonId = 1,
createdate = DateTime.Now,
isshow = true
});
guestbooks = await BaseDal.Query();
Console.WriteLine($"second time : the count of guestbooks is :{guestbooks.Count}");
uow.Commit();
}
return new ServiceResult<string>()
{
Success = true,
Message = "操作完成"
};
}
catch (Exception)
{
var passwords = await _passwordLibRepository.Query();
Console.WriteLine($"third time : the count of passwords is :{passwords.Count}");
var guestbooks = await BaseDal.Query();
Console.WriteLine($"third time : the count of guestbooks is :{guestbooks.Count}");
return new ServiceResult<string>()
{
Success = false,
Message = "操作异常"
};
}
}
[UseTran]
public async Task<bool> TestTranInRepositoryAOP()
{
var passwords = await _passwordLibRepository.Query();
Console.WriteLine($"first time : the count of passwords is :{passwords.Count}");
Console.WriteLine($"insert a data into the table PasswordLib now.");
var insertPassword = await _passwordLibRepository.Add(new PasswordLib()
{
IsDeleted = false,
plAccountName = "aaa",
plCreateTime = DateTime.Now
});
passwords = await _passwordLibRepository.Query(d => d.IsDeleted == false);
Console.WriteLine($"second time : the count of passwords is :{passwords.Count}");
//......
Console.WriteLine($"");
var guestbooks = await BaseDal.Query();
Console.WriteLine($"first time : the count of guestbooks is :{guestbooks.Count}");
int ex = 0;
Console.WriteLine($"\nThere's an exception!!");
int throwEx = 1 / ex;
Console.WriteLine($"insert a data into the table Guestbook now.");
var insertGuestbook = await BaseDal.Add(new Guestbook()
{
username = "bbb",
TiobonId = 1,
createdate = DateTime.Now,
isshow = true
});
guestbooks = await BaseDal.Query();
Console.WriteLine($"second time : the count of guestbooks is :{guestbooks.Count}");
return true;
}
/// <summary>
/// 测试使用同事务
/// </summary>
/// <returns></returns>
[UseTran(Propagation = Propagation.Required)]
public async Task<bool> TestTranPropagation()
{
var guestbooks = await base.Query();
Console.WriteLine($"first time : the count of guestbooks is :{guestbooks.Count}");
var insertGuestbook = await base.Add(new Guestbook()
{
username = "bbb",
TiobonId = 1,
createdate = DateTime.Now,
isshow = true
});
await _passwordLibServices.TestTranPropagation2();
return true;
}
/// <summary>
/// 测试无事务 Mandatory传播机制报错
/// </summary>
/// <returns></returns>
public async Task<bool> TestTranPropagationNoTran()
{
var guestbooks = await base.Query();
Console.WriteLine($"first time : the count of guestbooks is :{guestbooks.Count}");
var insertGuestbook = await base.Add(new Guestbook()
{
username = "bbb",
TiobonId = 1,
createdate = DateTime.Now,
isshow = true
});
await _passwordLibServices.TestTranPropagationNoTranError();
return true;
}
/// <summary>
/// 测试嵌套事务
/// </summary>
/// <returns></returns>
[UseTran(Propagation = Propagation.Required)]
public async Task<bool> TestTranPropagationTran()
{
var guestbooks = await base.Query();
Console.WriteLine($"first time : the count of guestbooks is :{guestbooks.Count}");
var insertGuestbook = await base.Add(new Guestbook()
{
username = "bbb",
TiobonId = 1,
createdate = DateTime.Now,
isshow = true
});
await _passwordLibServices.TestTranPropagationTran2();
return true;
}
}

@ -38364,41 +38364,6 @@
Reverse5 Reverse5
</summary> </summary>
</member> </member>
<member name="P:Tiobon.Core.Model.Models.Guestbook.TiobonId">
<summary>博客ID
</summary>
</member>
<member name="P:Tiobon.Core.Model.Models.Guestbook.createdate">
<summary>创建时间
</summary>
</member>
<member name="P:Tiobon.Core.Model.Models.Guestbook.phone">
<summary>手机
</summary>
</member>
<member name="P:Tiobon.Core.Model.Models.Guestbook.QQ">
<summary>qq
</summary>
</member>
<member name="P:Tiobon.Core.Model.Models.Guestbook.body">
<summary>留言内容
</summary>
</member>
<member name="P:Tiobon.Core.Model.Models.Guestbook.ip">
<summary>ip地址
</summary>
</member>
<member name="P:Tiobon.Core.Model.Models.Guestbook.isshow">
<summary>是否显示在前台,0否1是
</summary>
</member>
<member name="T:Tiobon.Core.Model.Models.Modules"> <member name="T:Tiobon.Core.Model.Models.Modules">
<summary> <summary>
接口API地址信息表 接口API地址信息表
@ -43638,51 +43603,6 @@
Offer文件路径 Offer文件路径
</summary> </summary>
</member> </member>
<member name="T:Tiobon.Core.Model.ViewModels.GuestbookViewModels">
<summary>
留言信息展示类
</summary>
</member>
<member name="P:Tiobon.Core.Model.ViewModels.GuestbookViewModels.id">
<summary>留言表
</summary>
</member>
<member name="P:Tiobon.Core.Model.ViewModels.GuestbookViewModels.TiobonId">
<summary>博客ID
</summary>
</member>
<member name="P:Tiobon.Core.Model.ViewModels.GuestbookViewModels.createdate">
<summary>创建时间
</summary>
</member>
<member name="P:Tiobon.Core.Model.ViewModels.GuestbookViewModels.phone">
<summary>手机
</summary>
</member>
<member name="P:Tiobon.Core.Model.ViewModels.GuestbookViewModels.QQ">
<summary>qq
</summary>
</member>
<member name="P:Tiobon.Core.Model.ViewModels.GuestbookViewModels.body">
<summary>留言内容
</summary>
</member>
<member name="P:Tiobon.Core.Model.ViewModels.GuestbookViewModels.ip">
<summary>ip地址
</summary>
</member>
<member name="P:Tiobon.Core.Model.ViewModels.GuestbookViewModels.isshow">
<summary>是否显示在前台,0否1是
</summary>
</member>
<member name="T:Tiobon.Core.Model.ViewModels.QuartzReflectionViewModel"> <member name="T:Tiobon.Core.Model.ViewModels.QuartzReflectionViewModel">
<summary> <summary>
实现IJob的类 实现IJob的类

Loading…
Cancel
Save