modify visuality
This commit is contained in:
@@ -3,7 +3,7 @@ using DotRas;
|
||||
using Microsoft.Win32.TaskScheduler;
|
||||
using NAudio.CoreAudioApi;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NLog;
|
||||
using Serilog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
@@ -12,9 +12,14 @@ using System.Net.NetworkInformation;
|
||||
using System.ServiceProcess;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using Serilog.Core;
|
||||
using Serilog.Sinks.File;
|
||||
using Serilog.Events;
|
||||
|
||||
namespace NetWork {
|
||||
class Program {
|
||||
namespace NetWork
|
||||
{
|
||||
class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// this function gets an array of service names, and start or stop command, and it runs on the array and
|
||||
/// </summary>
|
||||
@@ -45,7 +50,8 @@ namespace NetWork {
|
||||
foreach (var ser in Services) {
|
||||
try {
|
||||
ser.Stop();
|
||||
} catch {
|
||||
}
|
||||
catch {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -53,7 +59,8 @@ namespace NetWork {
|
||||
try {
|
||||
|
||||
ser.Start();
|
||||
} catch {
|
||||
}
|
||||
catch {
|
||||
|
||||
}
|
||||
|
||||
@@ -68,7 +75,7 @@ namespace NetWork {
|
||||
var device = new MMDeviceEnumerator();
|
||||
var Devices = device.EnumerateAudioEndPoints(DataFlow.Render, DeviceState.Active);
|
||||
foreach (var Device in Devices) {
|
||||
foreach (string ob in array) {
|
||||
foreach (string ob in array!) {
|
||||
if (Device.FriendlyName.Contains(ob)) {
|
||||
return true;
|
||||
}
|
||||
@@ -77,15 +84,7 @@ namespace NetWork {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static Logger StartLogger() {
|
||||
var config = new NLog.Config.LoggingConfiguration();
|
||||
var logfile = new NLog.Targets.FileTarget("lgfle") { FileName = "logme.txt" };
|
||||
config.AddRule(LogLevel.Debug, LogLevel.Fatal, logfile);
|
||||
NLog.LogManager.Configuration = config;
|
||||
NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
|
||||
return logger;
|
||||
}
|
||||
public static Logger logger = StartLogger();
|
||||
|
||||
/// <summary>
|
||||
/// String of paths
|
||||
/// </summary>
|
||||
@@ -102,7 +101,10 @@ namespace NetWork {
|
||||
if (stop) {
|
||||
Process[] ids = Process.GetProcessesByName("mstsc");
|
||||
foreach (var id in ids) {
|
||||
logger.Debug(id.MainWindowTitle);
|
||||
//using (ILogger log=Logger)
|
||||
//{
|
||||
// log.Debug(id.MainWindowTitle);
|
||||
//}
|
||||
Regex rdp = new("(משרדוש.rdp|161.2)");
|
||||
if (rdp.IsMatch(id.MainWindowTitle) || id.MainWindowTitle.Equals("חיבור לשולחן עבודה מרוחק")) {
|
||||
id.Kill();
|
||||
@@ -117,7 +119,7 @@ namespace NetWork {
|
||||
bool started = false;
|
||||
foreach (var id in ids) {
|
||||
Regex rdp = new("(משרדוש.rdp|161.2)");
|
||||
logger.Debug(id.MainWindowTitle);
|
||||
|
||||
if (rdp.IsMatch(id.MainWindowTitle) || id.MainWindowTitle.Equals("חיבור לשולחן עבודה מרוחק")) {
|
||||
started = true;
|
||||
}
|
||||
@@ -193,7 +195,8 @@ namespace NetWork {
|
||||
StopRDP();
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
}
|
||||
catch {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -228,7 +231,8 @@ namespace NetWork {
|
||||
try {
|
||||
wifiname = wlan.Interfaces[0].CurrentConnection.profileName;
|
||||
|
||||
} catch {
|
||||
}
|
||||
catch {
|
||||
wifiname = "";
|
||||
}
|
||||
return wifiname;
|
||||
@@ -253,7 +257,7 @@ namespace NetWork {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
static string GetLan(System.Net.NetworkInformation.NetworkInterface networkAdapter) {
|
||||
static string? GetLan(System.Net.NetworkInformation.NetworkInterface networkAdapter) {
|
||||
if (LanEthernet(networkAdapter) && IgnoreLan(networkAdapter)) {
|
||||
return networkAdapter.GetPhysicalAddress().ToString();
|
||||
}
|
||||
@@ -288,7 +292,7 @@ namespace NetWork {
|
||||
}
|
||||
|
||||
}
|
||||
net_dict.Add("Wi-Fi", IsItGoodWifi(getwifi));
|
||||
net_dict.Add("Wi-Fi", IsItGoodWifi(getwifi)!);
|
||||
net_dict["good_lan"] = getgoodland;
|
||||
if (getlan.Length > 0) {
|
||||
net_dict["lan"] = true;
|
||||
@@ -310,10 +314,10 @@ namespace NetWork {
|
||||
return "Wi-Fi";
|
||||
|
||||
}
|
||||
public static bool AllowedMac(string mac, string[] those_are_the_AllowedMacs = null) {
|
||||
public static bool AllowedMac(string mac, string?[] those_are_the_AllowedMacs = null) {
|
||||
string[] AllowedMac_adresses;
|
||||
if (!(those_are_the_AllowedMacs is null)) {
|
||||
AllowedMac_adresses = those_are_the_AllowedMacs;
|
||||
AllowedMac_adresses = those_are_the_AllowedMacs!;
|
||||
} else {
|
||||
AllowedMac_adresses = new string[] { "00E04C6813E4" };
|
||||
}
|
||||
@@ -325,7 +329,7 @@ namespace NetWork {
|
||||
return false;
|
||||
|
||||
}
|
||||
public static bool AllowedMac(string[] mac, string[] those_are_the_AllowedMacs = null) {
|
||||
public static bool AllowedMac(string[] mac, string?[] those_are_the_AllowedMacs = null) {
|
||||
foreach (var single_mac in mac) {
|
||||
if (AllowedMac(single_mac, those_are_the_AllowedMacs)) {
|
||||
return true;
|
||||
@@ -335,7 +339,7 @@ namespace NetWork {
|
||||
}
|
||||
public static void StartProgram(string process_name) {
|
||||
if (process_name.Contains("rdp") || process_name.Contains("mstsc")) {
|
||||
Process.Start("mstsc.exe", @"D:\Drive\מסמכים\vms\משרדוש.rdp");
|
||||
Process.Start("mstsc.exe", $"{Environment.ExpandEnvironmentVariables("%USERPROFILE%")}/Documents/משרדוש.rdp");
|
||||
} else if (Process.GetProcessesByName(process_name).Length < 1) {
|
||||
string process;
|
||||
if (progs.ContainsKey(process_name)) {
|
||||
@@ -441,7 +445,10 @@ namespace NetWork {
|
||||
return System.IO.File.ReadAllText("Other\\Data.ini").Equals("RunNetwork");
|
||||
}
|
||||
static void Main(string[] args) {
|
||||
logger.Debug("me");
|
||||
Log.Logger = new LoggerConfiguration().WriteTo.File("Logs/NetworkLog.log", LogEventLevel.Debug,
|
||||
"{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz}[{Level: u3}] {Message:lj}{NewLine}",
|
||||
rollingInterval: RollingInterval.Minute).CreateLogger();
|
||||
|
||||
//IgnoreFile.M();
|
||||
DoTheSchtik(IniData());
|
||||
|
||||
|
73
NetWork/Properties/Resources.Designer.cs
generated
Normal file
73
NetWork/Properties/Resources.Designer.cs
generated
Normal file
@@ -0,0 +1,73 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace NetWork.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("NetWork.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Byte[].
|
||||
/// </summary>
|
||||
internal static byte[] ek {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("ek", resourceCulture);
|
||||
return ((byte[])(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
124
NetWork/Properties/Resources.resx
Normal file
124
NetWork/Properties/Resources.resx
Normal file
@@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="ek" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Other\ek.pbk;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
</root>
|
BIN
desktop.ini
BIN
desktop.ini
Binary file not shown.
Reference in New Issue
Block a user