ComplianceServer/oldcode/WX.CRM.DataSynServer/Application/SyncPushService.cs

48 lines
1.5 KiB
C#

using DapperExtensions;
using System.Collections.Generic;
using WX.CRM.DataSynServer.Dao;
using WX.CRM.DataSynServer.Domain;
namespace WX.CRM.DataSynServer.Application
{
public class SyncPushService
{
public IEnumerable<SYNC_PUSH> GetList(int topNum, string deptCode = "")
{
using (var db = MySqlStore.GetConnection())
{
var predicate = Predicates.Field<SYNC_PUSH>(f => f.deptcode, Operator.Eq, deptCode);
IList<ISort> sort = new List<ISort>();
sort.Add(new Sort { PropertyName = "pkid", Ascending = true });
return db.GetPage<SYNC_PUSH>(predicate, sort, 0, topNum);
}
}
public void PushSucc(SYNC_PUSH info)
{
if (info == null)
return;
using (var db = MySqlStore.GetConnection())
{
var suc = new SYNC_PUSH_SUCC(info.jsontext, info.bidatatype, info.deptcode);
suc.ISBATCH = info.isbatch;
db.Insert(suc);
db.Delete(info);
}
}
public void PushError(SYNC_PUSH info, string errstr)
{
if (info == null)
return;
using (var db = MySqlStore.GetConnection())
{
var err = new SYNC_PUSH_ERR(info.jsontext, errstr, info.bidatatype, info.deptcode);
db.Insert(err);
db.Delete(info);
}
}
}
}