public static bool SslRemoteCertificateValidate(LoggerProxy log, bool skipInvalidCertificate, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { if (sslPolicyErrors == SslPolicyErrors.None) return true; using (var m = log.CreateScope(skipInvalidCertificate ? LogMsgType.Warning : LogMsgType.Error)) { m.WriteLine("Remote certification validation failed ({0}).", sslPolicyErrors); m.WriteLine(); m.WriteLine("Remote Certificate:"); if (certificate != null) { m.WriteLine(" Subject: {0}", certificate.Subject); m.WriteLine(" CertHash: {0}", certificate.GetCertHashString()); m.WriteLine(" Expiration: {0}", certificate.GetExpirationDateString()); m.WriteLine(" Serial: {0}", certificate.GetSerialNumberString()); m.WriteLine(" Algorithm: {0}", certificate.GetKeyAlgorithmParametersString()); } else { m.WriteLine(" <null>"); // no chance to skip return false; } m.WriteLine("Chain:"); var i = 0; foreach (var c in chain.ChainElements) { m.Write(" - {0}", c.Certificate?.Subject); if (i < chain.ChainStatus.Length) m.WriteLine(" --> {0}, {1}", chain.ChainStatus[i].Status, chain.ChainStatus[i].StatusInformation); else m.WriteLine(); i++; } } return skipInvalidCertificate; }
public void TestCleanup() { LoggerProxy.Close(); UpdaterProxy.Close(); }
public static void DebugWarning(this System.Object caller, System.Object message) { LoggerProxy.Get().Warning("[" + caller.ToString() + "]" + message); }
public DynamicPsHost(DynamicPowerShell powershell) { if (powershell == null) throw new ArgumentNullException("powershell"); this.instanceId = Guid.NewGuid(); this.powerShell = powershell; this.ui = new DynamicPsUserInterface(this); this.log = LoggerProxy.Create(this.GetService<ILogger>(false), "Powershell"); } // ctor
public static void DebugLog(this System.Object caller, System.Object message) { LoggerProxy.Get().Log(message); }
/// <summary> /// 执行任务 /// </summary> internal bool Run() { Init(); if (Status != TaskStatus.Init) { return(false); } lock (LockObj) { if (Status != TaskStatus.Init) { return(false); } Status = TaskStatus.Running; } new Thread(() => { try { while (true) { var isStop = false; lock (this) { isStop = this.Status == TaskStatus.Stopping; } // 获取执行者 TaskInvoker invoker = isStop ? null : NewInvoker(); if (invoker == null) { if (SetStop()) { OnStop?.Invoke(this, new TaskEventArgs() { Task = this }); this.Free(); break; } Thread.Sleep(1000); continue; } invoker.RunAsync((task) => { // 释放执行者 FreeInvoker(task); }); } } catch (Exception ex) { LoggerProxy.Error(LogSource, "call Run error.", ex); OnError?.Invoke(this, new TaskErrorEventArgs() { Ex = ex, Task = this }); } }).Start(); OnStart?.Invoke(this, new TaskEventArgs() { Task = this }); return(true); }
public FileServiceSession(DirectoryFileServiceItem service, int sessionId) { this.sessionId = sessionId; this.service = service; this.log = LoggerProxy.Create(service.Log, sessionId.ToString()); log.Info("Session started..."); service.OnSessionStart(); } // ctor
} // ctor public void Log(LoggerProxy log, string firstLine) { // logging log.Info(String.Join(Environment.NewLine, firstLine, " Filename: {0}", " Originator: {1}", " VirtualFileName: {2}", " Stamp: {3:F}", " Format: {4}", " MaximumRecordSize: {5:N0}", " FileSize: {6:N0}", " FileSizeUnpacked: {7:N0}", " Description: {8}" ), fileInfo.Name, originator, virtualFileName, fileStamp, format, maximumRecordSize, fileSize, fileSizeUnpacked, description ); } // proc Log
public void TestInitialize() { UpdaterProxy.Open(m_Updater); LoggerProxy.Open(m_Logger); m_States = m_HSM.GetStates(); }