112 lines
4.0 KiB
C#
112 lines
4.0 KiB
C#
|
using Api.Framework;
|
|||
|
using Api.Framework.Enums;
|
|||
|
using Api.Framework.Model;
|
|||
|
using Api.Framework.SDK;
|
|||
|
using Api.Framework.Tools;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
using Weixin.SNCirclePromotion.Entitys;
|
|||
|
using Weixin.SNCirclePromotion.Properties;
|
|||
|
|
|||
|
namespace Weixin.SNCirclePromotion
|
|||
|
{
|
|||
|
public class Class1 : Plugin
|
|||
|
{
|
|||
|
public Class1()
|
|||
|
{
|
|||
|
this.Logo = Resources.苏宁发单;
|
|||
|
this.Name = Resources.PluginName;
|
|||
|
this.Note = Resources.PluginNote;
|
|||
|
}
|
|||
|
|
|||
|
#region 自定义变量
|
|||
|
public static Config Config;
|
|||
|
private MainForm mainForm = null;
|
|||
|
#endregion
|
|||
|
|
|||
|
public override void Start()
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
var session = ApiClient.GetSession();
|
|||
|
#region 判断表是否存在,不存在创建表
|
|||
|
if (!session.TableExist<fl_plugin_sncirclepromotion_goodsinfos>()) session.CreateTable<fl_plugin_sncirclepromotion_goodsinfos>();
|
|||
|
|
|||
|
//如果存在原来的表将来的数据导入到新的表中,在原来的表给删除
|
|||
|
if (session.TableExist<fl_plugin_sncirclepromotion_sntgw>())
|
|||
|
{
|
|||
|
var pddtgws = session.Find<fl_plugin_sncirclepromotion_sntgw>("select * from fl_plugin_sncirclepromotion_sntgw").ToList();
|
|||
|
if (pddtgws != null)
|
|||
|
{
|
|||
|
foreach (var item in pddtgws)
|
|||
|
{
|
|||
|
session.Insertable<fl_adzone_info>(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_sncirclepromotion_sntgw>();
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
Config = this.ReadConfig<Config>(); //创建配置文件
|
|||
|
TimerTask.NewTimer<SendCircleFriendThread>(60); //创建线程 - 发送朋友圈的线程 60秒
|
|||
|
}
|
|||
|
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
|
|||
|
{
|
|||
|
TimerTask.Close<SendCircleFriendThread>(); //关闭线程
|
|||
|
if (mainForm != null)
|
|||
|
{
|
|||
|
mainForm.CloseForm(); //关闭窗体
|
|||
|
mainForm = null;
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
this.OnLog(ex.Message);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|