using HotelPms.Share.IO;
|
using HotelPms.Share.Util;
|
using System;
|
using System.Windows.Forms;
|
|
namespace HotelPms.Share.Windows.Service
|
{
|
public class MonitorSetting : DictionarySetting
|
{
|
public enum SettingKey : int
|
{
|
/// <summary>
|
/// 0.ClientSide 1.ServerSide
|
/// </summary>
|
ServiceType,
|
Port,
|
}
|
|
private static MonitorSetting m_Instance = null;
|
|
public static MonitorSetting Instance { get { return m_Instance; } }
|
|
/// <summary>
|
/// アプリケーションの初期化
|
/// </summary>
|
/// <returns></returns>
|
public static bool Initialize()
|
{
|
try
|
{
|
m_Instance = new MonitorSetting();
|
m_Instance.FileName = Application.StartupPath + @"\MonitorSetting.json";
|
m_Instance.Load();
|
return true;
|
}
|
catch (Exception ex)
|
{
|
OperationLog.Instance.WriteLog($"MonitorSetting.Initialize異常エラー:{ex.Message}");
|
return false;
|
}
|
}
|
|
public static void Dispose()
|
{
|
}
|
|
public override void SetDefault()
|
{
|
if (!Data.ContainsKey(SettingKey.ServiceType.ToString())) { Data.Add(SettingKey.ServiceType.ToString(), "0"); }
|
if (!Data.ContainsKey(SettingKey.Port.ToString())) { Data.Add(SettingKey.Port.ToString(), "46498"); }
|
}
|
|
/// <summary>
|
/// Windows起動時実行
|
/// </summary>
|
public static void SetStartUpRun()
|
{
|
try
|
{
|
//Runキーを開く
|
using (Microsoft.Win32.RegistryKey regkey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true))
|
{
|
if (regkey == null) { return; }
|
//値の名前に製品名、値のデータに実行ファイルのパスを指定し、書き込む
|
regkey.SetValue(Application.ProductName, Application.ExecutablePath);
|
//閉じる
|
regkey.Close();
|
}
|
}
|
catch { }
|
}
|
}
|
}
|