初始化项目
This commit is contained in:
143
AUTS.Services/Manager/TestLogs.cs
Normal file
143
AUTS.Services/Manager/TestLogs.cs
Normal file
@@ -0,0 +1,143 @@
|
||||
using AUTS.Domain.Entities;
|
||||
using AUTS.Domain.ViewModels;
|
||||
using AUTS.Services.Cache;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AUTS.Services.Manager
|
||||
{
|
||||
public partial class TestLogs
|
||||
{
|
||||
private static string TestLogTbName = "TBL_{0}_{1}_TestLog";//测试记录表名
|
||||
|
||||
public static ReturnResult<List< VM_OrderInternalStations>> GetStation(int ProductID, List<TBL_StationList> stationLists, List<TBL_Project> projects)
|
||||
{
|
||||
ReturnResult<List<VM_OrderInternalStations>> res = new ReturnResult<List<VM_OrderInternalStations>>();
|
||||
var oIStation = new List<VM_OrderInternalStations>();
|
||||
try
|
||||
{
|
||||
|
||||
var entity = stationLists.Where(e => e.ProjectID == ProductID && e.IsValid == 1).OrderBy(x => x.SnListOrder).ToList();
|
||||
foreach (var item in entity)
|
||||
{
|
||||
oIStation.Add(new VM_OrderInternalStations()
|
||||
{
|
||||
ID = item.ID,
|
||||
StationDesc = item.StationDesc,
|
||||
StationName = item.StationName
|
||||
});
|
||||
}
|
||||
res.Message = projects.FirstOrDefault(e => e.ID == ProductID).ProjectName;
|
||||
res.Data = oIStation;
|
||||
res.Status = 200;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
res.Message = "网络系统繁忙,请稍候再试!";
|
||||
Logs.WriteErrorLog(ex);
|
||||
|
||||
}
|
||||
return res;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取当前用户选择的库的下面的所有设备信息
|
||||
/// </summary>
|
||||
/// <param name="Id">UID</param>
|
||||
/// <returns></returns>
|
||||
public static List<TBL_UTS_Manage_DataServiceList> GetServiceList(int Id)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 获取当前用户选择的库
|
||||
var userAuthList = new List<TBL_UTS_Manage_DBList> { Manager.Users.GerOnUserCustomer()};
|
||||
//获取用户所有的库 CacheHelp.GetUserAuthList().Where(x => x.UserID == Id).ToList();
|
||||
var CustomerName = new List<string>();
|
||||
for (int i = 0; i < userAuthList.Count; i++)
|
||||
{
|
||||
CustomerName.AddRange(userAuthList[i].DatabaseName.Split(new string[] { "uts_" }, StringSplitOptions.RemoveEmptyEntries));
|
||||
}
|
||||
using (var db = new Uts_ManageEntities())
|
||||
{
|
||||
var CompanyList = new List<string>();
|
||||
|
||||
for (int i = 0; i < CustomerName.Count; i++)
|
||||
{
|
||||
string cName = CustomerName[i].ToLower();
|
||||
var Company = db.TBL_UTS_Manage_Company.FirstOrDefault(e => e.CustomerName.ToLower() == cName);
|
||||
CompanyList.Add(Company.CustomerName.ToLower());
|
||||
}
|
||||
if (CompanyList == null || CompanyList.Count == 0) return null;
|
||||
List<TBL_UTS_Manage_DataServiceList> data = db.TBL_UTS_Manage_DataServiceList.Where(x => CompanyList.Contains(x.CompanyName.ToLower())).OrderByDescending(x => x.IsOnline).ToList();
|
||||
return data;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelp.WriteExceptionLog(ex);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public static List<TBL_UTS_Manage_AppList> GetAppList()
|
||||
{
|
||||
List<TBL_UTS_Manage_AppList> userList = new List<TBL_UTS_Manage_AppList>();
|
||||
using (var db = new Uts_ManageEntities())
|
||||
{
|
||||
userList = db.TBL_UTS_Manage_AppList.ToList();
|
||||
}
|
||||
return userList;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取选择库下设备信息 及 是否在线
|
||||
/// </summary>
|
||||
/// <param name="Id"></param>
|
||||
/// <returns></returns>
|
||||
public static List<TBL_UTS_Manage_DataServiceList> GetServiceAppList(int Id) {
|
||||
List< TBL_UTS_Manage_DataServiceList> SERVER = GetServiceList(Id).Where(x=>x.ManageStatus==1).ToList();
|
||||
using (var db = new Uts_ManageEntities())
|
||||
{
|
||||
var APP = db.TBL_UTS_Manage_AppList.ToList();
|
||||
for (int i = 0; i < SERVER.Count; i++)
|
||||
{
|
||||
foreach (var item2 in APP)
|
||||
{
|
||||
if(item2.ServiceID != SERVER[i].ID) { continue; }
|
||||
var today = DateTime.Now;
|
||||
TimeSpan ts;
|
||||
ts = today - (item2.LastActiveDateTime ?? today);
|
||||
if (ts.TotalSeconds < 180)
|
||||
{
|
||||
SERVER[i].IsOnline = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
SERVER[i].IsOnline = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return SERVER.OrderByDescending(x=>x.IsOnline).ToList();
|
||||
}
|
||||
//截取字符串
|
||||
public string JieQu(string str)
|
||||
{
|
||||
string str2 = "";
|
||||
var LtStr = str.Split(',');
|
||||
int Sum = 2;
|
||||
for (int i = 0; i <= LtStr.Length; i++)
|
||||
{
|
||||
|
||||
str2 += LtStr[i] + ",";
|
||||
if (i == Sum - 1)
|
||||
{
|
||||
str2 = str2.Substring(0, str2.Length - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
Console.WriteLine(str2);
|
||||
return str2;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user