public static void DisplayIpaddress() { try { const string linkDescription = @"您可以通过以下链接访问:"; Log4Log.Info(linkDescription); ContentLog.WriteLine(linkDescription); var hostName = Dns.GetHostName(); var ipHostEntry = Dns.GetHostEntry(hostName); ipHostEntry .AddressList .Where(item => item.AddressFamily == AddressFamily.InterNetwork) .ToList() .ForEach(item => { var url = string.Format(@"http://{0}", item); Log4Log.Info(url); ContentLog.WriteLine(url); }); } catch (Exception ex) { var exceptionMessage = @"获取本机IP出错:" + ex.Message; Log4Log.Info(exceptionMessage); ContentLog.WriteLine(exceptionMessage); } }
public static void RegConfigFile(string fileName) { _configFileName = fileName; var configWatcher = new FCFileWatcher(Path.GetDirectoryName(fileName), Path.GetFileName(fileName)); configWatcher.Changed += (object sender, FileSystemEventArgs e) => { Log4Log.Info("SensitiveChanged-SensitiveRegister.Sensitive-SensitiveRegister.Sensitive-文件监控发现系统敏感文件已更新"); UpdateSensitive(); }; configWatcher.Start(); }
public HttpResponseMessage Open(string path) { Log4Log.Info(Request.ToString()); ContentLog.WriteLine(Request.ToString()); var httpResponseMessage = Request.Response(path); Log4Log.Info(httpResponseMessage.ToString()); ContentLog.WriteLine(httpResponseMessage.ToString()); return(httpResponseMessage); }
public static void RegConfigFile(string fileName) { _configFileName = fileName; var configWatcher = new FCFileWatcher(Path.GetDirectoryName(fileName), Path.GetFileName(fileName)); configWatcher.Changed += (object sender, FileSystemEventArgs e) => { Log4Log.Info("ConfigChanged-AgentMapping.Config-AgentMapping.Config-文件监控发现代理商域名映射配置信息文件已更新"); _allAgentList.Clear(); }; configWatcher.Start(); }
public static void RegConfigFile(string fileName) { _configFileName = fileName; var configWatcher = new FCFileWatcher(Path.GetDirectoryName(fileName), Path.GetFileName(fileName)); configWatcher.Changed += (object sender, FileSystemEventArgs e) => { Log4Log.Info("ConfigChanged-SettingConfigRegister.Configuration-SettingConfigRegister.Configuration-文件监控发现系统配置文件已更新"); _allConfigList.Clear(); xElement.Clear(); }; configWatcher.Start(); }
public HttpResponseMessage Index() { var path = Application.StartupPath; Log4Log.Info(Request.ToString()); ContentLog.WriteLine(Request.ToString()); var httpResponseMessage = Request.Response(path); Log4Log.Info(httpResponseMessage.ToString()); ContentLog.WriteLine(httpResponseMessage.ToString()); return(httpResponseMessage); }
public HttpResponseMessage Download(string filePath) { Log4Log.Info(Request.ToString()); ContentLog.WriteLine(Request.ToString()); if (File.Exists(filePath) == false) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "文件未找到")); } var response = new HttpResponseMessage(HttpStatusCode.OK); var fileName = Path.GetFileName(filePath); try { var fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read); { response.Content = new StreamContent(fileStream); response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment") { FileName = fileName }; } Log4Log.Info(response.ToString()); ContentLog.WriteLine(response.ToString()); return(response); } catch (Exception exception) { var httpResponseMessage = Request.CreateErrorResponse(HttpStatusCode.NotFound, exception.Message); Log4Log.Info(httpResponseMessage.ToString()); ContentLog.WriteLine(httpResponseMessage.ToString()); return(httpResponseMessage); } }
public HttpResponseMessage Play(HttpRequestMessage request, string filePath) { Log4Log.Info(Request.ToString()); ContentLog.WriteLine(Request.ToString()); try { var assembly = Assembly.GetExecutingAssembly(); var resourceStream = assembly.GetManifestResourceStream("YYX.FileFinder.video.html"); if (resourceStream == null) { throw new Exception("页面异常"); } var response = request.CreateResponse(HttpStatusCode.OK); using (var stream = new StreamReader(resourceStream)) { var html = stream.ReadToEnd(); var urlEncodeFilePath = HttpUtility.UrlEncode(filePath); var videoLink = $"/File/Download?filePath={urlEncodeFilePath}"; html = html.Replace("{videoLink}", videoLink); response.Content = new StringContent(html, Encoding.UTF8); response.Content.Headers.ContentType = new MediaTypeHeaderValue("text/html"); } Log4Log.Info(response.ToString()); ContentLog.WriteLine(response.ToString()); return(response); } catch (Exception exception) { var httpResponseMessage = Request.CreateErrorResponse(HttpStatusCode.NotFound, exception.Message); Log4Log.Info(httpResponseMessage.ToString()); ContentLog.WriteLine(httpResponseMessage.ToString()); return(httpResponseMessage); } }