009_DI-Elec/newFront/c#前端/SWS.CAD/Services/NotificationService.cs

124 lines
4.1 KiB
C#
Raw Normal View History

2025-08-15 16:34:31 +08:00

2025-09-04 18:28:02 +08:00
2025-08-15 16:34:31 +08:00
using SWS.CAD.Models;
using SWS.CAD.Models.NoEntity;
2025-09-04 18:28:02 +08:00
using SWS.Commons;
2025-08-15 16:34:31 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using System.Windows.Markup;
namespace SWS.CAD.Services
{
public class NotificationService : HttpService
{
public NotificationService() : base()
{
}
/// <summary>
///
/// </summary>
/// <param name="mode">0接收到的信息1发出去的信息</param>
/// <returns></returns>
public async Task<List<ec_notification>> GetUserAllNotification(int mode = 0)
{
var projectid = GlobalObject.curProject == null ? "" : GlobalObject.curProject.ProjectId;
var res = await this.GetAsync<List<ec_notification>>($"NotificationApi/GetUserAllNotification?ProjectId={projectid}&User={GlobalObject.userInfo.account}&mode={mode}");
if (res.code == 200)
{
if (res.data == null)
{ return new List<ec_notification>(); }
//res.data = res.data.Where(x => x.RetrieveUserID.ToUpper() != x.SenderUserID.ToUpper()).ToList();
return res.data;
}
else
{
}
return new List<ec_notification>(); ;
}
#region
/// <summary>
/// 提交已读
/// </summary>
/// <param name="IDs"></param>
/// <returns></returns>
public async Task<bool> SubmitUnread(string IDs)
{
var res = await this.GetAsync<Object>($"NotificationApi/ApproveNofity?ProjectId={GlobalObject.curProject.ProjectId}&IDs={IDs}"); ;
if (res.info == "OK")
{
return true;
}
else
{
}
return false;
}
#endregion
/// <summary>
/// 获取所有图纸,需要生产确认的检入记录
/// </summary>
/// <returns></returns>
public async Task<List<List<CheckInLogNeedApproveModel>>> GetCheckInLogNeedApprove()
{
try
{
string url = $"NotificationApi/GetCheckInLogNeedApprove?projectId={GlobalObject.curProject?.ProjectId}";
var res = await this.GetAsync<List<List<CheckInLogNeedApproveModel>>>(url);
if (res.code == 200)
{
return res.data;
}
else
{
string errorMsg = $"获取检入审核记录失败,信息:{res.info}";
LoggerHelper.Current.Error(errorMsg);
return null;
}
}
catch (Exception ex)
{
string errorMsg = $"获取检入审核记录失败:{ex.Message}";
LoggerHelper.Current.Error(errorMsg);
return null;
}
}
/// <summary>
/// 批量确认捡入记录里需要生产主管确认的
/// </summary>
/// <returns></returns>
public async Task<string> ApproveCheckInLog(string IDs)
{
try
{
string url = $"NotificationApi/ApproveCheckInLog?projectId={GlobalObject.curProject?.ProjectId}&userId={GlobalObject.userInfo.userId}&IDs={IDs}";
var res = await this.GetAsync<object>(url);
if (res.code == 200 && res.info.ToUpper().Contains("OK"))
{
return "";
}
else
{
string errorMsg = $"获取检入批量审核失败,信息:{res.info}";
LoggerHelper.Current.Error(errorMsg);
return null;
}
}
catch (Exception ex)
{
string errorMsg = $"获取检入批量审核失败:{ex.Message}";
LoggerHelper.Current.Error(errorMsg);
return null;
}
}
}
}