91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 58KB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發布日期: 2024-02-03
  • 語言: C#
  • 標簽: UPS??

資源簡介

服務器如果經常非法關機則很空易損壞系統,特別是使用軟鏡像或RAID-5的,每次非法關機后就需要重新同步,特別損壞硬盤。想偷懶從網上下載同類工具,卻都有毒,真TMD不厚道,被逼自行開發,使用C#。 文件說明: ServerAutoShutDown.exe---服務程序 SRVINSTW.EXE--服務安裝工具,使用方法請網上查 Config.ini--配置文件 IP---要檢查的IP地址,建議與UPS同一市電插座的路由器 T---檢查多少次后關機,每次為60000毫秒,則1分鐘。多少次,視你的UPS能撐多久而定。 原理:每分鐘Ping指定IP,如路由器IP,如2次,則3分鐘內還沒有Ping通,則視為停電,自動關機。 請注意 請在源碼中\ServerAutoShutDown\bin\Debug,將ServerAutoShutDown.exe復制出來,上傳時忘記更新根目錄那個文件了,那個是測試來的,關不了機

資源截圖

代碼片段和文件信息

using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Diagnostics;
using?System.ServiceProcess;
using?System.Text;
using?System.Net;
using?System.Net.NetworkInformation;
using?System.Windows.Forms;
namespace?ServerAutoShutDown
{
????public?partial?class?AutoShutDown?:?Servicebase
????{
????????System.Timers.Timer?t?=?new?System.Timers.Timer(60000);
????????int?ptimes?=?0;
????????public?AutoShutDown()
????????{
????????????InitializeComponent();
????????}

????????protected?override?void?onstart(string[]?args)
????????{
????????????t.Elapsed?+=?new?System.Timers.ElapsedEventHandler(PingTest);
????????????t.Enabled?=?true;
????????????t.AutoReset?=?true;
????????????t.Start();

????????}
????????private?void?PingTest(object?source?System.Timers.ElapsedEventArgs?e)
????????{
????????????try
????????????{
????????????????INIFile?ini?=?new?INIFile(Application.StartupPath?+?“\\Config.ini“);
????????????????Ping?pingSender?=?new?Ping();
????????????????string?strIP?=?ini.IniReadValue(“Config“?“IP“);
????????????????PingOptions?pingOption?=?new?PingOptions();
????????????????pingOption.DontFragment?=?true;

????????????????string?data?=?“SendMsg“;
????????????????byte[]?buffer?=?Encoding.ASCII.GetBytes(data);
????????????????int?timeout?=?120;
????????????????PingReply?reply?=?pingSender.Send(strIP?timeout?buffer);
????????????????if?(reply.Status?==?IPStatus.Success)
????????????????{
????????????????????//Ping通了
????????????????????ptimes?=?0;
????????????????}
????????????????else
????????????????{
????????????????????//Ping不通

????????????????????OutPutDebug(“??Ping?Timeout“);
????????????????????ptimes++;
????????????????????if?(ptimes?>?int.Parse(ini.IniReadValue(“Config“?“T“)))
????????????????????{
????????????????????????//4分鐘后沒有通,則自動關機
???????????????????????OutPutDebug?(“??Shutdown“);
?????????????????????????Process.Start(@“c:\windows\system32\shutdown.exe“?“-s?-t?0?-f“);
????????????????????}
????????????????????
????????????????}
????????????}
????????????catch?(Exception?ex)
????????????{
????????????????OutPutDebug(ex.Message);
????????????}

????????}

????????private?void?OutPutDebug(string?msg)
????????{

????????????System.IO.StreamWriter?tw?=?new?System.IO.StreamWriter(Application.StartupPath?+?“\\Shutdown.log“?true?Encoding.GetEncoding(“gb2312“));
????????????tw.WriteLine(DateTime.Now.ToString()?+?msg);
????????????tw.Close();
????????}
????????protected?override?void?onstop()
????????{

????????}
????}
}

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件??????28672??2006-02-28?15:06??SRVINSTW.EXE

?????文件???????7680??2010-07-03?22:04??ServerAutoShutDown.exe

?????文件?????????30??2010-07-03?22:05??Config.ini

?????目錄??????????0??2010-07-03?22:18??源碼

?????文件????????944??2010-07-01?21:51??源碼\ServerAutoShutDown.sln

????..A..H.?????17920??2010-07-03?22:09??源碼\ServerAutoShutDown.suo

?????文件???????2645??2010-07-03?22:09??源碼\ServerAutoShutDown\AutoShutDown.cs

?????文件???????1097??2010-07-01?21:51??源碼\ServerAutoShutDown\AutoShutDown.Designer.cs

?????文件???????8192??2010-07-03?22:09??源碼\ServerAutoShutDown\bin\Debug\ServerAutoShutDown.exe

?????文件??????24064??2010-07-03?22:09??源碼\ServerAutoShutDown\bin\Debug\ServerAutoShutDown.pdb

?????文件??????14328??2010-07-03?20:19??源碼\ServerAutoShutDown\bin\Debug\ServerAutoShutDown.vshost.exe

?????文件????????490??2007-07-21?01:33??源碼\ServerAutoShutDown\bin\Debug\ServerAutoShutDown.vshost.exe.manifest

?????文件???????3729??2010-07-03?21:48??源碼\ServerAutoShutDown\clsINI.cs

?????文件????????418??2010-07-03?22:04??源碼\ServerAutoShutDown\obj\Debug\ServerAutoShutDown.csproj.FileListAbsolute.txt

?????文件???????8192??2010-07-03?22:09??源碼\ServerAutoShutDown\obj\Debug\ServerAutoShutDown.exe

?????文件??????24064??2010-07-03?22:09??源碼\ServerAutoShutDown\obj\Debug\ServerAutoShutDown.pdb

?????文件????????516??2010-07-01?21:51??源碼\ServerAutoShutDown\Program.cs

?????文件???????1383??2010-07-01?23:01??源碼\ServerAutoShutDown\Properties\AssemblyInfo.cs

?????文件???????2863??2010-07-03?21:47??源碼\ServerAutoShutDown\ServerAutoShutDown.csproj

?????目錄??????????0??2010-07-01?21:51??源碼\ServerAutoShutDown\obj\Debug\Refactor

?????目錄??????????0??2010-07-01?21:51??源碼\ServerAutoShutDown\obj\Debug\TempPE

?????目錄??????????0??2010-07-01?23:18??源碼\ServerAutoShutDown\bin\Debug

?????目錄??????????0??2010-07-03?22:04??源碼\ServerAutoShutDown\obj\Debug

?????目錄??????????0??2010-07-01?21:51??源碼\ServerAutoShutDown\bin

?????目錄??????????0??2010-07-01?21:51??源碼\ServerAutoShutDown\obj

?????目錄??????????0??2010-07-01?23:01??源碼\ServerAutoShutDown\Properties

?????目錄??????????0??2010-07-03?22:09??源碼\ServerAutoShutDown

-----------?---------??----------?-----??----

???????????????147227????????????????????27



............此處省略0個文件信息

評論

共有 條評論