966 lines
42 KiB
C#
966 lines
42 KiB
C#
using Api.Framework;
|
||
using Api.Framework.SDK;
|
||
using Api.Framework.Tools;
|
||
using Api.Framework.Utils;
|
||
using Chat.Framework.WXSdk.Implement;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Threading;
|
||
using System.Windows.Forms;
|
||
using UI.Framework.Controls;
|
||
using UI.Framework.Forms;
|
||
using UserFission.Entitys;
|
||
using UserFission.Properties;
|
||
|
||
namespace UserFission
|
||
{
|
||
public partial class MainForm : BaseForm
|
||
{
|
||
public MainForm()
|
||
{
|
||
InitializeComponent();
|
||
this.Text = Resources.MainFormTitle;
|
||
}
|
||
|
||
public void CloseForm()
|
||
{
|
||
try
|
||
{
|
||
if (!this.IsDisposed)
|
||
{
|
||
this.Invoke(new Action(delegate
|
||
{
|
||
this.Close();
|
||
this.Dispose();
|
||
}));
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
ShowError(ex);
|
||
}
|
||
}
|
||
|
||
private void RefreshRewards()
|
||
{
|
||
var result = Tools.FindRewards(true);
|
||
label9.Visible = result.Count == 0;
|
||
gridControl7.DataSource = result;
|
||
}
|
||
|
||
private void MainForm_Load(object sender, EventArgs e)
|
||
{
|
||
try
|
||
{
|
||
if (Class1.Config.InviteGroupInfo2 == null)
|
||
{
|
||
if (Class1.Config.InviteGroupInfo != null && Class1.Config.InviteGroupInfo.Count != 0)
|
||
{
|
||
Class1.Config.InviteGroupInfo2 = new Dictionary<string, wxinfo>();
|
||
|
||
foreach (var item in Class1.Config.InviteGroupInfo)
|
||
{
|
||
var wx = new wxinfo();
|
||
wx.onoff = item.Value.onoff;
|
||
var groupIds = item.Value.groupIds;
|
||
foreach (var _item in groupIds)
|
||
{
|
||
if (!wx.groupInfos.ContainsKey(_item))
|
||
wx.groupInfos.Add(_item, string.Empty);
|
||
}
|
||
Class1.Config.InviteGroupInfo2.Add(item.Key, wx);
|
||
}
|
||
}
|
||
}
|
||
|
||
settingControl1.Bind(Class1.Config, 130);
|
||
|
||
#region 加载账号邀请码信息数据
|
||
|
||
pageControl1.Bind((page, size) =>
|
||
{
|
||
var session = ApiClient.GetSession();
|
||
var parm = session.NewParamMap();
|
||
parm.setPageParamters(page, size);
|
||
var where = string.IsNullOrWhiteSpace(text_userinfo.Text) ? "" : $"where m.username like '%{text_userinfo.Text.Replace("'", "''").Trim()}%' OR m.usernick like '%{text_userinfo.Text.Replace("'", "''").Trim()}%' OR ic.code like '%{text_userinfo.Text.Replace("'", "''").Trim()}%'";
|
||
var result = session.FindPage<user_invitation_code_temp>($"select m.id,m.robot_type as chattype,m.username as name,m.usernick as nick,ic.crt_time as crt_time,ic.code as code from fl_plugin_userfission_user_invitation_code ic LEFT JOIN fl_member_info m on ic.member_info_id = m.id {where}", parm);
|
||
return new PageControl.SerchResult() { Result = result.DataList, Total = result.Total };
|
||
}, gridControl1, 40, true, true);
|
||
|
||
var f = new ImageDesignForm();
|
||
f.TopLevel = false;
|
||
f.Parent = this.xtraTabPage2;
|
||
f.Show();
|
||
|
||
#endregion
|
||
|
||
#region 加载所有的账号
|
||
pageControl2.Bind((page, size) =>
|
||
{
|
||
var session = ApiClient.GetSession();
|
||
var parm = session.NewParamMap();
|
||
parm.setPageParamters(page, size);
|
||
var result = session.FindPage<automatic_approval_setting_temp>("select r.id as rid,r.name as name,r.nick as nick,a.onoff as onoff from fl_robot_info r left join fl_plugin_userfission_automatic_approval_setting a on r.id = a.rid", parm);
|
||
return new PageControl.SerchResult() { Result = result.DataList, Total = result.Total };
|
||
}, gridControl4, 40, true, true);
|
||
|
||
label3.Visible = gridView4.RowCount == 0;
|
||
|
||
#endregion
|
||
|
||
RefreshRewards();
|
||
|
||
numericUpDown1.Value = Class1.Config.FinishOrder_Rule;
|
||
if (Class1.Config.InvitegroupWay)
|
||
radioButton1.Checked = true;
|
||
else
|
||
radioButton2.Checked = true;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
ShowError(ex);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 窗体关闭
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
|
||
{
|
||
try
|
||
{
|
||
//比较最大值和最小值是否合法
|
||
if (Class1.Config.SuperiorSum1 > Class1.Config.SuperiorSum2)//推荐人奖励不符合
|
||
{
|
||
ShowError("推荐人奖励设置不合法:最大值不能小于最小值");
|
||
e.Cancel = true;
|
||
}
|
||
else if (Class1.Config.SubordinateSum1 > Class1.Config.SubordinateSum2)//新人奖励不符合
|
||
{
|
||
ShowError("新人奖励设置不合法:最大值不能小于最小值");
|
||
e.Cancel = true;
|
||
}
|
||
if (!e.Cancel)
|
||
{
|
||
Util.Save(Class1.Config);
|
||
OrderHelper.RefreshConfig(true);
|
||
//TimerTask.Close<ApplyFriendThread>();
|
||
//TimerTask.NewTimer<ApplyFriendThread>(Class1.Config.Retardation);
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
ShowError(ex);
|
||
}
|
||
}
|
||
|
||
private void gridView1_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
|
||
{
|
||
try
|
||
{
|
||
if (e.Column.Caption == "邀请码")
|
||
{
|
||
if (string.IsNullOrWhiteSpace(e.Value.ToString()))
|
||
throw new Exception("邀请码不能为空");
|
||
var selectRow = gridView1.GetSelectedRows()[0];
|
||
var id = this.gridView1.GetRowCellValue(selectRow, "ID").ToString();//获取ID列的数据
|
||
if (!Tools.CheckInvitationCode(e.Value.ToString()))
|
||
throw new Exception("邀请码已经存在,请换一组!");
|
||
else
|
||
{
|
||
var session = ApiClient.GetSession();
|
||
var invitation_code = session.Find<fl_plugin_userfission_user_invitation_code>("select * from fl_plugin_userfission_user_invitation_code where member_info_id = @id", new { id = id });
|
||
session.ExcuteSQL("update fl_plugin_userfission_user_invitation_code set code = @code where member_info_id = @id", new { code = e.Value.ToString(), id = id });
|
||
ShowSuccess("修改成功");
|
||
pageControl1.GotoPage(1);
|
||
}
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
ShowError(ex);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 搜索用户信息
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void simpleButton2_Click(object sender, EventArgs e)
|
||
{
|
||
try
|
||
{
|
||
pageControl1.GotoPage(1);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
ShowError(ex);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// tab标签改变的时候,将改变
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void xtraTabControl1_SelectedPageChanged(object sender, DevExpress.XtraTab.TabPageChangedEventArgs e)
|
||
{
|
||
try
|
||
{
|
||
if (xtraTabControl1.SelectedTabPageIndex == 3)
|
||
{
|
||
//&& f.WeixinType == WeixinType.Grpc微信
|
||
var wxBases = Chat.Framework.ChatClient.WXClient.Values.ToList().ToList().Where(f => f.Status == Chat.Framework.WXSdk.WxStatus.在线).ToList();
|
||
if (wxBases != null)
|
||
{
|
||
label1.Visible = wxBases.Count == 0;
|
||
label2.Visible = gridView3.RowCount == 0;
|
||
|
||
List<object> objList = new List<object>();
|
||
if (Class1.Config.InviteGroupInfo2 == null)
|
||
Class1.Config.InviteGroupInfo2 = new Dictionary<string, wxinfo>();
|
||
foreach (var item in wxBases)
|
||
{
|
||
var key = Class1.Config.InviteGroupInfo2.Keys.FirstOrDefault(f => f == item.WeixinHao);
|
||
if (!string.IsNullOrEmpty(key))
|
||
{
|
||
var result = Class1.Config.InviteGroupInfo2[key];
|
||
objList.Add(new { chatname = (item.WeixinType == WeixinType.QYHook微信 ? ChatType.企业微信 : ChatType.微信), name = key, nick = item.User.Nick, onoff = result.onoff });
|
||
}
|
||
else
|
||
{
|
||
objList.Add(new { chatname = (item.WeixinType == WeixinType.QYHook微信 ? ChatType.企业微信 : ChatType.微信), name = item.WeixinHao, nick = item.User.Nick, onoff = false });
|
||
//Class1.Config.InviteGroupInfo.Add(item.WeixinHao, new wx_info() { onoff = false, groupIds = new List<string>() });//字典中不存在,添加一条
|
||
Class1.Config.InviteGroupInfo2.Add(item.WeixinHao, new wxinfo() { onoff = false, groupInfos = new Dictionary<string, string>() });//字典中不存在,添加一条
|
||
}
|
||
}
|
||
gridControl2.DataSource = objList;
|
||
}
|
||
}
|
||
else if (xtraTabControl1.SelectedTabPageIndex == 4)
|
||
{
|
||
List<object> objList = new List<object>();
|
||
// && f.WeixinType == WeixinType.Grpc微信
|
||
var wxBases = Chat.Framework.ChatClient.WXClient.Values.ToList().Where(f => f.Status == Chat.Framework.WXSdk.WxStatus.在线).ToList();
|
||
if (wxBases != null)
|
||
{
|
||
//label5.Visible = qqBases.Count == 0;
|
||
//label4.Visible = gridView5.RowCount == 0;
|
||
|
||
//List<wx_info> wxkey = new List<wx_info>();
|
||
foreach (var item in wxBases)
|
||
{
|
||
var key = Class1.Config.NewComerGroupInfo.Keys.FirstOrDefault(f => f == item.WeixinHao);
|
||
if (!string.IsNullOrEmpty(key))
|
||
{
|
||
var result = Class1.Config.NewComerGroupInfo[key];
|
||
objList.Add(new { chatname = ChatType.微信, name = key, nick = item.User.Nick, onoff = result.onoff });
|
||
}
|
||
else
|
||
{
|
||
objList.Add(new { chatname = ChatType.微信, name = item.WeixinHao, nick = item.User.Nick, onoff = false });
|
||
Class1.Config.NewComerGroupInfo.Add(item.WeixinHao, new wx_info() { onoff = false, groupIds = new List<string>() });//字典中不存在,添加一条
|
||
}
|
||
}
|
||
}
|
||
|
||
label5.Visible = objList.Count == 0;
|
||
label4.Visible = gridView5.RowCount == 0;
|
||
|
||
gridControl6.DataSource = objList;
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
ShowError(ex);
|
||
}
|
||
}
|
||
|
||
|
||
private void RefreshGroupView()
|
||
{
|
||
#region 通过手动添加群信息
|
||
if (!string.IsNullOrWhiteSpace(weixinhao))
|
||
{
|
||
if (Class1.Config.InviteGroupInfo2.ContainsKey(weixinhao))
|
||
{
|
||
List<int> checkedIndexs = new List<int>();
|
||
var wx = Class1.Config.InviteGroupInfo2[weixinhao];
|
||
//wx.onoff
|
||
List<object> objList = new List<object>();
|
||
foreach (var item in wx.groupInfos)
|
||
{
|
||
objList.Add(new { group_id = item.Key, group_name = item.Value });
|
||
//if (item.Count != 0)
|
||
//{
|
||
// if (item.Contains(item.UserName))
|
||
// checkedIndexs.Add(i);
|
||
//}
|
||
//i++;
|
||
}
|
||
gridControl3.DataSource = objList;
|
||
if (checkedIndexs.Count != 0)
|
||
{
|
||
int[] indexs = checkedIndexs.ToArray();
|
||
foreach (var index in checkedIndexs)
|
||
{
|
||
gridView3.SelectRow(index);
|
||
}
|
||
}
|
||
label2.Visible = gridView3.RowCount == 0;
|
||
}
|
||
}
|
||
#endregion
|
||
}
|
||
|
||
/// <summary>
|
||
/// 左边的列表点击后保存下来的微信号
|
||
/// </summary>
|
||
string weixinhao = string.Empty;
|
||
|
||
//点击机器人,获取右边的机器人对应的配置
|
||
private void gridView2_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
|
||
{
|
||
try
|
||
{
|
||
if (e.Clicks == 1)
|
||
{
|
||
var rows = gridView2.GetSelectedRows();
|
||
if (rows != null && rows.Length != 0)
|
||
{
|
||
weixinhao = this.gridView2.GetRowCellValue(rows[0], "name").ToString();
|
||
RefreshGroupView();
|
||
|
||
//if (!string.IsNullOrEmpty(weixinhao))
|
||
//{
|
||
#region 之前读取通讯录 xxx
|
||
//var wxBase = Chat.Framework.ChatClient.WXClient.Values.ToList().FirstOrDefault(f => f.WeixinHao == weixinhao && f.Status == Chat.Framework.WXSdk.WxStatus.在线 && f.WeixinType == WeixinType.Grpc微信);
|
||
//if (wxBase != null)
|
||
//{
|
||
// var ipad = wxBase as WXClientImpl_IPAD;
|
||
// if (ipad == null) return;
|
||
// if (ipad.Friends.Count == 0)
|
||
// {
|
||
// Loding.ShowWaitForm();
|
||
// xtraTabControl1.Enabled = false;
|
||
// ipad.RefreshContact();
|
||
// int executionTime = 700;
|
||
// while (ipad.IsRefreshContact)
|
||
// {
|
||
// this.Sleep(1000);
|
||
// executionTime--;
|
||
// if (executionTime <= 0)
|
||
// {
|
||
// Loding.CloseWaitForm();
|
||
// throw new Exception("获取好友超时");
|
||
// }
|
||
// }
|
||
// xtraTabControl1.Enabled = true;
|
||
// Loding.CloseWaitForm();
|
||
// }
|
||
// var groups = ipad.Friends.Values.Where(f => !string.IsNullOrEmpty(f.ChatRoomOwner));
|
||
// List<string> groupInfo = new List<string>();
|
||
// if (Class1.Config.InviteGroupInfo.ContainsKey(weixinhao))
|
||
// {
|
||
// groupInfo = Class1.Config.InviteGroupInfo[weixinhao].groupIds;
|
||
// }
|
||
// List<object> objList = new List<object>();
|
||
// List<int> checkedIndexs = new List<int>();
|
||
// int i = 0;
|
||
// foreach (var item in groups)
|
||
// {
|
||
// var memberNum = item.ExtInfo.Replace(",", ",").Split(',').Length;//人员数量
|
||
// objList.Add(new { group_id = item.UserName, group_nick = item.NickName, member_num = memberNum });
|
||
// if (groupInfo.Count != 0)
|
||
// {
|
||
// if (groupInfo.Contains(item.UserName))
|
||
// checkedIndexs.Add(i);
|
||
// }
|
||
// i++;
|
||
// }
|
||
// gridControl3.DataSource = objList;
|
||
// if (checkedIndexs.Count != 0)
|
||
// {
|
||
// int[] indexs = checkedIndexs.ToArray();
|
||
// foreach (var index in checkedIndexs)
|
||
// {
|
||
// gridView3.SelectRow(index);
|
||
// }
|
||
// }
|
||
//}
|
||
//label2.Visible = gridView3.RowCount == 0;
|
||
#endregion
|
||
//}
|
||
}
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
ShowError(ex);
|
||
}
|
||
finally
|
||
{
|
||
xtraTabControl1.Enabled = true;
|
||
}
|
||
}
|
||
|
||
private void gridView3_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
|
||
{
|
||
//try
|
||
//{
|
||
// if (string.IsNullOrEmpty(weixinhao)) throw new Exception("请点击左侧列表选择机器人账号");
|
||
// if (e.Column.AbsoluteIndex == -1)
|
||
// {
|
||
// var flag = e.CellValue.ToString().ToLower() != "true";
|
||
// var groupIds = Class1.Config.InviteGroupInfo2[weixinhao].groupInfos;//获取配置文件中的群号集合
|
||
// var group_id = gridView3.GetRowCellDisplayText(gridView3.FocusedRowHandle, gridView3.Columns["group_id"]);//获取群号
|
||
// if (flag)//增加到集合中
|
||
// {
|
||
// if (!groupIds.ContainsKey(group_id))
|
||
// {
|
||
// var group_name = gridView3.GetRowCellDisplayText(gridView3.FocusedRowHandle, gridView3.Columns["group_name"]);//获取群号
|
||
// groupIds.Add(group_id, group_name);
|
||
// }
|
||
// }
|
||
// else
|
||
// {
|
||
// if (groupIds.ContainsKey(group_id))
|
||
// groupIds.Remove(group_id);
|
||
// }
|
||
// Util.Save(Class1.Config);
|
||
// }
|
||
//}
|
||
//catch (Exception ex)
|
||
//{
|
||
// ShowError(ex);
|
||
//}
|
||
}
|
||
|
||
private void gridView3_SelectionChanged(object sender, DevExpress.Data.SelectionChangedEventArgs e)
|
||
{
|
||
//try
|
||
//{
|
||
// if (e.ControllerRow < 0)
|
||
// {
|
||
// if (string.IsNullOrEmpty(weixinhao)) throw new Exception("请点击左侧列表选择机器人账号");
|
||
// var groupIds = Class1.Config.InviteGroupInfo2[weixinhao].groupInfos;//获取配置文件中的群号集合
|
||
// groupIds.Clear();
|
||
// if (gridView3.SelectedRowsCount != 0)
|
||
// {
|
||
// for (int i = 0; i < gridView3.SelectedRowsCount; i++)
|
||
// {
|
||
// var group_id = gridView3.GetRowCellDisplayText(i, gridView3.Columns["group_id"]);//获取群号
|
||
// if (!groupIds.ContainsKey(group_id))//增加到集合中
|
||
// {
|
||
// var group_name = gridView3.GetRowCellDisplayText(i, gridView3.Columns["group_name"]);//获取群号
|
||
// groupIds.Add(group_id, group_name);
|
||
// }
|
||
// }
|
||
// }
|
||
// Util.Save(Class1.Config);
|
||
// }
|
||
//}
|
||
//catch (Exception ex)
|
||
//{
|
||
// ShowError(ex);
|
||
//}
|
||
}
|
||
|
||
private void gridView2_RowCellClick_1(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
|
||
{
|
||
try
|
||
{
|
||
#region 开关单元格单击修改状态
|
||
if (e.Column.FieldName == "onoff")
|
||
{
|
||
if (e.Clicks == 1)
|
||
{
|
||
label2.Visible = gridView3.RowCount == 0;
|
||
|
||
if (!(bool)e.CellValue && MessageBox.Show("该微信确定禁用使用拉群功能吗?", "系统提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
|
||
return;
|
||
var name = gridView2.GetRowCellDisplayText(gridView2.FocusedRowHandle, gridView2.Columns["name"]);//获取群号
|
||
|
||
var inviteGroupInfo2 = Class1.Config.InviteGroupInfo2[name];
|
||
inviteGroupInfo2.onoff = !inviteGroupInfo2.onoff;
|
||
Util.Save(Class1.Config);
|
||
xtraTabControl1.SelectedTabPageIndex = 1;
|
||
xtraTabControl1.SelectedTabPageIndex = 3;
|
||
}
|
||
}
|
||
#endregion
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
ShowError(ex);
|
||
}
|
||
}
|
||
|
||
private void radioButton_CheckedChanged(object sender, EventArgs e)
|
||
{
|
||
try
|
||
{
|
||
Class1.Config.InvitegroupWay = radioButton1.Checked;
|
||
Util.Save(Class1.Config);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
ShowError(ex);
|
||
}
|
||
}
|
||
|
||
private void numericUpDown1_ValueChanged(object sender, EventArgs e)
|
||
{
|
||
try
|
||
{
|
||
Class1.Config.FinishOrder_Rule = (int)numericUpDown1.Value;
|
||
Util.Save(Class1.Config);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
ShowError(ex);
|
||
}
|
||
}
|
||
|
||
private void gridView4_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
|
||
{
|
||
try
|
||
{
|
||
var selectRow = gridView4.GetSelectedRows()[0];
|
||
var id = this.gridView4.GetRowCellValue(selectRow, "rid").ToString();//获取列的数据
|
||
|
||
#region 开关单元格双击修改状态
|
||
if (e.Column.FieldName == "onoff")
|
||
{
|
||
if (e.Clicks == 1)
|
||
{
|
||
if (!(bool)e.CellValue && MessageBox.Show("自动通过好友申请开关开启时,确定禁用该微信功能?", "系统提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
|
||
return;
|
||
var session = ApiClient.GetSession();
|
||
var aas = session.Find<fl_plugin_userfission_automatic_approval_setting>("select * from fl_plugin_userfission_automatic_approval_setting where rid = @id", new { id = id }).FirstOrDefault();
|
||
if (aas != null)//数据库中存在
|
||
{
|
||
aas.onoff = !aas.onoff;
|
||
session.Updateable(aas).ExecuteCommand();
|
||
}
|
||
else
|
||
{
|
||
aas = new fl_plugin_userfission_automatic_approval_setting() { onoff = true, rid = int.Parse(id) };
|
||
session.Insertable<fl_plugin_userfission_automatic_approval_setting>(aas).ExecuteCommand();
|
||
}
|
||
pageControl2.GotoPage(1);
|
||
}
|
||
}
|
||
#endregion
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
ShowError(ex);
|
||
}
|
||
}
|
||
|
||
private void gridView6_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
|
||
{
|
||
try
|
||
{
|
||
#region 开关单元格单击修改状态
|
||
if (e.Column.FieldName == "onoff")
|
||
{
|
||
if (e.Clicks == 1)
|
||
{
|
||
label4.Visible = gridView5.RowCount == 0;
|
||
|
||
if (!(bool)e.CellValue && MessageBox.Show("该微信确定禁用使用拉群功能吗?", "系统提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
|
||
return;
|
||
var name = gridView6.GetRowCellDisplayText(gridView6.FocusedRowHandle, gridView6.Columns["name"]);//获取群号
|
||
|
||
var NewComerGroupInfo = Class1.Config.NewComerGroupInfo[name];
|
||
NewComerGroupInfo.onoff = !NewComerGroupInfo.onoff;
|
||
Util.Save(Class1.Config);
|
||
xtraTabControl1.SelectedTabPageIndex = 1;
|
||
xtraTabControl1.SelectedTabPageIndex = 4;
|
||
}
|
||
}
|
||
#endregion
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
ShowError(ex);
|
||
}
|
||
}
|
||
|
||
//点击机器人,获取右边的机器人对应的配置
|
||
private void gridView6_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
|
||
{
|
||
try
|
||
{
|
||
if (e.Clicks == 1)
|
||
{
|
||
var rows = gridView6.GetSelectedRows();
|
||
if (rows != null && rows.Length != 0)
|
||
{
|
||
weixinhao = this.gridView6.GetRowCellValue(rows[0], "name").ToString();
|
||
if (!string.IsNullOrEmpty(weixinhao))
|
||
{
|
||
var wxBase = Chat.Framework.ChatClient.WXClient.Values.ToList().FirstOrDefault(f => f.WeixinHao == weixinhao && f.Status == Chat.Framework.WXSdk.WxStatus.在线);//&& f.WeixinType == WeixinType.Grpc微信
|
||
if (wxBase != null)
|
||
{
|
||
List<object> objList = new List<object>();
|
||
List<int> checkedIndexs = new List<int>();
|
||
List<string> groupInfo = new List<string>();
|
||
|
||
if (wxBase.GetType() == typeof(WXClientImpl_IPAD))
|
||
{
|
||
var ipad = wxBase as WXClientImpl_IPAD;
|
||
if (ipad == null) return;
|
||
if (ipad.Friends.Count == 0)
|
||
{
|
||
Loding.ShowWaitForm();
|
||
xtraTabControl1.Enabled = false;
|
||
ipad.RefreshContact();
|
||
int executionTime = 700;
|
||
while (ipad.IsRefreshContact)
|
||
{
|
||
this.Sleep(1000);
|
||
executionTime--;
|
||
if (executionTime <= 0)
|
||
{
|
||
Loding.CloseWaitForm();
|
||
throw new Exception("获取好友超时");
|
||
}
|
||
}
|
||
xtraTabControl1.Enabled = true;
|
||
Loding.CloseWaitForm();
|
||
}
|
||
var groups = ipad.Friends.Values.Where(f => !string.IsNullOrEmpty(f.ChatRoomOwner));
|
||
|
||
if (Class1.Config.NewComerGroupInfo.ContainsKey(weixinhao))
|
||
{
|
||
groupInfo = Class1.Config.NewComerGroupInfo[weixinhao].groupIds;
|
||
}
|
||
|
||
int i = 0;
|
||
foreach (var item in groups)
|
||
{
|
||
var memberNum = item.ExtInfo.Replace(",", ",").Split(',').Length;//人员数量
|
||
objList.Add(new { group_id = item.UserName, group_nick = item.NickName, member_num = memberNum });
|
||
if (groupInfo.Count != 0)
|
||
{
|
||
if (groupInfo.Contains(item.UserName))
|
||
checkedIndexs.Add(i);
|
||
}
|
||
i++;
|
||
}
|
||
}
|
||
else if (wxBase.GetType() == typeof(WXClientImpl_HOOK))
|
||
{
|
||
var hook = wxBase as WXClientImpl_HOOK;
|
||
if (hook == null) return;
|
||
if (hook.GroupMembers != null)
|
||
{
|
||
if (Class1.Config.NewComerGroupInfo.ContainsKey(weixinhao))
|
||
groupInfo = Class1.Config.NewComerGroupInfo[weixinhao].groupIds;
|
||
|
||
int i = 0;
|
||
foreach (var item in hook.GroupMembers)
|
||
{
|
||
var memberNum = item.Value.ToList();//人员数量
|
||
objList.Add(new { group_id = item.Key, group_nick = (hook.Friends == null ? "无" : hook.Friends.ContainsKey(item.Key) ? hook.Friends[item.Key].NickName : "无"), member_num = memberNum });
|
||
if (groupInfo.Count != 0)
|
||
{
|
||
if (groupInfo.Contains(item.Key))
|
||
checkedIndexs.Add(i);
|
||
}
|
||
i++;
|
||
}
|
||
}
|
||
}
|
||
|
||
gridControl5.DataSource = objList;
|
||
if (checkedIndexs.Count != 0)
|
||
{
|
||
int[] indexs = checkedIndexs.ToArray();
|
||
foreach (var index in checkedIndexs)
|
||
{
|
||
gridView5.SelectRow(index);
|
||
}
|
||
}
|
||
}
|
||
label4.Visible = gridView5.RowCount == 0;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
ShowError(ex);
|
||
}
|
||
finally
|
||
{
|
||
xtraTabControl1.Enabled = true;
|
||
}
|
||
}
|
||
|
||
private void gridView5_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
|
||
{
|
||
try
|
||
{
|
||
if (string.IsNullOrEmpty(weixinhao)) throw new Exception("请点击左侧列表选择机器人账号");
|
||
if (e.Column.AbsoluteIndex == -1)
|
||
{
|
||
var flag = e.CellValue.ToString().ToLower() != "true";
|
||
var groupIds = Class1.Config.NewComerGroupInfo[weixinhao].groupIds;//获取配置文件中的群号集合
|
||
var group_id = gridView5.GetRowCellDisplayText(gridView5.FocusedRowHandle, gridView5.Columns["group_id"]);//获取群号
|
||
if (flag)//增加到集合中
|
||
{
|
||
if (!groupIds.Contains(group_id))
|
||
groupIds.Add(group_id);
|
||
}
|
||
else
|
||
{
|
||
if (groupIds.Contains(group_id))
|
||
groupIds.Remove(group_id);
|
||
}
|
||
Util.Save(Class1.Config);
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
ShowError(ex);
|
||
}
|
||
}
|
||
|
||
private void gridView5_SelectionChanged(object sender, DevExpress.Data.SelectionChangedEventArgs e)
|
||
{
|
||
try
|
||
{
|
||
if (e.ControllerRow < 0)
|
||
{
|
||
if (string.IsNullOrEmpty(weixinhao)) throw new Exception("请点击左侧列表选择机器人账号");
|
||
var groupIds = Class1.Config.NewComerGroupInfo[weixinhao].groupIds;//获取配置文件中的群号集合
|
||
groupIds.Clear();
|
||
if (gridView5.SelectedRowsCount != 0)
|
||
{
|
||
for (int i = 0; i < gridView5.SelectedRowsCount; i++)
|
||
{
|
||
var group_id = gridView5.GetRowCellDisplayText(i, gridView5.Columns["group_id"]);//获取群号
|
||
if (!groupIds.Contains(group_id))//增加到集合中
|
||
groupIds.Add(group_id);
|
||
}
|
||
}
|
||
Util.Save(Class1.Config);
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
ShowError(ex);
|
||
}
|
||
}
|
||
|
||
private void 增加ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
try
|
||
{
|
||
try
|
||
{
|
||
var entity = new fl_plugin_userfission_superior_reward();
|
||
SettingForm form = new SettingForm(entity);
|
||
form.Text = "增加奖励条件";
|
||
form.ShowDialog();
|
||
if (entity.subordinate_order_totle == 0)
|
||
{
|
||
if (!this.IsDisposed) BaseForm.ShowError("下级订单数不能为零");
|
||
return;
|
||
}
|
||
var session = ApiClient.GetSession();
|
||
session.Saveable(entity).ExecuteCommand();
|
||
}
|
||
catch
|
||
{
|
||
if (!this.IsDisposed) BaseForm.ShowError("数据违反唯一性,请勿重复增加");
|
||
}
|
||
RefreshRewards();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
if (!this.IsDisposed) BaseForm.ShowError(ex);
|
||
}
|
||
}
|
||
|
||
private void 修改ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
try
|
||
{
|
||
var rows = gridView7.GetSelectedRows();
|
||
if (rows != null && rows.Length > 0)
|
||
{
|
||
var row = gridView7.GetRow(rows[0]) as fl_plugin_userfission_superior_reward;
|
||
SettingForm form = new SettingForm(row);
|
||
form.ShowDialog();
|
||
|
||
var session = ApiClient.GetSession();
|
||
session.Saveable(row).ExecuteCommand();
|
||
RefreshRewards();
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
if (!this.IsDisposed) BaseForm.ShowError(ex);
|
||
}
|
||
}
|
||
|
||
private void 删除ToolStripMenuItem_Click(object sender, EventArgs e)
|
||
{
|
||
try
|
||
{
|
||
var rows = gridView7.GetSelectedRows();
|
||
if (rows != null && rows.Length > 0)
|
||
{
|
||
var row = gridView7.GetRow(rows[0]) as base_model;
|
||
var session = ApiClient.GetSession();
|
||
session.ExcuteSQL("delete from fl_plugin_userfission_superior_reward where id = @id", new { id = row.id });
|
||
RefreshRewards();
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
if (!this.IsDisposed) BaseForm.ShowError(ex);
|
||
}
|
||
}
|
||
|
||
private void contex_1_Opening(object sender, System.ComponentModel.CancelEventArgs e)
|
||
{
|
||
try
|
||
{
|
||
var rows = gridView7.GetSelectedRows();
|
||
修改ToolStripMenuItem.Enabled = 删除ToolStripMenuItem.Enabled = (rows != null && rows.Length > 0);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
if (!this.IsDisposed) BaseForm.ShowError(ex);
|
||
}
|
||
}
|
||
|
||
private void toolStripMenuItem1_Click(object sender, EventArgs e)
|
||
{
|
||
try
|
||
{
|
||
if (string.IsNullOrEmpty(weixinhao)) throw new Exception("请先选择左侧列表机器人");
|
||
var groupForm = new EditGroupForm(weixinhao);
|
||
groupForm.ShowDialog();
|
||
RefreshGroupView();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
if (!this.IsDisposed) BaseForm.ShowError(ex);
|
||
}
|
||
}
|
||
|
||
private void toolStripMenuItem2_Click(object sender, EventArgs e)
|
||
{
|
||
try
|
||
{
|
||
var rows = gridView3.GetSelectedRows();
|
||
if (rows != null && rows.Length != 0)
|
||
{
|
||
if (string.IsNullOrEmpty(weixinhao)) throw new Exception("请先选择左侧列表机器人");
|
||
|
||
var group_id = this.gridView3.GetRowCellValue(rows[0], "group_id").ToString();
|
||
var group_nameObj = this.gridView3.GetRowCellValue(rows[0], "group_name");
|
||
var group_name = (group_nameObj == null ? string.Empty : group_nameObj.ToString());
|
||
var groupForm = new EditGroupForm(weixinhao, group_id, group_name);
|
||
groupForm.ShowDialog();
|
||
RefreshGroupView();
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
ShowError(ex);
|
||
}
|
||
}
|
||
|
||
private void toolStripMenuItem3_Click(object sender, EventArgs e)
|
||
{
|
||
try
|
||
{
|
||
var rows = gridView3.GetSelectedRows();
|
||
if (rows.Length != 0)
|
||
{
|
||
if (string.IsNullOrEmpty(weixinhao)) throw new Exception("请先选择左侧列表机器人");
|
||
for (int i = rows.Length - 1; i >= 0; i--)
|
||
{
|
||
var group_id = this.gridView3.GetRowCellValue(rows[i], "group_id").ToString();
|
||
if (Class1.Config.InviteGroupInfo2.ContainsKey(weixinhao) && Class1.Config.InviteGroupInfo2[weixinhao].groupInfos.ContainsKey(group_id))
|
||
{
|
||
|
||
Class1.Config.InviteGroupInfo2[weixinhao].groupInfos.Remove(group_id);
|
||
}
|
||
}
|
||
RefreshGroupView();
|
||
ShowSuccessAutoClose("删除成功");
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
|
||
}
|
||
}
|
||
|
||
private void toolStripMenuItem4_Click(object sender, EventArgs e)
|
||
{
|
||
//try
|
||
//{
|
||
// var selectRows = gridView1.GetSelectedRows();
|
||
// if (toolStripMenuItem4.Text.Contains("增"))
|
||
// {
|
||
// var editUserDefined = new EditUserDefinedForm(string.Empty);
|
||
// editUserDefined.ShowDialog();
|
||
// }
|
||
// else if (selectRows.Length > 0)
|
||
// {
|
||
// if (toolStripMenuItem4.Text.Contains("修"))
|
||
// {
|
||
// var editUserDefined = new EditUserDefinedForm(gridView1.GetRowCellValue(selectRows[0], "id").ToString());
|
||
// editUserDefined.ShowDialog();
|
||
// }
|
||
// else if (e.Item.Caption == "删除所有项")
|
||
// {
|
||
// var session = ApiClient.GetSession();
|
||
// session.Deleteable<fl_plugin_autoanswer_userdefinedlibrary>().ExecuteCommand();
|
||
// }
|
||
// else if (toolStripMenuItem4.Text.Contains("删"))
|
||
// {
|
||
// var session = ApiClient.GetSession();
|
||
// try
|
||
// {
|
||
// for (int i = selectRows.Length - 1; i >= 0; i--)
|
||
// {
|
||
// var pram = session.NewParamMap();
|
||
// var id = gridView1.GetRowCellValue(selectRows[i], "id").ToString();
|
||
// session.ExcuteSQL($"DELETE FROM fl_plugin_autoanswer_userdefinedlibrary where id = @id", new { id = id });
|
||
// }
|
||
// }
|
||
// catch (Exception ex)
|
||
// {
|
||
// throw ex;
|
||
// }
|
||
// }
|
||
// }
|
||
//}
|
||
//catch (Exception ex)
|
||
//{
|
||
// ShowError(ex);
|
||
//}
|
||
//finally
|
||
//{
|
||
// Tools.RefreshWordbanck();
|
||
// this.pageControl1.GotoPage(1);
|
||
// label6.Visible = gridView1.RowCount == 0;
|
||
//}
|
||
}
|
||
}
|
||
} |