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

120 lines
4.2 KiB
C#
Raw Normal View History

2022-09-20 03:10:29 +00:00
using Api.Framework;
using Api.Framework.Enums;
using Api.Framework.Model;
using Api.Framework.SDK;
using Api.Framework.Tools;
using System;
using System.Linq;
using Weixin.TBCirclePromotion.Entitys;
using Weixin.TBCirclePromotion.Properties;
namespace Weixin.TBCirclePromotion
{
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
/// <summary>
///
/// </summary>
public override void Start()
{
var session = ApiClient.GetSession();
#region
if (!session.TableExist<fl_plugin_tbcirclepromotion_goodsinfos>()) session.CreateTable<fl_plugin_tbcirclepromotion_goodsinfos>();
else
{
if (!session.ColumnExist("fl_plugin_tbcirclepromotion_goodsinfos", "goods_quan"))
session.AddColumn("fl_plugin_tbcirclepromotion_goodsinfos", "goods_quan", "varchar(255) default ''");
}
//如果存在原来的表将来的数据导入到新的表中,在原来的表给删除
if (session.TableExist<fl_plugin_tbcirclepromotion_tbtgw>())
{
var tbtgws = session.Find<fl_plugin_tbcirclepromotion_tbtgw>("select * from fl_plugin_tbcirclepromotion_tbtgw").ToList();
if (tbtgws != null)
{
foreach (var item in tbtgws)
{
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_tbcirclepromotion_tbtgw>();
}
#endregion
//创建配置文件
try
{
Config = this.ReadConfig<Config>();
Tools.GetBaseIco();//检测优惠券底图
}
catch (Exception ex)
{
this.OnLog(ex.Message);
}
//创建线程
TimerTask.NewTimer<SendCircleFriendThread>(60); //创建线程 - 发送朋友圈的线程 60秒
}
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);
}
}
}
}