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.
138 lines
4.4 KiB
138 lines
4.4 KiB
11 months ago
|
using System.Runtime.Serialization.Json;
|
||
|
using SiaSun.LMS.Model;
|
||
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Data;
|
||
|
using System.Linq;
|
||
|
using System.Text;
|
||
|
using System.Threading.Tasks;
|
||
|
using System.Windows;
|
||
|
using System.Windows.Controls;
|
||
|
using System.Windows.Data;
|
||
|
using System.Windows.Documents;
|
||
|
using System.Windows.Input;
|
||
|
using System.Windows.Media;
|
||
|
using System.Windows.Media.Imaging;
|
||
|
using System.Windows.Navigation;
|
||
|
using System.Windows.Shapes;
|
||
|
|
||
|
namespace SiaSun.LMS.WPFClient.SYS
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// MES_RETRY.xaml 的交互逻辑
|
||
|
/// </summary>
|
||
|
public partial class MES_RETRY : AvalonDock.DocumentContent
|
||
|
{
|
||
|
readonly bool boolAllowEdit = false;
|
||
|
readonly string strTableName = "MES_INTERFACE_RETRY";
|
||
|
readonly string strOrderField = "ID";
|
||
|
readonly string strTotalColumn = "ID";
|
||
|
readonly string strWhere = "1=1";
|
||
|
|
||
|
public MES_RETRY()
|
||
|
{
|
||
|
InitializeComponent();
|
||
|
}
|
||
|
|
||
|
|
||
|
private void DocumentContent_Loaded(object sender, RoutedEventArgs e)
|
||
|
{
|
||
|
LoadDataGrid();
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 加载数据
|
||
|
/// </summary>
|
||
|
private void LoadDataGrid()
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
this.gridQuery.U_WindowName = this.GetType().Name;
|
||
|
this.gridQuery.U_TableName = this.strTableName;
|
||
|
this.gridQuery.U_Where = this.strWhere;
|
||
|
this.gridQuery.U_OrderField = this.strOrderField;
|
||
|
this.gridQuery.U_TotalColumnName = this.strTotalColumn;
|
||
|
|
||
|
this.gridQuery.U_AllowOperatData = this.boolAllowEdit;
|
||
|
this.gridQuery.U_AllowPage = true;
|
||
|
this.gridQuery.U_AllowChecked = true;
|
||
|
|
||
|
this.gridQuery.U_InitControl();
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
MainApp._MessageDialog.ShowException(ex);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 重发
|
||
|
/// </summary>
|
||
|
/// <param name="sender"></param>
|
||
|
/// <param name="e"></param>
|
||
|
private void BtnRetryClick(object sender, RoutedEventArgs e)
|
||
|
{
|
||
|
//DateTime aa = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||
|
DateTime startTime = DateTime.Now; // 开始时间
|
||
|
DateTime endTime = Convert.ToDateTime("2024-01-29 23:00:00") ; // 结束时间
|
||
|
|
||
|
TimeSpan timeDifference = endTime.Subtract(startTime).Duration(); // 获取时间差异
|
||
|
int hoursDiff = (int)timeDifference.TotalHours; // 转换为小时数
|
||
|
try
|
||
|
{
|
||
|
if (!btnRetry.IsEnabled)
|
||
|
{
|
||
|
MainApp._MessageDialog.ShowException("接口重发中,请稍后点击");
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
//1.获取所有被选中的报文行
|
||
|
DataRowView[] dataRowViews = this.gridQuery.U_GetCheckedDataRows();
|
||
|
|
||
|
//2.锁定按钮
|
||
|
btnRetry.IsEnabled = false;
|
||
|
|
||
|
////3.新建线程循环重发
|
||
|
//Task reCallMes = Task.Factory.StartNew(() =>
|
||
|
//{
|
||
|
bool bResult = true;
|
||
|
string sResult = "";
|
||
|
|
||
|
foreach (DataRowView rowView in dataRowViews)
|
||
|
{
|
||
|
string responseMessage = rowView["MESSAGE"].ToString();
|
||
|
|
||
|
bResult = MainApp._I_BaseService.Invoke("S_ERPService", "MesRetry", new object[] { responseMessage }, out sResult);
|
||
|
|
||
|
///*无论成功与否,都需要删除本条记录,重发失败会向重发表中插入新的记录*/
|
||
|
//MainApp._I_BaseService.Invoke("S_ERPService", "DeleteRetryRecord", new object[] { Convert.ToInt32(rowView["ID"].ToString()) }, out sResult);
|
||
|
|
||
|
}
|
||
|
// });
|
||
|
|
||
|
//4.Wait
|
||
|
// reCallMes.Wait();
|
||
|
|
||
|
//5.恢复按钮功能
|
||
|
btnRetry.IsEnabled = true;
|
||
|
if (bResult)
|
||
|
{
|
||
|
MainApp._MessageDialog.ShowException("成功");
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
MainApp._MessageDialog.ShowException(sResult);
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
MainApp._MessageDialog.ShowException(ex);
|
||
|
|
||
|
btnRetry.IsEnabled = true;
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
}
|
||
|
}
|