本文整理汇总了C#中System.Utils.writeToLogFile方法的典型用法代码示例。如果您正苦于以下问题:C# Utils.writeToLogFile方法的具体用法?C# Utils.writeToLogFile怎么用?C# Utils.writeToLogFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Utils
的用法示例。
在下文中一共展示了Utils.writeToLogFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: runServiceCheck
public void runServiceCheck()
{
Utils util = new Utils();
ServiceController sc = null;
try
{
sc = new ServiceController(serviceName);
switch (sc.Status)
{
case ServiceControllerStatus.Running:
break;
case ServiceControllerStatus.Stopped:
sc.Start();
util.writeToLogFile("service checker starting "+serviceName);
break;
case ServiceControllerStatus.Paused:
sc.Stop();
sc.Start();
util.writeToLogFile("service checker starting " + serviceName);
break;
case ServiceControllerStatus.StopPending:
sc.Stop();
sc.Start();
util.writeToLogFile("service checker starting " + serviceName);
break;
case ServiceControllerStatus.StartPending:
sc.Stop();
sc.Start();
util.writeToLogFile("service checker starting " + serviceName);
break;
default:
break;
}
}
catch (Exception e)
{
util.writeEventLog(e.Message);
util.writeEventLog(e.StackTrace);
}
finally
{
try
{
if (sc != null) sc.Close();
} catch (Exception) {}
}
}
示例2: runHeartBeat
/// <summary>
/// Sends a heart-beat to the server, while also checking for updates
/// </summary>
public void runHeartBeat()
{
Boolean hasNewVersion = false;
Constants.STATIC_RUN_COUNTER++;
Utils util = new Utils();
try
{
ConfigObj cfg = util.readConfig();
if (cfg != null && cfg.remoteTarget != null && cfg.remoteServer != null && cfg.strId != null)
{
String data = util.getUrlStatusCode(cfg.remoteTarget);
HeartbeatData h = new HeartbeatData();
h.downloadSpeed = WebUtil.DownloadSpeed(false);
runUploadTrafficSensor(1024, out h.uploadSpeed);
h.assVersion = util.getAssemblyVersion();
h.errorCounter = Constants.STATIC_ERROR_COUNTER;
h.runCounter = Constants.STATIC_RUN_COUNTER;
h.strId = cfg.strId;
h.version = cfg.version;
string json = JsonConvert.SerializeObject(h);
String link = cfg.remoteServer + "?action=ACK&data=" + data + "&version=" + util.getAssemblyVersion() + "&strId=" + cfg.strId + "&errorcounter=" + Constants.STATIC_ERROR_COUNTER + "&runcounter=" + Constants.STATIC_RUN_COUNTER;
link = link.Trim();
String code = util.getUrlStatusCode(link);
util.writeToLogFile(link);
if (code != null)
{
if (!code.Equals("OK"))
{
Constants.STATIC_ERROR_COUNTER++;
}
else
{
hasNewVersion = runDownloadTrafficSensor();
runUploadTrafficSensor();
if (hasNewVersion)
{
updateService();
}
}
}
else
{
Constants.STATIC_ERROR_COUNTER++;
}
}
}
catch (Exception e)
{
Constants.STATIC_ERROR_COUNTER++;
util.writeEventLog(e.Message);
util.writeEventLog(e.StackTrace);
}
}