113 lines
4.5 KiB
C#
113 lines
4.5 KiB
C#
using DevExpress.XtraEditors;
|
|
using HL_FristAidPlatform_DTO;
|
|
using HL_FristAidPlatform_Public;
|
|
using Microsoft.AspNetCore.SignalR.Client;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Configuration;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace HL_FristAidPlatform_PreHospitalEmergency
|
|
{
|
|
public partial class Form_PersonList : XtraForm
|
|
{
|
|
public int type;
|
|
public string taskguid;
|
|
public HubConnection connection;
|
|
public DataTable dt;
|
|
public Form_PersonList(int _type, string taskGuid)
|
|
{
|
|
InitializeComponent();
|
|
type = _type;
|
|
taskguid = taskGuid;
|
|
SignalRConnection();
|
|
}
|
|
public async void SignalRConnection()
|
|
{
|
|
connection = new HubConnectionBuilder().WithUrl(ConfigurationManager.AppSettings["WebApiUrl"] + "signalr/chatHub")
|
|
.Build();
|
|
await connection.StartAsync();
|
|
connection.Closed += async (error) =>
|
|
{
|
|
await Task.Delay(new Random().Next(0, 5) * 1000);
|
|
await connection.StartAsync();
|
|
};
|
|
}
|
|
|
|
private void Form_PersonList_Load(object sender, EventArgs e)
|
|
{
|
|
BindPerson(type);
|
|
}
|
|
|
|
public void BindPerson(int type)
|
|
{
|
|
dt = DBHelpClass.Get(string.Format("api/admin/T_SYS_User/GetDrvingUserList?hospitalGuid={0}&type={1}", Information.Hospital.GUID, type));
|
|
checkedListBoxControl1.DataSource = dt;//显示分页结果
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
this.checkedListBoxControl1.DisplayMember = "Name";
|
|
this.checkedListBoxControl1.ValueMember = "GUID";
|
|
}
|
|
else
|
|
{
|
|
lbl_msg.Visible = true;
|
|
simpleButton1.Enabled = false;
|
|
simpleButton1.Appearance.BackColor = Color.FromArgb(128, 134, 149);
|
|
simpleButton1.Appearance.BackColor2 = Color.FromArgb(128, 134, 149);
|
|
simpleButton1.ForeColor = System.Drawing.Color.FromArgb(81, 90, 110);
|
|
}
|
|
}
|
|
|
|
private void simpleButton2_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
|
|
private async void simpleButton1_Click(object sender, EventArgs e)
|
|
{
|
|
DataRow[] rows = dt.Select("Name='" + checkedListBoxControl1.GetItemText(checkedListBoxControl1.SelectedIndex) + "'");
|
|
try
|
|
{
|
|
|
|
UpdateDrvingpPersonnelDTO dto = new UpdateDrvingpPersonnelDTO();
|
|
dto.DrvingUserGUID = checkedListBoxControl1.CheckedItems[0].ToString();
|
|
dto.Type = type;
|
|
dto.GUID = taskguid;
|
|
List<UpdateDrvingpPersonnelDTO> list = new List<UpdateDrvingpPersonnelDTO>();
|
|
list.Add(dto);
|
|
string url = "api/service/FristAidTran/UpdateDrvingpPersonnel";
|
|
ClientFactory<UpdateDrvingpPersonnelDTO> httpClient = new HttpClientFactory<UpdateDrvingpPersonnelDTO>();
|
|
Client<UpdateDrvingpPersonnelDTO> client = httpClient.VisitFactory();
|
|
ListEntity<UpdateDrvingpPersonnelDTO> t = client.Post(url, list);
|
|
if (t.Success)
|
|
{
|
|
Form_TaskDetailInfo info;
|
|
info = (Form_TaskDetailInfo)this.Owner;
|
|
info.UpdateName(type, checkedListBoxControl1.GetItemText(checkedListBoxControl1.SelectedIndex));
|
|
|
|
if (rows.Length > 0)
|
|
////从客户端调用集线器方法 使用指定的方法名称和参数在服务器上调用中心方法
|
|
await connection.InvokeAsync("SendMessageToGroupAsync", rows[0].ItemArray[2].ToString(), "您有一个出警任务待处理");
|
|
this.Close();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//发送上线信息
|
|
await connection.InvokeAsync("OnLine", Information.User.ID.ToString());
|
|
SignalRConnection();
|
|
if (rows.Length > 0)
|
|
////从客户端调用集线器方法 使用指定的方法名称和参数在服务器上调用中心方法
|
|
await connection.InvokeAsync("SendMessageToGroupAsync", rows[0].ItemArray[2].ToString(), "您有一个出警任务待处理");
|
|
this.Close();
|
|
}
|
|
}
|
|
}
|
|
}
|