80 lines
3.5 KiB
C#
80 lines
3.5 KiB
C#
using Api.Framework;
|
|
using Api.Framework.Enums;
|
|
using Api.Framework.Tools;
|
|
using SqlSugar;
|
|
using System.Collections.Generic;
|
|
using Weixin.CircleTools.Entitys;
|
|
using Weixin.CircleTools.Properties;
|
|
|
|
namespace Weixin.CircleTools
|
|
{
|
|
public static class SessionExt
|
|
{
|
|
const string taskinfos_temp_list = "taskinfos_temp_list";
|
|
public static List<fl_plugin_circletools_taskinfos> FindTaskInfosTempGroups(this SqlSugarClient session, bool refresh = false)
|
|
{
|
|
for (int i = 0; i < 2; i++)
|
|
{
|
|
try
|
|
{
|
|
var pddinfo_temp_groups = ApiClient.Cache.Get<List<fl_plugin_circletools_taskinfos>>(taskinfos_temp_list);//根据KEY、获得缓存
|
|
if (refresh || pddinfo_temp_groups == null)
|
|
{
|
|
pddinfo_temp_groups = session.Find<fl_plugin_circletools_taskinfos>("select * from fl_plugin_circletools_taskinfos");
|
|
ApiClient.Cache.Set(taskinfos_temp_list, pddinfo_temp_groups, 60);
|
|
}
|
|
return pddinfo_temp_groups;
|
|
}
|
|
catch (System.Exception)
|
|
{
|
|
ApiClient.Cache.Remove(taskinfos_temp_list);
|
|
continue;
|
|
}
|
|
}
|
|
return new List<fl_plugin_circletools_taskinfos>();
|
|
}
|
|
|
|
|
|
//-------------------------------------------------------------------------------
|
|
|
|
|
|
const string tbinfo_temp_list_adzones = "tbinfo_temp_list_adzones";
|
|
|
|
/// <summary>
|
|
/// 获取fl_plugin_tbrebate_tbtgw表的数据集合缓存
|
|
/// </summary>
|
|
/// <param name="session"></param>
|
|
/// <param name="refresh">刷新</param>
|
|
/// <returns></returns>
|
|
public static List<tbinfo_temp> FindTbInfoTempGroups(this SqlSugarClient session, bool refresh = false)
|
|
{
|
|
for (int i = 0; i < 2; i++)
|
|
{
|
|
try
|
|
{
|
|
var tbinfo_temp_groups = ApiClient.Cache.Get<List<tbinfo_temp>>(tbinfo_temp_list_adzones);//根据KEY、获得缓存
|
|
if (refresh || tbinfo_temp_groups == null)
|
|
{
|
|
tbinfo_temp_groups = session.Find<tbinfo_temp>($"select ri.id as ID,ri.type as chattype,ri.name as name,ri.nick as nick,flag.adzone_pid as adzone_pid,flag.adzone_name as adzone_name,flag.onoff as onoff,flag.adzone_pid_cps_name as adzone_pid_cps_name from fl_robot_info ri left join (select r.id as ID,r.type as chattype,r.name as name,r.nick as nick,a.adzone_pid as adzone_pid,a.adzone_name as adzone_name,a.onoff as onoff,a.adzone_pid_cps_name as adzone_pid_cps_name from fl_robot_info r left join fl_adzone_info a on r.id = a.robot_id where alliance_id = @allianceId and custom_type = @customType) flag on ri.id = flag.ID", new { allianceId = (int)CpsType.阿里妈妈, customType = Resources.SoftwareType });
|
|
ApiClient.Cache.Set(tbinfo_temp_list_adzones, tbinfo_temp_groups, 60);
|
|
}
|
|
return tbinfo_temp_groups;
|
|
}
|
|
catch (System.Exception)
|
|
{
|
|
ApiClient.Cache.Remove(tbinfo_temp_list_adzones);
|
|
continue;
|
|
}
|
|
}
|
|
return new List<tbinfo_temp>();
|
|
}
|
|
|
|
public static void Clear()
|
|
{
|
|
ApiClient.Cache.Remove(taskinfos_temp_list);
|
|
ApiClient.Cache.Remove(tbinfo_temp_list_adzones);
|
|
}
|
|
|
|
}
|
|
}
|