Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

添加企业微信支持 #223

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Agent/Hangfire.HttpJob.Agent/JobContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,11 @@ public class JobItem
/// </summary>
public DingTalkOption DingTalk { get; set; }

/// <summary>
/// 企业微信配置
/// </summary>
public WorkWeixinOption WorkWeixin { get; set; }

/// <summary>
/// 服务端传过来的storage配置
/// </summary>
Expand All @@ -297,6 +302,23 @@ public class DingTalkOption
/// </summary>
public bool IsAtAll { get; set; }
}
public class WorkWeixinOption
{
/// <summary>
/// 企业微信Webhook地址
/// </summary>
public string Key { get; set; }

/// <summary>
/// 通知是否@对应手机号的人员 , 分割
/// </summary>
public string AtPhones { get; set; }

/// <summary>
/// 通知是否@所有人
/// </summary>
public bool IsAtAll { get; set; }
}

public class JobStorageConfig
{
Expand Down
5 changes: 5 additions & 0 deletions Client/Hangfire.HttpJob.Client/BackgroundJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,5 +200,10 @@ public BackgroundJob()
/// </summary>
public DingTalkOption DingTalk { get; set; }

/// <summary>
/// 钉钉配置
/// </summary>
public WorkWeixinOption WorkWeixin { get; set; }

}
}
6 changes: 4 additions & 2 deletions Client/Hangfire.HttpJob.Client/HangfireJobClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ private static HttpJobItem PrepareAddBackgroundHttpJobItem(string hangfireServer
CallbackEL = backgroundJob.CallbackEL,
QueueName = backgroundJob.QueueName,
TimeZone = backgroundJob.TimeZone,
DingTalk = backgroundJob.DingTalk
DingTalk = backgroundJob.DingTalk,
WorkWeixin = backgroundJob.WorkWeixin
};

AppendChildJob(jobItem, backgroundJob.Success, backgroundJob.Fail);
Expand Down Expand Up @@ -247,7 +248,8 @@ private static HttpJobItem PrepareAddRecurringHttpJobItem(string hangfireServerU
Headers = recurringJob.Headers,
CallbackEL = recurringJob.CallbackEL,
TimeZone = recurringJob.TimeZone,
DingTalk = recurringJob.DingTalk
DingTalk = recurringJob.DingTalk,
WorkWeixin = recurringJob.WorkWeixin
};

AppendChildJob(jobItem,recurringJob.Success,recurringJob.Fail);
Expand Down
22 changes: 22 additions & 0 deletions Client/Hangfire.HttpJob.Client/HttpJobItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ internal class BaseHttpJobInfo
/// 钉钉配置
/// </summary>
public DingTalkOption DingTalk { get; set; }

/// <summary>
/// 企业微信配置
/// </summary>
public WorkWeixinOption WorkWeixin { get; set; }
#endregion
}
public class DingTalkOption
Expand All @@ -123,6 +128,23 @@ public class DingTalkOption
/// </summary>
public bool IsAtAll { get; set; }
}
public class WorkWeixinOption
{
/// <summary>
/// 企业微信Webhook地址
/// </summary>
public string Key { get; set; }

/// <summary>
/// 通知是否@对应手机号的人员 , 分割
/// </summary>
public string AtPhones { get; set; }

/// <summary>
/// 通知是否@所有人
/// </summary>
public bool IsAtAll { get; set; }
}

internal class HttpJobItem : BaseHttpJobInfo
{
Expand Down
5 changes: 5 additions & 0 deletions Client/Hangfire.HttpJob.Client/RecurringJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,10 @@ public RecurringJob()
/// 钉钉配置
/// </summary>
public DingTalkOption DingTalk { get; set; }

/// <summary>
/// 企业微信配置
/// </summary>
public WorkWeixinOption WorkWeixin { get; set; }
}
}
12 changes: 12 additions & 0 deletions Server/Hangfire.HttpJob/Content/httpjob.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,18 @@
IsAtAll: config.DingtalkAtAll == 'true' ? true : false
}
}
if (config.EnableWorkWeixin && config.EnableWorkWeixin == 'true') {
normalObj.WorkWeixin = {
Token: config.WorkWeixinToken || "",
AtPhones: config.WorkWeixinPhones || "",
IsAtAll: config.WorkWeixinAtAll == 'true' ? true : false
}
recurringObj.WorkWeixin = {
Token: config.WorkWeixinToken || "",
AtPhones: config.WorkWeixinPhones || "",
IsAtAll: config.WorkWeixinAtAll == 'true' ? true : false
}
}
var normal_templete = JSON.stringify(normalObj); // "{\"JobName\":\"\",\"Method\":\"GET\",\"ContentType\":\"application/json\",\"Url\":\"http://\",\"DelayFromMinutes\":1,\"Headers\":{},\"Data\":{},\"Timeout\":" + config.GlobalHttpTimeOut + ",\"BasicUserName\":\"\",\"BasicPassword\":\"\",\"QueueName\":\"" + config.DefaultBackGroundJobQueueName + "\",\"EnableRetry\":false,\"RetryTimes\":3,\"RetryDelaysInSeconds\":\"20,30,60\",\"SendSucMail\":false,\"SendFaiMail\":true,\"Mail\":\"\",\"AgentClass\":\"\",\"CallbackEL\":\"\"}";
var recurring_templete = JSON.stringify(recurringObj); // "{\"JobName\":\"\",\"Method\":\"GET\",\"ContentType\":\"application/json\",\"Url\":\"http://\",\"Headers\":{},\"Data\":{},\"Timeout\":" + config.GlobalHttpTimeOut + ",\"Cron\":\"\",\"BasicUserName\":\"\",\"BasicPassword\":\"\",\"QueueName\":\"" + config.DefaultRecurringQueueName + "\",\"EnableRetry\":false,\"RetryTimes\":3,\"RetryDelaysInSeconds\":\"20,30,60\",\"SendSucMail\":false,\"SendFaiMail\":true,\"Mail\":\"\",\"AgentClass\":\"\",\"CallbackEL\":\"\"}";
// console.log(normal_templete);
Expand Down
Loading