ab56a9bcf7
SVN-Revision: r240
89 lines
3.0 KiB
C#
89 lines
3.0 KiB
C#
using Lskj.Util;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Configuration.Install;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace ServerNotice
|
|
{
|
|
[RunInstaller(true)]
|
|
public partial class ProjectInstaller : System.Configuration.Install.Installer
|
|
{
|
|
public ProjectInstaller()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
protected override void OnBeforeInstall(IDictionary savedState)
|
|
{
|
|
IniControl();
|
|
}
|
|
protected override void OnBeforeUninstall(IDictionary savedState)
|
|
{
|
|
IniControl();
|
|
}
|
|
/// <summary>
|
|
/// 初始化界面的本机ip地址值和端口
|
|
/// </summary>
|
|
private void IniControl()
|
|
{
|
|
try
|
|
{
|
|
foreach (IPAddress _IPAddress in Dns.GetHostEntry(Dns.GetHostName()).AddressList)
|
|
{
|
|
if (_IPAddress.AddressFamily.ToString() == "InterNetwork")
|
|
{
|
|
//AddressIP = "192.168.0.240";
|
|
string AddressIP = _IPAddress + "";
|
|
string serviceName = IniHelper.Read("MenuConfig.ini", "ServiceInfo", "ServiceName");
|
|
string serviceDescription = IniHelper.Read("MenuConfig.ini", "ServiceInfo", "ServiceDescription");
|
|
if (!string.IsNullOrEmpty(serviceName))
|
|
{
|
|
this.serviceInstaller1.ServiceName = serviceName;
|
|
}
|
|
if (!string.IsNullOrEmpty(serviceDescription))
|
|
{
|
|
this.serviceInstaller1.Description = serviceDescription;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
WriteLog("错误信息:" + ex.Message);
|
|
}
|
|
}
|
|
private void WriteLog(string message)
|
|
{
|
|
try
|
|
{
|
|
string path = Path.Combine(Lskj.Util.PubUtil.AbsolutelyPath + "LogFile.log");
|
|
if (File.Exists(path))
|
|
{
|
|
FileInfo fileInfo = new FileInfo(path);
|
|
if (fileInfo.Length > 1024 * 10)
|
|
{
|
|
fileInfo.Delete();
|
|
}
|
|
}
|
|
if (!Directory.Exists(Path.GetDirectoryName(path)))
|
|
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
|
if (!File.Exists(path))
|
|
File.Create(path);
|
|
StreamWriter writer = File.AppendText(path);
|
|
writer.WriteLine("");
|
|
writer.WriteLine(DateTime.Now.ToString("日志记录HH:mm:ss") + " " + message + " ");
|
|
writer.Flush();
|
|
writer.Close();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
}
|
|
}
|
|
}
|