59 lines
1.7 KiB
C#
59 lines
1.7 KiB
C#
using DapperExtensions;
|
|
using MySql.Data.MySqlClient;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
using System.Linq;
|
|
using WX.CRM.DataSynClient.Domain;
|
|
|
|
namespace WX.CRM.DataSynClient.Dao
|
|
{
|
|
public class MySqlStore : IStore
|
|
{
|
|
private static readonly string _conn = ConfigurationManager.ConnectionStrings["DataSyncMySql"].ConnectionString;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static MySqlConnection GetConnection()
|
|
{
|
|
DapperExtensions.DapperExtensions.SqlDialect = new DapperExtensions.Sql.MySqlDialect();
|
|
return new MySqlConnection(_conn);
|
|
}
|
|
|
|
public IEnumerable<SYNC_PUSH> GetList(int topNum)
|
|
{
|
|
using (var db = GetConnection())
|
|
{
|
|
//var predicate = Predicates.Field<SYNC_PUSH>(f => f.deptcode, Operator.Eq, string.Empty);
|
|
IList<ISort> sort = new List<ISort>
|
|
{
|
|
new Sort { PropertyName = "pkid", Ascending = true }
|
|
};
|
|
return db.GetPage<SYNC_PUSH>(null, sort, 0, topNum).ToList();
|
|
}
|
|
}
|
|
|
|
public void PushSucc(SYNC_PUSH info)
|
|
{
|
|
if (info == null)
|
|
return;
|
|
|
|
using (var db = GetConnection())
|
|
{
|
|
var suc = new SYNC_PUSH_SUCC(info.jsontext, info.bidatatype, info.deptcode);
|
|
db.Insert(suc);
|
|
db.Delete(info);
|
|
}
|
|
}
|
|
|
|
public void Insert(SYNC_RECEIVE info)
|
|
{
|
|
using (var db = GetConnection())
|
|
{
|
|
db.Insert(info);
|
|
}
|
|
}
|
|
}
|
|
}
|