1
This commit is contained in:
+6
-3
@@ -155,6 +155,7 @@
|
||||
<Compile Include="BaseInfo\PracticeCertificateService.cs" />
|
||||
<Compile Include="BaseInfo\ProjectTypeService.cs" />
|
||||
<Compile Include="BaseInfo\QualityQuestionTypeService.cs" />
|
||||
<Compile Include="BaseInfo\GJSXTypeService.cs" />
|
||||
<Compile Include="BaseInfo\QuestionTypeService.cs" />
|
||||
<Compile Include="BaseInfo\RectificationMeasureService.cs" />
|
||||
<Compile Include="BaseInfo\RiskLevelService.cs" />
|
||||
@@ -312,6 +313,7 @@
|
||||
<Compile Include="DoorServer\InOutService.cs" />
|
||||
<Compile Include="DoorServer\DoorServerService.cs" />
|
||||
<Compile Include="DropListService.cs" />
|
||||
<Compile Include="Email_Send\Email_PopService.cs" />
|
||||
<Compile Include="EnvironmentalCheckService.cs" />
|
||||
<Compile Include="GlobalSuppressions.cs" />
|
||||
<Compile Include="HJGL\BaseInfo\Base_ComponentsService.cs" />
|
||||
@@ -692,6 +694,7 @@
|
||||
<Compile Include="HSSE\SitePerson\PersonService.cs" />
|
||||
<Compile Include="PZHGL\GJSX\GJSXItemService.cs" />
|
||||
<Compile Include="PZHGL\GJSX\GJSXProcessService.cs" />
|
||||
<Compile Include="PZHGL\GJSX\GJSXMonitorService.cs" />
|
||||
<Compile Include="PZHGL\GJSX\GJSXService.cs" />
|
||||
<Compile Include="PZHGL\InformationProject\ConstructionLogService.cs" />
|
||||
<Compile Include="PZHGL\InformationProject\ConstructionPlanApproveService.cs" />
|
||||
@@ -1099,7 +1102,7 @@
|
||||
<Version>4.5.1</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.Configuration.ConfigurationManager">
|
||||
<Version>6.0.0</Version>
|
||||
<Version>6.0.1</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.Diagnostics.DiagnosticSource">
|
||||
<Version>4.7.1</Version>
|
||||
@@ -1114,13 +1117,13 @@
|
||||
<Version>4.5.3</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.Security.AccessControl">
|
||||
<Version>4.7.0</Version>
|
||||
<Version>6.0.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.Security.Permissions">
|
||||
<Version>6.0.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.Security.Principal.Windows">
|
||||
<Version>4.7.0</Version>
|
||||
<Version>5.0.0</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ProjectView>ProjectFiles</ProjectView>
|
||||
<ProjectView>ShowAllFiles</ProjectView>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,128 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
public static class GJSXTypeService
|
||||
{
|
||||
public static Model.SGGLDB db = Funs.DB;
|
||||
|
||||
/// <summary>
|
||||
/// 根据主键获取信息
|
||||
/// </summary>
|
||||
/// <param name="typeId"></param>
|
||||
/// <returns></returns>
|
||||
public static Model.Base_GJSXType GetGJSXTypeById(string typeId)
|
||||
{
|
||||
return Funs.DB.Base_GJSXType.FirstOrDefault(e => e.GJSXTypeID == typeId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加
|
||||
/// </summary>
|
||||
/// <param name="?"></param>
|
||||
public static void AddGJSXType(Model.Base_GJSXType questionType)
|
||||
{
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
Model.Base_GJSXType newGJSXType = new Model.Base_GJSXType
|
||||
{
|
||||
GJSXTypeID = questionType.GJSXTypeID,
|
||||
GJSXTypeCode = questionType.GJSXTypeCode,
|
||||
GJSXTypeName = questionType.GJSXTypeName,
|
||||
ProjectId = questionType.ProjectId
|
||||
};
|
||||
|
||||
db.Base_GJSXType.InsertOnSubmit(newGJSXType);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改
|
||||
/// </summary>
|
||||
/// <param name="teamGroup"></param>
|
||||
public static void UpdateGJSXType(Model.Base_GJSXType questionType)
|
||||
{
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
Model.Base_GJSXType newGJSXType = db.Base_GJSXType.FirstOrDefault(e => e.GJSXTypeID == questionType.GJSXTypeID);
|
||||
if (newGJSXType != null)
|
||||
{
|
||||
newGJSXType.GJSXTypeCode = questionType.GJSXTypeCode;
|
||||
newGJSXType.GJSXTypeName = questionType.GJSXTypeName;
|
||||
newGJSXType.ProjectId = questionType.ProjectId;
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据主键删除信息
|
||||
/// </summary>
|
||||
/// <param name="typeId"></param>
|
||||
public static void DeleteGJSXTypeById(string typeId)
|
||||
{
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
Model.Base_GJSXType questionType = db.Base_GJSXType.FirstOrDefault(e => e.GJSXTypeID == typeId);
|
||||
{
|
||||
db.Base_GJSXType.DeleteOnSubmit(questionType);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取类别下拉项
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static List<Model.Base_GJSXType> GetGJSXTypeList()
|
||||
{
|
||||
var list = (from x in Funs.DB.Base_GJSXType orderby x.GJSXTypeCode select x).ToList();
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 事项类别表下拉框
|
||||
/// </summary>
|
||||
/// <param name="dropName">下拉框名字</param>
|
||||
/// <param name="isShowPlease">是否显示请选择</param>
|
||||
public static void InitGJSXTypeDropDownList(FineUIPro.DropDownList dropName, bool isShowPlease)
|
||||
{
|
||||
dropName.DataValueField = "GJSXTypeID";
|
||||
dropName.DataTextField = "GJSXTypeName";
|
||||
dropName.DataSource = GetGJSXTypeList();
|
||||
dropName.DataBind();
|
||||
if (isShowPlease)
|
||||
{
|
||||
Funs.FineUIPleaseSelect(dropName);
|
||||
}
|
||||
}
|
||||
|
||||
public static Model.Base_GJSXType GetGJSXTypeByName(string name)
|
||||
{
|
||||
return Funs.DB.Base_GJSXType.FirstOrDefault(e => e.GJSXTypeName == name);
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据项目Id获取事项类别下拉项
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static List<Model.Base_GJSXType> GetGJSXTypeByTempleteList(string ProjectId)
|
||||
{
|
||||
var list = (from x in Funs.DB.Base_GJSXType where x.ProjectId == ProjectId orderby x.GJSXTypeCode select x).ToList();
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 事项类别表下拉框
|
||||
/// </summary>
|
||||
/// <param name="dropName">下拉框名字</param>
|
||||
/// <param name="isShowPlease">是否显示请选择</param>
|
||||
public static void InitGJSXTypeByTempleteDropDownList(FineUIPro.DropDownList dropName, string ProjectId, bool isShowPlease)
|
||||
{
|
||||
dropName.DataValueField = "GJSXTypeID";
|
||||
dropName.DataTextField = "GJSXTypeName";
|
||||
dropName.DataSource = GetGJSXTypeByTempleteList(ProjectId);
|
||||
dropName.DataBind();
|
||||
if (isShowPlease)
|
||||
{
|
||||
Funs.FineUIPleaseSelect(dropName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -899,10 +899,14 @@ namespace BLL
|
||||
public const string SynchronizationMenuId = "6EDFBE24-9419-4E73-AC2E-CAD30A754A73";
|
||||
|
||||
/// <summary>
|
||||
/// 问题类型
|
||||
/// 紧急程度
|
||||
/// </summary>
|
||||
public const string QuestionTypeMenuId = "3044D68E-5018-4B57-BFC4-FBE4BCCA8B8B";
|
||||
/// <summary>
|
||||
/// 关键事项类别
|
||||
/// </summary>
|
||||
public const string GJSXTypeMenuId = "C7E69F5F-04A8-41F9-8EA1-C41B13248421";
|
||||
/// <summary>
|
||||
/// 文档类别
|
||||
/// </summary>
|
||||
public const string DocTypeMenuId = "F0DF2F2B-7C12-4A0F-B7D4-0B00BADE1D64";
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
using Model;
|
||||
using System.Linq;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
public static class Email_PopService
|
||||
{
|
||||
#region 获取邮件设置
|
||||
/// <summary>
|
||||
/// 获取邮件设置
|
||||
/// </summary>
|
||||
/// <param name="EmailID">邮件设置Id</param>
|
||||
/// <returns></returns>
|
||||
public static Email_Pop GetEmail_Pop(string EmailID)
|
||||
{
|
||||
return Funs.DB.Email_Pop.FirstOrDefault(x => x.EmailID == EmailID);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 邮件管理
|
||||
/// <summary>
|
||||
/// 邮件设置
|
||||
/// </summary>
|
||||
/// <param name="eProject"></param>
|
||||
public static void AddEmail_Pop(Email_Pop email_Pop)
|
||||
{
|
||||
Email_Pop pf = Funs.DB.Email_Pop.FirstOrDefault(e => e.EmailID == email_Pop.EmailID);
|
||||
if (pf == null)
|
||||
{
|
||||
pf = new Email_Pop();
|
||||
pf.EmailID = email_Pop.EmailID;
|
||||
pf.EmailFwq = email_Pop.EmailFwq;
|
||||
pf.EmailDk = email_Pop.EmailDk;
|
||||
pf.EmailYx = email_Pop.EmailYx;
|
||||
pf.EmailUsername = email_Pop.EmailUsername;
|
||||
pf.EmailPass = email_Pop.EmailPass;
|
||||
pf.CreateTime = email_Pop.CreateTime;
|
||||
pf.CreateName = email_Pop.CreateName;
|
||||
pf.CreateUserId = email_Pop.CreateUserId;
|
||||
pf.UpdateTime = email_Pop.UpdateTime;
|
||||
pf.UpdateName = email_Pop.UpdateName;
|
||||
pf.UpdateUserId = email_Pop.UpdateUserId;
|
||||
|
||||
Funs.DB.Email_Pop.InsertOnSubmit(pf);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 修改
|
||||
/// <summary>
|
||||
/// 修改
|
||||
/// </summary>
|
||||
/// <param name="email_Params"></param>
|
||||
public static void UpdateEmail_Pop(Email_Pop email_Pop)
|
||||
{
|
||||
Email_Pop pf = Funs.DB.Email_Pop.FirstOrDefault(e => e.EmailID == email_Pop.EmailID);
|
||||
|
||||
pf.EmailID = email_Pop.EmailID;
|
||||
pf.EmailFwq = email_Pop.EmailFwq;
|
||||
pf.EmailDk = email_Pop.EmailDk;
|
||||
pf.EmailYx = email_Pop.EmailYx;
|
||||
pf.EmailUsername = email_Pop.EmailUsername;
|
||||
pf.EmailPass = email_Pop.EmailPass;
|
||||
pf.UpdateTime = email_Pop.UpdateTime;
|
||||
pf.UpdateName = email_Pop.UpdateName;
|
||||
pf.UpdateUserId = email_Pop.UpdateUserId;
|
||||
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,231 @@
|
||||
using System.Linq;
|
||||
using System.Timers;
|
||||
using System;
|
||||
using System.Net.Mail;
|
||||
using System.Net;
|
||||
using System.Collections.Generic;
|
||||
using Model;
|
||||
using System.Data.SqlClient;
|
||||
using System.Data;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
public static class GJSXMonitorService
|
||||
{
|
||||
public static Model.SGGLDB db = Funs.DB;
|
||||
|
||||
/// <summary>
|
||||
/// 关键事项超期预警定时提醒发送邮箱
|
||||
/// </summary>
|
||||
public static void OverdueWarningSendEmail()
|
||||
{
|
||||
try
|
||||
{
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
//取未关闭且已经超期的数据
|
||||
|
||||
string strSql = @"select
|
||||
DATEDIFF(DAY, CompleteDate, isnull(CloseDate,getdate())) AS DateDiffDays
|
||||
,a.GJSXID,a.ProjectId,a.Detail,a.createDate,Base_Project.ProjectName,Base_Unit.UnitName,a.CloseDate,a.IsManypeople,a.CompleteDate,a.AttachUrl
|
||||
,case a.state when 2 then '正在进行' when 3 then '待办' when 0 then '已关闭' when 1 then '开放' end as state
|
||||
,CNProfessionalName = STUFF((SELECT ',' + Base_CNProfessional.ProfessionalName FROM dbo.Base_CNProfessional where PATINDEX('%,' + RTRIM(Base_CNProfessional.CNProfessionalId) + ',%', ',' + a.CNProfessional_ID + ',') > 0 FOR XML PATH('')), 1, 1,'')
|
||||
,QuestionTypeName = STUFF((SELECT ',' + Base_QuestionType.QuestionTypeName FROM dbo.Base_QuestionType where PATINDEX('%,' + RTRIM(Base_QuestionType.QuestionTypeID) + ',%', ',' + a.QuestionTypeID + ',') > 0 FOR XML PATH('')), 1, 1,'')
|
||||
,GJSXTypeName = STUFF((SELECT ',' + Base_GJSXType.GJSXTypeName FROM dbo.Base_GJSXType where PATINDEX('%,' + RTRIM(Base_GJSXType.GJSXTypeID) + ',%', ',' + a.GJSXTypeID + ',') > 0 FOR XML PATH('')), 1, 1,'')
|
||||
,a.UserID,b.UserName
|
||||
--,b.Email as UserEmail
|
||||
,a.User_ReceiveID as User_ReceiveUserId
|
||||
,User_ReceiveUserName = STUFF((SELECT ',' + p2.UserName FROM dbo.Sys_User as p2 where PATINDEX('%,' + RTRIM(p2.UserId) + ',%', ',' + a.User_ReceiveID + ',') > 0 FOR XML PATH('')), 1, 1,'')
|
||||
--,User_ReceiveUserEmail = STUFF((SELECT ',' + p2.Email FROM dbo.Sys_User as p2 where PATINDEX('%,' + RTRIM(p2.UserId) + ',%', ',' + a.User_ReceiveID + ',') > 0 FOR XML PATH('')), 1, 1,'')
|
||||
,a.user_Acceptance as User_AcceptanceUserId
|
||||
,User_AcceptanceUserName = STUFF((SELECT ',' + p2.UserName FROM dbo.Sys_User as p2 where PATINDEX('%,' + RTRIM(p2.UserId) + ',%', ',' + a.user_Acceptance + ',') > 0 FOR XML PATH('')), 1, 1,'')
|
||||
--,User_AcceptanceUserEmail = STUFF((SELECT ',' + p2.Email FROM dbo.Sys_User as p2 where PATINDEX('%,' + RTRIM(p2.UserId) + ',%', ',' + a.user_Acceptance + ',') > 0 FOR XML PATH('')), 1, 1,'')
|
||||
,a.CsUsers as User_CsUserIds
|
||||
,User_CsUsers = STUFF((SELECT ',' + p2.UserName FROM dbo.Sys_User as p2 where PATINDEX('%,' + RTRIM(p2.UserId) + ',%', ',' + a.CsUsers + ',') > 0 FOR XML PATH('')), 1, 1,'')
|
||||
--,User_CsUsersUserEmail = STUFF((SELECT ',' + p2.Email FROM dbo.Sys_User as p2 where PATINDEX('%,' + RTRIM(p2.UserId) + ',%', ',' + a.CsUsers + ',') > 0 FOR XML PATH('')), 1, 1,'')
|
||||
from GJSX as a
|
||||
left join Sys_User as b on a.UserId = b.UserId
|
||||
left join[dbo].[Base_Project] on a.ProjectId = Base_Project.ProjectId
|
||||
left join[dbo].[Base_Unit] on a.UnitId = Base_Unit.UnitId
|
||||
where 1=1 and a.state<>'0' and GETDATE()>a.CompleteDate ";
|
||||
|
||||
List<SqlParameter> listStr = new List<SqlParameter>();
|
||||
SqlParameter[] parameter = listStr.ToArray();
|
||||
|
||||
DataTable table = SQLHelper.GetDataTableRunText(strSql, parameter);
|
||||
|
||||
// 使用LINQ将DataTable转换为List<GJSXItem>
|
||||
var lstOverdue = table.AsEnumerable().Select(row => new GJSXItem
|
||||
{
|
||||
DateDiffDays = Convert.ToInt32(row["DateDiffDays"]),
|
||||
GJSXID = row["GJSXID"].ToString(),
|
||||
ProjectId = row["ProjectId"].ToString(),
|
||||
ProjectName = row["ProjectName"].ToString(),
|
||||
UnitName = row["UnitName"].ToString(),
|
||||
Detail = row["Detail"].ToString(),
|
||||
CNProfessionalName = row["CNProfessionalName"].ToString(),
|
||||
QuestionTypeName = row["QuestionTypeName"].ToString(),
|
||||
GJSXTypeName = row["GJSXTypeName"].ToString(),
|
||||
UserID = row["UserID"].ToString(),
|
||||
UserName = row["UserName"].ToString(),
|
||||
//UserEmail = row["UserEmail"].ToString(),
|
||||
User_ReceiveUserId = row["User_ReceiveUserId"].ToString(),
|
||||
User_ReceiveUserName = row["User_ReceiveUserName"].ToString(),
|
||||
//User_ReceiveUserEmail = row["User_ReceiveUserEmail"].ToString(),
|
||||
User_AcceptanceUserId = row["User_AcceptanceUserId"].ToString(),
|
||||
User_AcceptanceUserName = row["User_AcceptanceUserName"].ToString(),
|
||||
//User_AcceptanceUserEmail = row["User_AcceptanceUserEmail"].ToString(),
|
||||
User_CsUserIds = row["User_CsUserIds"].ToString(),
|
||||
User_CsUsers = row["User_CsUsers"].ToString(),
|
||||
//User_CsUsersUserEmail = row["User_CsUsersUserEmail"].ToString(),
|
||||
CompleteDate = Convert.ToDateTime(row["CompleteDate"].ToString())
|
||||
}).ToList();
|
||||
|
||||
#region 根据用户聚合推送,多个事项合并推送
|
||||
|
||||
//获取有邮箱的用户
|
||||
var userIds = BLL.UserService.GetUserHaveEmailList();
|
||||
if (userIds.Any() && lstOverdue.Any())
|
||||
{
|
||||
var lstProject = lstOverdue.Select(x => new { x.ProjectId ,x.ProjectName}).Distinct().ToList();
|
||||
foreach (var pro in lstProject)
|
||||
{
|
||||
var lstProjectOverdue = lstOverdue.Where(x => x.ProjectId == pro.ProjectId).ToList();
|
||||
if (lstProjectOverdue.Any())
|
||||
{
|
||||
string projectName = pro.ProjectName;
|
||||
foreach (var user in userIds)
|
||||
{
|
||||
MailMessage mail = new MailMessage();
|
||||
//邮件主题
|
||||
mail.Subject = $"关键事项超期预警提醒——{projectName}";
|
||||
mail.To.Add(user.Email);
|
||||
mail.IsBodyHtml = true;//确保邮件正文被当作HTML解析
|
||||
|
||||
StringBuilder tbodyStr = new StringBuilder();
|
||||
int index = 1;
|
||||
//责任人为本人
|
||||
var acceptanceItems = lstProjectOverdue.Where(x => x.User_AcceptanceUserId.Contains(user.UserId)).OrderByDescending(x => x.DateDiffDays).ToList();
|
||||
if (acceptanceItems.Any())
|
||||
{
|
||||
foreach (var item in acceptanceItems)
|
||||
{
|
||||
tbodyStr.Append($"<tr><td>{index}</td><td>本人负责</td><td>{item.UnitName}</td><td>{item.Detail}</td><td>{item.GJSXTypeName}</td><td>{item.UserName}</td><td>{item.User_AcceptanceUserName}</td><td>{item.CompleteDate.ToShortDateString()}</td><td>{(item.DateDiffDays > 0 ? item.DateDiffDays : "半")}</td></tr>");
|
||||
index++;
|
||||
}
|
||||
}
|
||||
//发起人为本人
|
||||
var userItems = lstProjectOverdue.Where(x => x.UserID == user.UserId).OrderByDescending(x => x.DateDiffDays).ToList();
|
||||
if (userItems.Any())
|
||||
{
|
||||
foreach (var item in userItems)
|
||||
{
|
||||
tbodyStr.Append($"<tr><td>{index}</td><td>本人发起</td><td>{item.UnitName}</td><td>{item.Detail}</td><td>{item.GJSXTypeName}</td><td>{item.UserName}</td><td>{item.User_AcceptanceUserName}</td><td>{item.CompleteDate.ToShortDateString()}</td><td>{(item.DateDiffDays > 0 ? item.DateDiffDays : "半")}</td></tr>");
|
||||
index++;
|
||||
}
|
||||
}
|
||||
//跟踪人为本人
|
||||
var receiveItems = lstProjectOverdue.Where(x => x.User_ReceiveUserId.Contains(user.UserId)).OrderByDescending(x => x.DateDiffDays).ToList();
|
||||
if (receiveItems.Any())
|
||||
{
|
||||
foreach (var item in receiveItems)
|
||||
{
|
||||
tbodyStr.Append($"<tr><td>{index}</td><td>本人跟踪</td><td>{item.UnitName}</td><td>{item.Detail}</td><td>{item.GJSXTypeName}</td><td>{item.UserName}</td><td>{item.User_AcceptanceUserName}</td><td>{item.CompleteDate.ToShortDateString()}</td><td>{(item.DateDiffDays > 0 ? item.DateDiffDays : "半")}</td></tr>");
|
||||
index++;
|
||||
}
|
||||
}
|
||||
//抄送人为本人
|
||||
var csUserItems = lstProjectOverdue.Where(x => x.User_CsUserIds.Contains(user.UserId)).OrderByDescending(x => x.DateDiffDays).ToList();
|
||||
if (csUserItems.Any())
|
||||
{
|
||||
foreach (var item in csUserItems)
|
||||
{
|
||||
tbodyStr.Append($"<tr><td>{index}</td><td>抄送本人</td><td>{item.UnitName}</td><td>{item.Detail}</td><td>{item.GJSXTypeName}</td><td>{item.UserName}</td><td>{item.User_AcceptanceUserName}</td><td>{item.CompleteDate.ToShortDateString()}</td><td>{(item.DateDiffDays > 0 ? item.DateDiffDays : "半")}</td></tr>");
|
||||
index++;
|
||||
}
|
||||
}
|
||||
//邮件正文
|
||||
string bodyStr = @"<html>
|
||||
<head>
|
||||
<style>
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
}
|
||||
th, td {
|
||||
border: 1px solid black;
|
||||
padding: 8px;
|
||||
text-align: left;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h2>关键事项超期预警提醒</h2>
|
||||
<a href='https://zhgd.cwcec.com/'>请点击此处,查看详细信息,并及时处置关闭</a>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>序号</th>
|
||||
<th>类型</th>
|
||||
<th>责任单位</th>
|
||||
<th>事项描述</th>
|
||||
<th>事项类别</th>
|
||||
<th>发起人</th>
|
||||
<th>责任人</th>
|
||||
<th>约定完成时间</th>
|
||||
<th>超期时间(天)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>" + tbodyStr.ToString() + "</tbody></table></body></html>";
|
||||
|
||||
mail.Body = bodyStr;
|
||||
|
||||
PushEmail(mail);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发送邮件
|
||||
/// </summary>
|
||||
/// <param name="mail"></param>
|
||||
private static void PushEmail(MailMessage mail)
|
||||
{
|
||||
//获取发送邮箱配置
|
||||
Email_Pop pops = BLL.Email_PopService.GetEmail_Pop("7EC5E991-B7A0-495A-90ED-2BE15370C959");
|
||||
if (pops != null)
|
||||
{
|
||||
SmtpClient client = new SmtpClient(pops.EmailFwq);//替换为你的SMTP服务器地址
|
||||
client.Port = int.Parse(pops.EmailDk);//587或465如果使用SSL
|
||||
client.EnableSsl = true;//如果服务器支持SSL,设置为true
|
||||
client.DeliveryMethod = SmtpDeliveryMethod.Network;
|
||||
client.UseDefaultCredentials = false;
|
||||
client.Credentials = new NetworkCredential(pops.EmailYx, pops.EmailPass);//替换为你的邮箱和服务授权码
|
||||
mail.From = new MailAddress(pops.EmailYx);//发件人邮箱地址
|
||||
try
|
||||
{
|
||||
client.Send(mail);
|
||||
//Console.WriteLine("Email sent successfully.");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//Console.WriteLine("Email sending failed: " + ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
public static class GJSXService
|
||||
public static class GJSXService
|
||||
{
|
||||
public static Model.SGGLDB db = Funs.DB;
|
||||
|
||||
@@ -29,23 +29,25 @@ namespace BLL
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
Model.GJSX newGJSX = new Model.GJSX
|
||||
{
|
||||
GJSXID = _GJSX.GJSXID,
|
||||
Detail = _GJSX.Detail,
|
||||
UserID = _GJSX.UserID,
|
||||
CreateDate = _GJSX.CreateDate,
|
||||
User_ReceiveID = _GJSX.User_ReceiveID,
|
||||
CNProfessional_ID = _GJSX.CNProfessional_ID,
|
||||
ProjectId = _GJSX.ProjectId,
|
||||
UnitId = _GJSX.UnitId,
|
||||
CloseDate = _GJSX.CloseDate,
|
||||
State = _GJSX.State,
|
||||
QuestionTypeID = _GJSX.QuestionTypeID,
|
||||
IsManypeople = _GJSX.IsManypeople,
|
||||
CompleteDate = _GJSX.CompleteDate,
|
||||
AttachUrl = _GJSX.AttachUrl,
|
||||
User_Acceptance = _GJSX.User_Acceptance,
|
||||
GJSXID = _GJSX.GJSXID,
|
||||
Detail = _GJSX.Detail,
|
||||
UserID = _GJSX.UserID,
|
||||
CreateDate = _GJSX.CreateDate,
|
||||
User_ReceiveID = _GJSX.User_ReceiveID,
|
||||
CNProfessional_ID = _GJSX.CNProfessional_ID,
|
||||
ProjectId = _GJSX.ProjectId,
|
||||
UnitId = _GJSX.UnitId,
|
||||
CloseDate = _GJSX.CloseDate,
|
||||
State = _GJSX.State,
|
||||
QuestionTypeID = _GJSX.QuestionTypeID,
|
||||
GJSXTypeId = _GJSX.GJSXTypeId,
|
||||
IsManypeople = _GJSX.IsManypeople,
|
||||
CompleteDate = _GJSX.CompleteDate,
|
||||
AttachUrl = _GJSX.AttachUrl,
|
||||
User_Acceptance = _GJSX.User_Acceptance,
|
||||
ProgressStatus = _GJSX.ProgressStatus,
|
||||
|
||||
CsUsers=_GJSX.CsUsers
|
||||
CsUsers = _GJSX.CsUsers
|
||||
};
|
||||
|
||||
db.GJSX.InsertOnSubmit(newGJSX);
|
||||
@@ -73,11 +75,13 @@ namespace BLL
|
||||
newGJSX.CloseDate = _GJSX.CloseDate;
|
||||
newGJSX.State = _GJSX.State;
|
||||
newGJSX.QuestionTypeID = _GJSX.QuestionTypeID;
|
||||
newGJSX.GJSXTypeId = _GJSX.GJSXTypeId;
|
||||
newGJSX.IsManypeople = _GJSX.IsManypeople;
|
||||
newGJSX.CompleteDate = _GJSX.CompleteDate;
|
||||
newGJSX.AttachUrl = _GJSX.AttachUrl;
|
||||
newGJSX.User_Acceptance = _GJSX.User_Acceptance;
|
||||
newGJSX.CsUsers = _GJSX.CsUsers;
|
||||
newGJSX.ProgressStatus = _GJSX.ProgressStatus;
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
@@ -97,17 +101,15 @@ namespace BLL
|
||||
}
|
||||
|
||||
private static int count;
|
||||
|
||||
|
||||
public static System.Collections.IEnumerable GetListData(string projectId)
|
||||
{
|
||||
IQueryable<Model.GJSX> q =GetGJSXList().AsQueryable();
|
||||
IQueryable<Model.GJSX> q = GetGJSXList().AsQueryable();
|
||||
|
||||
|
||||
if (!string.IsNullOrEmpty(projectId))
|
||||
{
|
||||
q = q.Where(e => e.ProjectId == projectId);
|
||||
}
|
||||
|
||||
|
||||
count = q.Count();
|
||||
if (count == 0)
|
||||
@@ -131,6 +133,7 @@ namespace BLL
|
||||
x.CloseDate,
|
||||
x.State,
|
||||
x.QuestionTypeID,
|
||||
x.GJSXTypeId,
|
||||
x.CompleteDate,
|
||||
x.AttachUrl,
|
||||
x.User_Acceptance
|
||||
@@ -138,6 +141,17 @@ namespace BLL
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据项目Id,获取关键事项责任人list
|
||||
/// </summary>
|
||||
/// <param name="projectId"></param>
|
||||
/// <returns></returns>
|
||||
public static List<string> GetGJSXUserList(string projectId)
|
||||
{
|
||||
var list = (from x in Funs.DB.GJSX where x.ProjectId == projectId select x.User_Acceptance).Distinct().ToList();
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取问题下拉项
|
||||
/// </summary>
|
||||
|
||||
@@ -365,6 +365,16 @@ namespace BLL
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取有邮箱的用户
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static List<Model.Sys_User> GetUserHaveEmailList()
|
||||
{
|
||||
var list = (from x in Funs.DB.Sys_User where x.Email != null && x.Email != "" orderby x.UserName select x).ToList();
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取用户下拉选项
|
||||
/// </summary>
|
||||
@@ -1618,9 +1628,9 @@ namespace BLL
|
||||
// return (from x in Funs.DB.View_ProjectUserWorkPost where x.ProjectId == projectId && x.WorkPostName == workPostName select x.UserName).ToList();
|
||||
//}
|
||||
|
||||
public static List<string> GetUserNameListsByUnitIdWorkPostName(string projectId,string unitId, string workPostName)
|
||||
public static List<string> GetUserNameListsByUnitIdWorkPostName(string projectId, string unitId, string workPostName)
|
||||
{
|
||||
return (from x in Funs.DB.View_ProjectUserWorkPost where x.ProjectId == projectId && x.UnitId== unitId && x.WorkPostName == workPostName select x.UserName).ToList();
|
||||
return (from x in Funs.DB.View_ProjectUserWorkPost where x.ProjectId == projectId && x.UnitId == unitId && x.WorkPostName == workPostName select x.UserName).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,26 +1,20 @@
|
||||
using FineUIPro;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing.Printing;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
|
||||
public static class InterFaceLogService
|
||||
|
||||
public static class InterFaceLogService
|
||||
{
|
||||
public static Model.SGGLDB db = Funs.DB;
|
||||
|
||||
public const string Type1 = "上报";
|
||||
public const string Type2= "下发";
|
||||
public const string Type2 = "下发";
|
||||
public const string Type3 = "回调";
|
||||
|
||||
#region 获取列表
|
||||
|
||||
#region 获取列表
|
||||
/// <summary>
|
||||
/// 记录数
|
||||
/// </summary>
|
||||
@@ -29,25 +23,25 @@ namespace BLL
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public static List<Model.InterFaceLog> GetInterFaceLogByModle(Model.InterFaceLog table)
|
||||
{
|
||||
var q= from x in db.InterFaceLog
|
||||
where
|
||||
( string.IsNullOrEmpty(table.InterFaceLogId)||x.InterFaceLogId.Contains(table.InterFaceLogId)) &&
|
||||
( string.IsNullOrEmpty(table.UserId)||x.UserId.Contains(table.UserId)) &&
|
||||
( string.IsNullOrEmpty(table.UnitId)||x.UnitId.Contains(table.UnitId)) &&
|
||||
( string.IsNullOrEmpty(table.InterFaceName)||x.InterFaceName.Contains(table.InterFaceName)) &&
|
||||
( string.IsNullOrEmpty(table.InterFaceUrl)||x.InterFaceUrl.Contains(table.InterFaceUrl)) &&
|
||||
( string.IsNullOrEmpty(table.InterFaceMehtod)||x.InterFaceMehtod.Contains(table.InterFaceMehtod)) &&
|
||||
( string.IsNullOrEmpty(table.InterFaceBody)||x.InterFaceBody.Contains(table.InterFaceBody)) &&
|
||||
( string.IsNullOrEmpty(table.InterFaceReturnData)||x.InterFaceReturnData.Contains(table.InterFaceReturnData)) &&
|
||||
( string.IsNullOrEmpty(table.InterFaceType)||x.InterFaceType.Contains(table.InterFaceType)) &&
|
||||
( string.IsNullOrEmpty(table.IP)||x.IP.Contains(table.IP))
|
||||
orderby x.InterFaceLogDate descending
|
||||
select x
|
||||
;
|
||||
|
||||
return q.ToList();
|
||||
public static IQueryable<Model.InterFaceLog> GetInterFaceLogByModle(Model.InterFaceLog table)
|
||||
{
|
||||
var q = from x in db.InterFaceLog
|
||||
where
|
||||
(string.IsNullOrEmpty(table.InterFaceLogId) || x.InterFaceLogId.Contains(table.InterFaceLogId)) &&
|
||||
(string.IsNullOrEmpty(table.UserId) || x.UserId.Contains(table.UserId)) &&
|
||||
(string.IsNullOrEmpty(table.UnitId) || x.UnitId.Contains(table.UnitId)) &&
|
||||
(string.IsNullOrEmpty(table.InterFaceName) || x.InterFaceName.Contains(table.InterFaceName)) &&
|
||||
(string.IsNullOrEmpty(table.InterFaceUrl) || x.InterFaceUrl.Contains(table.InterFaceUrl)) &&
|
||||
(string.IsNullOrEmpty(table.InterFaceMehtod) || x.InterFaceMehtod.Contains(table.InterFaceMehtod)) &&
|
||||
(string.IsNullOrEmpty(table.InterFaceBody) || x.InterFaceBody.Contains(table.InterFaceBody)) &&
|
||||
(string.IsNullOrEmpty(table.InterFaceReturnData) || x.InterFaceReturnData.Contains(table.InterFaceReturnData)) &&
|
||||
(string.IsNullOrEmpty(table.InterFaceType) || x.InterFaceType.Contains(table.InterFaceType)) &&
|
||||
(string.IsNullOrEmpty(table.IP) || x.IP.Contains(table.IP))
|
||||
orderby x.InterFaceLogDate descending
|
||||
select x
|
||||
;
|
||||
|
||||
return q;
|
||||
}
|
||||
|
||||
/// 获取分页列表
|
||||
@@ -57,62 +51,60 @@ namespace BLL
|
||||
/// <returns></returns>
|
||||
public static IEnumerable getListData(Model.InterFaceLog table, Grid Grid1)
|
||||
{
|
||||
var q= GetInterFaceLogByModle(table);
|
||||
var q = GetInterFaceLogByModle(table);
|
||||
count = q.Count();
|
||||
if (count == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
q = q.Skip(Grid1.PageSize * (Grid1.PageIndex)).Take(Grid1.PageSize).ToList();
|
||||
// q = SortConditionHelper.SortingAndPaging(q, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize);
|
||||
q = q.Skip(Grid1.PageSize * (Grid1.PageIndex)).Take(Grid1.PageSize);
|
||||
// q = SortConditionHelper.SortingAndPaging(q, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize);
|
||||
return (from x in q
|
||||
select new
|
||||
{
|
||||
x.InterFaceLogId,
|
||||
x.UserId,
|
||||
x.UnitId,
|
||||
x.InterFaceName,
|
||||
x.InterFaceUrl,
|
||||
x.InterFaceMehtod,
|
||||
x.InterFaceBody,
|
||||
x.InterFaceReturnData,
|
||||
x.InterFaceLogDate,
|
||||
x.InterFaceType,
|
||||
x.LogSate,
|
||||
x.IP,
|
||||
|
||||
});
|
||||
select new
|
||||
{
|
||||
x.InterFaceLogId,
|
||||
x.UserId,
|
||||
x.UnitId,
|
||||
x.InterFaceName,
|
||||
x.InterFaceUrl,
|
||||
x.InterFaceMehtod,
|
||||
x.InterFaceBody,
|
||||
x.InterFaceReturnData,
|
||||
x.InterFaceLogDate,
|
||||
x.InterFaceType,
|
||||
x.LogSate,
|
||||
x.IP,
|
||||
|
||||
}).ToList();
|
||||
}
|
||||
#endregion
|
||||
|
||||
public static Model.InterFaceLog GetInterFaceLogById(string InterFaceLogId)
|
||||
{
|
||||
return db.InterFaceLog.FirstOrDefault(x=>x.InterFaceLogId==InterFaceLogId);
|
||||
public static Model.InterFaceLog GetInterFaceLogById(string InterFaceLogId)
|
||||
{
|
||||
return db.InterFaceLog.FirstOrDefault(x => x.InterFaceLogId == InterFaceLogId);
|
||||
}
|
||||
|
||||
|
||||
public static void AddInterFaceLog(Model.InterFaceLog newtable)
|
||||
{
|
||||
|
||||
|
||||
Model.InterFaceLog table = new Model.InterFaceLog{
|
||||
InterFaceLogId=newtable.InterFaceLogId,
|
||||
UserId=newtable.UserId,
|
||||
UnitId=newtable.UnitId,
|
||||
InterFaceName=newtable.InterFaceName,
|
||||
InterFaceUrl=newtable.InterFaceUrl,
|
||||
InterFaceMehtod=newtable.InterFaceMehtod,
|
||||
InterFaceBody=newtable.InterFaceBody,
|
||||
InterFaceReturnData=newtable.InterFaceReturnData,
|
||||
InterFaceLogDate=newtable.InterFaceLogDate,
|
||||
InterFaceType=newtable.InterFaceType,
|
||||
LogSate=newtable.LogSate,
|
||||
IP=newtable.IP,
|
||||
Model.InterFaceLog table = new Model.InterFaceLog
|
||||
{
|
||||
InterFaceLogId = newtable.InterFaceLogId,
|
||||
UserId = newtable.UserId,
|
||||
UnitId = newtable.UnitId,
|
||||
InterFaceName = newtable.InterFaceName,
|
||||
InterFaceUrl = newtable.InterFaceUrl,
|
||||
InterFaceMehtod = newtable.InterFaceMehtod,
|
||||
InterFaceBody = newtable.InterFaceBody,
|
||||
InterFaceReturnData = newtable.InterFaceReturnData,
|
||||
InterFaceLogDate = newtable.InterFaceLogDate,
|
||||
InterFaceType = newtable.InterFaceType,
|
||||
LogSate = newtable.LogSate,
|
||||
IP = newtable.IP,
|
||||
};
|
||||
Funs.DB.InterFaceLog.InsertOnSubmit(table);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
public static void WriteInterFaceLog(string InterFaceSetlId, string InterFaceBody, string ReturnData, string InterFaceType,bool isSuccess)
|
||||
public static void WriteInterFaceLog(string InterFaceSetlId, string InterFaceBody, string ReturnData, string InterFaceType, bool isSuccess)
|
||||
{
|
||||
var InterfaceSetModel = InterFaceSetService.GetInterFaceSetById(InterFaceSetlId);
|
||||
Model.InterFaceLog table = new Model.InterFaceLog();
|
||||
@@ -131,7 +123,7 @@ namespace BLL
|
||||
table.UnitId = InterfaceSetModel.UnitId;
|
||||
table.InterFaceUrl = InterfaceSetModel.InterFaceUrl;
|
||||
table.InterFaceMehtod = InterfaceSetModel.UrlReqMethod;
|
||||
|
||||
|
||||
break;
|
||||
case Type2:
|
||||
table.UnitId = InterfaceSetModel.AuthUnitIds;
|
||||
@@ -150,36 +142,34 @@ namespace BLL
|
||||
|
||||
public static void UpdateInterFaceLog(Model.InterFaceLog newtable)
|
||||
{
|
||||
|
||||
Model.InterFaceLog table = db.InterFaceLog.FirstOrDefault(x=>x.InterFaceLogId==newtable.InterFaceLogId);
|
||||
if (table != null)
|
||||
|
||||
Model.InterFaceLog table = db.InterFaceLog.FirstOrDefault(x => x.InterFaceLogId == newtable.InterFaceLogId);
|
||||
if (table != null)
|
||||
{
|
||||
table.InterFaceLogId=newtable.InterFaceLogId;
|
||||
table.UserId=newtable.UserId;
|
||||
table.UnitId=newtable.UnitId;
|
||||
table.InterFaceName=newtable.InterFaceName;
|
||||
table.InterFaceUrl=newtable.InterFaceUrl;
|
||||
table.InterFaceMehtod=newtable.InterFaceMehtod;
|
||||
table.InterFaceBody=newtable.InterFaceBody;
|
||||
table.InterFaceReturnData=newtable.InterFaceReturnData;
|
||||
table.InterFaceLogDate=newtable.InterFaceLogDate;
|
||||
table.InterFaceType=newtable.InterFaceType;
|
||||
table.LogSate=newtable.LogSate;
|
||||
table.IP=newtable.IP;
|
||||
table.InterFaceLogId = newtable.InterFaceLogId;
|
||||
table.UserId = newtable.UserId;
|
||||
table.UnitId = newtable.UnitId;
|
||||
table.InterFaceName = newtable.InterFaceName;
|
||||
table.InterFaceUrl = newtable.InterFaceUrl;
|
||||
table.InterFaceMehtod = newtable.InterFaceMehtod;
|
||||
table.InterFaceBody = newtable.InterFaceBody;
|
||||
table.InterFaceReturnData = newtable.InterFaceReturnData;
|
||||
table.InterFaceLogDate = newtable.InterFaceLogDate;
|
||||
table.InterFaceType = newtable.InterFaceType;
|
||||
table.LogSate = newtable.LogSate;
|
||||
table.IP = newtable.IP;
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public static void DeleteInterFaceLogById (string InterFaceLogId)
|
||||
{
|
||||
|
||||
Model.InterFaceLog table =Funs.DB.InterFaceLog.FirstOrDefault(x=>x.InterFaceLogId==InterFaceLogId);
|
||||
if (table != null)
|
||||
{
|
||||
public static void DeleteInterFaceLogById(string InterFaceLogId)
|
||||
{
|
||||
Model.InterFaceLog table = Funs.DB.InterFaceLog.FirstOrDefault(x => x.InterFaceLogId == InterFaceLogId);
|
||||
if (table != null)
|
||||
{
|
||||
Funs.DB.InterFaceLog.DeleteOnSubmit(table);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,187 @@
|
||||
namespace BLL
|
||||
{
|
||||
using Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
public static class InterFaceService
|
||||
{
|
||||
public static Model.SGGLDB db = Funs.DB;
|
||||
|
||||
/// <summary>
|
||||
/// 获取接口设置信息
|
||||
/// </summary>
|
||||
/// <param name="InterFaceSetId">设置Id</param>
|
||||
/// <returns>接口设置信息</returns>
|
||||
public static Model.InterFaceSet GetFaceSetById(string InterFaceSetId)
|
||||
{
|
||||
return Funs.DB.InterFaceSet.FirstOrDefault(e => e.InterFaceSetId == InterFaceSetId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 增加接口设置信息
|
||||
/// </summary>
|
||||
/// <param name="faceset">接口设置</param>
|
||||
public static void AddFaceSet(Model.InterFaceSet faceset)
|
||||
{
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
string newKeyID = SQLHelper.GetNewID(typeof(Model.InterFaceSet));
|
||||
List<InterFaceDetail> detailList = new List<InterFaceDetail>();
|
||||
Model.InterFaceSet newSet = new Model.InterFaceSet
|
||||
{
|
||||
InterFaceSetId = newKeyID,
|
||||
InterFaceName = faceset.InterFaceName,
|
||||
AuthUnitIds = faceset.AuthUnitIds,
|
||||
AuthUnitName = faceset.AuthUnitName,
|
||||
InterFaceUrl = faceset.InterFaceUrl,
|
||||
InterFaceForUrl = faceset.InterFaceForUrl,
|
||||
ValidPeriod = faceset.ValidPeriod,
|
||||
UnitId = faceset.UnitId,
|
||||
TxtRemarks = faceset.TxtRemarks,
|
||||
IsOpen = faceset.IsOpen,
|
||||
IsReqPost = faceset.IsReqPost,
|
||||
IsCallBack= faceset.IsCallBack,
|
||||
InterFaceCallBackUrl= faceset.InterFaceCallBackUrl,
|
||||
};
|
||||
//明细表
|
||||
foreach (var AuthUnitId in newSet.AuthUnitIds.Split(','))
|
||||
{
|
||||
Model.InterFaceDetail deteil = new Model.InterFaceDetail
|
||||
{
|
||||
InterFaceDetailId = SQLHelper.GetNewID(typeof(Model.InterFaceDetail)),
|
||||
InterFaceName = newSet.InterFaceName,
|
||||
UnitId = newSet.UnitId,
|
||||
AuthUnitIds = AuthUnitId,
|
||||
InterFaceSetlId = newSet.InterFaceSetId,
|
||||
ReportState = false,
|
||||
GainState = false,
|
||||
};
|
||||
detailList.Add(deteil);
|
||||
}
|
||||
db.InterFaceDetail.InsertAllOnSubmit(detailList);
|
||||
db.InterFaceSet.InsertOnSubmit(newSet);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改接口设置信息
|
||||
/// </summary>
|
||||
/// <param name="user">接口设置实体</param>
|
||||
public static void UpdateFaceSet(Model.InterFaceSet user)
|
||||
{
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
List<InterFaceDetail> detailList = new List<InterFaceDetail>();
|
||||
Model.InterFaceSet newSet = db.InterFaceSet.FirstOrDefault(e => e.InterFaceSetId == user.InterFaceSetId);
|
||||
if (newSet != null)
|
||||
{
|
||||
newSet.InterFaceName = user.InterFaceName;
|
||||
newSet.AuthUnitIds = user.AuthUnitIds;
|
||||
newSet.AuthUnitName = user.AuthUnitName;
|
||||
newSet.InterFaceUrl = user.InterFaceUrl;
|
||||
newSet.InterFaceForUrl = user.InterFaceForUrl;
|
||||
newSet.UnitId = user.UnitId;
|
||||
newSet.ValidPeriod = user.ValidPeriod;
|
||||
newSet.UnitId = user.UnitId;
|
||||
newSet.TxtRemarks = user.TxtRemarks;
|
||||
newSet.IsOpen = user.IsOpen;
|
||||
newSet.IsReqPost = user.IsReqPost;
|
||||
newSet.IsCallBack = user.IsCallBack;
|
||||
newSet.InterFaceCallBackUrl= user.InterFaceCallBackUrl;
|
||||
var AuthUnitIds = newSet.AuthUnitIds.Split(',');
|
||||
//明细表
|
||||
List<Model.InterFaceDetail> FaceDetailList = db.InterFaceDetail.Where(e => e.InterFaceSetlId == user.InterFaceSetId).ToList();
|
||||
//删除无效明细
|
||||
var oldDetails = FaceDetailList.Where(p=> !AuthUnitIds.Equals(p.AuthUnitIds)) ;
|
||||
if (oldDetails.Count() > 0)
|
||||
{
|
||||
db.InterFaceDetail.DeleteAllOnSubmit(oldDetails);
|
||||
}
|
||||
foreach (var AuthUnitId in AuthUnitIds)
|
||||
{
|
||||
Model.InterFaceDetail deteil = new Model.InterFaceDetail
|
||||
{
|
||||
InterFaceDetailId = SQLHelper.GetNewID(typeof(Model.InterFaceDetail)),
|
||||
InterFaceName = newSet.InterFaceName,
|
||||
UnitId = newSet.UnitId,
|
||||
AuthUnitIds = AuthUnitId,
|
||||
InterFaceSetlId = newSet.InterFaceSetId,
|
||||
};
|
||||
var FaceDetail = FaceDetailList.FirstOrDefault(p => p.AuthUnitIds == AuthUnitId);
|
||||
if (FaceDetail == null)
|
||||
{
|
||||
detailList.Add(deteil);
|
||||
}
|
||||
}
|
||||
db.InterFaceDetail.InsertAllOnSubmit(detailList);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据Id删除信息
|
||||
/// </summary>
|
||||
/// <param name="SetId"></param>
|
||||
public static void DeleteFaceSet(string SetId)
|
||||
{
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
Model.InterFaceSet FaceSet = db.InterFaceSet.FirstOrDefault(e => e.InterFaceSetId == SetId);
|
||||
if (FaceSet != null)
|
||||
{
|
||||
var logs = from x in db.Sys_Log where x.UserId == SetId select x;
|
||||
if (logs.Count() > 0)
|
||||
{
|
||||
db.Sys_Log.DeleteAllOnSubmit(logs);
|
||||
}
|
||||
db.InterFaceSet.DeleteOnSubmit(FaceSet);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存上报数据记录
|
||||
/// </summary>
|
||||
/// <param name="newItem">上报数据</param>
|
||||
/// <returns></returns>
|
||||
public static string SaveUpData(Model.InterFaceItem newItem)
|
||||
{
|
||||
if (newItem.FaceLogDate.Count() == 0)
|
||||
return "数据不可为空!";
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
List<string> InterFaceLogIdList = new List<string>();
|
||||
List<Model.InterFaceLog> logList = new List<Model.InterFaceLog>();
|
||||
string message = string.Empty;
|
||||
var FaceDetailList = db.InterFaceDetail.Where(x => newItem.FaceLogDate.Select(p=>p.UnitId).Equals(x.UnitId));
|
||||
foreach (var item in newItem.FaceLogDate)
|
||||
{
|
||||
//如果配置接口名称存在 进行数据保存
|
||||
var faceDetail = FaceDetailList.FirstOrDefault(p => p.InterFaceName == item.InterFaceName);
|
||||
if (faceDetail != null)
|
||||
{
|
||||
faceDetail.ReportDate = DateTime.Now;
|
||||
faceDetail.ReportState = true;
|
||||
Model.InterFaceLog FaceLog = new Model.InterFaceLog();
|
||||
FaceLog.InterFaceLogId = SQLHelper.GetNewID(typeof(Model.InterFaceLog));
|
||||
FaceLog.TxtContent = item.TxtContent;
|
||||
FaceLog.InterFaceLogDate = Convert.ToDateTime(item.InterFaceLogDate);
|
||||
FaceLog.LogSate = false;
|
||||
FaceLog.CollCropCode = item.CollCropCode;
|
||||
FaceLog.IP = item.IP;
|
||||
FaceLog.UnitId = item.UnitId;
|
||||
FaceLog.InterFaceDetailId = faceDetail.InterFaceDetailId;
|
||||
logList.Add(FaceLog);
|
||||
}
|
||||
else //配置接口名称不存在 记录反馈给前端提示
|
||||
{
|
||||
InterFaceLogIdList.Add(item.InterFaceName);
|
||||
}
|
||||
}
|
||||
db.InterFaceLog.InsertAllOnSubmit(logList);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
|
||||
return "数据同步成功";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,12 +8,9 @@ using System.Text;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
|
||||
public static class InterFaceSetService
|
||||
public static class InterFaceSetService
|
||||
{
|
||||
|
||||
|
||||
#region 获取列表
|
||||
#region 获取列表
|
||||
/// <summary>
|
||||
/// 记录数
|
||||
/// </summary>
|
||||
@@ -22,24 +19,24 @@ namespace BLL
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public static List<Model.InterFaceSet> GetInterFaceSetByModle(Model.InterFaceSet table)
|
||||
{
|
||||
var q= from x in Funs.DB.InterFaceSet
|
||||
where
|
||||
( string.IsNullOrEmpty(table.InterFaceSetId)||x.InterFaceSetId.Contains(table.InterFaceSetId)) &&
|
||||
( string.IsNullOrEmpty(table.InterFaceName)||x.InterFaceName.Contains(table.InterFaceName)) &&
|
||||
( string.IsNullOrEmpty(table.InterFaceUrl)||x.InterFaceUrl.Contains(table.InterFaceUrl)) &&
|
||||
( string.IsNullOrEmpty(table.UnitId)||x.UnitId.Contains(table.UnitId)) &&
|
||||
( string.IsNullOrEmpty(table.AuthUnitIds)||x.AuthUnitIds.Contains(table.AuthUnitIds)) &&
|
||||
( string.IsNullOrEmpty(table.AuthUnitName)||x.AuthUnitName.Contains(table.AuthUnitName)) &&
|
||||
( string.IsNullOrEmpty(table.ValidPeriod)||x.ValidPeriod.Contains(table.ValidPeriod)) &&
|
||||
( string.IsNullOrEmpty(table.TxtRemarks)||x.TxtRemarks.Contains(table.TxtRemarks)) &&
|
||||
( string.IsNullOrEmpty(table.InterFaceForUrl)||x.InterFaceForUrl.Contains(table.InterFaceForUrl)) &&
|
||||
( string.IsNullOrEmpty(table.InterFaceCallBackUrl)||x.InterFaceCallBackUrl.Contains(table.InterFaceCallBackUrl))
|
||||
select x
|
||||
;
|
||||
|
||||
return q.ToList();
|
||||
public static List<Model.InterFaceSet> GetInterFaceSetByModle(Model.InterFaceSet table)
|
||||
{
|
||||
var q = from x in Funs.DB.InterFaceSet
|
||||
where
|
||||
(string.IsNullOrEmpty(table.InterFaceSetId) || x.InterFaceSetId.Contains(table.InterFaceSetId)) &&
|
||||
(string.IsNullOrEmpty(table.InterFaceName) || x.InterFaceName.Contains(table.InterFaceName)) &&
|
||||
(string.IsNullOrEmpty(table.InterFaceUrl) || x.InterFaceUrl.Contains(table.InterFaceUrl)) &&
|
||||
(string.IsNullOrEmpty(table.UnitId) || x.UnitId.Contains(table.UnitId)) &&
|
||||
(string.IsNullOrEmpty(table.AuthUnitIds) || x.AuthUnitIds.Contains(table.AuthUnitIds)) &&
|
||||
(string.IsNullOrEmpty(table.AuthUnitName) || x.AuthUnitName.Contains(table.AuthUnitName)) &&
|
||||
(string.IsNullOrEmpty(table.ValidPeriod) || x.ValidPeriod.Contains(table.ValidPeriod)) &&
|
||||
(string.IsNullOrEmpty(table.TxtRemarks) || x.TxtRemarks.Contains(table.TxtRemarks)) &&
|
||||
(string.IsNullOrEmpty(table.InterFaceForUrl) || x.InterFaceForUrl.Contains(table.InterFaceForUrl)) &&
|
||||
(string.IsNullOrEmpty(table.InterFaceCallBackUrl) || x.InterFaceCallBackUrl.Contains(table.InterFaceCallBackUrl))
|
||||
select x
|
||||
;
|
||||
|
||||
return q.ToList();
|
||||
}
|
||||
|
||||
/// 获取分页列表
|
||||
@@ -49,107 +46,113 @@ namespace BLL
|
||||
/// <returns></returns>
|
||||
public static IEnumerable getListData(Model.InterFaceSet table, Grid Grid1)
|
||||
{
|
||||
var q= GetInterFaceSetByModle(table);
|
||||
var q = GetInterFaceSetByModle(table);
|
||||
count = q.Count();
|
||||
if (count == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
// q= q.Take(Grid1.PageSize * Grid1.PageIndex).Skip(Grid1.PageSize * (Grid1.PageIndex)).ToList();
|
||||
// q = SortConditionHelper.SortingAndPaging(q, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize);
|
||||
// q = SortConditionHelper.SortingAndPaging(q, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize);
|
||||
return from x in q
|
||||
select new
|
||||
{
|
||||
x.InterFaceSetId,
|
||||
x.InterFaceName,
|
||||
x.InterFaceUrl,
|
||||
x.UnitId,
|
||||
x.AuthUnitIds,
|
||||
x.AuthUnitName,
|
||||
x.IsOpen,
|
||||
x.ValidPeriod,
|
||||
x.TxtRemarks,
|
||||
x.InterFaceForUrl,
|
||||
x.IsCallBack,
|
||||
x.InterFaceCallBackUrl,
|
||||
x.UrlReqMethod,
|
||||
x.CallBackUrlReqMethod,
|
||||
x.ForUrlReqMethod
|
||||
|
||||
x.InterFaceSetId,
|
||||
x.InterFaceName,
|
||||
x.InterFaceUrl,
|
||||
x.UnitId,
|
||||
x.AuthUnitIds,
|
||||
x.AuthUnitName,
|
||||
x.IsOpen,
|
||||
x.ValidPeriod,
|
||||
x.TxtRemarks,
|
||||
x.InterFaceForUrl,
|
||||
x.IsCallBack,
|
||||
x.InterFaceCallBackUrl,
|
||||
x.UrlReqMethod,
|
||||
x.CallBackUrlReqMethod,
|
||||
x.ForUrlReqMethod
|
||||
|
||||
};
|
||||
}
|
||||
#endregion
|
||||
|
||||
public static Model.InterFaceSet GetInterFaceSetById(string InterFaceSetId)
|
||||
{
|
||||
return Funs.DB.InterFaceSet.FirstOrDefault(x=>x.InterFaceSetId==InterFaceSetId);
|
||||
}
|
||||
public static List<Model.InterFaceSet> GetInterFaceSets()
|
||||
public static Model.InterFaceSet GetInterFaceSetById(string InterFaceSetId)
|
||||
{
|
||||
var q = (from x in Funs.DB.InterFaceSet select x).ToList();
|
||||
return Funs.DB.InterFaceSet.FirstOrDefault(x => x.InterFaceSetId == InterFaceSetId);
|
||||
}
|
||||
public static List<Model.InterFaceSet> GetInterFaceSets()
|
||||
{
|
||||
var q = (from x in Funs.DB.InterFaceSet select x).ToList();
|
||||
return q;
|
||||
}
|
||||
|
||||
public static void AddInterFaceSet(Model.InterFaceSet newtable)
|
||||
{
|
||||
|
||||
Model.InterFaceSet table = new Model.InterFaceSet{
|
||||
InterFaceSetId=newtable.InterFaceSetId,
|
||||
InterFaceName=newtable.InterFaceName,
|
||||
InterFaceUrl=newtable.InterFaceUrl,
|
||||
UnitId=newtable.UnitId,
|
||||
AuthUnitIds=newtable.AuthUnitIds,
|
||||
AuthUnitName=newtable.AuthUnitName,
|
||||
IsOpen=newtable.IsOpen,
|
||||
ValidPeriod=newtable.ValidPeriod,
|
||||
TxtRemarks=newtable.TxtRemarks,
|
||||
InterFaceForUrl=newtable.InterFaceForUrl,
|
||||
IsCallBack=newtable.IsCallBack,
|
||||
InterFaceCallBackUrl=newtable.InterFaceCallBackUrl,
|
||||
UrlReqMethod=newtable.UrlReqMethod,
|
||||
ForUrlReqMethod=newtable.ForUrlReqMethod,
|
||||
CallBackUrlReqMethod= newtable.CallBackUrlReqMethod,
|
||||
|
||||
Model.InterFaceSet table = new Model.InterFaceSet
|
||||
{
|
||||
InterFaceSetId = newtable.InterFaceSetId,
|
||||
InterFaceName = newtable.InterFaceName,
|
||||
InterFaceUrl = newtable.InterFaceUrl,
|
||||
UnitId = newtable.UnitId,
|
||||
AuthUnitIds = newtable.AuthUnitIds,
|
||||
AuthUnitName = newtable.AuthUnitName,
|
||||
IsOpen = newtable.IsOpen,
|
||||
ValidPeriod = newtable.ValidPeriod,
|
||||
TxtRemarks = newtable.TxtRemarks,
|
||||
InterFaceForUrl = newtable.InterFaceForUrl,
|
||||
IsCallBack = newtable.IsCallBack,
|
||||
InterFaceCallBackUrl = newtable.InterFaceCallBackUrl,
|
||||
UrlReqMethod = newtable.UrlReqMethod,
|
||||
ForUrlReqMethod = newtable.ForUrlReqMethod,
|
||||
CallBackUrlReqMethod = newtable.CallBackUrlReqMethod,
|
||||
IsSingleRequest = newtable.IsSingleRequest,
|
||||
RequestJsonBody = newtable.RequestJsonBody,
|
||||
|
||||
};
|
||||
Funs.DB.InterFaceSet.InsertOnSubmit(table);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void UpdateInterFaceSet(Model.InterFaceSet newtable)
|
||||
{
|
||||
|
||||
Model.InterFaceSet table = Funs.DB.InterFaceSet.FirstOrDefault(x=>x.InterFaceSetId==newtable.InterFaceSetId);
|
||||
if (table != null)
|
||||
|
||||
Model.InterFaceSet table = Funs.DB.InterFaceSet.FirstOrDefault(x => x.InterFaceSetId == newtable.InterFaceSetId);
|
||||
if (table != null)
|
||||
{
|
||||
table.InterFaceSetId=newtable.InterFaceSetId;
|
||||
table.InterFaceName=newtable.InterFaceName;
|
||||
table.InterFaceUrl=newtable.InterFaceUrl;
|
||||
table.UnitId=newtable.UnitId;
|
||||
table.AuthUnitIds=newtable.AuthUnitIds;
|
||||
table.AuthUnitName=newtable.AuthUnitName;
|
||||
table.IsOpen=newtable.IsOpen;
|
||||
table.ValidPeriod=newtable.ValidPeriod;
|
||||
table.TxtRemarks=newtable.TxtRemarks;
|
||||
table.InterFaceForUrl=newtable.InterFaceForUrl;
|
||||
table.IsCallBack=newtable.IsCallBack;
|
||||
table.InterFaceCallBackUrl=newtable.InterFaceCallBackUrl;
|
||||
table.UrlReqMethod=newtable.UrlReqMethod;
|
||||
table.ForUrlReqMethod=newtable.ForUrlReqMethod;
|
||||
table.CallBackUrlReqMethod=newtable.CallBackUrlReqMethod;
|
||||
table.InterFaceSetId = newtable.InterFaceSetId;
|
||||
table.InterFaceName = newtable.InterFaceName;
|
||||
table.InterFaceUrl = newtable.InterFaceUrl;
|
||||
table.UnitId = newtable.UnitId;
|
||||
table.AuthUnitIds = newtable.AuthUnitIds;
|
||||
table.AuthUnitName = newtable.AuthUnitName;
|
||||
table.IsOpen = newtable.IsOpen;
|
||||
table.ValidPeriod = newtable.ValidPeriod;
|
||||
table.TxtRemarks = newtable.TxtRemarks;
|
||||
table.InterFaceForUrl = newtable.InterFaceForUrl;
|
||||
table.IsCallBack = newtable.IsCallBack;
|
||||
table.InterFaceCallBackUrl = newtable.InterFaceCallBackUrl;
|
||||
table.UrlReqMethod = newtable.UrlReqMethod;
|
||||
table.ForUrlReqMethod = newtable.ForUrlReqMethod;
|
||||
table.CallBackUrlReqMethod = newtable.CallBackUrlReqMethod;
|
||||
table.IsSingleRequest = newtable.IsSingleRequest;
|
||||
table.RequestJsonBody = newtable.RequestJsonBody;
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public static void DeleteInterFaceSetById (string InterFaceSetId)
|
||||
{
|
||||
|
||||
Model.InterFaceSet table =Funs.DB.InterFaceSet.FirstOrDefault(x=>x.InterFaceSetId==InterFaceSetId);
|
||||
if (table != null)
|
||||
{
|
||||
public static void DeleteInterFaceSetById(string InterFaceSetId)
|
||||
{
|
||||
|
||||
Model.InterFaceSet table = Funs.DB.InterFaceSet.FirstOrDefault(x => x.InterFaceSetId == InterFaceSetId);
|
||||
if (table != null)
|
||||
{
|
||||
Funs.DB.InterFaceSet.DeleteOnSubmit(table);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
public static void InitInterFaceDropDownList(FineUIPro.DropDownList dropName, bool isShowPlease)
|
||||
{
|
||||
|
||||
@@ -12,13 +12,13 @@ using System.Text;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
|
||||
public static class InterFaceTaskService
|
||||
|
||||
public static class InterFaceTaskService
|
||||
{
|
||||
public static Model.SGGLDB db = Funs.DB;
|
||||
|
||||
|
||||
#region 获取列表
|
||||
public static Model.SGGLDB db = Funs.DB;
|
||||
|
||||
|
||||
#region 获取列表
|
||||
/// <summary>
|
||||
/// 记录数
|
||||
/// </summary>
|
||||
@@ -27,19 +27,19 @@ namespace BLL
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public static List<Model.InterFaceTask> GetInterFaceTaskByModle(Model.InterFaceTask table)
|
||||
{
|
||||
var q= from x in db.InterFaceTask
|
||||
where
|
||||
( string.IsNullOrEmpty(table.InterFaceTaskId)||x.InterFaceTaskId.Contains(table.InterFaceTaskId)) &&
|
||||
( string.IsNullOrEmpty(table.InterFaceName)||x.InterFaceName.Contains(table.InterFaceName)) &&
|
||||
( string.IsNullOrEmpty(table.InterFaceSetLists)||x.InterFaceSetLists.Contains(table.InterFaceSetLists)) &&
|
||||
( string.IsNullOrEmpty(table.Frequency)||x.Frequency.Contains(table.Frequency)) &&
|
||||
(table.Enable ==null|| x.Enable==table.Enable)
|
||||
select x
|
||||
;
|
||||
|
||||
return q.ToList();
|
||||
public static List<Model.InterFaceTask> GetInterFaceTaskByModle(Model.InterFaceTask table)
|
||||
{
|
||||
var q = from x in db.InterFaceTask
|
||||
where
|
||||
(string.IsNullOrEmpty(table.InterFaceTaskId) || x.InterFaceTaskId.Contains(table.InterFaceTaskId)) &&
|
||||
(string.IsNullOrEmpty(table.InterFaceName) || x.InterFaceName.Contains(table.InterFaceName)) &&
|
||||
(string.IsNullOrEmpty(table.InterFaceSetLists) || x.InterFaceSetLists.Contains(table.InterFaceSetLists)) &&
|
||||
(string.IsNullOrEmpty(table.Frequency) || x.Frequency.Contains(table.Frequency)) &&
|
||||
(table.Enable == null || x.Enable == table.Enable)
|
||||
select x
|
||||
;
|
||||
|
||||
return q.ToList();
|
||||
}
|
||||
|
||||
/// 获取分页列表
|
||||
@@ -49,79 +49,80 @@ namespace BLL
|
||||
/// <returns></returns>
|
||||
public static IEnumerable getListData(Model.InterFaceTask table, Grid Grid1)
|
||||
{
|
||||
var q= GetInterFaceTaskByModle(table);
|
||||
var q = GetInterFaceTaskByModle(table);
|
||||
count = q.Count();
|
||||
if (count == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
// q= q.Take(Grid1.PageSize * Grid1.PageIndex).Skip(Grid1.PageSize * (Grid1.PageIndex)).ToList();
|
||||
// q = SortConditionHelper.SortingAndPaging(q, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize);
|
||||
// q = SortConditionHelper.SortingAndPaging(q, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize);
|
||||
return from x in q
|
||||
select new
|
||||
{
|
||||
x.InterFaceTaskId,
|
||||
x.InterFaceName,
|
||||
x.InterFaceSetLists,
|
||||
x.Frequency,
|
||||
x.CreateTime,
|
||||
x.Enable,
|
||||
|
||||
x.InterFaceTaskId,
|
||||
x.InterFaceName,
|
||||
x.InterFaceSetLists,
|
||||
x.Frequency,
|
||||
x.CreateTime,
|
||||
x.Enable,
|
||||
|
||||
};
|
||||
}
|
||||
#endregion
|
||||
|
||||
public static Model.InterFaceTask GetInterFaceTaskById(string InterFaceTaskId)
|
||||
{
|
||||
return db.InterFaceTask.FirstOrDefault(x=>x.InterFaceTaskId==InterFaceTaskId);
|
||||
public static Model.InterFaceTask GetInterFaceTaskById(string InterFaceTaskId)
|
||||
{
|
||||
return db.InterFaceTask.FirstOrDefault(x => x.InterFaceTaskId == InterFaceTaskId);
|
||||
}
|
||||
public static void AddInterFaceTask(Model.InterFaceTask newtable)
|
||||
{
|
||||
|
||||
Model.InterFaceTask table = new Model.InterFaceTask{
|
||||
InterFaceTaskId=newtable.InterFaceTaskId,
|
||||
InterFaceName=newtable.InterFaceName,
|
||||
InterFaceSetLists=newtable.InterFaceSetLists,
|
||||
Frequency=newtable.Frequency,
|
||||
CreateTime=newtable.CreateTime,
|
||||
Enable=newtable.Enable,
|
||||
|
||||
Model.InterFaceTask table = new Model.InterFaceTask
|
||||
{
|
||||
InterFaceTaskId = newtable.InterFaceTaskId,
|
||||
InterFaceName = newtable.InterFaceName,
|
||||
InterFaceSetLists = newtable.InterFaceSetLists,
|
||||
Frequency = newtable.Frequency,
|
||||
CreateTime = newtable.CreateTime,
|
||||
Enable = newtable.Enable,
|
||||
};
|
||||
db.InterFaceTask.InsertOnSubmit(table);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void UpdateInterFaceTask(Model.InterFaceTask newtable)
|
||||
{
|
||||
|
||||
Model.InterFaceTask table = db.InterFaceTask.FirstOrDefault(x=>x.InterFaceTaskId==newtable.InterFaceTaskId);
|
||||
if (table != null)
|
||||
|
||||
Model.InterFaceTask table = db.InterFaceTask.FirstOrDefault(x => x.InterFaceTaskId == newtable.InterFaceTaskId);
|
||||
if (table != null)
|
||||
{
|
||||
table.InterFaceTaskId=newtable.InterFaceTaskId;
|
||||
table.InterFaceName=newtable.InterFaceName;
|
||||
table.InterFaceSetLists=newtable.InterFaceSetLists;
|
||||
table.Frequency=newtable.Frequency;
|
||||
table.CreateTime=newtable.CreateTime;
|
||||
table.Enable=newtable.Enable;
|
||||
table.InterFaceTaskId = newtable.InterFaceTaskId;
|
||||
table.InterFaceName = newtable.InterFaceName;
|
||||
table.InterFaceSetLists = newtable.InterFaceSetLists;
|
||||
table.Frequency = newtable.Frequency;
|
||||
table.CreateTime = newtable.CreateTime;
|
||||
table.Enable = newtable.Enable;
|
||||
db.SubmitChanges();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public static void DeleteInterFaceTaskById (string InterFaceTaskId)
|
||||
{
|
||||
|
||||
Model.InterFaceTask table =db.InterFaceTask.FirstOrDefault(x=>x.InterFaceTaskId==InterFaceTaskId);
|
||||
if (table != null)
|
||||
{
|
||||
public static void DeleteInterFaceTaskById(string InterFaceTaskId)
|
||||
{
|
||||
|
||||
Model.InterFaceTask table = db.InterFaceTask.FirstOrDefault(x => x.InterFaceTaskId == InterFaceTaskId);
|
||||
if (table != null)
|
||||
{
|
||||
db.InterFaceTask.DeleteOnSubmit(table);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
#region 执行任务
|
||||
public static void ExecuteTasks(string InterFaceTaskId)
|
||||
{
|
||||
|
||||
|
||||
var model = GetInterFaceTaskById(InterFaceTaskId);
|
||||
var InterFaceSetlIds = model.InterFaceSetLists.Split(',');
|
||||
foreach (var item in InterFaceSetlIds)
|
||||
@@ -143,13 +144,16 @@ namespace BLL
|
||||
}
|
||||
try
|
||||
{
|
||||
if (InterfaceSetModel.IsSingleRequest == true)
|
||||
{
|
||||
var taskData = GetSingleRequestData(InterfaceSetModel.InterFaceUrl, InterfaceSetModel.RequestJsonBody, InterfaceSetModel.UrlReqMethod);
|
||||
bool taskSuccess = taskData.code == 1;
|
||||
InterFaceLogService.WriteInterFaceLog(InterFaceSetlId, InterfaceSetModel.RequestJsonBody, JsonConvert.SerializeObject(taskData), InterFaceLogService.Type1, taskSuccess);
|
||||
return;
|
||||
}
|
||||
|
||||
var sourseData = GetSourseData(InterfaceSetModel.InterFaceUrl, InterfaceSetModel.UrlReqMethod);
|
||||
bool sourseisSuccess = false;
|
||||
if (sourseData.code == 1)
|
||||
{
|
||||
sourseisSuccess = true;
|
||||
}
|
||||
bool sourseisSuccess = sourseData.code == 1;
|
||||
InterFaceLogService.WriteInterFaceLog(InterFaceSetlId, "", JsonConvert.SerializeObject(sourseData), InterFaceLogService.Type1, sourseisSuccess);
|
||||
if (sourseData.code == 0)
|
||||
{
|
||||
@@ -157,11 +161,7 @@ namespace BLL
|
||||
}
|
||||
var TargetData = GetTargetData(InterfaceSetModel.InterFaceForUrl, sourseData, InterfaceSetModel.ForUrlReqMethod);
|
||||
|
||||
bool TargetisSuccess = false;
|
||||
if (TargetData.code == 1)
|
||||
{
|
||||
TargetisSuccess = true;
|
||||
}
|
||||
bool TargetisSuccess = TargetData.code == 1;
|
||||
InterFaceLogService.WriteInterFaceLog(InterFaceSetlId, JsonConvert.SerializeObject(sourseData.data), JsonConvert.SerializeObject(TargetData), InterFaceLogService.Type2, TargetisSuccess);
|
||||
|
||||
if (TargetData.code == 0 || InterfaceSetModel.IsCallBack == false)
|
||||
@@ -178,27 +178,60 @@ namespace BLL
|
||||
InterFaceLogService.WriteInterFaceLog(InterFaceSetlId, JsonConvert.SerializeObject(sourseData.data), JsonConvert.SerializeObject(callbackData), InterFaceLogService.Type3, CallBackisSuccess);
|
||||
|
||||
}
|
||||
catch (Exception ex )
|
||||
catch (Exception ex)
|
||||
{
|
||||
Model.InterFaceLog interFaceLog=new InterFaceLog();
|
||||
interFaceLog.InterFaceLogId=Guid.NewGuid().ToString();
|
||||
Model.InterFaceLog interFaceLog = new InterFaceLog();
|
||||
interFaceLog.InterFaceLogId = Guid.NewGuid().ToString();
|
||||
interFaceLog.InterFaceType = "异常";
|
||||
interFaceLog.LogSate = false;
|
||||
interFaceLog.InterFaceLogDate= DateTime.Now;
|
||||
interFaceLog.InterFaceLogDate = DateTime.Now;
|
||||
interFaceLog.InterFaceName = InterfaceSetModel.InterFaceName;
|
||||
interFaceLog.InterFaceReturnData = ex.ToString();
|
||||
InterFaceLogService.AddInterFaceLog(interFaceLog);
|
||||
}
|
||||
|
||||
}
|
||||
public static Model.ReturnData GetSourseData(string baseurl,string ReqMethod)
|
||||
public static Model.ReturnData GetSingleRequestData(string baseurl, string requestJsonBody, string ReqMethod)
|
||||
{
|
||||
Model.ReturnData returnData = new ReturnData();
|
||||
string token = "C4A62EC0-E5D3-4EBF-A5FA-E56AA89633C0";
|
||||
string Content = "";
|
||||
switch (ReqMethod)
|
||||
{
|
||||
case "Get":
|
||||
case "Get":
|
||||
Content = Funs.RequestGet(baseurl, token);
|
||||
break;
|
||||
case "Post":
|
||||
Content = Funs.RequestPost(baseurl, token, requestJsonBody);
|
||||
break;
|
||||
}
|
||||
//var client = new RestClient(baseurl);
|
||||
//client.Timeout = -1;
|
||||
//var request = new RestRequest(Method.POST);
|
||||
//request.AddHeader("token", "AF17168B-87BD-4GLY-1111-F0A0A1158F9B");
|
||||
//IRestResponse response = client.Execute(request);
|
||||
//Console.WriteLine(response.Content);
|
||||
try
|
||||
{
|
||||
returnData = JsonConvert.DeserializeObject<Model.ReturnData>(Content);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
returnData.code = 0;
|
||||
returnData.message = "获取数据失败:" + Content;
|
||||
}
|
||||
|
||||
|
||||
return returnData;
|
||||
}
|
||||
|
||||
public static Model.ReturnData GetSourseData(string baseurl, string ReqMethod)
|
||||
{
|
||||
Model.ReturnData returnData = new ReturnData();
|
||||
string token = "C4A62EC0-E5D3-4EBF-A5FA-E56AA89633C0";
|
||||
string Content = "";
|
||||
switch (ReqMethod)
|
||||
{
|
||||
case "Get":
|
||||
Content = Funs.RequestGet(baseurl, token);
|
||||
break;
|
||||
case "Post":
|
||||
@@ -278,7 +311,7 @@ namespace BLL
|
||||
}
|
||||
return responeData;
|
||||
}
|
||||
public static ReturnData ExecuteCallBack(string baseurl, ReturnData DataInput,string ReqMethod)
|
||||
public static ReturnData ExecuteCallBack(string baseurl, ReturnData DataInput, string ReqMethod)
|
||||
{
|
||||
Model.ReturnData returnData = new ReturnData();
|
||||
if (DataInput.code == 1)
|
||||
|
||||
@@ -11,27 +11,6 @@ namespace BLL
|
||||
{
|
||||
JobKey key = context.JobDetail.Key;
|
||||
|
||||
// note: use context.MergedJobDataMap in production code
|
||||
JobDataMap dataMap = context.JobDetail.JobDataMap;
|
||||
string InterFaceTaskId = dataMap.GetString("InterFaceTaskId");
|
||||
|
||||
//使用异步任务来实现
|
||||
await Task.Run(() =>
|
||||
{
|
||||
|
||||
InterFaceTaskService.ExecuteTasks(InterFaceTaskId);
|
||||
|
||||
|
||||
//Console.WriteLine($"{DateTime.Now}【{Thread.CurrentThread.ManagedThreadId}】:自定义的工作正在执行... ...");
|
||||
});
|
||||
}
|
||||
}
|
||||
public class CLJob : IJob
|
||||
{
|
||||
public async Task Execute(IJobExecutionContext context)
|
||||
{
|
||||
JobKey key = context.JobDetail.Key;
|
||||
|
||||
// note: use context.MergedJobDataMap in production code
|
||||
JobDataMap dataMap = context.JobDetail.JobDataMap;
|
||||
string InterFaceTaskId = dataMap.GetString("InterFaceTaskId");
|
||||
@@ -39,8 +18,8 @@ namespace BLL
|
||||
//使用异步任务来实现
|
||||
await Task.Run(() =>
|
||||
{
|
||||
MonitorService.PipelineWeldingQuantities();
|
||||
|
||||
InterFaceTaskService.ExecuteTasks(InterFaceTaskId);
|
||||
|
||||
|
||||
//Console.WriteLine($"{DateTime.Now}【{Thread.CurrentThread.ManagedThreadId}】:自定义的工作正在执行... ...");
|
||||
|
||||
@@ -1,31 +1,25 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Specialized;
|
||||
using System.Drawing.Printing;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Quartz;
|
||||
using Quartz.Impl;
|
||||
using Quartz;
|
||||
using Quartz.Impl;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
namespace BLL
|
||||
{
|
||||
public class QuartzServices
|
||||
{
|
||||
|
||||
public static async Task Init()
|
||||
{
|
||||
|
||||
|
||||
|
||||
//初始化计划者
|
||||
StdSchedulerFactory factory = new StdSchedulerFactory();
|
||||
// StdSchedulerFactory factory = new StdSchedulerFactory(properties);
|
||||
// StdSchedulerFactory factory = new StdSchedulerFactory(properties);
|
||||
IScheduler scheduler = await factory.GetScheduler();
|
||||
var jobAndTriggerMapping = new Dictionary<IJobDetail, IReadOnlyCollection<ITrigger>>();
|
||||
var jobAndTriggerMapping = new Dictionary<IJobDetail, IReadOnlyCollection<ITrigger>>();
|
||||
// 将映射关系包装成制度字典集合
|
||||
var model = new Model.InterFaceTask();
|
||||
model.Enable = true;
|
||||
@@ -40,15 +34,13 @@ using System.Threading.Tasks;
|
||||
//keyValuePairs.Add(item.InterFaceTaskId, scheduler);
|
||||
//Funs.ScheduledTasks = keyValuePairs;
|
||||
}
|
||||
|
||||
//// jobAndTriggerMapping[GetClJobDetail()] = GetClTrigger();//增加材料定时
|
||||
var readOnlyjobAndTriggerMapping = new ReadOnlyDictionary<IJobDetail, IReadOnlyCollection<ITrigger>>(jobAndTriggerMapping);
|
||||
await scheduler.ScheduleJobs(readOnlyjobAndTriggerMapping, true);
|
||||
await scheduler.Start(); //只有启动了,里面的任务才会定时触发
|
||||
Funs.ScheduledTasks = scheduler;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static void ISchedulerShupDown(IScheduler scheduler)
|
||||
{
|
||||
scheduler.Shutdown();
|
||||
@@ -76,15 +68,15 @@ using System.Threading.Tasks;
|
||||
{
|
||||
var jobDetail1 = GetJobDetailByInterFaceTaskId(model.InterFaceTaskId);
|
||||
var trigger1 = GetTriggerByTime(model.InterFaceTaskId, model.Frequency);
|
||||
await scheduler.ScheduleJob(jobDetail1, trigger1,true);
|
||||
await scheduler.ScheduleJob(jobDetail1, trigger1, true);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
var jobDetail1 = GetJobDetailByInterFaceTaskId(model.InterFaceTaskId);
|
||||
var trigger1 = GetTriggerByTime(model.InterFaceTaskId, model.Frequency);
|
||||
await scheduler.ScheduleJob(jobDetail1, trigger1,true);
|
||||
await scheduler.ScheduleJob(jobDetail1, trigger1, true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -93,9 +85,9 @@ using System.Threading.Tasks;
|
||||
if (scheduler.GetJobDetail(jk, default) != null)
|
||||
{
|
||||
await scheduler.DeleteJob(jk, default);
|
||||
|
||||
|
||||
// SyncScheduledTasks(model.InterFaceTaskId, scheduler, 2);
|
||||
|
||||
// SyncScheduledTasks(model.InterFaceTaskId, scheduler, 2);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -121,16 +113,16 @@ using System.Threading.Tasks;
|
||||
{
|
||||
if (type == 0)
|
||||
{
|
||||
// Funs.ScheduledTasks.Add(InterFaceTaskId, scheduler);
|
||||
// Funs.ScheduledTasks.Add(InterFaceTaskId, scheduler);
|
||||
}
|
||||
else if (type == 1)
|
||||
{
|
||||
// Funs.ScheduledTasks.Remove(InterFaceTaskId);
|
||||
// Funs.ScheduledTasks.Add(InterFaceTaskId, scheduler);
|
||||
// Funs.ScheduledTasks.Remove(InterFaceTaskId);
|
||||
// Funs.ScheduledTasks.Add(InterFaceTaskId, scheduler);
|
||||
}
|
||||
else if (type == 2)
|
||||
{
|
||||
// Funs.ScheduledTasks.Remove(InterFaceTaskId);
|
||||
// Funs.ScheduledTasks.Remove(InterFaceTaskId);
|
||||
}
|
||||
}
|
||||
public static IJobDetail GetJobDetailByInterFaceTaskId(string InterFaceTaskId)
|
||||
@@ -145,8 +137,9 @@ using System.Threading.Tasks;
|
||||
public static ReadOnlyCollection<ITrigger> GetTriggerByTime(string InterFaceTaskId, string time)
|
||||
{
|
||||
string cron = "0 0 0/& * * ? ";
|
||||
cron = cron.Replace("&", time);
|
||||
// cron = "0 0/1 * * * ? ";
|
||||
// cron = cron.Replace("&", time);
|
||||
cron = time;
|
||||
// cron = "0 0/1 * * * ? ";
|
||||
//创建触发器
|
||||
var trigger1 = new ReadOnlyCollection<ITrigger>(
|
||||
new List<ITrigger>()
|
||||
@@ -161,38 +154,6 @@ using System.Threading.Tasks;
|
||||
return trigger1;
|
||||
|
||||
}
|
||||
|
||||
#region 材料到货
|
||||
|
||||
public static IJobDetail GetClJobDetail()
|
||||
{ //创建Job
|
||||
IJobDetail jobDetail1 = JobBuilder.Create<CLJob>()
|
||||
.WithIdentity("CL", "group1")//给Job身份
|
||||
.WithDescription("任务的描述,方便查找")
|
||||
.Build();
|
||||
return jobDetail1;
|
||||
}
|
||||
public static ReadOnlyCollection<ITrigger> GetClTrigger()
|
||||
{
|
||||
string cron = "0 0/1 * * * ? ";
|
||||
cron = "0 0/1 * * * ? ";
|
||||
//创建触发器
|
||||
var trigger1 = new ReadOnlyCollection<ITrigger>(
|
||||
new List<ITrigger>()
|
||||
{
|
||||
TriggerBuilder.Create()
|
||||
.WithIdentity("CL", "group1") //给触发器身份
|
||||
.WithDescription("触发器的描述,方便查找")
|
||||
.StartAt(new DateTimeOffset(DateTime.Now.AddSeconds(10))) //.StartNow()都是启动触发器方式
|
||||
.WithCronSchedule(cron) //定时策略,Cron表达式
|
||||
.Build()
|
||||
});
|
||||
return trigger1;
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user