You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
84 lines
2.3 KiB
84 lines
2.3 KiB
using Dapper;
|
|
using Npgsql;
|
|
using Shentun.Peis.Asbitems;
|
|
using Shentun.Peis.Enums;
|
|
using Shentun.Peis.PlugIns.ChargeRequests;
|
|
using Shentun.Peis.PlugIns.LisRequests;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data.Common;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Shentun.Peis.PlugIns.SyncAsbitemPrice
|
|
{
|
|
public class SyncAsbitemPricePlugInsBase : ThirdPlugInsBase
|
|
{
|
|
public SyncAsbitemPricePlugInsBase(Guid thirdInterfaceId) : base(thirdInterfaceId)
|
|
{
|
|
|
|
}
|
|
|
|
public virtual async Task SyncAsbitemPriceAsync()
|
|
{
|
|
|
|
}
|
|
|
|
public async Task<List<AsbitemForSyncAsbitem>> GetAsbitemsAsync()
|
|
{
|
|
using (DbConnection conn = new NpgsqlConnection(AppConnctionStr))
|
|
{
|
|
string sql;
|
|
sql = @" select * from asbitem
|
|
";
|
|
var asbitems = (await conn.QueryAsync<AsbitemForSyncAsbitem>(sql
|
|
)).ToList();
|
|
|
|
return asbitems;
|
|
}
|
|
}
|
|
|
|
public async Task UpdateAsbitemPriceAsync(AsbitemForSyncAsbitem asbitem)
|
|
{
|
|
using (DbConnection conn = new NpgsqlConnection(AppConnctionStr))
|
|
{
|
|
await conn.OpenAsync();
|
|
using (var trans = await conn.BeginTransactionAsync())
|
|
{
|
|
try
|
|
{
|
|
string sql;
|
|
sql = @" update asbitem set price = @Price" +
|
|
@" where id = @AsbitemId and concurrency_stamp = @ConcurrencyStamp
|
|
";
|
|
await conn.ExecuteAsync(sql,
|
|
new
|
|
{
|
|
asbitem.Price,
|
|
asbitem.Id,
|
|
asbitem.ConcurrencyStamp
|
|
}, trans);
|
|
await trans.CommitAsync();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
await trans.RollbackAsync();
|
|
throw ex;
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
public override Task DoWork()
|
|
{
|
|
SyncAsbitemPriceAsync().Wait();
|
|
return Task.CompletedTask;
|
|
}
|
|
}
|
|
}
|