using ryCommon; using ryCommonDb; using rySafe; using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Net.NetworkInformation; using System.Text; using System.Threading.Tasks; namespace LiveTools { public class Config { public static bool InitCef { get; set; } = false; public static int isAutoLogin = 0; public static UserInfo UserInfo { get; set; } = new UserInfo(); public static string Api_Url = "http://reg.itjs.top/API/"; public static string SoftId = "LiveTools"; public static bool MustUpdate = false; public static string NewVerUrl = ""; public static RyPostGet ry_api = new RyPostGet(); /// /// 默认礼物特效 /// public static bool GiftTrigger { get; set; } = true; public static bool PlaySound { get; set; } = true; /// /// 是否允许多个声音同时播放 /// public static bool MultiPlaySound { get; set; } = true; public static int PicSize { get; set; } = 70; public static int PicCount { get; set; } = 10; /// /// 礼物缓存 /// public static Hashtable GiftCache { get; set; } = new Hashtable(); public static UsingLock GiftLock { get; set; } = new UsingLock(); public static void LoadSetting() { Json json = new Json(RyFiles.ReadAllText(Config.UserDbFolder + "\\Setting.json")); GiftTrigger = json.GetJsonValue("GiftTrigger", true); PlaySound = json.GetJsonValue("PlaySound", true); MultiPlaySound = json.GetJsonValue("MultiPlaySound", true); PicSize = json.GetJsonValue("PicSize", 70); PicCount = json.GetJsonValue("PicCount", 10); } /// /// 数据库完整路径 /// public static string DbFullPath { get { return UserDbFolder + "\\MyDb.dat"; } } public static string GetCurrentFolder { get { return System.IO.Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule?.FileName??"").TrimEnd('\\') ??""; } } /// /// 系统数据文件夹 /// public static string SysDbFolder { get { return GetCurrentFolder + "\\SysDb"; } } /// /// 所有用户数据文件夹 /// public static string AllUserDbFolder { get { return GetCurrentFolder + "\\UserDb"; } } /// /// 用户数据文件夹 /// public static string UserDbFolder { get { if(UserInfo.UserId.Length>0) { return GetCurrentFolder + "\\UserDb\\"+ UserInfo.UserId; } return GetCurrentFolder + "\\UserDb"; } } /// /// 创建数据库 /// public static void CreateDb() { IDbInterface db = new SQLiteDataProvider(); if (db.ConnDb(DbFullPath) == 1) { #region 规则表 RyQuickSQL mySQL = new("Rules"); mySQL.AddField("RuleName", ""); mySQL.AddField("SortIndex", 0d); mySQL.AddField("RuleJson", ""); mySQL.AddField("AddTime", 0L); mySQL.AddField("EditTime", 0L); db.CreateDb(mySQL); #endregion #region 直播表 mySQL.Clear(); mySQL.TableName = "Direct"; mySQL.AddField("Name", ""); mySQL.AddField("Platform", ""); mySQL.AddField("DirectId", ""); mySQL.AddField("DirectJson", ""); mySQL.AddField("AddTime", 0L); mySQL.AddField("EditTime", 0L); db.CreateDb(mySQL); #endregion // } } /// /// 为1表示登录 /// /// public static int IsLogin() { if (UserInfo.UserId.Length == 0) { return 0; } if (UserInfo.UserId.Length>0 && UserInfo.OutTime>=DateTime.Now.ToInt64()) { return 1; } return -1; } public static string GetMac() { IPGlobalProperties computerProperties = IPGlobalProperties.GetIPGlobalProperties(); NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces(); // HostName = computerProperties.HostName; Console.WriteLine("Interface information for {0}.{1} ", computerProperties.HostName, computerProperties.DomainName); if (nics == null || nics.Length < 1) { return ""; } foreach (NetworkInterface adapter in nics) { IPInterfaceProperties properties = adapter.GetIPProperties(); // .GetIPInterfaceProperties(); string Description = adapter.Description;//接口的描述 string NetworkInterfaceType = adapter.NetworkInterfaceType.ToString();//获取接口类型 PhysicalAddress address = adapter.GetPhysicalAddress();//返回MAC地址 if (NetworkInterfaceType != "Loopback" && NetworkInterfaceType == "Ethernet") return adapter.GetPhysicalAddress().ToString(); //byte[] bytes = address.GetAddressBytes(); //for (int i = 0; i < bytes.Length; i++) //{ // //.ToString("X2") 将byte数组转换成字符串 // Console.Write("{0}", bytes[i].ToString("X2")); // if (i != bytes.Length - 1) // { // Console.Write("-"); // } //} } return ""; } } }