old_flsystem/FLSystem/Forms/AddCloudblack.cs

104 lines
4.2 KiB
C#

using Api.Framework;
using Api.Framework.Model;
using Api.Framework.Tools;
using System;
using Newtonsoft.Json;
using UI.Framework.Forms;
namespace FLSystem.Forms
{
public partial class AddCloudblack : BaseForm
{
public AddCloudblack(fl_member_info info)
{
InitializeComponent();
this.info = info;
this.textEdit1.Text = this.info.robot_type.ToString();
this.textEdit2.Text = this.info.username;
this.textEdit3.Text = this.info.usernick;
}
fl_member_info info;
private void simpleButton1_Click(object sender, EventArgs e)
{
ServiceResult rst = null;
try
{
CloudBlack black = new CloudBlack();
rst = black.InsertBlack(info, this.textEdit4.Text);
if (rst.Ok)
{
info.status = Api.Framework.Enums.MemberType.;
var session = ApiClient.GetSession();
session.Updateable<fl_member_info>(new { status = info.status }).Where(f => f.id == info.id).ExecuteCommand();
var _black = session.Queryable<fl_blackuser>().First(f => f.username == info.username && f.usertype == info.robot_type);
if (_black != null)
{
_black.nickname = info.usernick;
_black.remark = textEdit4.Text;
_black.iscloud = true;
_black.isdel = false;//标记没有被删除
session.Updateable(_black).ExecuteCommand();
}
else
{
_black = new fl_blackuser();
_black.usertype = info.robot_type;
_black.username = info.username;
_black.nickname = info.usernick;
_black.remark = textEdit4.Text;
_black.isdel = false;
_black.iscloud = true;
_black.updatetime = DateTime.Now;
session.Insertable(_black).ExecuteCommand();
}
BaseForm.ShowSuccess(rst.Message);
this.Close();
}
else
throw new Exception(rst.Message ?? rst.Data?.ToString());
}
catch (Exception ex)
{
EventClient.OnEvent("添加云黑名单异常:", "添加云黑名单:" + (rst == null ? string.Empty : JsonConvert.SerializeObject(rst)));
BaseForm.ShowError(ex);
}
}
private void simpleButton2_Click(object sender, EventArgs e)
{
ServiceResult rst = null;
try
{
CloudBlack black = new CloudBlack();
rst = black.RemoveBlack(info);
if (rst != null && rst.Ok)
{
info.status = Api.Framework.Enums.MemberType.;
var session = ApiClient.GetSession();
session.Updateable<fl_member_info>(new { status = info.status }).Where(f => f.id == info.id).ExecuteCommand();
var blackuser = session.Queryable<fl_blackuser>().First(f => f.username == info.username && f.usertype == info.robot_type);
if (blackuser != null)
{
blackuser.isdel = true;
blackuser.iscloud = false;
blackuser.updatetime = DateTime.Now;
session.Updateable(blackuser).ExecuteCommand();
}
BaseForm.ShowSuccess(rst.Message);
this.Close();
}
else
throw new Exception(rst.Message ?? rst.Data?.ToString());
}
catch (Exception ex)
{
EventClient.OnEvent("删除云黑名单异常:", "删除云黑名单:" + (rst == null ? string.Empty : CsharpHttpHelper.HttpHelper.ObjectToJson(rst)));
BaseForm.ShowError(ex);
}
}
}
}