2022-09-20 03:10:29 +00:00
using Api.Framework ;
using Api.Framework.Cps ;
using Api.Framework.Enums ;
using Api.Framework.Events ;
using Api.Framework.Model ;
using Api.Framework.SDK ;
using Api.Framework.Tools ;
using Api.Framework.Utils ;
using Chat.Framework ;
using Chat.Framework.QQSdk ;
using Chat.Framework.QQSdk.Events ;
using Chat.Framework.WXSdk ;
using Chat.Framework.WXSdk.Implement ;
using CsharpHttpHelper ;
using DevExpress.XtraBars ;
using DevExpress.XtraEditors ;
using DevExpress.XtraTab ;
using FLSystem.Events ;
using FLSystem.Properties ;
using FLSystem.Win32Api ;
using GeneralFramework ;
using Grant.Framework ;
using Newtonsoft.Json ;
using Newtonsoft.Json.Linq ;
using PCRobot.Pack ;
using System ;
using System.Collections ;
using System.Collections.Generic ;
using System.Diagnostics ;
using System.Drawing ;
using System.IO ;
using System.Linq ;
using System.Reflection ;
using System.Text ;
using System.Threading ;
using System.Threading.Tasks ;
using System.Windows.Forms ;
using Microsoft.Win32 ;
using UI.Framework.Controls ;
using UI.Framework.Forms ;
using UI.Framework.Tools ;
using static Api . Framework . Tools . TBHelper ;
namespace FLSystem.Forms
{
public partial class main : BaseForm
{
public main ( )
{
InitializeComponent ( ) ;
#region 锁 屏
timeClear = new TimerClearEventHandler ( Time_Clear ) ; //如果操作了系统,则重新计时
mouseKeyHook . KeyDown + = new KeyEventHandler ( mouseKeyHook_KeyDown ) ;
mouseKeyHook . KeyUp + = new KeyEventHandler ( mouseKeyHook_KeyUp ) ;
mouseKeyHook . KeyPress + = new KeyPressEventHandler ( mouseKeyHook_KeyPress ) ;
mouseKeyHook . OnMouseActivity + = new MouseEventHandler ( mouseKeyHook_OnMouseActivity ) ;
mouseKeyHook . Start ( true , true ) ;
#endregion
}
#region 锁 主 程 序
public delegate void TimerClearEventHandler ( ) ;
public delegate void ShowTimeEventHandler ( ) ;
private MouseKeyHook mouseKeyHook = new MouseKeyHook ( true , true ) ;
public bool lockState = false ;
private bool timerEnable = false ;
private TimerClearEventHandler timeClear ;
private void Time_Clear ( )
{
if ( timerEnable )
{
this . timer1 . Stop ( ) ;
this . timer1 . Start ( ) ;
}
}
void mouseKeyHook_OnMouseActivity ( object sender , MouseEventArgs e ) { this . Invoke ( this . timeClear ) ; }
void mouseKeyHook_KeyPress ( object sender , KeyPressEventArgs e ) { this . Invoke ( this . timeClear ) ; }
void mouseKeyHook_KeyUp ( object sender , KeyEventArgs e ) { this . Invoke ( this . timeClear ) ; }
void mouseKeyHook_KeyDown ( object sender , KeyEventArgs e ) { this . Invoke ( this . timeClear ) ; }
#endregion
KeyboardHook kh ;
/// <summary>
/// 同步黑名单
/// </summary>
private System . Timers . Timer timerBlackUser = null ;
public void main_Load ( object sender , EventArgs e )
{
try
{
DevExpress . UserSkins . BonusSkins . Register ( ) ;
DevExpress . Skins . SkinManager . EnableFormSkins ( ) ;
DevExpress . Utils . WXPaint . WXPPainter . Default . ThemeChanged + = Default_ThemeChanged ;
GrantClient . Get ( ) . LodingAbout ( 1003 , Program . ReadICO ( ) ) ;
if ( ! ApiClient . SelectDbbase ( ) ) Program . Exit ( ) ;
var skin = Util . AppConfig_GetValue ( "SkinName" ) ;
//DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle(skin == "Basic" ? "The Bezier" : skin);
if ( ! Util . AppConfig_ExistItem ( "ShowTgwz" ) )
Util . AppConfig_AddItem ( "ShowTgwz" , "0" ) ;
Util . AppConfig_ModifyItem ( "ShowTgwz" , "1" ) ;
if ( ! Util . AppConfig_ExistItem ( "StartDy" ) )
Util . AppConfig_AddItem ( "StartDy" , "0" ) ;
Util . AppConfig_ModifyItem ( "StartDy" , "1" ) ;
if ( ! Util . AppConfig_ExistItem ( "BlackUserTime" ) )
Util . AppConfig_AddItem ( "BlackUserTime" , " " ) ;
#region 菜 单 导 航 栏
if ( ! Util . AppConfig_ExistItem ( "Nav" ) )
Util . AppConfig_AddItem ( "Nav" , "" ) ;
var navConfig = Util . AppConfig_GetValue ( "Nav" ) ;
if ( ! string . IsNullOrWhiteSpace ( navConfig ) )
{
try
{
var jsonData = PackTool . DecompressString ( navConfig ) ;
var treeList = JsonConvert . DeserializeObject < List < NavTree > > ( jsonData ) ;
var indexList = treeList . GroupBy ( f = > f . index ) . Select ( f = > f . Key ) . ToList ( ) ;
for ( int i = 0 ; i < indexList . Count ; i + + )
{
var tree = treeList . FirstOrDefault ( f = > f . ceng = = 1 & & f . index = = i ) ;
if ( tree ! = null )
{
if ( i = = 0 )
{
if ( ! tree . check )
ribbonPage1 . Visible = false ;
else
SetShow ( treeList , i ) ;
}
else if ( i = = 1 )
{
if ( ! tree . check )
ribbonPage2 . Visible = false ;
else
SetShow ( treeList , i ) ;
}
else if ( i = = 2 )
{
if ( ! tree . check )
ribbonPage3 . Visible = false ;
else
SetShow ( treeList , i ) ;
}
else if ( i = = 3 )
{
if ( ! tree . check )
ribbonPage4 . Visible = false ;
else
SetShow ( treeList , i ) ;
}
else if ( i = = 4 )
{
var t2List = treeList . Where ( f = > f . ceng = = 2 & & f . index = = i & & f . check ) . Select ( f = > f . name ) . ToList ( ) ;
ApiClient . ShowPluginList = t2List ;
}
}
}
}
catch ( Exception )
{ }
}
#endregion
//if (!Util.AppConfig_ExistItem("WphNav"))
// Util.AppConfig_AddItem("WphNav", "0");
this . Text = GrantClient . Get ( ) . About [ "title" ] . ToString ( ) ;
this . notify_pallet . Text = this . Text ;
Loding . ShowWaitForm ( ) ;
var result = ApiClient . Initialization ( ) ;
//ChatMemberHandleEvent.FindChatObject += ChatMemberHandleEvent_FindChatObject;
//ChatMemberHandleEvent.UpdateChatFriends += ChatMemberHandleEvent_UpdateChatFriends;
//ChatMemberHandleEvent.UpdateChatGroupMembers += ChatMemberHandleEvent_UpdateChatGroupMembers;
if ( ! result ) Program . Exit ( ) ;
AlimamaApi . Init ( ) ;
Loding . CloseWaitForm ( ) ;
//btn_home_manage.Visibility = BarItemVisibility.Never;
ItemClick ( btn_home_manage , null ) ; //显示首页
ItemClick ( btn_log_manage , null ) ; //显示日志
try
{
ApiClient . SocketInitialization ( ) ;
}
catch ( Exception ex )
{
ShowErrorAutoClose ( ex , 10000 ) ;
}
//TODO 禁用抖音禁用
var StartDy = Util . AppConfig_GetValue ( "StartDy" ) ;
if ( StartDy = = "1" )
{
barButtonItem_douyin . Enabled = barButtonItem99 . Enabled = barButtonItem100 . Enabled = true ;
ItemClick ( barButtonItem_douyin , null ) ;
}
var session = ApiClient . GetSession ( ) ;
Thread . Sleep ( 200 ) ;
this . Icon = Program . ReadICO ( ) ;
this . notify_pallet . Icon = this . Icon ;
EventClient . MethodEvent + = EventClient_MethodEvent ;
MainEvent . CommonEvents + = Main_CommonEvents ;
this . Disposed + = Control_Disposed ;
ReadNote ( false ) ;
barStaticItem12 . Caption = "专业版V" + ApiClient . CurVersion ;
this . xtraTabControl1 . SelectedTabPageIndex = 0 ;
RefreshAccount ( ) ;
ChatClient . MessFrequentSleepTime = ApiClient . Setting . SystemConfig . mess_frequent_sleep_time ;
//ChatClient.QQPool.LoginChangeEvent += QQPool_LoginChangeEvent;
ChatClient . Events . WXRefreshUserEvent + = Events_WXRefreshUserEvent ;
ChatClient . Events . WXChangeStatusEvent + = Events_WXChangeStatusEvent ;
ChatClient . QQEvents . QQRefreshUserEvent + = Events_QQRefreshUserEvent ;
ChatClient . QQEvents . LoginChangeEvent + = QQEvents_LoginChangeEvent ;
EventClient . SharedEvent + = EventClient_SharedEvent ;
UpdTime ( ) ;
//new Utils();
EventClient . OnEvent ( this , MethodType . 刷 新 配 置 文 件 ) ;
#region 精 简 消 息
System . ComponentModel . ComponentResourceManager resources = new System . ComponentModel . ComponentResourceManager ( typeof ( main ) ) ;
this . barButtonItem9 . ImageOptions . Image = ( System . Drawing . Image ) ( resources . GetObject ( "barButtonItem10.ImageOptions.Image" ) ) ;
this . barButtonItem9 . ImageOptions . LargeImage = global :: FLSystem . Properties . Resources . 停 止 __4_ ;
this . barButtonItem9 . Caption = "停止接收" ;
if ( ApiClient . Setting . SystemConfig . message_warning_switch )
{
this . barButtonItem93 . Caption = "关闭【双12】模式" ;
this . barButtonItem93 . ImageOptions . Image = ( System . Drawing . Image ) ( resources . GetObject ( "barButtonItem93.ImageOptions.Image" ) ) ;
this . barButtonItem93 . ImageOptions . LargeImage = ( System . Drawing . Image ) ( resources . GetObject ( "barButtonItem93.ImageOptions.LargeImage" ) ) ;
}
else
{
this . barButtonItem93 . Caption = "开启【双12】模式" ;
this . barButtonItem93 . ImageOptions . Image = ( ( System . Drawing . Image ) ( resources . GetObject ( "barButtonItem94.ImageOptions.Image" ) ) ) ;
this . barButtonItem93 . ImageOptions . LargeImage = ( ( System . Drawing . Image ) ( resources . GetObject ( "barButtonItem94.ImageOptions.LargeImage" ) ) ) ;
}
#endregion
#region ipad协议出现remark为PCWechat Hook的情况 , 导 致 无 法 手 动 自 动 登 陆 ( 修 改 为 空 值 )
var _robots = session . FindRobots ( ) . Where ( f = > f . type = = ChatType . 微 信 & & f . remark = = "PCWechat HOOK" & & f . token . StartsWith ( @"{""data"":" ) ) ;
foreach ( var item in _robots )
{
item . remark = string . Empty ;
session . SaveOrUpdate ( item ) ;
}
#endregion
var WxRobots = session . FindRobots ( true ) . Where ( f = > f . is_login & & f . type = = ChatType . 微 信 & & f . remark ! = "PCWechat HOOK" ) . ToList ( ) ;
TaskTool tasks = new TaskTool ( ) ;
if ( WxRobots . Count ! = 0 )
{
if ( BaseForm . ShowSuccessAutoClose ( @ "对不起,由于近期个别微信有出现封号!
为 了 您 的 账 号 安 全 , 暂 时 不 提 供 协 议 登 陆 !
请 下 载 【 易 转 发 - 微 信 官 方 客 户 端 】 登 陆 , 保 障 您 的 账 号 安 全 !
- - - - - - - - - - - - -
下 载 地 址 已 复 制 到 剪 切 板 , 请 粘 贴 到 浏 览 器 下 载
- - - - - - - - - - - - -
注 意 : 如 果 您 执 意 要 通 过 协 议 登 陆 , 请 点 击 确 定 ! ! ! ", new DialogResult[] { DialogResult.OK, DialogResult.Cancel }, 0) == DialogResult.OK)
{
foreach ( var item in WxRobots )
{
var _item = item ;
tasks . AddTask ( delegate ( )
{
try
{
EventClient . OnEvent ( this , $"正在自动微信->{_item.nick}({item.name})..." ) ;
var flag = ChatClient . LoginWeixin ( _item . name , _item . token ) ;
}
catch ( Exception ex )
{
EventClient . OnEvent ( this , $"登录微信->{_item.nick}({item.name})异常:{ex.Message}" ) ;
}
} ) ;
}
}
else
{
try
{
Clipboard . SetDataObject ( Resources . 易 转 发 下 载 地 址 + "?=" + new Random ( ) . Next ( 100 , 2000 ) ) ;
}
catch ( Exception ex )
{ }
}
}
var QQRobots = session . FindRobots ( true ) . Where ( f = > f . is_login & & f . type = = ChatType . QQ ) . ToList ( ) ;
if ( QQRobots ! = null & & QQRobots . Count ! = 0 )
{
foreach ( var item in QQRobots )
{
var QQRobot = item ;
tasks . AddTask ( delegate ( )
{
try
{
EventClient . OnEvent ( this , $"正在自动QQ->{QQRobot.nick}({QQRobot.name})..." ) ;
if ( ! string . IsNullOrWhiteSpace ( QQRobot . token ) )
{
var dic = HttpExtend . JsonToDictionary ( Encoding . UTF8 . GetString ( HttpExtend . HexToByte ( QQRobot . token ) ) ) ;
if ( dic ! = null )
{
if ( dic . ContainsKey ( "QQ" ) )
{
var QQ = dic [ "QQ" ] ? . ToString ( ) ;
if ( ! string . IsNullOrWhiteSpace ( QQ ) & & dic . ContainsKey ( "Password" ) )
{
var Password = dic [ "Password" ] ? . ToString ( ) ;
var qq = uint . Parse ( QQ ) ;
if ( ChatClient . QQClients . ContainsKey ( QQ ) )
{
var qBase = ChatClient . QQClients [ QQ ] ;
qBase . Login ( ) ;
}
else
{
//QQ自动登录
var IsEQQ = false ;
if ( ! string . IsNullOrWhiteSpace ( Password ) & & dic . ContainsKey ( "IsEQQ" ) )
IsEQQ = ( dic [ "IsEQQ" ] . ToString ( ) . ToLower ( ) = = "true" ) ;
var qqClient = ChatClient . LoginQQ ( QQ , Password ) ;
}
}
}
}
}
}
catch ( Exception ex )
{
EventClient . OnEvent ( this , $"登录QQ->{QQRobot.nick}({QQRobot.name})异常:{ex.Message},{ex.StackTrace}" ) ;
}
} ) ;
Thread . Sleep ( 500 ) ;
}
}
tasks . Start ( 30 , AsyncCallbackMethod ) ;
EventClient . OnEvent ( this , MethodType . 刷 新 机 器 人 ) ;
ChatClient . WXSdkConfig . IsDebug = false ;
ChatClient . WXSdkConfig . MsgConvertToFriend = ApiClient . Setting . SystemConfig . msg_wx_convertswich = = SwitchType . 开 启 ? true : false ;
isLodingOk = true ;
kh = new KeyboardHook ( ) ;
kh . SetHook ( ) ;
kh . OnKeyDownEvent + = kh_OnKeyDownEvent ;
System . Timers . Timer timerLok = new System . Timers . Timer ( ) ;
timerLok . Elapsed + = timer_lockForm_Tick ;
timerLok . Interval = 5 * 60000 ; //测试1分钟锁屏
timerLok . Start ( ) ;
#region 激 活 抖 音 xxx
//TODO 禁用抖音禁用
//if (StartDy == "1")
//{
// TaskTool tasks_douyin = new TaskTool();
// var douyinMember = CpsClient.Members.Where(f => f.cpstype == CpsType.抖音联盟 /*&& f.is_download == SwitchType.开启*/).ToList();
// if (douyinMember != null && douyinMember.Count != 0)
// {
//抖音单登版本EO
//if (douyinMember.Count > 1)
//{
// for (int i = 1; i < douyinMember.Count; i++)
// {
// session.Delete(douyinMember[i]);
// CpsClient.Members.Remove(douyinMember[i]);
// }
//}
//抖音多版本EO
//foreach (var item in douyinMember)
//{
// var _item = item;
// try
// {
// _item.is_valid = true;
// _item.online = false;
// EventClient.OnEvent(this, $"激活抖音->{_item.usernick}({item.username})...");
// var api = CpsClient.CreateDouyinRequest(_item);
// var form = new douyin_form_login1();
// DouyinApi.douyinApiAction?.Invoke(api);
// form.Show();
// //抖音隐藏
// if (ApiClient.Setting.SystemConfig.hidedy && !string.IsNullOrWhiteSpace(api.Member.username))
// form.Hide();
// }
// catch (Exception ex)
// {
// EventClient.OnEvent(this, $"激活抖音->{_item.usernick}({item.username})异常:{ex.Message}");
// }
// Thread.Sleep(500);
//}
// }
//}
#endregion
2022-10-08 04:22:46 +00:00
#region 唯 品 会
//var wphCount = CpsClient.Members.Count(f => f.cpstype == CpsType.唯品联盟);
2022-09-20 03:10:29 +00:00
2022-10-08 04:22:46 +00:00
//var robots = session.FindRobots();
////if (wphCount == 0 && (WphNav == null || WphNav == "0"))
//if (wphCount == 0 && robots != null && robots.Count != 0)
//{
// if (!Util.AppConfig_ExistItem("ShowWphAd"))
// Util.AppConfig_AddItem("ShowWphAd", "1");
// var ShowWphAd = Util.AppConfig_GetValue("ShowWphAd");
// if (ShowWphAd == "1")
// {
// Thread th = new Thread(delegate ()
// {
// Thread.Sleep(5000);
// try
// {
// var Rst = MessageBox.Show("请尽快设置唯品会联盟,目前唯品会高消费年轻人群剧增,是否立即设置?", "询问", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
// if (Rst != DialogResult.Yes)
// {
// Rst = MessageBox.Show("唯品会设置只需要1分钟,您确定要放弃吗?(≈1个亿)", "询问", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
// if (Rst == DialogResult.Yes)
// {
// Util.AppConfig_ModifyItem("ShowWphAd", "0");
// return;
// }
// }
// Rst = MessageBox.Show("您是否已经有唯品会账号,点击Yes登录唯品会,点击No注册唯品会", "询问", MessageBoxButtons.YesNo);
// if (Rst == DialogResult.No)
// {
// var form = new WphRegisterForm();
// form.ShowDialog();
// }
// //登录唯品会
// var cps_member = LoginCps(CpsType.唯品联盟);
// if (cps_member == null)
// //throw new Exception("唯品会cps对象为空,可能登录异常");
// return;
// //打开唯品会插件
// if (PluginClient.Plugins != null)
// {
// var plugin = PluginClient.Plugins.FirstOrDefault(f => f.Name == "唯品会返利");
// if (plugin != null)
// {
// PluginClient.UnInstall(plugin);
// Thread.Sleep(200);
// PluginClient.Install(plugin);
// }
// }
// //创建推广位,判断是否有推广位,没有推广位创建一个推广位,有推广位,给没有设置推广位的机器人设置推广位
// #region 获取唯品会推广位
// var api = CpsClient.CreateWeipinhuiRequest(cps_member);
// var pidResult = WeipinhuiApi.GetWphTgw(api);
// if (result != null)
// {
// //推广位为空,创建推广位
// if (pidResult.total == 0)
// WeipinhuiApi.CreateWphTgw(api);
// pidResult = WeipinhuiApi.GetWphTgw(api);
// if (pidResult != null && pidResult.pidInfoList != null && pidResult.total != 0)
// {
// var tmp = pidResult.pidInfoList[0];
// if (tmp != null)
// {
// var tgw = new Tuiguangwei()
// {
// Member = cps_member,
// Name = tmp.pidName,
// Pid = tmp.pid
// };
// // 设置推广位
// var robotList = session.FindRobots();
// foreach (var robot in robotList)
// {
// setWphTgw((int)robot.id, tgw);
// }
// }
// }
// }
// #endregion
// }
// catch (Exception ex)
// {
// EventClient.OnEvent("引导设置唯品会异常", $"{ex.Message} - {ex.StackTrace}");
// }
// finally
// {
// ////监听刷新
// //PluginClient.LodingPlugin();
// }
// //1.搞个唯品会注册页
// //2.打开联盟登录页,自动登录后关闭窗口即可
// //3.自动启用唯品会插件,并设置好推广位
// //var form = new WPHNavForm();
// //if (form.ShowDialog() == DialogResult.OK)
// //{
// // //下次检测到唯品会未登录是否提示
// // Util.AppConfig_ModifyItem("WphNav", form.isIgnore ? "1" : "0");
// //}
// });
// th.ApartmentState = ApartmentState.STA; //属性设置成单线程
// th.IsBackground = true;
// th.Start();
// }
//}
//else
//{
// if (!Util.AppConfig_ExistItem("ShowWphAd"))
// Util.AppConfig_AddItem("ShowWphAd", "0");
// else
// Util.AppConfig_ModifyItem("ShowWphAd", "0");
//}
#endregion 唯 品 会
2022-09-20 03:10:29 +00:00
//#region MyRegion
//var ss = Util.Read<Dictionary<string, object>>("插件-积分管理-配置");
//var ssss = Newtonsoft.Json.JsonConvert.SerializeObject(ss);
//var fff = ssss.Contains("ExchangeCommercialPayTip_MiniApp");
//#endregion
System . Timers . Timer timer = new System . Timers . Timer ( ) ;
timer . Elapsed + = Timer_Elapsed ;
timer . Interval = 40 * 60 * 1000 ;
//timer.Interval = 1000;
timer . Start ( ) ;
//下载黑名单
timerBlackUser = new System . Timers . Timer ( 1000 ) ;
timerBlackUser . Elapsed + = Timer_ElapsedBlackUser ;
timer . Interval = 1000 ;
timerBlackUser . Start ( ) ;
}
catch ( Exception ex )
{
try { Loding . CloseWaitForm ( ) ; } catch ( Exception ) { }
if ( ex . Message . Contains ( "连接数据库过程中发生错误" ) )
ShowError ( @ "连接数据库过程中发生错误
检 查 服 务 器 是 否 正 常 连 接 字 符 串 是 否 正 确 ");
else
ShowError ( ex . Message + "\r\n" + ex . StackTrace ) ;
Program . Exit ( ) ;
}
finally
{
ItemClick ( barButtonItem6 , null ) ;
//监听刷新
//PluginClient.LodingPlugin();
this . WindowState = FormWindowState . Normal ;
Task . Run ( ( ) = >
{
Thread . Sleep ( 1000 * 60 ) ;
CheckSystemEventsHandlersForFreeze ( ) ;
} ) ;
}
}
private static void CheckSystemEventsHandlersForFreeze ( )
{
try
{
var handlers = typeof ( SystemEvents ) . GetField ( "_handlers" , BindingFlags . NonPublic | BindingFlags . Static ) . GetValue ( null ) ;
var handlersValues = handlers . GetType ( ) . GetProperty ( "Values" ) . GetValue ( handlers ) ;
foreach ( var invokeInfos in ( handlersValues as IEnumerable ) . OfType < object > ( ) . ToArray ( ) )
foreach ( var invokeInfo in ( invokeInfos as IEnumerable ) . OfType < object > ( ) . ToArray ( ) )
{
try
{
var syncContext = invokeInfo . GetType ( ) . GetField ( "_syncContext" , BindingFlags . NonPublic | BindingFlags . Instance ) . GetValue ( invokeInfo ) ;
if ( syncContext = = null ) throw new Exception ( "syncContext missing" ) ;
if ( ! ( syncContext is WindowsFormsSynchronizationContext ) ) continue ;
var threadRef = ( WeakReference ) syncContext . GetType ( ) . GetField ( "destinationThreadRef" , BindingFlags . NonPublic | BindingFlags . Instance ) . GetValue ( syncContext ) ;
if ( ! threadRef . IsAlive ) continue ;
var thread = ( Thread ) threadRef . Target ;
if ( thread . ManagedThreadId = = 1 ) continue ; // Change here if you have more valid UI threads to ignore
var dlg = ( Delegate ) invokeInfo . GetType ( ) . GetField ( "_delegate" , BindingFlags . NonPublic | BindingFlags . Instance ) . GetValue ( invokeInfo ) ;
SetLog ( $"SystemEvents handler '{dlg.Method.DeclaringType}.{dlg.Method.Name}' could freeze app due to wrong thread: "
+ $"{thread.ManagedThreadId},{thread.IsThreadPoolThread},{thread.IsAlive},{thread.Name}" ) ;
}
catch ( Exception e )
{
SetLog ( e . ToString ( ) + "线程BB" ) ;
}
}
}
catch ( Exception e )
{
SetLog ( e . ToString ( ) + "线程AA" ) ;
}
}
private static void SetLog ( string log )
{
var filename = HttpExtend . MapFile ( $"{DateTime.Now.ToString(" yyyy - MM - dd HH ")}.log" , "Cache\\Ka" ) ;
#region 原 始 写 法
//创建或打开日志文件,向日志文件末尾追加记录
//StreamWriter mySw = File.AppendText(filename);
//向日志文件写入内容
//string writeContent = time + "|" + typeGrade + ":" + type + "|" + className + ":" + content;
//mySw.WriteLine(writeContent);
//关闭日志文件
//mySw.Close();
#endregion
//(优化写法)创建或打开日志文件,向日志文件末尾追加记录,关闭日志文件
using ( StreamWriter mySw = File . AppendText ( filename ) )
{
string writeContent = $@"{DateTime.Now.ToString(" HH : mm : ss ")} => {log}
";
mySw . WriteLine ( writeContent ) ; //向日志文件写入内容
mySw . Close ( ) ; //关闭日志文件
}
}
private void Default_ThemeChanged ( object sender , EventArgs e )
{
//EventClient.OnEvent("", $"{JsonConvert.SerializeObject(sender)} - {JsonConvert.SerializeObject(e)}");
}
private void EventClient_SharedEvent ( object sender , SharedEvents e )
{
Task . Run ( ( ) = >
{
try
{
//shared["msg_type"] = "抖音验证码";
//shared["cps_type"] = CpsType.抖音联盟;
//shared["msg_username"] = api.Member.username;
if ( ! e . Shareds . ContainsKey ( "msg_type" ) & & e . Shareds [ "msg_type" ] ? . ToString ( ) = = "抖音验证码" )
return ;
var cps = HttpExtend . ConvertEnum < CpsType > ( e . Shareds [ "cps_type" ] . ToString ( ) ) ;
var username = e . Shareds [ "msg_username" ] . ToString ( ) ;
var usernick = e . Shareds [ "msg_usernick" ] . ToString ( ) ;
ApiClient . SendNoticeMessage ( $ @ "【抖音重要通知】
账 号 : { usernick } ( { username } )
通 知 : 请 滑 动 验 证 码 , 否 则 部 分 订 单 无 法 同 步 ! ");
var verify = new douyin_verify ( username ) ;
verify . ShowDialog ( ) ;
}
catch ( Exception ex )
{
EventClient . OnEvent ( "" , $"异常:{ex.Message}" ) ;
}
} ) ;
}
/// <summary>
/// 设置唯品会推广位
/// </summary>
/// <param name="robotid"></param>
/// <param name="tgw"></param>
private void setWphTgw ( int robotid , Tuiguangwei tgw )
{
try
{
var session = ApiClient . GetSession ( ) ;
var adzones = session . FindAdzoneInfos ( true ) . Where ( f = > f . alliance_id = = ( int ) CpsType . 唯 品 联 盟 & & f . custom_type = = Resources . SoftwareType & & f . robot_id = = robotid ) . ToList ( ) ;
//var pidName = e.Column.FieldName == "pid_chief_name" ? "chief" : "deputy";
//var adzone = adzones.FirstOrDefault(f => f.extend == pidName);
#region 这 里 判 断 存 在 两 个 推 广 位 ( 主 / 副 ) , 不 存 在 的 ( 主 副 数 据 将 创 建 对 象 )
if ( adzones ! = null & & adzones . Count < 2 )
{
var pidNames = new string [ ] { "chief" , "deputy" } ;
for ( int i = 0 ; i < pidNames . Length ; i + + )
{
#region 有 出 现 两 个 重 复 无 法 修 复 的 情 况 , 删 除 一 个
var repetAdzone = adzones . Where ( f = > f . extend = = pidNames [ i ] ) . ToList ( ) ;
if ( repetAdzone . Count > 1 )
{
for ( int z = 1 ; z < = repetAdzone . Count - 1 ; z + + )
{
session . Deleteable ( repetAdzone [ z ] ) . ExecuteCommand ( ) ;
}
adzones = session . FindAdzoneInfos ( true ) . Where ( f = > f . alliance_id = = ( int ) CpsType . 唯 品 联 盟 & & f . custom_type = = Resources . SoftwareType & & f . robot_id = = robotid ) . ToList ( ) ;
}
#endregion
var adzone = adzones . FirstOrDefault ( f = > f . extend = = pidNames [ i ] ) ;
if ( adzone = = null )
{
adzones = new List < fl_adzone_info > ( ) ;
foreach ( var item in pidNames )
{
var adzoneInfo = CreateAdzoneInfo ( tgw . Name , tgw . Pid , tgw . Member . username , robotid , item ) ;
session . SaveOrUpdate ( adzoneInfo ) ;
adzones . Add ( adzoneInfo ) ;
}
}
}
}
#endregion
session . FindAdzoneInfos ( true ) ;
session . FindWeipinhuiAutoBindPid ( true ) ; //刷新推广位
}
catch ( Exception ex )
{ }
}
/// <summary>
/// 创建fl_adzone_info对象
/// </summary>
/// <param name="adzone_name"></param>
/// <param name="adzone_pid"></param>
/// <param name="adzone_pid_cps_name"></param>
/// <param name="rid"></param>
/// <param name="item"></param>
/// <returns></returns>
private fl_adzone_info CreateAdzoneInfo ( string adzone_name , string adzone_pid , string adzone_pid_cps_name , int rid , string item , bool onoff = false )
{
return new fl_adzone_info ( )
{
custom_type = Resources . WPHSoftwareType , //自定义类型
adzone_name = adzone_name , //推广位名称
adzone_pid = adzone_pid , //推广位pid
adzone_pid_cps_name = adzone_pid_cps_name , //推广位cps名称
alliance_id = ( int ) CpsType . 唯 品 联 盟 , //联盟id
robot_id = rid , //机器人id
group_id = string . Empty , //群id
member_id = 0 , //私人id
is_download = false , //不下载
onoff = onoff , //不禁用
extend = item
} ;
}
void timer_lockForm_Tick ( object sender , EventArgs e )
{
if ( ApiClient . Setting . SystemConfig . is_lock_main = = SwitchType . 开 启 )
{
if ( ! lockState )
{
lockState = true ;
this . Hide ( ) ;
LockForm form = new LockForm ( this . Size ) ;
form . ShowDialog ( ) ;
this . Show ( ) ;
lockState = false ;
}
}
}
private void kh_OnKeyDownEvent ( object sender , KeyEventArgs e )
{
if ( e . KeyData = = ( Keys . S | Keys . Alt ) ) { this . Show ( ) ; } //Alt+S显示窗口
if ( e . KeyData = = ( Keys . H | Keys . Alt ) ) { this . Hide ( ) ; } //Alt+H隐藏窗口
}
private void Control_Disposed ( object sender , EventArgs e )
{
MainEvent . CommonEvents - = Main_CommonEvents ;
}
private void Main_CommonEvents ( object sender , CommonEvents e )
{
try
{
if ( e . Commons = = null ) return ;
if ( e . Commons . ContainsKey ( "cps_type" ) & & e . Commons . ContainsKey ( "username" ) )
{
var cps = ( CpsType ) int . Parse ( e . Commons [ "cps_type" ] . ToString ( ) ) ;
var username = e . Commons [ "username" ] . ToString ( ) ;
var buttonItem = new BarButtonItem ( ) ;
switch ( cps )
{
case CpsType . 阿 里 妈 妈 :
buttonItem . Caption = "阿里妈妈订单管理" ;
buttonItem . ImageOptions . Image = global :: FLSystem . Properties . Resources . 淘 宝 _20 ;
buttonItem . ImageOptions . LargeImage = global :: FLSystem . Properties . Resources . 淘 宝 __2_ ;
break ;
case CpsType . 多 多 进 宝 :
buttonItem . Caption = "拼多多订单管理" ;
buttonItem . ImageOptions . Image = global :: FLSystem . Properties . Resources . 拼 多 多 _20 ;
buttonItem . ImageOptions . LargeImage = global :: FLSystem . Properties . Resources . 拼 多 多 __4_ ;
break ;
case CpsType . 京 东 联 盟 :
buttonItem . Caption = "京东订单管理" ;
buttonItem . ImageOptions . Image = global :: FLSystem . Properties . Resources . 京 东 _20 ;
buttonItem . ImageOptions . LargeImage = global :: FLSystem . Properties . Resources . 京 东 _20 ;
break ;
case CpsType . 唯 品 联 盟 :
buttonItem . Caption = "唯品会订单管理" ;
buttonItem . ImageOptions . Image = global :: FLSystem . Properties . Resources . 唯 品 会 12 ;
buttonItem . ImageOptions . LargeImage = global :: FLSystem . Properties . Resources . 唯 品 会 12 ;
break ;
case CpsType . 抖 音 联 盟 :
buttonItem . Caption = "抖音订单管理" ;
buttonItem . ImageOptions . Image = global :: FLSystem . Properties . Resources . 抖 音 ;
buttonItem . ImageOptions . LargeImage = global :: FLSystem . Properties . Resources . 抖 音 ;
break ;
case CpsType . 苏 宁 易 购 :
buttonItem . Caption = "苏宁易购订单管理" ;
buttonItem . ImageOptions . Image = global :: FLSystem . Properties . Resources . 苏 宁 小 ;
buttonItem . ImageOptions . LargeImage = global :: FLSystem . Properties . Resources . 苏 宁 小 ;
break ;
case CpsType . 快 手 联 盟 :
buttonItem . Caption = "快手订单管理" ;
buttonItem . ImageOptions . Image = global :: FLSystem . Properties . Resources . 小 快 手 ;
buttonItem . ImageOptions . LargeImage = global :: FLSystem . Properties . Resources . 小 快 手 ;
break ;
default :
break ;
}
buttonItem . Tag = new { username = username } ;
ItemClick ( buttonItem , null ) ;
}
else if ( e . Commons . ContainsKey ( "control_name" ) & & e . Commons . ContainsKey ( "username" ) )
{
var control_name = e . Commons [ "control_name" ] . ToString ( ) ;
var username = e . Commons [ "username" ] . ToString ( ) ;
if ( control_name = = "查看用户信息" )
{
var buttonItem = new BarButtonItem ( ) ;
System . ComponentModel . ComponentResourceManager resources = new System . ComponentModel . ComponentResourceManager ( typeof ( main ) ) ;
buttonItem . Caption = "用户管理" ;
buttonItem . ImageOptions . Image = ( ( Image ) ( resources . GetObject ( "barButtonItem43.ImageOptions.Image" ) ) ) ;
buttonItem . ImageOptions . LargeImage = ( ( Image ) ( resources . GetObject ( "barButtonItem43.ImageOptions.LargeImage" ) ) ) ;
buttonItem . Tag = new { username = username } ;
ItemClick ( buttonItem , null ) ;
}
else if ( control_name = = "提现管理" )
{
var buttonItem = new BarButtonItem ( ) ;
System . ComponentModel . ComponentResourceManager resources = new System . ComponentModel . ComponentResourceManager ( typeof ( main ) ) ;
buttonItem . Caption = "提现管理" ;
buttonItem . ImageOptions . Image = ( ( Image ) ( resources . GetObject ( "barButtonItem76.ImageOptions.Image" ) ) ) ;
buttonItem . ImageOptions . LargeImage = ( ( Image ) ( resources . GetObject ( "barButtonItem76.ImageOptions.LargeImage" ) ) ) ;
buttonItem . Tag = new { username = username , query_type = e . Commons [ "query_type" ] . ToString ( ) } ;
ItemClick ( buttonItem , null ) ;
}
}
else if ( e . Commons . ContainsKey ( "type" ) & & e . Commons . ContainsKey ( "trade_parent_id" ) )
{
var type = e . Commons [ "type" ] . ToString ( ) ;
if ( type = = "阿里妈妈维权订单" )
{
var trade_parent_id = e . Commons [ "trade_parent_id" ] . ToString ( ) ;
var buttonItem = new BarButtonItem ( ) ;
System . ComponentModel . ComponentResourceManager resources = new System . ComponentModel . ComponentResourceManager ( typeof ( main ) ) ;
buttonItem . Caption = "阿里妈妈维权订单管理" ;
buttonItem . ImageOptions . Image = global :: FLSystem . Properties . Resources . 淘 宝 _20 ;
buttonItem . ImageOptions . LargeImage = global :: FLSystem . Properties . Resources . 淘 宝 __2_ ;
buttonItem . Tag = new { username = trade_parent_id } ;
ItemClick ( buttonItem , null ) ;
}
}
}
catch ( Exception ex )
{
ShowError ( ex ) ;
}
}
/// <summary>
/// 刷新用户信息
/// </summary>
/// <param name="client"></param>
private void Events_QQRefreshUserEvent ( QQBase client )
{
try
{
lock ( lock_obj )
{
var robot = client ;
var session = ApiClient . GetSession ( ) ;
var user = session . FindRobotInfo ( client . QQ . ToString ( ) , ChatType . QQ , true ) ;
if ( user = = null )
{
user = new fl_robot_info ( )
{
name = client . QQ . ToString ( ) ,
type = ChatType . QQ
} ;
}
user . uin = client . QQ . ToString ( ) ;
user . is_login = client . IsLogin ;
user . nick = client . Nickname ;
var token = client . ToString ( ) ;
if ( ! string . IsNullOrWhiteSpace ( token ) )
user . token = token ;
if ( user . is_login )
{
var custm = Grant . Framework . GrantClient . Get ( ) . FindCostomer ( client . QQ . ToString ( ) , 1002 ) ;
if ( custm ! = null )
user . end_time = custm . endTime ;
else
{
if ( string . IsNullOrWhiteSpace ( user . end_time ) )
user . end_time = DateTime . Now . AddMinutes ( - 1 ) . ToString ( "yyyy/MM/dd HH:mm:ss" ) ;
}
}
bool isinsert = user . id = = 0 ? true : false ;
session . SaveOrUpdate ( user ) ;
if ( isinsert ) EventClient . OnEvent ( this , MethodType . 刷 新 机 器 人 ) ;
}
}
catch { }
}
private void Events_QQRefreshUserEvent ( object sender , QQRefreshUser e )
{
if ( e . QQBase ! = null & & e . QQBase . QQ ! = 0 ) { Events_QQRefreshUserEvent ( e . QQBase ) ; }
}
private void QQEvents_LoginChangeEvent ( object sender , QQLoginChangeEvents e )
{
try
{
if ( e . QQBase ! = null & & e . QQBase . QQ ! = 0 )
{
Events_QQRefreshUserEvent ( e . QQBase ) ;
var client = e . QQBase ;
//离线通知
if ( ! string . IsNullOrWhiteSpace ( ApiClient . Setting . SystemConfig . notice_robotname ) )
{
if ( ! e . IsLogin )
{
var session = ApiClient . GetSession ( ) ;
var robot = session . FindRobotInfo ( client . QQ . ToString ( ) , ChatType . QQ , true ) ;
if ( robot = = null )
robot = session . FindRobotInfo ( client . QQ . ToString ( ) , ChatType . QQ , true ) ;
if ( robot ! = null & & robot . off_line_tip = = SwitchType . 开 启 )
{
string msg = $"离线通知\n————\nQQ账号: {client.QQ}\nQQ昵称: {client.Nickname}\n当前状态: {(e.IsLogin ? " 在 线 " : " 离 线 ")}\n系统时间: {DateTime.Now.ToString(" yyyy - MM - dd HH : mm : ss ")}" ;
ApiClient . SendNoticeMessage ( msg ) ;
ApiClient . SendAdminEmail ( ApiClient . Setting . SystemConfig . account_admin_email , "机器人离线通知" , msg , true ) ;
}
}
}
}
}
catch { }
}
private void Events_WXChangeStatusEvent ( object sender , Chat . Framework . WXSdk . Events . WXChangeStatus e )
{
try
{
if ( e . Client ! = null & & e . Client . User ! = null & & e . Client . User . Uin ! = 0 )
{
Events_WXRefreshUserEvent ( e . Client ) ;
var client = e . Client ;
//离线通知
if ( ! string . IsNullOrWhiteSpace ( ApiClient . Setting . SystemConfig . notice_robotname ) )
{
if ( client . Status = = WxStatus . 已 掉 线 | | client . Status = = WxStatus . 已 退 出 )
{
var session = ApiClient . GetSession ( ) ;
var robot = session . FindRobotInfo ( client . WeixinHao , ChatType . 微 信 , true ) ;
if ( robot = = null )
robot = session . FindRobotInfo ( client . WeixinHao , ChatType . 企 业 微 信 , true ) ;
if ( robot ! = null & & robot . off_line_tip = = SwitchType . 开 启 )
{
string msg = $"离线通知\n————\n微信账号: {client.WeixinHao}\n微信昵称: {client.User.Nick}\n当前状态: {client.Status}\n系统时间: {DateTime.Now.ToString(" yyyy - MM - dd HH : mm : ss ")}" ;
ApiClient . SendNoticeMessage ( msg ) ;
ApiClient . SendAdminEmail ( ApiClient . Setting . SystemConfig . account_admin_email , "机器人离线通知" , msg , true ) ;
}
}
}
}
}
catch { }
}
private bool isLodingOk = false ;
/// <summary>
/// 账号信息赋值
/// </summary>
private void RefreshAccount ( )
{
var account = Grant . Framework . GrantClient . Get ( ) . accounts ;
barButtonItem53 . Caption = account . username ;
barStaticItem5 . Caption = Math . Round ( account . point / 100.00 , 2 ) . ToString ( "0.00" ) + " 元" ;
barStaticItem8 . Caption = Math . Round ( account . sumPoint / 100.00 , 2 ) . ToString ( "0.00" ) + " 元" ;
}
private void AsyncCallbackMethod ( IAsyncResult ar )
{
EventClient . OnEvent ( this , $"自动登录线程已完成!" ) ;
}
private object lock_obj = new object ( ) ;
/// <summary>
/// 刷新用户信息
/// </summary>
/// <param name="client"></param>
private void Events_WXRefreshUserEvent ( Chat . Framework . WXSdk . Implement . WeixinBase client )
{
try
{
lock ( lock_obj )
{
var robot = client ;
var session = ApiClient . GetSession ( ) ;
var ctype = robot . WeixinType = = WeixinType . QYHook微信 ? ChatType . 企 业 微 信 : ChatType . 微 信 ;
var user = session . FindRobotInfo ( robot . WeixinHao , ctype , true ) ;
if ( user = = null )
{
user = new fl_robot_info ( )
{
name = client . WeixinHao ,
type = ctype
} ;
}
user . uin = client . User . Uin . ToString ( ) ;
user . is_login = client . Status = = Chat . Framework . WXSdk . WxStatus . 在 线 ? true : false ;
user . nick = client . User . Nick ;
if ( client . WeixinType = = WeixinType . Grpc微信 )
user . token = client . ToString ( ) ;
if ( user . is_login )
{
var custm = Grant . Framework . GrantClient . Get ( ) . FindCostomer ( client . User . Uin . ToString ( ) , 1001 ) ;
if ( custm ! = null )
user . end_time = custm . endTime ;
var ipad = client as Chat . Framework . WXSdk . Implement . WXClientImpl_IPAD ;
if ( ipad ! = null )
{
var device = session . Queryable < fl_wechat_device > ( ) . Where ( f = > f . weixinhao = = user . name ) . Single ( ) ;
if ( device = = null ) device = new fl_wechat_device ( ) { weixinhao = client . WeixinHao } ;
device . device_info = ipad . DeviceId ;
session . Saveable < fl_wechat_device > ( device ) . ExecuteCommand ( ) ;
}
}
bool isinsert = user . id = = 0 ? true : false ;
session . SaveOrUpdate ( user ) ;
if ( isinsert ) EventClient . OnEvent ( this , MethodType . 刷 新 机 器 人 ) ;
}
}
catch { }
}
private void Events_WXRefreshUserEvent ( object sender , Chat . Framework . WXSdk . Events . WXRefreshUser e )
{
if ( e . Client ! = null & & e . Client . User ! = null & & e . Client . User . Uin ! = 0 ) { Events_WXRefreshUserEvent ( e . Client ) ; }
}
private object MethodEventLock = new object ( ) ;
/// <summary>
///
/// </summary>
private void EventClient_MethodEvent ( object sender , MethodType e )
{
this . Invoke ( new Action ( delegate
{
try
{
lock ( MethodEventLock )
{
switch ( e )
{
case MethodType . 刷 新 应 用 :
var page = this . xtraTabControl1 . TabPages . FirstOrDefault ( f = > f . Text = = "应用功能" ) ;
if ( page ! = null )
{
foreach ( Control item in page . Controls )
{
item . Dispose ( ) ;
}
page . Controls . Clear ( ) ;
var list = PluginClient . Plugins . ToArray ( ) ;
foreach ( Plugin item in list )
{
page . AddContral ( new plugin_control ( item ) ) ;
}
page . AutoScroll = true ;
}
break ;
}
}
}
catch ( Exception ex )
{
ShowError ( ex ) ;
}
} ) ) ;
}
//销毁选项夹
private void xtraTabControl1_CloseButtonClick ( object sender , EventArgs e )
{
try
{
DevExpress . XtraTab . ViewInfo . ClosePageButtonEventArgs EArg = ( DevExpress . XtraTab . ViewInfo . ClosePageButtonEventArgs ) e ;
string name = EArg . Page . Text ; //得到关闭的选项卡的text
foreach ( XtraTabPage page in xtraTabControl1 . TabPages ) //遍历得到和关闭的选项卡一样的Text
{
if ( page . Text = = name )
{
xtraTabControl1 . TabPages . Remove ( page ) ;
foreach ( Control item in page . Controls )
{
item . Dispose ( ) ;
}
page . Dispose ( ) ;
return ;
}
}
}
catch ( Exception ex )
{
ShowError ( ex ) ;
}
}
//增加选项夹
private void AddControlPage ( string pageName , Control control , Image img = null )
{
try
{
//增加tabpage
XtraTabPage xpage = new XtraTabPage ( ) ;
xpage . Name = pageName ;
xpage . Text = pageName ;
if ( img ! = null )
xpage . ImageOptions . Image = img ;
//if (xpage.Text == "运行日志" || xpage.Text == "抖音活跃列表" || xpage.Text == "首页公告")
if ( xpage . Text = = "运行日志" | | xpage . Text = = "首页公告" )
xpage . ShowCloseButton = DevExpress . Utils . DefaultBoolean . False ;
control . Dock = DockStyle . Fill ;
xpage . Controls . Add ( control ) ; //添加要增加的控件
xtraTabControl1 . TabPages . Add ( xpage ) ;
xtraTabControl1 . SelectedTabPage = xpage ; //显示该页
}
catch ( Exception ex )
{
XtraMessageBox . Show ( ex . Message , "AddControlPage Error" , MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
}
}
//添加Control
private void ItemClick ( object sender , ItemClickEventArgs e )
{
BarItem btn = sender as BarItem ;
if ( btn = = null ) btn = e . Item ;
var cha = ApiClient . Cache ;
var username = string . Empty ;
var query_type = string . Empty ;
if ( btn . Tag ! = null )
{
var usernameProperty = btn . Tag . GetType ( ) . GetProperty ( "username" ) ;
if ( usernameProperty ! = null )
username = usernameProperty . GetValue ( btn . Tag ) . ToString ( ) ;
var query_typeProperty = btn . Tag . GetType ( ) . GetProperty ( "query_type" ) ;
if ( query_typeProperty ! = null )
query_type = query_typeProperty . GetValue ( btn . Tag ) . ToString ( ) ;
}
//判断是否已创建过
foreach ( XtraTabPage page in xtraTabControl1 . TabPages )
{
if ( page . Text = = btn . Caption )
{
xtraTabControl1 . SelectedTabPage = page ; //显示该页
return ;
}
}
try
{
Loding . ShowWaitForm ( ) ;
}
catch ( Exception )
{
ShowError ( "当前有正在加载的数据,请稍后重试!" ) ;
return ;
}
Image img = null ;
try
{
img = PickBox . ResizeImage ( btn . ImageOptions . LargeImage = = null ? btn . ImageOptions . Image : btn . ImageOptions . LargeImage , new Size ( 22 , 22 ) ) ;
Control control = null ;
switch ( btn . Caption )
{
case "首页公告" :
{
control = new home_control ( ) ;
break ;
}
case "群通知机器人" :
{
control = new notice_robotapi_control ( ) ;
break ;
}
case "强制结算订单" :
{
control = new cps_coerce_alimama ( ) ;
break ;
}
case "机器人管理" :
{
control = new robot_manage_control ( ) ;
break ;
}
case "用户管理" :
{
control = new member_manage_control ( username ) ;
break ;
}
case "群负责人" :
{
control = new group_manage_control ( ) ;
break ;
}
case "开发调试" :
{
control = new plugin_debug ( ) ;
break ;
}
case "查询商品记录" :
{
control = new item_query_hist_control ( ) ;
break ;
}
case "应用功能" :
{
_EnabledControl ( false ) ;
control = new plugin_manage ( ) ;
_EnabledControl ( ) ;
break ;
}
case "联盟管理" :
{
control = new cps_manage_control ( ) ;
break ;
}
case "系统设置" :
{
var temp = new SettingControl ( ) ;
temp . Bind ( ApiClient . Setting . SystemConfig ) ;
control = temp ;
break ;
}
case "其他设置" :
{
control = new setting_system_control ( ) ;
break ;
}
case "拼多多订单管理" :
{
control = new cps_order_pinduoduo ( username ) ;
break ;
}
case "唯品会订单管理" :
{
control = new cps_order_weipinhui ( username ) ;
break ;
}
case "阿里妈妈订单管理" :
{
control = new cps_order_alimama ( username ) ;
break ;
}
case "阿里妈妈维权订单管理" :
{
control = new cps_order_refund_alimama ( username ) ;
break ;
}
case "京东订单管理" :
{
control = new cps_order_jingdong ( username ) ;
break ;
}
case "快手订单管理" :
{
//TODO 快手
2022-10-08 06:50:40 +00:00
throw new Exception ( "该功能尚未开发完成,请等待更新!" ) ;
2022-09-20 03:10:29 +00:00
control = new cps_order_kuaishou ( username ) ;
break ;
}
case "抖音订单管理" :
{
//TODO 禁用抖音禁用
var StartDy = Util . AppConfig_GetValue ( "StartDy" ) ;
if ( StartDy ! = "1" )
throw new Exception ( "该功能尚未开发完成,请等待更新!" ) ;
else
{
control = new cps_order_douyin ( username ) ;
break ;
}
}
case "苏宁易购订单管理" :
{
control = new cps_order_suning ( username ) ;
break ;
}
case "运行日志" :
{
control = new system_log_control ( ) ;
break ;
}
case "抖音活跃列表" :
{
//control = new system_douyin_action_control();
//break;
return ;
}
case "保存配置" :
{
ChatClient . WXSdkConfig . IsDebug = false ;
Util . AppConfig_ModifyItem ( "SkinName" , skin_manager . Caption ) ;
if ( ApiClient . Setting ! = null ) ApiClient . Setting . Save ( ) ;
ShowSuccessAutoClose ( "已保存配置,并应用!" ) ;
return ;
}
case "淘宝订单尾号" :
{
control = new member_order_lastnum ( ) ;
break ;
}
case "数据报表" :
{
control = new data_report_control ( ) ;
break ;
}
case "提现管理" :
{
control = new point_manage_control ( username , query_type ) ;
break ;
}
case "手动转链" :
{
control = new convert_tool_control ( ) ;
break ;
}
default :
throw new Exception ( "该功能尚未开发完成,请等待更新!" ) ;
}
AddControlPage ( btn . Caption , control , img ) ;
}
catch ( Exception ex )
{
ShowError ( ex , "创建异常" ) ;
}
finally
{
Loding . CloseWaitForm ( ) ;
}
}
//窗口即将关闭
private void main_FormClosing ( object sender , FormClosingEventArgs e )
{
try
{
//if (isLodingOk && sender.GetType() != typeof(OnlineUpdate.Client))
if ( isLodingOk & & e ! = null )
{
var result = XtraMessageBox . Show ( "您确定要退出软件吗?" , "谨慎操作" , MessageBoxButtons . YesNo , MessageBoxIcon . Question ) ;
if ( result ! = DialogResult . Yes )
{
e . Cancel = true ;
return ;
}
}
ApiClient . Setting . Save ( ) ;
var list = ChatClient . WXClient . Values . ToList ( ) ;
foreach ( WeixinBase item in list ) Events_WXRefreshUserEvent ( item ) ;
this . notify_pallet . Visible = false ;
Util . AppConfig_ModifyItem ( "SkinName" , skin_manager . Caption ) ;
if ( ApiClient . Setting ! = null ) ApiClient . Setting . Save ( ) ;
kh . UnHook ( ) ;
}
catch { }
if ( sender ! = null & & e = = null )
{
Process . Start ( "检查更新.exe" , "FLSystem.exe" ) ;
}
Program . Exit ( ) ;
}
//UpdateSoft update = null;
//LevelUpdate.UpdateForm update = null;
//检查更新
private void barButtonItem1_ItemClick ( object sender , ItemClickEventArgs e )
{
try
{
var LatestData = UpdateClient . GetCloudFileHist ( ) ;
if ( ! string . IsNullOrWhiteSpace ( LatestData ) )
{
if ( new UpdateForm ( LatestData ) . ShowDialog ( ) = = DialogResult . OK )
main_FormClosing ( LatestData , null ) ;
}
else MessageBox . Show ( "暂无新版本!" , "检查更新" , MessageBoxButtons . OK , MessageBoxIcon . Information ) ;
}
catch ( Exception ex )
{ }
}
//测试SMTP邮件
private void barButtonItem16_ItemClick ( object sender , ItemClickEventArgs e )
{
try
{
ApiClient . SendAdminEmail ( ApiClient . Setting . SystemConfig . SMTP_User , "测试邮件" , "您如果收到此邮件,表示可以正常使用该功能!" , false , false ) ;
ShowSuccess ( "已发送邮件,请注意查收!" ) ;
}
catch ( Exception ex )
{
ShowError ( ex ) ;
}
}
//登录拼多多
private void barButtonItem21_ItemClick ( object sender , ItemClickEventArgs e )
{
if ( LoginCps ( CpsType . 多 多 进 宝 ) ! = null ) ItemClick ( btn_cps_manage , e ) ;
}
private fl_cps_member LoginCps ( CpsType type )
{
try
{
var member = CpsClient . Login ( type ) ;
if ( member ! = null )
{
EventClient . OnEvent ( null , MethodType . 刷 新 联 盟 ) ;
}
return member ;
}
catch ( Exception ex )
{
// if (ex.Message.Contains(@"“CefSharp.Core.Runtime.dll”或它的某一个依赖项"))
// {
// EventClient.OnEvent("系统缺少服务", $@"请点击链接,下载组件并安装,安装完成后重启软件
//下载地址:https://wwa.lanzoui.com/iDDvsroqrxc");
// try
// {
// Clipboard.SetDataObject("https://wwa.lanzoui.com/iDDvsroqrxc" + "?=" + new Random().Next(100, 2000));
// }
// catch (Exception)
// { }
// BaseForm.ShowError(@"当前系统缺少组件,请看软件日志,按提示安装相应的组件
//下载地址已经复制到粘贴板,在网页中打开即可");
// }
// else
// ShowError(ex.Message, "抖音创建异常");
}
return null ;
}
private void barButtonItem30_ItemClick ( object sender , ItemClickEventArgs e )
{
new plugin_sort_form ( ) . ShowDialog ( ) ;
PluginClient . LodingPlugin ( ) ;
}
/// <summary>
/// 修改控件客户交互状态 (Enabled)
/// </summary>
/// <param name="flag"></param>
private void _EnabledControl ( bool flag = true )
{
barButtonItem29 . Enabled = barButtonItem30 . Enabled = barButtonItem31 . Enabled = barButtonItem6 . Enabled = flag ;
}
private void barButtonItem29_ItemClick ( object sender , ItemClickEventArgs e )
{
//监听刷新
PluginClient . LodingPlugin ( ) ;
}
private void barButtonItem31_ItemClick ( object sender , ItemClickEventArgs e )
{
//监听刷新
PluginClient . LodingPlugin ( true ) ;
}
private void barButtonItem25_ItemClick ( object sender , ItemClickEventArgs e )
{
if ( LoginCps ( CpsType . 阿 里 妈 妈 ) ! = null ) ItemClick ( btn_cps_manage , e ) ;
}
private void simpleButton1_Click ( object sender , EventArgs e )
{
var client = ChatClient . WXClient . FirstOrDefault ( ) . Value ;
var label = client . GetLabelList ( ) . First ( ) ;
//client.AddLabel("Test2");
client . EditUserLabel ( new [ ] { "wxid_8s44kddouuaj21" } , new System . Collections . Generic . List < Chat . Framework . WXSdk . Implement . Lable > ( ) { label } ) ;
// client.ModifyUserTag(new[] { "wxid_8s44kddouuaj21" });
//new LoginWechat62Data().ShowDialog();
//var str = "<msg bigheadimgurl=\"http://wx.qlogo.cn/mmhead/ver_1/5LnxGuicImnmq0IonTk4cQ2rMpDpldkF2EOARwCrhtEH2VmMYrRxC92zTBPRZX1QqZtPd2UOUfZGVF73sKN3cB8mvBibKxkF5SgFjyn0S0sLs/0\" smallheadimgurl=\"http://wx.qlogo.cn/mmhead/ver_1/5LnxGuicImnmq0IonTk4cQ2rMpDpldkF2EOARwCrhtEH2VmMYrRxC92zTBPRZX1QqZtPd2UOUfZGVF73sKN3cB8mvBibKxkF5SgFjyn0S0sLs/132\" username=\"yangshu5188\" nickname=\"杨曙\" fullpy=\"?yangshu?\" shortpy=\"\" alias=\"\" imagestatus=\"3\" scene=\"17\" province=\"昆士兰\" city=\"澳大利亚\" sign=\"\" sex=\"1\" certflag=\"0\" certinfo=\"\" brandIconUrl=\"\" brandHomeUrl=\"\" brandSubscriptConfigUrl=\"\" brandFlags=\"0\" regionCode=\"AU_Queensland_Gold Coast\" />";
//client.SendMessage("wxid_8s44kddouuaj21", str);
}
private void barButtonItem40_ItemClick ( object sender , ItemClickEventArgs e )
{
Process . Start ( Util . MapPath ( "Plugin" ) ) ;
}
private void barButtonItem5_ItemClick ( object sender , ItemClickEventArgs e )
{
Process . Start ( Util . MapPath ( "Plugin" ) ) ;
}
private void barButtonItem4_ItemClick ( object sender , ItemClickEventArgs e )
{
Process . Start ( Util . MapPath ( "" ) ) ;
}
private void barButtonItem3_ItemClick ( object sender , ItemClickEventArgs e )
{
this . notify_pallet . Visible = false ;
Program . Exit ( ) ;
}
private void barButtonItem2_ItemClick ( object sender , ItemClickEventArgs e )
{
this . notify_pallet . Visible = false ;
Program . Exit ( true ) ;
}
private void barButtonItem10_ItemClick ( object sender , ItemClickEventArgs e )
{
}
private void barButtonItem9_ItemClick ( object sender , ItemClickEventArgs e )
{
System . ComponentModel . ComponentResourceManager resources = new System . ComponentModel . ComponentResourceManager ( typeof ( main ) ) ;
if ( ! EventClient . StopParsing )
{
this . barButtonItem9 . ImageOptions . Image = ( System . Drawing . Image ) ( resources . GetObject ( "barButtonItem9.ImageOptions.Image" ) ) ;
this . barButtonItem9 . ImageOptions . LargeImage = ( System . Drawing . Image ) ( resources . GetObject ( "barButtonItem9.ImageOptions.LargeImage" ) ) ;
this . barButtonItem9 . Caption = "接收信息" ;
}
else
{
this . barButtonItem9 . ImageOptions . Image = ( System . Drawing . Image ) ( resources . GetObject ( "barButtonItem10.ImageOptions.Image" ) ) ;
this . barButtonItem9 . ImageOptions . LargeImage = global :: FLSystem . Properties . Resources . 停 止 __4_ ;
this . barButtonItem9 . Caption = "停止接收" ;
}
EventClient . StopParsing = ! EventClient . StopParsing ;
}
private void barButtonItem50_ItemClick ( object sender , ItemClickEventArgs e )
{
try
{
var flag = ChatClient . LoginWeixin ( ) ;
if ( flag ) ItemClick ( btn_robot_manage , e ) ;
}
catch ( Exception ex )
{
BaseForm . ShowError ( ex ) ;
}
}
private DateTime RefPluginControlTime = DateTime . MinValue ;
private Thread RefPluginControlTimer = null ;
private void main_SizeChanged ( object sender , EventArgs e )
{
try
{
//判断是否选择的是最小化按钮
if ( WindowState = = FormWindowState . Minimized )
{
//托盘显示图标等于托盘图标对象
//注意notifyIcon1是控件的名字而不是对象的名字
this . notify_pallet . Visible = true ;
//隐藏任务栏区图标
this . ShowInTaskbar = false ;
}
else
{
this . notify_pallet . Visible = false ;
Control page = this . xtraTabControl1 . SelectedTabPage ;
if ( page ! = null & & page . Text = = "应用功能" & & page . Controls . Count > 0 )
{
if ( page . Controls . Count = = 1 & & page . Controls [ 0 ] . Name = = "plugin_manage" )
page = page . Controls [ 0 ] ;
lock ( lock_obj )
{
RefPluginControlTime = DateTime . Now . AddSeconds ( 1 ) ;
if ( RefPluginControlTimer = = null | | ! RefPluginControlTimer . IsAlive )
{
RefPluginControlTimer = new Thread ( new ThreadStart ( delegate
{
while ( DateTime . Now < RefPluginControlTime )
{
Thread . Sleep ( 200 ) ;
}
Invoke ( new Action ( delegate
{
_EnabledControl ( false ) ;
page . RefreshContral ( ) ;
_EnabledControl ( ) ;
} ) ) ;
} ) ) ;
RefPluginControlTimer . IsBackground = true ;
RefPluginControlTimer . Start ( ) ;
}
}
}
}
}
catch
{ }
}
private void notify_pallet_MouseDoubleClick ( object sender , MouseEventArgs e )
{
this . Visible = true ;
this . WindowState = FormWindowState . Normal ;
this . ShowInTaskbar = true ;
}
/// <summary>
/// 读取公告
/// </summary>
private void ReadNote ( bool f5 = true )
{
try
{
if ( f5 ) Grant . Framework . GrantClient . Get ( ) . RefreshAbout ( 1003 ) ;
var notes = GrantClient . Get ( ) . About . ContainsKey ( "notice" ) ? GrantClient . Get ( ) . About [ "notice" ] . ToString ( ) : string . Empty ;
// var notes = ApiClient.GetServerConfig("FLSystemNotice");
if ( ! string . IsNullOrEmpty ( notes ) )
{
var temp = notes . Split ( '|' ) ;
this . Invoke ( new Action ( delegate
{
try
{
this . PublicNote . Caption = temp [ new Random ( ) . Next ( 0 , temp . Length ) ] ;
}
catch ( Exception )
{
}
} ) ) ;
}
}
catch ( Exception )
{ }
}
private static long timeCount = 0 ;
private void timer1_Tick ( object sender , EventArgs e )
{
new Action ( delegate ( )
{
timeCount + + ;
try
{
ReadNote ( ) ;
var session = ApiClient . GetSession ( ) ;
var robots = session . FindRobots ( ) ;
//刷新信息
foreach ( var item in robots )
{
if ( item . type = = ChatType . 微 信 | | item . type = = ChatType . 企 业 微 信 )
{
var client = ChatClient . WXClient . Values . ToList ( ) . FirstOrDefault ( f = > f . WeixinHao = = item . name ) ;
if ( client ! = null )
{
//item.token = (item.token.Contains("Chat.Framework.WXSdk.Implement.WXClientImpl_") || client.WeixinType != WeixinType.Grpc微信) ? string.Empty : client.ToString();
if ( client . WeixinType = = WeixinType . Grpc微信 )
item . token = client . ToString ( ) ;
item . is_login = client . Status = = WxStatus . 在 线 ? true : false ;
session . SaveOrUpdate ( item ) ;
}
}
}
//重新读取
robots = session . FindRobots ( true ) ;
StringBuilder sb = new StringBuilder ( ) ;
foreach ( var item in robots )
{
var isLogin = false ;
if ( Chat . Framework . ChatClient . WXClient . ContainsKey ( item . name ) )
{
var wxbase = Chat . Framework . ChatClient . WXClient [ item . name ] ;
isLogin = wxbase . Status ! = WxStatus . 在 线 ;
}
if ( isLogin & & item . off_line_tip = = SwitchType . 开 启 )
sb . Append ( $"{item.type}账号:{item.nick}({item.name})\n" ) ;
}
string msg = sb . ToString ( ) . Trim ( ) ;
if ( ! string . IsNullOrEmpty ( msg ) )
{
msg = $"离线通知\n————\n{msg.Trim()}" ;
ApiClient . SendNoticeMessage ( msg ) ;
ApiClient . SendAdminEmail ( ApiClient . Setting . SystemConfig . account_admin_email , "机器人离线通知" , msg , true ) ;
}
//账号授权提示
if ( timeCount % 48 = = 0 ) //降低频率一天提醒一次
{
sb . Length = 0 ;
foreach ( var item in robots )
{
if ( string . IsNullOrWhiteSpace ( item . end_time ) ) continue ;
DateTime end_time = DateTime . MinValue ;
DateTime . TryParse ( item . end_time , out end_time ) ;
if ( end_time ! = DateTime . MinValue ) //&& end_time >= DateTime.Now)
{
if ( end_time . AddDays ( 1 ) < DateTime . Now ) continue ;
if ( end_time < DateTime . Now )
{
sb . AppendLine ( $"{item.type}账号:{item.nick}({item.uin}) 授权已经到期" ) ;
}
else
{
var time = end_time - DateTime . Now ;
if ( time . TotalDays < 7 )
sb . AppendLine ( $"{item.type}账号:{item.nick}({item.uin}) 授权剩余{time.Days}天{time.Hours}小时{time.Minutes}分" ) ;
}
}
}
msg = sb . ToString ( ) . Trim ( ) ;
if ( ! string . IsNullOrEmpty ( msg ) )
{
msg = $"账号授权即将到期通知\n————\n{msg.Trim()}\n\n温馨提示: 为了您的账号能正常使用, 请及时给账号续期" ;
ApiClient . SendNoticeMessage ( msg ) ;
ApiClient . SendAdminEmail ( ApiClient . Setting . SystemConfig . account_admin_email , "机器人即将到期通知" , msg , true ) ;
}
}
//系统有更新提示
if ( timeCount % 60 = = 0 )
{
try
{
var LatestData = UpdateClient . GetCloudFileHist ( ) ;
if ( ! string . IsNullOrWhiteSpace ( LatestData ) )
{
try
{
StringBuilder sb1 = new StringBuilder ( ) ;
sb1 . AppendLine ( "返利系统有更新啦:" ) ;
sb1 . AppendLine ( "" ) ;
sb1 . AppendLine ( LatestData ) ;
//foreach (var item in versions)
//{
// sb1.Append($"{item.Name} -- {item.Version}\r\n");
// var index = 10;
// for (int i = 0; i < item.Message.Count; i++)
// {
// if (index > i)
// sb1.AppendLine($"{i + 1}、{item.Message[i]}");
// else
// {
// sb1.AppendLine($"{i + 1}、。。。");
// break;
// }
// }
// sb1.AppendLine("");
//}
var info = sb1 . ToString ( ) . Trim ( ) ;
if ( ! string . IsNullOrWhiteSpace ( info ) )
{
ApiClient . SendNoticeMessage ( info ) ;
}
}
catch ( Exception ex )
{ }
}
}
catch ( Exception ex )
{
}
}
}
catch { }
} ) . BeginInvoke ( null , null ) ;
}
//登录京东联盟
private void barButtonItem26_ItemClick ( object sender , ItemClickEventArgs e )
{
var member = LoginCps ( CpsType . 京 东 联 盟 ) ;
if ( member ! = null )
{
ItemClick ( btn_cps_manage , e ) ;
}
}
private void barButtonItem97_ItemClick ( object sender , ItemClickEventArgs e )
{
if ( LoginCps ( CpsType . 唯 品 联 盟 ) ! = null ) ItemClick ( btn_cps_manage , e ) ;
}
private void barButtonItem100_ItemClick ( object sender , ItemClickEventArgs e )
{
if ( LoginCps ( CpsType . 抖 音 联 盟 ) ! = null ) ItemClick ( btn_cps_manage , e ) ;
}
private void barButtonItem107_ItemClick ( object sender , ItemClickEventArgs e )
{
if ( LoginCps ( CpsType . 苏 宁 易 购 ) ! = null ) ItemClick ( btn_cps_manage , e ) ;
}
private void barButtonItem8_ItemClick ( object sender , ItemClickEventArgs e )
{
string filename = Util . MapFile ( "C#_Plugin.doc" , "File\\Design" ) ;
}
private void barButtonItem59_ItemClick ( object sender , ItemClickEventArgs e )
{
try
{
var config = ApiClient . Setting . SystemConfig ;
var cer = config . pay_wechat_sh_cerpath ;
if ( ! System . IO . File . Exists ( cer ) ) throw new Exception ( "对不起,证书文件不存在!" ) ;
var cerdata = File . ReadAllBytes ( cer ) ;
WechatPay pay = new WechatPay ( ) ;
var result = pay . Upload ( config . pay_wechat_host , config . pay_wechat_gzh_appid , config . pay_wechat_gzh_appsecret , config . pay_wechat_sh_appid , config . pay_wechat_sh_appsecret , cerdata , config . pay_wechat_web_footer ) ;
ShowSuccess ( result ) ;
}
catch ( Exception ex )
{
ShowError ( ex . Message ) ;
}
}
private void xtraTabControl1_SelectedPageChanged ( object sender , TabPageChangedEventArgs e )
{
try
{
var page = this . xtraTabControl1 . SelectedTabPage ;
if ( page ! = null & & page . Text = = "应用功能" )
{
//page.Controls.Clear();
if ( page . Name = = "" )
if ( page . Controls . Count > 0 )
{
Invoke ( new Action ( delegate
{
_EnabledControl ( false ) ;
page . RefreshContral ( ) ;
_EnabledControl ( ) ;
} ) ) ;
}
}
else if ( page ! = null & & page . Text = = "提现管理" )
{
EventClient . OnEvent ( this , MethodType . 刷 新 配 置 文 件 ) ; //刷新积分管理中的配置文件
}
}
catch { }
}
private void barButtonItem11_ItemClick ( object sender , ItemClickEventArgs e )
{
new EncPlugin ( ) . Show ( ) ;
}
private void barButtonItem65_ItemClick ( object sender , ItemClickEventArgs e )
{
try
{
if ( MessageBox . Show ( "是否重启软件?" , "提示" , MessageBoxButtons . YesNo , MessageBoxIcon . Question ) = = DialogResult . Yes )
{
ApiClient . Setting . Save ( ) ;
#region 是 否 允 许 软 件 重 启 [ 创 建 一 个 名 为 reset 的 空 文 件 , 在 FLSystem的Program中判断这个文件是否存在 , 存 在 将 允 许 重 启 ]
var reset_program = Util . MapFile ( "reset" , "File" ) ;
File . Create ( reset_program ) ;
#endregion
Application . ExitThread ( ) ;
Thread thtmp = new Thread ( new ParameterizedThreadStart ( run ) ) ;
object appName = Application . ExecutablePath ;
Thread . Sleep ( 500 ) ;
thtmp . Start ( appName ) ;
}
}
catch ( Exception ex )
{
BaseForm . ShowError ( ex ) ;
}
}
private void run ( Object obj )
{
Process ps = new Process ( ) ;
ps . StartInfo . FileName = obj . ToString ( ) ;
ps . Start ( ) ;
}
private void barButtonItem66_ItemClick ( object sender , ItemClickEventArgs e )
{
Process . Start ( Util . MapPath ( ) ) ;
}
private void barButtonItem34_ItemClick ( object sender , ItemClickEventArgs e )
{
new LeavingMessageForm ( ) . ShowDialog ( ) ;
}
private void CreateWebApiEvent ( object sender , ItemClickEventArgs e )
{
var form = new web_api_form ( ) ;
form . ShowDialog ( ) ;
}
private void barButtonItem77_ItemClick ( object sender , ItemClickEventArgs e )
{
new update_log_form ( ) . ShowDialog ( ) ;
}
private void barButtonItem78_ItemClick ( object sender , ItemClickEventArgs e )
{
Process . Start ( Util . MapPath ( ) ) ;
}
private void barButtonItem51_ItemClick ( object sender , ItemClickEventArgs e )
{
ChatClient . LoginQQ ( "" ) ;
}
#region QQ
#endregion
/// <summary>
/// 同步服务器缓存
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void barButtonItem42_ItemClick ( object sender , ItemClickEventArgs e )
{
try
{
//AlimamaApi.FindTransferAddress(AlimamaApi.TargetType.产品库, true);
//var ss = AlimamaApi.FindTransferAddress(AlimamaApi.TargetType.淘口令, true);
AlimamaApi . RefreshTkUrl ( ) ;
TbAnalysis . TklRegToEmpty ( ) ;
//删除云黑名单缓存
Api . Framework . Tools . Util . RemoveCache ( "Cloud_Black" ) ;
ShowSuccess ( "缓存更新成功!" ) ;
}
catch ( Exception )
{ }
}
private void barButtonItem90_ItemClick ( object sender , ItemClickEventArgs e )
{
new AuthorizationManage ( ) . ShowDialog ( ) ;
}
private void barButtonItem91_ItemClick ( object sender , ItemClickEventArgs e )
{
new AuthorizationManage ( ) . ShowDialog ( ) ;
}
private void barButtonItem92_ItemClick ( object sender , ItemClickEventArgs e )
{
var wx = ChatClient . WXClient . FirstOrDefault ( ) . Value as WXClientImpl_IPAD ;
wx . Socket . TestError ( ) ;
}
private void main_KeyDown ( object sender , KeyEventArgs e )
{
try
{
if ( e . Alt )
{
if ( e . KeyCode = = Keys . Oem3 )
{
var ShowTgwz = Util . AppConfig_GetValue ( "ShowTgwz" ) ;
var state = ShowTgwz = = "1" ? "0" : "1" ;
string mess = string . Empty ;
if ( Util . AppConfig_ModifyItem ( "ShowTgwz" , state ) )
mess = state = = "1" ? "成功激活推广位组" : "成功隐藏推广位组" ;
else
mess = state = = "1" ? "激活推广位组失败" : "隐藏推广位组失败" ;
ShowSuccess ( mess ) ;
}
}
}
catch ( Exception ex )
{
ShowError ( ex ) ;
}
}
private void button1_Click ( object sender , EventArgs e )
{
try
{
//if (ApiClient.Server != null && ApiClient.Server.State == SuperSocket.SocketBase.ServerState.Running)
//{
// ChatClient.PCRobotPool.SendAppUpdate();
// BaseForm.ShowSuccessAutoClose("请求远程更新成功!!!");
//}
//else
//{
// throw new Exception("Socket通讯未开启,此操作无效!!!");
//}
//var robot = ApiClient.GetSession().FindRobotInfo("wxid_vebvd7abpq1m22", ChatType.微信);
//var sends = new List<temp_send_data>();
//sends.Add(new temp_send_data() { Groupid = string.Empty, Message = @"撒法第三款了房间里的撒咖啡[分段][延迟=900]机房的凯撒奖发了多少", Robot = robot, TouserName = "wujiahua0876" });
//ApiClient.SendMessage(sends.ToArray());
//var msg = ApiClient.SendWechatPay(new { test = "123大爷啊.乱码啊" }, "测试啊", 5);
//Console.WriteLine();
}
catch ( Exception ex )
{
BaseForm . ShowErrorAutoClose ( ex ) ;
}
}
private void barButtonItem93_ItemClick ( object sender , ItemClickEventArgs e )
{
System . ComponentModel . ComponentResourceManager resources = new System . ComponentModel . ComponentResourceManager ( typeof ( main ) ) ;
if ( ! ApiClient . Setting . SystemConfig . message_warning_switch )
{
if ( XtraMessageBox . Show ( @ "确定要开启吗?
开 启 后 :
① 、 订 单 绑 定 等 相 关 提 示 语 ( 不 通 知 )
② 、 返 利 正 在 查 询 中 提 示 语 ( 不 通 知 )
③ 、 上 下 级 订 单 提 成 提 示 语 ( 不 通 知 )
作 用 : ( 有 效 防 止 微 信 消 息 频 繁 )
一 般 在 双 11 、 双 12 、 618 等 重 要 节 假 日 开 启 ! ", " 温 馨 提 示 ", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.Cancel) return;
this . barButtonItem93 . Caption = "关闭【双12】模式" ;
this . barButtonItem93 . ImageOptions . Image = ( System . Drawing . Image ) ( resources . GetObject ( "barButtonItem93.ImageOptions.Image" ) ) ;
this . barButtonItem93 . ImageOptions . LargeImage = ( System . Drawing . Image ) ( resources . GetObject ( "barButtonItem93.ImageOptions.LargeImage" ) ) ;
}
else
{
this . barButtonItem93 . Caption = "开启【双12】模式" ;
this . barButtonItem93 . ImageOptions . Image = ( ( System . Drawing . Image ) ( resources . GetObject ( "barButtonItem94.ImageOptions.Image" ) ) ) ;
this . barButtonItem93 . ImageOptions . LargeImage = ( ( System . Drawing . Image ) ( resources . GetObject ( "barButtonItem94.ImageOptions.LargeImage" ) ) ) ;
}
ApiClient . Setting . SystemConfig . message_warning_switch = ! ApiClient . Setting . SystemConfig . message_warning_switch ;
Util . Save ( ApiClient . Setting . SystemConfig ) ;
ApiClient . Setting . Save ( ) ;
}
/// <summary>
/// 机器人离线自动登录记录
/// 离线后尝试自动登录成功的不记录
/// 离线后自动尝试登录不成功的记录
/// 有记录但是已经人工登录成功的清除
/// 有记录但是没有自动登录不成功的记录增加
/// </summary>
public Dictionary < string , int > robotOffLineAutoLoginList = new Dictionary < string , int > ( ) ;
private void autologin_timer_Tick ( object sender , EventArgs e )
{
new Action ( delegate ( )
{
try
{
var session = ApiClient . GetSession ( ) ;
//重新读取
var robots = session . FindRobots ( true ) . Where ( f = > f . type = = ChatType . 微 信 & & f . remark ! = "PCWechat HOOK" ) ;
var wxClients = ChatClient . WXClient . Values ;
foreach ( var robot in robots )
{
var isLogin = wxClients . FirstOrDefault ( f = > robot . name = = f . WeixinHao & & ( f . Status = = WxStatus . 已 掉 线 | | f . Status = = WxStatus . 已 退 出 | | f . Status = = WxStatus . 未 登 录 | | f . Status = = WxStatus . 登 录 中 ) ) = = null ;
if ( robotOffLineAutoLoginList . ContainsKey ( robot . name ) )
{
if ( isLogin | | robot . off_line_auto_login = = SwitchType . 关 闭 )
robotOffLineAutoLoginList . Remove ( robot . name ) ;
else if ( ! isLogin & & robot . off_line_auto_login = = SwitchType . 开 启 )
robotOffLineAutoLoginList [ robot . name ] = robotOffLineAutoLoginList [ robot . name ] + 1 ;
}
else
{
if ( ! isLogin )
{
robotOffLineAutoLoginList . Add ( robot . name , 1 ) ;
}
}
}
if ( robotOffLineAutoLoginList . Count = = 0 ) return ;
TaskTool tasks = new TaskTool ( ) ;
foreach ( var item in robots )
{
if ( ! robotOffLineAutoLoginList . ContainsKey ( item . name ) )
continue ;
else if ( robotOffLineAutoLoginList [ item . name ] > 2 )
continue ;
var _item = item ;
tasks . AddTask ( delegate ( )
{
try
{
EventClient . OnEvent ( this , $"正在尝试自动微信->{_item.name}({_item.nick})..." ) ;
var wx = ChatClient . WXClient . FirstOrDefault ( f = > f . Key = = _item . name ) . Value ;
if ( wx ! = null ) wx . ResetConnection ( ) ;
else ChatClient . LoginWeixin ( _item . name , _item . token ) ;
}
catch ( Exception ex )
{
EventClient . OnEvent ( this , $"自动登录微信->{_item.name}({_item.nick})异常:{ex.Message}" ) ;
}
} ) ;
}
if ( tasks . Tasks . Count ! = 0 )
tasks . Start ( 30 , AsyncCallbackMethod2 ) ;
}
catch { }
} ) . BeginInvoke ( null , null ) ;
UpdTime ( ) ;
}
/// <summary>
/// 更新win时间
/// </summary>
public void UpdTime ( )
{
try
{
new Action ( delegate ( )
{
try
{
HttpHelper http = new HttpHelper ( ) ;
var item = new HttpItem ( ) ;
item . URL = "http://quan.suning.com/getSysTime.do" ;
var html = http . GetHtml ( item ) . Html ;
var temp = JObject . Parse ( html ) ;
if ( temp [ "sysTime2" ] ! = null )
{
var time = DateTime . Parse ( temp [ "sysTime2" ] . ToString ( ) . Trim ( ) ) ;
Daytime . SetWindowsClock ( time ) ;
}
}
catch ( Exception ex )
{ }
} ) . BeginInvoke ( null , null ) ;
}
catch ( Exception ex )
{ }
}
private void AsyncCallbackMethod2 ( IAsyncResult ar )
{
EventClient . OnEvent ( this , MethodType . 刷 新 机 器 人 ) ;
EventClient . OnEvent ( this , $"尝试自动登录线程已完成!" ) ;
var session = ApiClient . GetSession ( ) ;
var robots = session . FindRobots ( true ) . Where ( f = > f . type = = ChatType . 微 信 & & f . remark ! = "PCWechat HOOK" ) ;
var wxClients = ChatClient . WXClient . Values ;
foreach ( var robot in robots )
{
var isLogin = wxClients . FirstOrDefault ( f = > robot . name = = f . WeixinHao & & ( f . Status = = WxStatus . 已 掉 线 | | f . Status = = WxStatus . 已 退 出 | | f . Status = = WxStatus . 未 登 录 ) ) = = null ;
if ( isLogin | | robot . off_line_auto_login = = SwitchType . 关 闭 )
robotOffLineAutoLoginList . Remove ( robot . name ) ;
}
}
private void barButtonItem86_ItemClick ( object sender , ItemClickEventArgs e )
{
new TCPForm ( ) . ShowDialog ( ) ;
}
private void barButtonItem103_ItemClick ( object sender , ItemClickEventArgs e )
{
try
{
if ( ApiClient . Server ! = null & & ApiClient . Server . State = = SuperSocket . SocketBase . ServerState . Running )
{
ChatClient . PCRobotPool . SendAppUpdate ( ) ;
BaseForm . ShowSuccessAutoClose ( "请求远程更新成功!!!" ) ;
}
else
throw new Exception ( "Socket通讯未开启,此操作无效!!!" ) ;
}
catch ( Exception ex )
{
BaseForm . ShowErrorAutoClose ( ex ) ;
}
}
private void SetShow ( List < NavTree > treeList , int index )
{
var t2List = treeList . Where ( f = > f . ceng = = 2 & & f . index = = index ) . ToList ( ) ;
foreach ( var t2 in t2List )
{
if ( t2 . name = = "首页公告" )
btn_home_manage . Visibility = t2 . check ? BarItemVisibility . Always : BarItemVisibility . Never ;
if ( t2 . name = = "接收信息" )
barButtonItem9 . Visibility = t2 . check ? BarItemVisibility . Always : BarItemVisibility . Never ;
if ( t2 . name = = "双十二" )
barButtonItem93 . Visibility = t2 . check ? BarItemVisibility . Always : BarItemVisibility . Never ;
if ( t2 . name = = "联盟管理" )
btn_cps_manage . Visibility = t2 . check ? BarItemVisibility . Always : BarItemVisibility . Never ;
if ( t2 . name = = "登录联盟" )
barButtonItem20 . Visibility = t2 . check ? BarItemVisibility . Always : BarItemVisibility . Never ;
if ( t2 . name = = "授权管理" )
barButtonItem91 . Visibility = t2 . check ? BarItemVisibility . Always : BarItemVisibility . Never ;
if ( t2 . name = = "机器人管理" )
btn_robot_manage . Visibility = t2 . check ? BarItemVisibility . Always : BarItemVisibility . Never ;
if ( t2 . name = = "登录机器人" )
barButtonItem19 . Visibility = t2 . check ? BarItemVisibility . Always : BarItemVisibility . Never ;
if ( t2 . name = = "数据报表" )
btn_data_manage . Visibility = t2 . check ? BarItemVisibility . Always : BarItemVisibility . Never ;
if ( t2 . name = = "运行日志" )
btn_log_manage . Visibility = t2 . check ? BarItemVisibility . Always : BarItemVisibility . Never ;
if ( t2 . name = = "系统设置" )
barButtonItem13 . Visibility = t2 . check ? BarItemVisibility . Always : BarItemVisibility . Never ;
if ( t2 . name = = "其他设置" )
barButtonItem41 . Visibility = t2 . check ? BarItemVisibility . Always : BarItemVisibility . Never ;
if ( t2 . name = = "保存配置" )
barButtonItem56 . Visibility = t2 . check ? BarItemVisibility . Always : BarItemVisibility . Never ;
if ( t2 . name = = "订单管理" )
barButtonItem48 . Visibility = t2 . check ? BarItemVisibility . Always : BarItemVisibility . Never ;
if ( t2 . name = = "提现管理" )
barButtonItem76 . Visibility = t2 . check ? BarItemVisibility . Always : BarItemVisibility . Never ;
if ( t2 . name = = "用户管理" )
barButtonItem43 . Visibility = t2 . check ? BarItemVisibility . Always : BarItemVisibility . Never ;
if ( t2 . name = = "群负责人" )
barButtonItem67 . Visibility = t2 . check ? BarItemVisibility . Always : BarItemVisibility . Never ;
if ( t2 . name = = "群通知机器人" )
barButtonItem96 . Visibility = t2 . check ? BarItemVisibility . Always : BarItemVisibility . Never ;
if ( t2 . name = = "测试邮件通信" )
barButtonItem16 . Visibility = t2 . check ? BarItemVisibility . Always : BarItemVisibility . Never ;
if ( t2 . name = = "同步服务器缓存" )
barButtonItem42 . Visibility = t2 . check ? BarItemVisibility . Always : BarItemVisibility . Never ;
if ( t2 . name = = "上传商户配置" )
barButtonItem59 . Visibility = t2 . check ? BarItemVisibility . Always : BarItemVisibility . Never ;
if ( t2 . name = = "查询商品记录" )
barButtonItem49 . Visibility = t2 . check ? BarItemVisibility . Always : BarItemVisibility . Never ;
if ( t2 . name = = "淘宝订单尾号" )
barButtonItem57 . Visibility = t2 . check ? BarItemVisibility . Always : BarItemVisibility . Never ;
if ( t2 . name = = "强制结算订单" )
barButtonItem63 . Visibility = t2 . check ? BarItemVisibility . Always : BarItemVisibility . Never ;
if ( t2 . name = = "应用功能" )
barButtonItem6 . Visibility = t2 . check ? BarItemVisibility . Always : BarItemVisibility . Never ;
if ( t2 . name = = "刷新应用" )
barButtonItem29 . Visibility = t2 . check ? BarItemVisibility . Always : BarItemVisibility . Never ;
if ( t2 . name = = "全部重启" )
barButtonItem31 . Visibility = t2 . check ? BarItemVisibility . Always : BarItemVisibility . Never ;
if ( t2 . name = = "执行顺序" )
barButtonItem30 . Visibility = t2 . check ? BarItemVisibility . Always : BarItemVisibility . Never ;
if ( t2 . name = = "开发调试" )
barButtonItem27 . Visibility = t2 . check ? BarItemVisibility . Always : BarItemVisibility . Never ;
if ( t2 . name = = "加密应用" )
barButtonItem11 . Visibility = t2 . check ? BarItemVisibility . Always : BarItemVisibility . Never ;
if ( t2 . name = = "应用目录" )
barButtonItem40 . Visibility = t2 . check ? BarItemVisibility . Always : BarItemVisibility . Never ;
if ( t2 . name = = "手动转链" )
barButtonItem81 . Visibility = t2 . check ? BarItemVisibility . Always : BarItemVisibility . Never ;
if ( t2 . name = = "Web通讯" )
barButtonItem72 . Visibility = t2 . check ? BarItemVisibility . Always : BarItemVisibility . Never ;
if ( t2 . name = = "Socket通讯" )
barButtonItem86 . Visibility = t2 . check ? BarItemVisibility . Always : BarItemVisibility . Never ;
if ( t2 . name = = "更新易转发" )
barButtonItem103 . Visibility = t2 . check ? BarItemVisibility . Always : BarItemVisibility . Never ;
if ( t2 . name = = "检查更新" )
barButtonItem39 . Visibility = t2 . check ? BarItemVisibility . Always : BarItemVisibility . Never ;
if ( t2 . name = = "更新摘要" )
barButtonItem77 . Visibility = t2 . check ? BarItemVisibility . Always : BarItemVisibility . Never ;
if ( t2 . name = = "软件目录" )
barButtonItem78 . Visibility = t2 . check ? BarItemVisibility . Always : BarItemVisibility . Never ;
if ( t2 . name = = "建议反馈" )
barButtonItem34 . Visibility = t2 . check ? BarItemVisibility . Always : BarItemVisibility . Never ;
if ( t2 . name = = "重启软件" )
barButtonItem65 . Visibility = t2 . check ? BarItemVisibility . Always : BarItemVisibility . Never ;
}
}
private bool isrun = false ;
private void Timer_Elapsed ( object sender , System . Timers . ElapsedEventArgs e )
{
if ( isrun )
return ;
isrun = true ;
try
{
var h = DateTime . Now . Hour ; if ( ! ( 1 < = h & & h < 3 ) )
return ;
try
{
var robots = ChatClient . WXClient . Values . Where ( f = > f . Status = = WxStatus . 在 线 ) . ToList ( ) ;
foreach ( var robot in robots )
{
try
{
var db = ApiClient . GetSession ( ) ;
var members = db . Find < fl_member_info > ( "select * from fl_member_info where robot_name = @robotname and headurl = @headurl" , new { robotname = robot . WeixinHao , headurl = "" } ) ;
var friends = robot . Friends ;
foreach ( var member in members )
{
if ( friends ! = null & & friends . ContainsKey ( member . username ) )
{
var headurl = friends [ member . username ] . BigHeadImgUrl ;
if ( ! string . IsNullOrWhiteSpace ( headurl ) )
{
member . headurl = friends [ member . username ] . BigHeadImgUrl ;
db . SaveOrUpdate ( member ) ;
}
}
else
{
var f = robot . GetContact ( member . username ) ;
if ( f ! = null )
{
if ( ! string . IsNullOrWhiteSpace ( f . BigHeadImgUrl ) )
{
member . headurl = f . BigHeadImgUrl ;
db . SaveOrUpdate ( member ) ;
}
}
}
}
}
catch ( Exception ex )
{ }
}
}
catch ( Exception exception )
{ }
}
catch ( Exception ex )
{ }
finally
{
isrun = false ;
}
}
private ChatType SetUserType ( int itemType )
{
switch ( itemType )
{
case 0 :
return ChatType . 微 信 ;
case 1 :
return ChatType . QQ ;
case 2 :
return ChatType . 企 业 微 信 ;
}
return ChatType . 微 信 ;
}
/// <summary>
/// 读取黑名单
/// </summary>
/// <param name="isAsc"></param>
/// <param name="callback"></param>
public static void ReadBlacklist ( DateTime updateDateTime , bool isAsc , Func < List < CloudBlacklistResult > , int , int , bool > callback )
{
var size = 1000 ;
var index = 1 ;
while ( true )
{
var res = YZCloudApiHelper . GetBlacklist ( new BlacklistSearchPagingInput ( )
{
PageIndex = index ,
PageSize = size ,
UserToken = "" ,
IsAsc = isAsc ,
UpdateDateTime = updateDateTime ,
AuditState = AuditStateEmun . Succee
} ) ;
if ( res = = null | | res . Datas . Count < = 0 )
{
break ;
}
if ( callback ? . Invoke ( res . Datas , index , res . PageNumber ) = = true )
{
break ;
}
if ( index < = 0 )
{
break ;
}
index + + ;
}
}
private static bool isrunblackuser = false ;
public void Timer_ElapsedBlackUser ( object sender , System . Timers . ElapsedEventArgs e )
{
if ( isrunblackuser ) return ;
isrunblackuser = true ;
var db = ApiClient . GetSession ( ) ;
try
{
if ( timerBlackUser . Interval = = 1000 )
timerBlackUser . Interval = 5 * 60 * 1000 ;
#region 同 步 云 黑 名 单
var BlackUserTime = Util . AppConfig_GetValue ( "BlackUserTime" ) ;
//Util.AppConfig_ModifyItem("BlackUserTime", "");
ReadBlacklist (
string . IsNullOrWhiteSpace ( BlackUserTime ) ? DateTime . MinValue : DateTime . Parse ( BlackUserTime ) , false ,
( items , index , total ) = >
{
//Console.WriteLine("输出:" + index + "|" + total + "|" + items.Count);
BlackUserTime = Util . AppConfig_GetValue ( "BlackUserTime" ) ;
var syncTime = string . IsNullOrWhiteSpace ( BlackUserTime )
? DateTime . MinValue
: DateTime . Parse ( BlackUserTime ) ;
if ( syncTime ! = DateTime . MinValue )
{
syncTime = syncTime . AddMinutes ( - 1 ) ;
}
bool issyncAdd = false ;
db . Ado . BeginTran ( ) ;
foreach ( var item in items )
{
if ( item . UpdateDateTime > = syncTime )
{
issyncAdd = true ;
var type = SetUserType ( item . Type ) ;
var info = db . Queryable < fl_blackuser > ( )
. Where ( w = > w . username = = item . UserName & & w . usertype = = type ) . First ( ) ;
if ( info = = null )
{
info = new fl_blackuser ( ) ;
info . usertype = type ;
info . username = item . UserName ;
info . nickname = item . UserNick ;
info . remark = item . Remark ;
info . avatar = item . Avatar ;
info . updatetime = item . UpdateDateTime ; //DateTime.Now;
info . isdel = item . IsRemove ;
info . iscloud = true ;
db . Insertable ( info ) . ExecuteCommand ( ) ;
}
else
{
//if (info.isdel)
//{
// //如果本地已经删除,则忽略。
// continue;
//}
info . avatar = item . Avatar ;
info . isdel = item . IsRemove ;
info . updatetime = item . UpdateDateTime ;
info . remark = item . Remark ;
info . iscloud = true ;
db . Updateable ( info ) . ExecuteCommand ( ) ;
}
}
}
if ( issyncAdd )
{
//保存最后同步的时间
Util . AppConfig_ModifyItem ( "BlackUserTime" ,
items . LastOrDefault ( ) . UpdateDateTime . ToString ( "yyyy-MM-dd HH:mm:ss" ) ) ;
//items.LastOrDefault().UpdateDateTime);
}
db . Ado . CommitTran ( ) ;
return false ;
} ) ;
#endregion
}
catch ( Exception ex )
{
db . Ado . RollbackTran ( ) ;
}
finally
{
isrunblackuser = false ;
}
}
private void barButtonItem108_ItemClick ( object sender , ItemClickEventArgs e )
{
//TODO 快手
2022-10-08 06:50:40 +00:00
return ;
2022-09-20 03:10:29 +00:00
if ( LoginCps ( CpsType . 快 手 联 盟 ) ! = null )
ItemClick ( btn_cps_manage , e ) ;
}
}
}