步步为盈
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

115 lines
3.8 KiB

using BBWY.Common.Models;
using QYDongDongTool;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Windows;
namespace BBWY.Client.Helpers
{
public class DongDongHelper : IDenpendency
{
private CSharpAPIs csapi;
private System.Timers.Timer inJectionTimer;
public DongDongHelper()
{
csapi = new CSharpAPIs();
inJectionTimer = new System.Timers.Timer(20000);
inJectionTimer.Elapsed += InJectionTimer_Elapsed;
}
private void InJectionTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
InJection();
}
private void InJection()
{
try
{
var jdweb_cef_subprocessList = Process.GetProcessesByName("jdwb_cef_subprocess");
if (jdweb_cef_subprocessList.Length > 0)
{
foreach (var jdweb_cef_subprocess in jdweb_cef_subprocessList)
{
ProcessStartInfo pi = new ProcessStartInfo();
//p.UseShellExecute = true;
pi.CreateNoWindow = true;
pi.FileName = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "InJectionDongDong", "dllin(3).exe");
pi.Arguments = $"[{jdweb_cef_subprocess.Id}]";
pi.Verb = "runas";
pi.RedirectStandardOutput = true;
var p = Process.Start(pi);
string output = p.StandardOutput.ReadToEnd();
p.WaitForExit();
Console.WriteLine($"jdweb_cef_subprocess {jdweb_cef_subprocess.Id} output: {output}");
}
}
}
catch (Exception ex)
{
Console.WriteLine($"InJection Error, {ex.Message}");
}
}
public void StartInJection()
{
if (!inJectionTimer.Enabled)
{
InJection();
inJectionTimer.Start();
}
}
/// <summary>
/// 获取全部登录咚咚账号
/// </summary>
/// <returns></returns>
public List<string> GetAllDongdongUser()
{
List<string> dongdongList = new List<string>();
var list = csapi.GetAllDesktopWindows();
var windows = list.Where(c => c.szClassName == "Qt5QWindowIcon").ToList(); //DD_JM_Workbench_DLG
windows.ForEach(info =>
{
dongdongList.Add(info.szWindowName.Replace("的工作台", string.Empty)
.Replace("-咚咚融合工作台", string.Empty));
});
return dongdongList;
}
/// <summary>
/// 唤醒咚咚
/// </summary>
/// <param name="waiterName"></param>
/// <param name="buyerAccount"></param>
public void WakeUpDongDong(string waiterName, string buyerAccount)
{
var url = $"jdworkstation://jm/?command=openDD&pin={waiterName}&client={buyerAccount}";
try
{
try
{
//Process.Start("explorer.exe", url);
ShellExecuteHelper.ShellExecute(IntPtr.Zero, "open", url, string.Empty, string.Empty, ShellExecuteHelper.ShowCommands.SW_SHOWNORMAL);
}
catch (Exception ex)
{
Clipboard.SetText(url);
MessageBox.Show($"{ex.Message}\r\n唤醒咚咚失败,唤醒链接已复制到剪切板,请手动打开浏览器唤醒", "提示");
}
}
catch { throw; }
}
}
}