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.
724 lines
26 KiB
724 lines
26 KiB
using CK.SCP.Models;
|
|
using CK.SCP.Models.Base;
|
|
using CK.SCP.Models.Enums;
|
|
using CK.SCP.Models.ExchangeCenterTables;
|
|
using CK.SCP.Utils;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
using System.Data;
|
|
using System.Data.Entity.Migrations;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace CK.SCP.Controller
|
|
{
|
|
public class UN_EC_CONTROLLER
|
|
{
|
|
public static ResultObject<List<TEA_SYSTEM>> Get_TEA_SYSTEM_List(TEA_SYSTEM p_entity)
|
|
{
|
|
ResultObject<List<TEA_SYSTEM>> _ret = new ResultObject<List<TEA_SYSTEM>>();
|
|
try
|
|
{
|
|
using (var db = EntitiesFactory.CreateExchangeCenterInstance())
|
|
{
|
|
IQueryable<TEA_SYSTEM> q = db.TEA_SYSTEM;
|
|
if (!string.IsNullOrEmpty(p_entity.SystemName))
|
|
{
|
|
q = q.Where(p => p.SystemName.Contains(p_entity.SystemName));
|
|
}
|
|
if (!string.IsNullOrEmpty(p_entity.SystemDesc))
|
|
{
|
|
q = q.Where(p => p.SystemDesc.Contains(p_entity.SystemDesc));
|
|
}
|
|
if (!string.IsNullOrEmpty(p_entity.Password))
|
|
{
|
|
q = q.Where(p => p.Password.Contains(p_entity.Password));
|
|
}
|
|
if (!string.IsNullOrEmpty(p_entity.Email))
|
|
{
|
|
q = q.Where(p => p.Email.Contains(p_entity.Email));
|
|
}
|
|
if (!string.IsNullOrEmpty(p_entity.ClientIp))
|
|
{
|
|
q = q.Where(p => p.ClientIp.Contains(p_entity.ClientIp));
|
|
}
|
|
if (!string.IsNullOrEmpty(p_entity.SessionId))
|
|
{
|
|
q = q.Where(p => p.SessionId.Contains(p_entity.SessionId));
|
|
}
|
|
if (!string.IsNullOrEmpty(p_entity.Domain))
|
|
{
|
|
q = q.Where(p => p.Domain.Contains(p_entity.Domain));
|
|
}
|
|
if (!string.IsNullOrEmpty(p_entity.Site))
|
|
{
|
|
q = q.Where(p => p.Site.Contains(p_entity.Site));
|
|
}
|
|
if (p_entity.UID != 0)
|
|
{
|
|
q = q.Where(p => p.UID == p_entity.UID);
|
|
}
|
|
if (!string.IsNullOrEmpty(p_entity.CreateUser))
|
|
{
|
|
q = q.Where(p => p.CreateUser.Contains(p_entity.CreateUser));
|
|
}
|
|
if (!string.IsNullOrEmpty(p_entity.Remark))
|
|
{
|
|
q = q.Where(p => p.Remark.Contains(p_entity.Remark));
|
|
}
|
|
if (!string.IsNullOrEmpty(p_entity.UpdateUser))
|
|
{
|
|
q = q.Where(p => p.UpdateUser.Contains(p_entity.UpdateUser));
|
|
}
|
|
if (p_entity.IsChecked != false)
|
|
{
|
|
q = q.Where(p => p.IsChecked == p_entity.IsChecked);
|
|
}
|
|
if (p_entity.Enable != false)
|
|
{
|
|
q = q.Where(p => p.Enable == p_entity.Enable);
|
|
}
|
|
|
|
_ret.State = ReturnStatus.Succeed;
|
|
_ret.Result = q.ToList();
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
_ret.State = ReturnStatus.Failed;
|
|
_ret.ErrorList.Add(e);
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(TEA_SYSTEM), "Get_TEA_SYSTEM_List", e.Message);
|
|
throw e;
|
|
}
|
|
return _ret;
|
|
}
|
|
|
|
|
|
public static ResultObject<bool> Save_TEA_SYSTEM(List<TEA_SYSTEM> p_entitys)
|
|
{
|
|
ResultObject<bool> _ret = new ResultObject<bool>();
|
|
try
|
|
{
|
|
using (var db = EntitiesFactory.CreateExchangeCenterInstance())
|
|
{
|
|
foreach (var itm in p_entitys)
|
|
{
|
|
db.TEA_SYSTEM.AddOrUpdate(itm);
|
|
}
|
|
if (db.SaveChanges() != -1)
|
|
{
|
|
_ret.State = ReturnStatus.Succeed;
|
|
_ret.Result = true;
|
|
}
|
|
else
|
|
{
|
|
_ret.State = ReturnStatus.Failed;
|
|
_ret.Result = false;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
_ret.State = ReturnStatus.Failed;
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(TEA_SYSTEM), "Save_TEA_SYSTEM", e.Message);
|
|
_ret.Result = false;
|
|
_ret.ErrorList.Add(e);
|
|
throw e;
|
|
}
|
|
return _ret;
|
|
}
|
|
|
|
|
|
|
|
public static ResultObject<bool> Del_TEA_SYSTEM(List<TEA_SYSTEM> p_entitys)
|
|
{
|
|
ResultObject<bool> _ret = new ResultObject<bool>();
|
|
try
|
|
{
|
|
using (var db = EntitiesFactory.CreateExchangeCenterInstance())
|
|
{
|
|
foreach (var itm in p_entitys)
|
|
{
|
|
db.TEA_SYSTEM.Remove(itm);
|
|
}
|
|
if (db.SaveChanges() != -1)
|
|
{
|
|
_ret.State = ReturnStatus.Succeed;
|
|
_ret.Result = true;
|
|
}
|
|
else
|
|
{
|
|
_ret.State = ReturnStatus.Failed;
|
|
_ret.Result = false;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
_ret.State = ReturnStatus.Failed;
|
|
_ret.Result = false;
|
|
_ret.ErrorList.Add(e);
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(TEA_SYSTEM), "Del_TEA_SYSTEM", e.Message); throw e;
|
|
}
|
|
return _ret;
|
|
}
|
|
|
|
|
|
|
|
public static DataTable Get_EC_TASK_List(string p_taskId, string p_tableName)
|
|
{
|
|
DataTable dt = new DataTable(); ;
|
|
var dbSetting = GlobalConfig.ExchangeCenterDB;
|
|
try
|
|
{
|
|
|
|
var strConn = EntitiesFactory.GetEfConnectionString(dbSetting);
|
|
SqlConnection conn = new System.Data.SqlClient.SqlConnection();
|
|
//conn.ConnectionString = db.Database.Connection.ConnectionString;
|
|
|
|
conn.ConnectionString = strConn;
|
|
|
|
if (conn.State != ConnectionState.Open)
|
|
{
|
|
conn.Open();
|
|
}
|
|
SqlCommand cmd = new SqlCommand();
|
|
|
|
cmd.Connection = conn;
|
|
string _sql = string.Format("select * from {0} where taskid='{1}'", p_tableName, p_taskId);
|
|
|
|
cmd.CommandText = _sql;
|
|
|
|
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
|
|
|
|
adapter.Fill(dt);
|
|
conn.Close();
|
|
|
|
}
|
|
catch (SqlException ex)
|
|
{
|
|
throw new Exception($"系统无法连接到数据库:{dbSetting},请检查配置的服务器,数据库,用户名和密码等信息是否正确。{Environment.NewLine}{ex}");
|
|
}
|
|
|
|
return dt;
|
|
}
|
|
|
|
|
|
public static DataTable Get_TABLE_NAME_List()
|
|
{
|
|
DataTable dt = new DataTable(); ;
|
|
var dbSetting = GlobalConfig.ExchangeCenterDB;
|
|
try
|
|
{
|
|
|
|
var strConn = EntitiesFactory.GetEfConnectionString(dbSetting);
|
|
SqlConnection conn = new System.Data.SqlClient.SqlConnection();
|
|
//conn.ConnectionString = db.Database.Connection.ConnectionString;
|
|
|
|
conn.ConnectionString = strConn;
|
|
|
|
if (conn.State != ConnectionState.Open)
|
|
{
|
|
conn.Open();
|
|
}
|
|
SqlCommand cmd = new SqlCommand();
|
|
|
|
cmd.Connection = conn;
|
|
string _sql = "select NAME from sysobjects where xtype in ('u','v')";
|
|
|
|
cmd.CommandText = _sql;
|
|
|
|
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
|
|
|
|
adapter.Fill(dt);
|
|
conn.Close();
|
|
|
|
}
|
|
catch (SqlException ex)
|
|
{
|
|
throw new Exception($"系统无法连接到数据库:{dbSetting},请检查配置的服务器,数据库,用户名和密码等信息是否正确。{Environment.NewLine}{ex}");
|
|
}
|
|
return dt;
|
|
}
|
|
|
|
public static DataTable Get_TABLE_NAME_List(DB_CONNECTION p_connection)
|
|
{
|
|
DataTable dt = new DataTable(); ;
|
|
var dbSetting = GlobalConfig.ScpDatabase;
|
|
try
|
|
{
|
|
|
|
switch (p_connection)
|
|
{
|
|
case DB_CONNECTION.AppBoxDB:
|
|
dbSetting = GlobalConfig.AppBoxDatabase;
|
|
break;
|
|
case DB_CONNECTION.DataCenterDB:
|
|
dbSetting = GlobalConfig.DataCenterDB;
|
|
break;
|
|
case DB_CONNECTION.ExchangeCenterDB:
|
|
dbSetting = GlobalConfig.ExchangeCenterDB;
|
|
break;
|
|
case DB_CONNECTION.ScpDB:
|
|
dbSetting = GlobalConfig.ScpDatabase;
|
|
break;
|
|
case DB_CONNECTION.UniApiDB:
|
|
dbSetting = GlobalConfig.UniApiDatabase;
|
|
break;
|
|
case DB_CONNECTION.WmsDB:
|
|
dbSetting = GlobalConfig.WmsDatabase;
|
|
break;
|
|
|
|
}
|
|
|
|
var strConn = EntitiesFactory.GetEfConnectionString(dbSetting);
|
|
SqlConnection conn = new System.Data.SqlClient.SqlConnection();
|
|
//conn.ConnectionString = db.Database.Connection.ConnectionString;
|
|
|
|
conn.ConnectionString = strConn;
|
|
|
|
if (conn.State != ConnectionState.Open)
|
|
{
|
|
conn.Open();
|
|
}
|
|
SqlCommand cmd = new SqlCommand();
|
|
|
|
cmd.Connection = conn;
|
|
string _sql = "select NAME from sysobjects where xtype in ('u','v')";
|
|
|
|
cmd.CommandText = _sql;
|
|
|
|
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
|
|
|
|
adapter.Fill(dt);
|
|
conn.Close();
|
|
|
|
}
|
|
catch (SqlException ex)
|
|
{
|
|
throw new Exception($"系统无法连接到数据库:{dbSetting},请检查配置的服务器,数据库,用户名和密码等信息是否正确。{Environment.NewLine}{ex}");
|
|
}
|
|
return dt;
|
|
}
|
|
|
|
public static DataTable Get_EC_COLUMNS_List(string p_tableName)
|
|
{
|
|
DataTable dt = new DataTable(); ;
|
|
var dbSetting = GlobalConfig.ExchangeCenterDB;
|
|
try
|
|
{
|
|
|
|
var strConn = EntitiesFactory.GetEfConnectionString(dbSetting);
|
|
SqlConnection conn = new System.Data.SqlClient.SqlConnection();
|
|
//conn.ConnectionString = db.Database.Connection.ConnectionString;
|
|
|
|
conn.ConnectionString = strConn;
|
|
|
|
if (conn.State != ConnectionState.Open)
|
|
{
|
|
conn.Open();
|
|
}
|
|
SqlCommand cmd = new SqlCommand();
|
|
|
|
cmd.Connection = conn;
|
|
string _sql = string.Format("SELECT COLUMN_NAME,DATA_TYPE FROM INFORMATION_SCHEMA.columns WHERE TABLE_NAME='{0}'", p_tableName);
|
|
|
|
cmd.CommandText = _sql;
|
|
|
|
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
|
|
|
|
adapter.Fill(dt);
|
|
conn.Close();
|
|
|
|
}
|
|
catch (SqlException ex)
|
|
{
|
|
throw new Exception($"系统无法连接到数据库:{dbSetting},请检查配置的服务器,数据库,用户名和密码等信息是否正确。{Environment.NewLine}{ex}");
|
|
}
|
|
return dt;
|
|
}
|
|
|
|
|
|
|
|
|
|
public static DataTable Get_EC_COLUMNS_List(DB_CONNECTION p_connection,string p_tableName)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
dt.TableName = p_tableName;
|
|
|
|
var dbSetting = GlobalConfig.ScpDatabase;
|
|
|
|
try
|
|
{
|
|
switch (p_connection)
|
|
{
|
|
case DB_CONNECTION.AppBoxDB:
|
|
dbSetting = GlobalConfig.AppBoxDatabase;
|
|
break;
|
|
case DB_CONNECTION.DataCenterDB:
|
|
dbSetting = GlobalConfig.DataCenterDB;
|
|
break;
|
|
case DB_CONNECTION.ExchangeCenterDB:
|
|
dbSetting = GlobalConfig.ExchangeCenterDB;
|
|
break;
|
|
case DB_CONNECTION.ScpDB:
|
|
dbSetting = GlobalConfig.ScpDatabase;
|
|
break;
|
|
case DB_CONNECTION.UniApiDB:
|
|
dbSetting = GlobalConfig.UniApiDatabase;
|
|
break;
|
|
case DB_CONNECTION.WmsDB:
|
|
dbSetting = GlobalConfig.WmsDatabase;
|
|
break;
|
|
|
|
}
|
|
|
|
var strConn = EntitiesFactory.GetEfConnectionString(dbSetting);
|
|
SqlConnection conn = new System.Data.SqlClient.SqlConnection();
|
|
//conn.ConnectionString = db.Database.Connection.ConnectionString;
|
|
|
|
conn.ConnectionString = strConn;
|
|
|
|
if (conn.State != ConnectionState.Open)
|
|
{
|
|
conn.Open();
|
|
}
|
|
SqlCommand cmd = new SqlCommand();
|
|
|
|
cmd.Connection = conn;
|
|
string _sql = string.Format("SELECT COLUMN_NAME,DATA_TYPE,IS_NULLABLE FROM INFORMATION_SCHEMA.columns WHERE TABLE_NAME='{0}'", p_tableName);
|
|
|
|
cmd.CommandText = _sql;
|
|
|
|
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
|
|
|
|
adapter.Fill(dt);
|
|
conn.Close();
|
|
|
|
}
|
|
catch (SqlException ex)
|
|
{
|
|
throw new Exception($"系统无法连接到数据库:{dbSetting},请检查配置的服务器,数据库,用户名和密码等信息是否正确。{Environment.NewLine}{ex}");
|
|
}
|
|
return dt;
|
|
}
|
|
public static DataTable Get_EC_TABLE_List(string p_tableName)
|
|
{
|
|
DataTable dt = new DataTable(); ;
|
|
var dbSetting = GlobalConfig.ExchangeCenterDB;
|
|
try
|
|
{
|
|
|
|
var strConn = EntitiesFactory.GetEfConnectionString(dbSetting);
|
|
SqlConnection conn = new System.Data.SqlClient.SqlConnection();
|
|
//conn.ConnectionString = db.Database.Connection.ConnectionString;
|
|
|
|
conn.ConnectionString = strConn;
|
|
|
|
if (conn.State != ConnectionState.Open)
|
|
{
|
|
conn.Open();
|
|
}
|
|
SqlCommand cmd = new SqlCommand();
|
|
|
|
cmd.Connection = conn;
|
|
string _sql = string.Format("SELECT * FROM {0}", p_tableName);
|
|
|
|
cmd.CommandText = _sql;
|
|
|
|
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
|
|
|
|
adapter.Fill(dt);
|
|
conn.Close();
|
|
|
|
}
|
|
catch (SqlException ex)
|
|
{
|
|
throw new Exception($"系统无法连接到数据库:{dbSetting},请检查配置的服务器,数据库,用户名和密码等信息是否正确。{Environment.NewLine}{ex}");
|
|
}
|
|
return dt;
|
|
}
|
|
|
|
|
|
public static void Get_TEA_TASK_SUB_List(TEA_TASK_SUB p_entity, Action<ResultObject<IQueryable<TEA_TASK_SUB>>> p_action)
|
|
{
|
|
ResultObject<IQueryable<TEA_TASK_SUB>> _ret = new ResultObject<IQueryable<TEA_TASK_SUB>>();
|
|
try
|
|
{
|
|
using (var db = EntitiesFactory.CreateExchangeCenterInstance())
|
|
{
|
|
IQueryable<TEA_TASK_SUB> q = db.TEA_TASK_SUB;
|
|
if (!string.IsNullOrEmpty(p_entity.TableName))
|
|
{
|
|
q = q.Where(p => p.TableName.Contains(p_entity.TableName));
|
|
}
|
|
if (!string.IsNullOrEmpty(p_entity.Creator))
|
|
{
|
|
q = q.Where(p => p.Creator.Contains(p_entity.Creator));
|
|
}
|
|
if (p_entity.DataCount != 0)
|
|
{
|
|
q = q.Where(p => p.DataCount == p_entity.DataCount);
|
|
}
|
|
if (!string.IsNullOrEmpty(p_entity.Subscriber))
|
|
{
|
|
q = q.Where(p => p.Subscriber.Contains(p_entity.Subscriber));
|
|
}
|
|
if (p_entity.FailedCount != 0)
|
|
{
|
|
q = q.Where(p => p.FailedCount == p_entity.FailedCount);
|
|
}
|
|
if (!string.IsNullOrEmpty(p_entity.FailedInfo))
|
|
{
|
|
q = q.Where(p => p.FailedInfo.Contains(p_entity.FailedInfo));
|
|
}
|
|
if (!string.IsNullOrEmpty(p_entity.Domain))
|
|
{
|
|
q = q.Where(p => p.Domain.Contains(p_entity.Domain));
|
|
}
|
|
if (!string.IsNullOrEmpty(p_entity.Site))
|
|
{
|
|
q = q.Where(p => p.Site.Contains(p_entity.Site));
|
|
}
|
|
if (p_entity.UID != 0)
|
|
{
|
|
q = q.Where(p => p.UID == p_entity.UID);
|
|
}
|
|
if (!string.IsNullOrEmpty(p_entity.CreateUser))
|
|
{
|
|
q = q.Where(p => p.CreateUser.Contains(p_entity.CreateUser));
|
|
}
|
|
if (!string.IsNullOrEmpty(p_entity.Remark))
|
|
{
|
|
q = q.Where(p => p.Remark.Contains(p_entity.Remark));
|
|
}
|
|
if (!string.IsNullOrEmpty(p_entity.UpdateUser))
|
|
{
|
|
q = q.Where(p => p.UpdateUser.Contains(p_entity.UpdateUser));
|
|
}
|
|
if (p_entity.TaskList.Count > 0)
|
|
{
|
|
q = q.Where(p => p_entity.TaskList.Contains(p.TaskState));
|
|
}
|
|
if (p_entity.TaskID != Guid.Empty)
|
|
{
|
|
q = q.Where(p => p_entity.TaskID == p.TaskID);
|
|
}
|
|
|
|
if (p_entity.BeginTime != null)
|
|
{
|
|
q = q.Where(p => p_entity.BeginTime.Value <= p.CreateTime);
|
|
}
|
|
if (p_entity.EndTime != null)
|
|
{
|
|
q = q.Where(p => p_entity.EndTime >= p.CreateTime);
|
|
}
|
|
|
|
_ret.Result = q;
|
|
_ret.State = ReturnStatus.Succeed;
|
|
p_action(_ret);
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
_ret.State = ReturnStatus.Failed;
|
|
_ret.ErrorList.Add(e);
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(TEA_TASK_SUB), "Get_TEA_TASK_SUB_List", e.Message);
|
|
throw e;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
public static ResultObject<bool> Save_TEA_TASK_SUB(List<long> p_listUid, EnumTaskState p_state)
|
|
{
|
|
ResultObject<bool> _ret = new ResultObject<bool>();
|
|
try
|
|
{
|
|
using (var db = EntitiesFactory.CreateExchangeCenterInstance())
|
|
{
|
|
var _lst = db.TEA_TASK_SUB.Where(p => p_listUid.Contains(p.UID)).ToList();
|
|
foreach (var itm in _lst)
|
|
{
|
|
itm.TaskState = p_state;
|
|
db.TEA_TASK_SUB.AddOrUpdate(itm);
|
|
}
|
|
if (db.SaveChanges() != -1)
|
|
{
|
|
_ret.State = ReturnStatus.Succeed;
|
|
_ret.Result = true;
|
|
}
|
|
else
|
|
{
|
|
_ret.State = ReturnStatus.Failed;
|
|
_ret.Result = false;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
_ret.State = ReturnStatus.Failed;
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(TEA_TASK_SUB), "Save_TEA_TASK_SUB", e.Message);
|
|
_ret.Result = false;
|
|
_ret.ErrorList.Add(e);
|
|
throw e;
|
|
}
|
|
return _ret;
|
|
}
|
|
|
|
|
|
|
|
public ResultObject<bool> Del_TEA_TASK_SUB(List<TEA_TASK_SUB> p_entitys)
|
|
{
|
|
ResultObject<bool> _ret = new ResultObject<bool>();
|
|
try
|
|
{
|
|
using (var db = EntitiesFactory.CreateExchangeCenterInstance())
|
|
{
|
|
foreach (var itm in p_entitys)
|
|
{
|
|
db.TEA_TASK_SUB.Remove(itm);
|
|
}
|
|
if (db.SaveChanges() != -1)
|
|
{
|
|
_ret.State = ReturnStatus.Succeed;
|
|
_ret.Result = true;
|
|
}
|
|
else
|
|
{
|
|
_ret.State = ReturnStatus.Failed;
|
|
_ret.Result = false;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
_ret.State = ReturnStatus.Failed;
|
|
_ret.Result = false;
|
|
_ret.ErrorList.Add(e);
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(TEA_TASK_SUB), "Del_TEA_TASK_SUB", e.Message); throw e;
|
|
}
|
|
return _ret;
|
|
}
|
|
|
|
public static ResultObject<List<TEA_SUBSCRIBE>> Get_TEA_SUBSCRIBE_List(TEA_SUBSCRIBE p_entity)
|
|
{
|
|
ResultObject<List<TEA_SUBSCRIBE>> _ret = new ResultObject<List<TEA_SUBSCRIBE>>();
|
|
try
|
|
{
|
|
using (var db = EntitiesFactory.CreateExchangeCenterInstance())
|
|
{
|
|
IQueryable<TEA_SUBSCRIBE> q = db.TEA_SUBSCRIBE;
|
|
if (!string.IsNullOrEmpty(p_entity.TableName))
|
|
{
|
|
q = q.Where(p => p.TableName.Contains(p_entity.TableName));
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.Subscriber))
|
|
{
|
|
q = q.Where(p => p.Subscriber.Contains(p_entity.Subscriber));
|
|
}
|
|
if (p_entity.UID != 0)
|
|
{
|
|
q = q.Where(p => p.UID == p_entity.UID);
|
|
}
|
|
|
|
|
|
_ret.State = ReturnStatus.Succeed;
|
|
_ret.Result = q.ToList();
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
_ret.State = ReturnStatus.Failed;
|
|
_ret.ErrorList.Add(e);
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(TEA_SUBSCRIBE), "Get_TEA_SUBSCRIBE_List", e.Message);
|
|
throw e;
|
|
}
|
|
return _ret;
|
|
}
|
|
|
|
|
|
public static ResultObject<bool> Save_TEA_SUBSCRIBE(List<TEA_SUBSCRIBE> p_entitys)
|
|
{
|
|
ResultObject<bool> _ret = new ResultObject<bool>();
|
|
try
|
|
{
|
|
using (var db = EntitiesFactory.CreateExchangeCenterInstance())
|
|
{
|
|
foreach (var itm in p_entitys)
|
|
{
|
|
db.TEA_SUBSCRIBE.AddOrUpdate(itm);
|
|
}
|
|
if (db.SaveChanges() != -1)
|
|
{
|
|
_ret.State = ReturnStatus.Succeed;
|
|
_ret.Result = true;
|
|
}
|
|
else
|
|
{
|
|
_ret.State = ReturnStatus.Failed;
|
|
_ret.Result = false;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
_ret.State = ReturnStatus.Failed;
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(TEA_SUBSCRIBE), "Save_TEA_SUBSCRIBE", e.Message);
|
|
_ret.Result = false;
|
|
_ret.ErrorList.Add(e);
|
|
throw e;
|
|
}
|
|
return _ret;
|
|
}
|
|
|
|
|
|
|
|
public static ResultObject<bool> Del_TEA_SUBSCRIBE(List<int> p_list)
|
|
{
|
|
ResultObject<bool> _ret = new ResultObject<bool>();
|
|
try
|
|
{
|
|
using (var db = EntitiesFactory.CreateExchangeCenterInstance())
|
|
{
|
|
|
|
var _entitys= db.TEA_SUBSCRIBE.Where(p => p_list.Contains(p.UID)).ToList();
|
|
|
|
|
|
foreach (var itm in _entitys)
|
|
{
|
|
db.TEA_SUBSCRIBE.Remove(itm);
|
|
}
|
|
if (db.SaveChanges() != -1)
|
|
{
|
|
_ret.State = ReturnStatus.Succeed;
|
|
_ret.Result = true;
|
|
}
|
|
else
|
|
{
|
|
_ret.State = ReturnStatus.Failed;
|
|
_ret.Result = false;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
_ret.State = ReturnStatus.Failed;
|
|
_ret.Result = false;
|
|
_ret.ErrorList.Add(e);
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(TEA_SUBSCRIBE), "Del_TEA_SUBSCRIBE", e.Message); throw e;
|
|
}
|
|
return _ret;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|