102 lines
2.8 KiB
C#
102 lines
2.8 KiB
C#
|
using Api.Framework;
|
|||
|
using Api.Framework.SDK;
|
|||
|
using Api.Framework.Tools;
|
|||
|
using EncourageUser.Entitys;
|
|||
|
using EncourageUser.Properties;
|
|||
|
using SqlSugar;
|
|||
|
using System;
|
|||
|
using System.Collections.Concurrent;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
|
|||
|
namespace EncourageUser
|
|||
|
{
|
|||
|
public class Class1 : Plugin
|
|||
|
{
|
|||
|
public Class1()
|
|||
|
{
|
|||
|
this.Name = Resources.PluginName;
|
|||
|
this.Note = Resources.PluginNote;
|
|||
|
this.Logo = Resources.群发;
|
|||
|
}
|
|||
|
|
|||
|
#region 自定义变量
|
|||
|
private MainForm mainForm = null;
|
|||
|
#endregion
|
|||
|
|
|||
|
public override void Start()
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
var session = ApiClient.GetSession();
|
|||
|
#region 判断表是否存在,不存在创建表
|
|||
|
if (!session.TableExist<fl_plugin_encourage_user_messs>())
|
|||
|
{
|
|||
|
session.CreateTable<fl_plugin_encourage_user_messs>();
|
|||
|
session.AddUnique<fl_plugin_encourage_user_messs>("note");
|
|||
|
|
|||
|
session.Insertable(new fl_plugin_encourage_user_messs() { note = "测试", mess = "本条为测试消息" }).ExecuteCommand();
|
|||
|
}
|
|||
|
|
|||
|
if (!session.TableExist<fl_qunfa_task>())
|
|||
|
{
|
|||
|
session.CreateTable<fl_qunfa_task>();
|
|||
|
}
|
|||
|
|
|||
|
if (!session.TableExist<fl_qunfa_user>())
|
|||
|
{
|
|||
|
session.CreateTable<fl_qunfa_user>();
|
|||
|
session.AddIndex<fl_qunfa_user>("taskid", "issend", "sendtime");
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
var thread = TimerTask.NewTimer<TaskJob>(30) as TaskJob; //创建线程 - 监听好友朋友圈和接口的线程 1秒
|
|||
|
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
this.OnLog(ex.Message);
|
|||
|
}
|
|||
|
}
|
|||
|
public override void ShowForm()
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
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
|
|||
|
{
|
|||
|
if (mainForm != null)
|
|||
|
{
|
|||
|
mainForm.CloseForm();
|
|||
|
mainForm = null;
|
|||
|
}
|
|||
|
|
|||
|
TaskJob.AbortAll();
|
|||
|
TimerTask.Close<TaskJob>();
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
this.OnLog(ex.Message);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
}
|