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

112 lines
4.1 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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.WPHCirclePromotion.Entitys;
using Weixin.WPHCirclePromotion.Properties;
namespace Weixin.WPHCirclePromotion
{
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_wphcirclepromotion_goodsinfos>()) session.CreateTable<fl_plugin_wphcirclepromotion_goodsinfos>();
//如果存在原来的表将来的数据导入到新的表中,在原来的表给删除
if (session.TableExist<fl_plugin_wphcirclepromotion_wphtgw>())
{
var pddtgws = session.Find<fl_plugin_wphcirclepromotion_wphtgw>("select * from fl_plugin_wphcirclepromotion_wphtgw").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_wphcirclepromotion_wphtgw>();
}
#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);
}
}
}
}