96 lines
3.8 KiB
C#
96 lines
3.8 KiB
C#
using Kurisu.Core.ConfigurableOptions.Attributes;
|
|
|
|
|
|
namespace Dlhis.ScheduledTask.Configurations
|
|
{
|
|
[Configuration]
|
|
public class ServiceSettings
|
|
{
|
|
public string ServerUrl { get; private set; }
|
|
|
|
public string UserName { get; private set; }
|
|
|
|
public string Password { get; private set; }
|
|
|
|
public string SyncTime { get; private set; }
|
|
public int AttendanceUploadInterval { get; private set; }
|
|
public string AttendanceUploadUrl { get; private set; }
|
|
public string DlhisDatabase { get; private set; }
|
|
|
|
public string Werks { get; private set; }
|
|
|
|
public DateTime BeginSyncDate { get; private set; }
|
|
public int ApiPort { get; private set; }
|
|
public string EHRWebServiceUserName { get; set; }
|
|
public string EHRWebServicePassword { get; set; }
|
|
public string EHRInsertRecordApiUrl { get; set; }
|
|
public string EHRDeleteRecordApiUrl { get; set; }
|
|
|
|
public string EHRSavePhotoApiUrl { get; set; }
|
|
|
|
|
|
/// <summary>
|
|
/// 获取员工卡片信息RESUT地址
|
|
/// </summary>
|
|
public string EHR_GET_WORK_CARD_INFOApiUrl { get; set; }
|
|
|
|
/// <summary>
|
|
/// REST账号
|
|
/// </summary>
|
|
public string RestUserName { get; set; }
|
|
|
|
/// <summary>
|
|
/// REST密码
|
|
/// </summary>
|
|
public string RestPassword { get; set; }
|
|
public ServiceSettings()
|
|
{
|
|
//ServerUrl = ConfigurationManager.AppSettings[nameof(ServerUrl)];
|
|
//UserName = ConfigurationManager.AppSettings[nameof(UserName)];
|
|
//Password = ConfigurationManager.AppSettings[nameof(Password)];
|
|
//SyncTime = ConfigurationManager.AppSettings[nameof(SyncTime)];
|
|
//DlhisDatabase = ConfigurationManager.AppSettings[nameof(DlhisDatabase)];
|
|
//AttendanceUploadUrl = ConfigurationManager.AppSettings[nameof(AttendanceUploadUrl)];
|
|
//AttendanceUploadInterval = SafeParseInt(ConfigurationManager.AppSettings[nameof(AttendanceUploadInterval)]);
|
|
//Werks = ConfigurationManager.AppSettings[nameof(Werks)];
|
|
//BeginSyncDate = SafeParseDate(ConfigurationManager.AppSettings[nameof(BeginSyncDate)], DateTime.Today);
|
|
//ApiPort = SafeParseInt(ConfigurationManager.AppSettings[nameof(ApiPort)], 8099);
|
|
//EHRWebServiceUserName = ConfigurationManager.AppSettings[nameof(EHRWebServiceUserName)];
|
|
//EHRWebServicePassword = ConfigurationManager.AppSettings[nameof(EHRWebServicePassword)];
|
|
//EHRInsertRecordApiUrl = ConfigurationManager.AppSettings[nameof(EHRInsertRecordApiUrl)];
|
|
//EHRDeleteRecordApiUrl = ConfigurationManager.AppSettings[nameof(EHRDeleteRecordApiUrl)];
|
|
//EHRSavePhotoApiUrl = ConfigurationManager.AppSettings[nameof(EHRSavePhotoApiUrl)];
|
|
//EHR_GET_WORK_CARD_INFOApiUrl = ConfigurationManager.AppSettings[nameof(EHR_GET_WORK_CARD_INFOApiUrl)];
|
|
//RestUserName = ConfigurationManager.AppSettings[nameof(RestUserName)];
|
|
//RestPassword = ConfigurationManager.AppSettings[nameof(RestPassword)];
|
|
}
|
|
|
|
private static int SafeParseInt(string value, int defaultValue = 0)
|
|
{
|
|
if (int.TryParse(value, out int i))
|
|
{
|
|
return i;
|
|
}
|
|
return defaultValue;
|
|
}
|
|
|
|
private static bool SafeParseBoolean(string value, bool defaultValue = false)
|
|
{
|
|
if (bool.TryParse(value, out var b))
|
|
{
|
|
return b;
|
|
}
|
|
return defaultValue;
|
|
}
|
|
|
|
private static DateTime SafeParseDate(string value, DateTime defaultValue)
|
|
{
|
|
if (DateTime.TryParse(value, out var b))
|
|
{
|
|
return b;
|
|
}
|
|
return defaultValue;
|
|
}
|
|
}
|
|
}
|