old_flsystem/应用/Weixin.CircleTools/Class1.cs

139 lines
5.1 KiB
C#
Raw Normal View History

2022-09-20 03:10:29 +00:00
using Api.Framework;
using Api.Framework.SDK;
using Weixin.CircleTools.Properties;
using Api.Framework.Tools;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Weixin.CircleTools.Entitys;
using Weixin.CircleTools;
using Api.Framework.Enums;
using Api.Framework.Model;
namespace CircleFriendsTools
{
public class Class1 : Plugin
{
public Class1()
{
this.Logo = Resources.;
this.Name = Resources.PluginName;
this.Note = Resources.PluginNote;
}
#region
public static Config Config = null;
private MainForm mainForm = null;
public static StringBuilder strb = new StringBuilder();
#endregion
public override void Start()
{
try
{
var session = ApiClient.GetSession();
if (!session.TableExist<fl_plugin_circletools_taskinfos>()) session.CreateTable<fl_plugin_circletools_taskinfos>();
else
{
if (!session.ColumnExist("fl_plugin_circletools_taskinfos", "task_comment"))
{
session.AddColumn("fl_plugin_circletools_taskinfos", "task_comment", "text");
}
if (!session.ColumnExist("fl_plugin_circletools_taskinfos", "robotnames"))
{
session.AddColumn("fl_plugin_circletools_taskinfos", "robotnames", "text");
session.ExcuteSQL("update fl_plugin_circletools_taskinfos set robotnames = '" + string.Join(",", session.FindRobots().Select(f => f.name)) + "'");
}
2022-09-23 06:48:20 +00:00
try
{
session.UpdateColumnType("fl_plugin_circletools_taskinfos", "robotnames", "text");
}
catch (Exception)
{ }
2022-09-20 03:10:29 +00:00
}
if (session.TableExist<fl_plugin_circletools_tgw>())
{
var tbtgws = session.Find<fl_plugin_circletools_tgw>("select * from fl_plugin_circletools_tgw").ToList();
if (tbtgws != null)
{
foreach (var item in tbtgws)
{
session.Insertable(new fl_adzone_info()
{
adzone_name = item.pid_name, //推广位名称
adzone_pid = item.pid, //推广位pid
adzone_pid_cps_name = item.pid_cps_name, //推广位cps名称
alliance_id = (int)CpsType., //联盟id
robot_id = item.robot_id, //机器人id
group_id = string.Empty, //群id
is_download = false, //不下载
member_id = 0, //私人id
onoff = item.onoff, //不禁用
custom_type = Resources.SoftwareType //自定义类型
}).ExecuteCommand();
}
}
session.DropTable<fl_plugin_circletools_tgw>();
}
Config = this.ReadConfig<Config>();
var thread = TimerTask.NewTimer<MonitorThread>(1) as MonitorThread; //创建线程 - 监听好友朋友圈和接口的线程 1秒
2022-09-22 03:39:51 +00:00
thread.Init();
2022-09-20 03:10:29 +00:00
thread.plugin = this;
}
catch (Exception ex)
{
this.OnLog(ex.Message);
}
}
public override void ShowForm()
{
try
{
if (Config.transpond_send_usernames == null)
{
Config.transpond_send_usernames = new List<string>();
Config.transpond_send_usernames = Chat.Framework.ChatClient.WXClient.Values.ToList().Select(f => f.WeixinHao.Trim()).ToList();
}
if (mainForm == null || mainForm.IsDisposed)
{
mainForm = new MainForm();
mainForm.Show();
}
mainForm.TopMost = true;
mainForm.TopMost = false;
}
catch (Exception ex)
{
this.OnLog(ex.Message);
}
}
public override void Stop()
{
try
{
TimerTask.Close<MonitorThread>();
SessionExt.Clear();
if (mainForm != null)
{
mainForm.CloseForm();
mainForm = null;
}
}
catch (Exception ex)
{
this.OnLog(ex.Message);
}
}
}
}