using System; using System.Collections.Generic; using System.Linq; using System.Text; using RestSharp; using CommonEntity; using RCUHost.Protocols; using Common; using RCUHost.Implement; using System.Net; using System.Collections; using CacheManager.Core; using CSRedis; using System.Threading.Tasks; using System.IO; using System.Collections.Concurrent; using System.Threading; using Newtonsoft.Json.Linq; using Domain; using System.Diagnostics; using Common.Logging; using Quartz; using Quartz.Impl; using System.Net.Sockets; using System.ComponentModel; using SimpleUdp; namespace ConsoleApplication1 { public enum FF { A = 0x01 | 0x02 | 0x03, B = 0x05 } public class User : EqualityComparer { public string username { get; set; } public string password { get; set; } public int oauth_id { get; set; } public override bool Equals(User x, User y) { if (x.username.Equals(y.username)) { return true; } return false; } public override int GetHashCode(User obj) { return obj.username.GetHashCode(); } } public class FCS_ReturnInfo { public int success { get; set; } public FCS_ReturnData data { get; set; } } // {"success": 1, "data": true, "rmsg": {"code": "s_job_orders", "param": ["JO-0001970-01"]}} public class FCS_JobResponse { public int success { get; set; } public bool data { get; set; } //"rmsg": //[ //{ // "code": "s_user_not_found", // "param": [] //} //] public List rmsg { get; set; } } public class FCSJobResponseData { public string code { get; set; } public List param { get; set; } } public class FCS_ReturnData { public bool is_authenticated { get; set; } public string access_token { get; set; } public string refresh_token { get; set; } public bool show_password_expire { get; set; } public string password_expired_date { get; set; } public bool password_expired { get; set; } public bool valid_license_access { get; set; } public bool require_reset { get; set; } public string property_config { get; set; } public string show_pp { get; set; } public int oauth_id { get; set; } public bool is_ip_valid { get; set; } public bool is_support_aliyun { get; set; } } public class FCS_JobRequest { public List location_uuid { get; set; } public List service_items { get; set; } public string remark { get; set; } public string assigned_to { get; set; } public int user_type { get; set; } } public class FCS_service_items { public string item_uuid { get; set; } public int quantity { get; set; } } class Program { public static byte ConvertLastFourBitsToByte(BitArray bitArray) { if (bitArray == null || bitArray.Count < 4) throw new ArgumentException("BitArray is too short or null."); byte result = 0; for (int i = bitArray.Count - 4, j = 0; i < bitArray.Count; i++, j++) { if (bitArray[i]) { result |= (byte)(1 << j); } } return result; } public static byte CombineBitsToByte(bool bit0, bool bit1, bool bit2, bool bit3) { byte result = (byte)((bit0 ? 1 : 0) << 3); // 将bit0移到第4位(高位) result |= (byte)((bit1 ? 1 : 0) << 2); // 将bit1移到第3位 result |= (byte)((bit2 ? 1 : 0) << 1); // 将bit2移到第2位 result |= (byte)(bit3 ? 1 : 0); // 将bit3移到第1位(低位) return result; } public static string FCSLoginUrl = "https://api.fcs1cloud.com"; public static void Login() { byte gh = 0x05; string HHH789 = gh.ToString("000"); MemoryCacheHelper.Set("a", "0x19", DateTimeOffset.Now.AddSeconds(5)); Thread.Sleep(6000); var QQQQQ = MemoryCacheHelper.Get("a"); string str = Newtonsoft.Json.JsonConvert.SerializeObject(""); var client1 = new RestClient(FCSLoginUrl); var request1 = new RestRequest("/api/security/authenticate", Method.POST); Dictionary dic = new Dictionary(); User us = new User(); us.username = "hb.rcu"; us.password = "abc123"; us.oauth_id = 1; request1.AddJsonBody(us); var QQQ = client1.Execute(request1); HttpStatusCode HHH = QQQ.StatusCode; string ddd = QQQ.Content; JObject jsonObject = JObject.Parse(ddd); string city = (string)jsonObject.SelectToken("Person.Address.City"); var FFFA = Newtonsoft.Json.JsonConvert.DeserializeObject(ddd); //client1.ExecuteAsync(request1, (response) => //{ // Console.WriteLine(response.Content); //}); } public static void JobRequest() { var client1 = new RestClient(FCSLoginUrl); var request1 = new RestRequest("/api-secure/job/request", Method.POST); FCS_JobRequest fff = new FCS_JobRequest(); fff.location_uuid = new List() { "bd5bd36e-67a9-4a76-93ea-3e1acc8f5f1f" }; fff.service_items = new List() { new FCS_service_items() { item_uuid="f905590d-cae7-4d07-8d0d-f88b5b44b786", quantity=1 } }; fff.remark = "test_remark"; fff.assigned_to = "auto"; fff.user_type = 1; string WER = Newtonsoft.Json.JsonConvert.SerializeObject(fff); string Key = "FCS_Security_Authenticate"; string NNN = CSRedisCacheHelper.Get_Partition(Key); //这里不处理登录的逻辑 //缓存里面只保存 登录成功的token //只 处理 请求 失败的 if (string.IsNullOrEmpty(NNN)) { //并且将Token写入到缓存 } else { } request1.AddHeader("token", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiI2NGZjYjhjMS1jZDZjLTRkMTktOTc3My05YzkxYmZhNjQ2YWQiLCJpYXQiOjE3NDI0MzU1NDYsImV4cCI6MTc0MjQ0NjM0Niwic2NoZW1hIjoibnhnXzcwNzA1OTEzX2VhcXoiLCJ1c2VyIjoiYWYwNzg3YTQtMmM2NC00NWRiLWEzMjktNzg0ZGYwZWRjOGZjIiwiZGVmYXVsdF9wcm9wZXJ0eSI6IjA3MTY3M2IzLWQ4OTMtNDQwYi1iM2YwLTY0YTBkOTY0ZWIyOSIsInRvX3JlZnJlc2giOnRydWUsInR5cGUiOiJhY2Nlc3MiLCJpbml0X2Vwb2NoIjoxNzQyNDM1NTQ2LCJtZWRpdW1fY29kZSI6IldFQiJ9.cuRCfgu2sT2cThnAMv2H8B-XRQiJWgFR25O95bZdVz0"); request1.AddHeader("property", "071673b3-d893-440b-b3f0-64a0d964eb29"); request1.AddParameter("payload", WER); var QQQ = client1.Execute(request1); HttpStatusCode HHH = QQQ.StatusCode; string ddd = QQQ.Content; JObject jsonObject = JObject.Parse(ddd); var error = jsonObject.SelectToken("error"); //如果有错 if (error != null) { //重新登录 //再次请求 } } public class QianLiMa_PMS { public static string FCSLoginUrl = "http://blv-rd.tech:19056"; public static void QiYong(string hotel_code, string add_or_remove) { var client1 = new RestClient(FCSLoginUrl); var request1 = new RestRequest("/api/Values/PostData", Method.POST); //注意方法是POST //两个参数名字必须是 topic 和payload ,区分大小写的 request1.AddQueryParameter("hotelcode", hotel_code); request1.AddQueryParameter("add_or_remove", add_or_remove); string str = client1.Execute(request1).Content; //client1.ExecuteAsync(request1, (response) => //{ // string str = response.Content; //}); } } public class iotVoiceData { public string room { get; set; } public int @event { get; set; } } public static void VVV_VVV() { string result = string.Empty; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Ssl3;//设置这个安全协议必须在创建请求之前! HttpWebRequest req = (HttpWebRequest)WebRequest.Create("https://skyworth-business.com//skill-api/web/sync/remoteControl"); req.Method = "POST"; req.ContentType = "application/json"; var WER = new iotVoiceData() { room = "0EC0", @event = 4 }; var postData = Newtonsoft.Json.JsonConvert.SerializeObject(WER); byte[] data = Encoding.UTF8.GetBytes(postData); req.ContentLength = data.Length; using (Stream reqStream = req.GetRequestStream()) { reqStream.Write(data, 0, data.Length); } HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); using (Stream stream = resp.GetResponseStream()) { using (StreamReader reader = new StreamReader(stream, Encoding.UTF8)) { result = reader.ReadToEnd();//获取响应内容 } } } public virtual void Run() { long lll = 9223372036854775807; lll = lll + 5; Console.WriteLine(lll); //log.Info("------- Initializing ----------------------"); //// First we must get a reference to a scheduler ISchedulerFactory sf = new StdSchedulerFactory(); IScheduler sched = sf.GetScheduler(); //log.Info("------- Initialization Complete -----------"); //// computer a time that is on the next round minute //DateTimeOffset runTime = DateBuilder.EvenMinuteDate(DateTimeOffset.UtcNow); //log.Info("------- Scheduling Job -------------------"); //// define the job and tie it to our HelloJob class //IJobDetail job = JobBuilder.Create() // .WithIdentity("job1", "group1") // .Build(); //// Trigger the job to run on the next round minute //ITrigger trigger = TriggerBuilder.Create() // .WithIdentity("trigger1", "group1") // .StartAt(runTime) // .Build(); //// Tell quartz to schedule the job using our trigger //sched.ScheduleJob(job, trigger); //log.Info(string.Format("{0} will run at: {1}", job.Key, runTime.ToString("r"))); //// Start up the scheduler (nothing can actually run until the //// scheduler has been started) //sched.Start(); //log.Info("------- Started Scheduler -----------------"); //// wait long enough so that the scheduler as an opportunity to //// run the job! //log.Info("------- Waiting 65 seconds... -------------"); //// wait 65 seconds to show jobs //Thread.Sleep(TimeSpan.FromSeconds(65)); //// shut down the scheduler //log.Info("------- Shutting Down ---------------------"); //sched.Shutdown(true); //log.Info("------- Shutdown Complete -----------------"); } public static void FanHui() { try { Console.WriteLine("111111111111111"); } catch (Exception) { throw; } finally { } } public class EMP { public virtual void AAA() { Console.WriteLine("nnnnnnnnnnnn"); } } public class BOSS : EMP { public override void AAA() { Console.WriteLine("aaaaaaaaa"); } } public static void T_T() { Interlocked.Increment(ref DataTongJi.RecordLostPackage); if (DataTongJi.RecordLostPackage == DataTongJi.DefineLostPackage) { Interlocked.Exchange(ref DataTongJi.RecordLostPackage, 0); return; } else { } } public static void TcpClientInvoke() { // 服务器IP和端口 string serverIp = "127.0.0.1"; // 替换为你的服务器IP int serverPort = 11000; // 替换为你的服务器端口 // 要发送的消息 string message = "Hello, UDP Server!"; try { // 创建UDP客户端 using (UdpClient client = new UdpClient()) { Console.WriteLine("1111111111111"); // 将消息转换为字节数组 byte[] data = Encoding.ASCII.GetBytes(message); // 发送数据 client.Send(data, data.Length, serverIp, serverPort); // 可选:接收服务器响应(如果需要) // IPEndPoint remoteEP = new IPEndPoint(IPAddress.Any, 0); // byte[] receivedData = client.Receive(ref remoteEP); // string response = Encoding.ASCII.GetString(receivedData); // Console.WriteLine($"收到来自 {remoteEP} 的响应: {response}"); } } catch (Exception ex) { } } public static long LLL333 = 0; public enum DeviceType { /// /// 主机继电器 /// [Description("主机继电器")] Relay = 1, /// /// 弱电输出 /// [Description("弱电输出")] LVout = 3, /// /// 服务信息 /// [Description("服务信息")] ServiceInfo = 4 } public static void DuoGeTask() { var TotalKey = "UDPPackage_TotalRecvPackage"; UDPPackageCount LLL_T = null; DataTongJi.TotalCount.TryGetValue(TotalKey, out LLL_T); if (LLL_T != null) { //LLL_T.Count = LC; //Interlocked.Increment(ref LLL_T.Count); } else { UDPPackageCount u = new UDPPackageCount(); u.Count = 1; DataTongJi.TotalCount.TryAdd(TotalKey, u); } } // 消费者组模式 //static async Task ConsumerGroup(string name, CancellationToken token) //{ // var processed = 0; // while (!token.IsCancellationRequested) // { // var messages = await _redis.XReadGroupAsync("mygroup", name, 1, 5000, (StreamKey, ">")); // if (messages?.Length > 0) // { // foreach (var msg in messages[0].messages) // { // Console.WriteLine($"[{name}] 处理: {msg.field["content"]}"); // await _redis.XAckAsync(StreamKey, "mygroup", msg.id); // processed++; // } // } // } // Console.WriteLine($"[{name}] 处理了 {processed} 条消息"); //} public static void SC() { CSRedisCacheHelper.redis.XAdd("MyStr", "*", new ValueTuple("d", "da")); CSRedisCacheHelper.redis.XAdd("MyStr", "*", new ValueTuple("d", "da")); CSRedisCacheHelper.redis.XAdd("MyStr", "*", new ValueTuple("d", "da")); var str = CSRedisCacheHelper.redis.XRead(3, 10000, new ValueTuple("MyStr", "$")); //CSRedisCacheHelper.redis.XGroupCreate("AAA","BBB"); //CSRedisCacheHelper.redis.XAdd("AAA",new ValueTuple("1","一个数据")); //var messages= CSRedisCacheHelper.redis.XReadGroup("AA", "BBB", 10,5000,new ValueTuple("AA", ">")); //foreach (var stream in messages) //{ // CSRedisCacheHelper.redis.XAck("AAA","BBB",stream.Item1); // Console.WriteLine(stream.Item2); //} //await CSre _redis.XGroupCreateAsync(StreamKey, "competitors", "0-0", true); CSRedisCacheHelper.StreamConsume(1, "", ""); } static void FileRe() { string sourcePath = "1.txt"; string destinationPath = "2.txt"; // 如果目标文件存在,先删除 if (File.Exists(destinationPath)) { File.Delete(destinationPath); } // 重命名/移动文件 File.Move(sourcePath, destinationPath); } static ConcurrentBag> aaH = new ConcurrentBag>(); static ConcurrentDictionary> aaJ = new ConcurrentDictionary>(); static void YiQianQueue() { aaJ.TryAdd("1", new ConcurrentQueue()); Task.Factory.StartNew(() => { ConcurrentQueue a = null; bool bf = aaJ.TryGetValue("1", out a); if (bf) { for (int i = 0; i < 100; i++) { a.Enqueue(i.ToString()); } } }); Task.Factory.StartNew(() => { ConcurrentQueue a = null; bool bf = aaJ.TryGetValue("1", out a); if (bf) { string st = null; a.TryDequeue(out st); } }); } public static void UDPTTS() { UdpEndpoint u = new UdpEndpoint("127.0.0.1", 3350); } /// /// 设置名单 /// public static void SetBlockData() { var DDD = File.ReadAllText("2.txt", Encoding.UTF8); var QS = Newtonsoft.Json.JsonConvert.DeserializeObject>(DDD); foreach (var item in QS) { var client1 = new RestClient("https://www.boonlive-rcu.com"); var request1 = new RestRequest("/api/BlockLWSet", Method.POST); Block_NameList bas = new Block_NameList(); bas.HostNumberList = new List(); bas.HotelCode = item.Key; request1.AddJsonBody(bas); var QQQ = client1.Execute(request1); HttpStatusCode HHH = QQQ.StatusCode; string ddd = QQQ.Content; } } public class JiShu { public string Name { get; set; } public int Count { get; set; } } static void Main(string[] args) { SetBlockData(); Console.ReadLine(); var redisusa = CSRedisCacheHelper.redis; var key = "key_Issues457"; var group = "group_Issues457"; var consumer = "consumer_Issues457"; var maxLen = 9999; //删除,重新创建,并加入数据,进行测试 redisusa.Del(key); redisusa.XGroupCreate(key, group, "0", true); redisusa.XAdd(key, maxLen, "*", new ValueTuple("data", "my data1")); //检查pending表的长度 //!!!!!!pending表不存在时,读取会报错!!!!!!!!! var pending0 = redisusa.XPending(key, group); //消费确认前,pending 应该等于0 //读取未阅读的消息1,读取2次 var new1 = redisusa.XReadGroup(group, consumer, 1, 1, new ValueTuple(key, ">")); var new2 = redisusa.XReadGroup(group, consumer, 1, 1, new ValueTuple(key, ">")); var ssa = new1[0].Item1; //var id1 = new1[0].data[0].id; redisusa.XAck(key, group, "1763536561353-0"); //string NSA1a= CSRedisCacheHelper.redis.BRPop(3,"a"); //CSRedisCacheHelper.redis.LPush("a","bbb"); //CSRedisCacheHelper.redis.LPush("a","111"); //CSRedisCacheHelper.redis.LPush("a","222"); //CSRedisCacheHelper.redis.LPush("a","333"); //string NSA1= CSRedisCacheHelper.redis.BRPop(300,"a"); //string NSA2= CSRedisCacheHelper.redis.BRPop(300,"a"); //string NSA3= CSRedisCacheHelper.redis.BRPop(300,"a"); UDPTTS(); Console.ReadLine(); //0011101000011100 ushort StatusReceiver = 0x3A1C; int status = StatusReceiver >> 15;//开关 int modeas = (StatusReceiver >> 12) & 0x03;//模式 int fanSpeed = (StatusReceiver >> 11) & 0x03;//风速 int valve = (StatusReceiver >> 10) & 0x01;//阀门 int temperature = (StatusReceiver >> 5) & 0x1F;//设定温度 int currentTemp = StatusReceiver & 0x01F;//当前温度(室内温度) byte[] bbb111 = new byte[] { 0x1c, 0x3a }; BitArray bit = new BitArray(bbb111); BitArray bit2 = new BitArray(8); bit2.SetAll(false); for (int i = 0; i < bit2.Length; i++) { bit2.Set(i, bit[i]); } int[] array = new int[1]; bit2.CopyTo(array, 0); Console.WriteLine(array[0]); foreach (var item in bit2) { Console.WriteLine(item.ToString()); } Console.WriteLine("*****************"); bool b111 = bit[13]; bool b222 = bit[12]; bool b333 = bit[11]; bool b444 = bit[10]; int mode = 0; //1制冷,2制热,3送风 if (b222 == true && b111 == false) { mode = 1; } else if (b222 == false && b111 == true) { mode = 2; } else if (b222 == true && b111 == true) { mode = 3; } else { } int fanspeed = 0; //0自动,1低速,2中速,3高速 if (b444 == true && b333 == false) { fanspeed = 1; } else if (b444 == false && b333 == true) { fanspeed = 2; } else if (b444 == true && b333 == true) { fanspeed = 3; } else if (b444 == false && b333 == false) { fanspeed = 0; } else { } foreach (bool item in bit) { Console.WriteLine(item.ToString()); } FileRe(); Console.ReadKey(); SC(); var US = DeviceType.Relay; var enumValue = (DeviceType)Enum.ToObject(typeof(Device), US); byte Chakaffsdf = CSRedisCacheHelper.Get_Partition("NNNNNNNNNNN", 5); long lll = -9223372036854775807; lll = lll + 5; Console.WriteLine(lll); StepInfo s = new StepInfo(); s.Step = 2; s.StepDescription = "你好这是一个测试数据"; string ti = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); s.TriggerTime = ti; string NNN35 = Newtonsoft.Json.JsonConvert.SerializeObject(s); CSRedisCacheHelper.Publish("redis-roomstatus-monitor", NNN35); return; Interlocked.Exchange(ref LLL333, 3333); Interlocked.Exchange(ref LLL333, 5555); for (int i = 0; i < 10; i++) { T_T(); } BOSS mnm = new BOSS(); mnm.AAA(); CSRedisCacheHelper.redis3.LPush("abc", "a1"); CSRedisCacheHelper.redis3.LPush("abc", "a2"); CSRedisCacheHelper.redis3.LPush("abc", "a3"); var a23 = CSRedisCacheHelper.redis3.LPop("abc"); var a24 = CSRedisCacheHelper.redis3.LPop("abc"); var a25 = CSRedisCacheHelper.redis3.LPop("abc"); var Time = "*/10 * * * *"; string[] datalll = Time.Split('/', ' '); var ak47 = new ValueTuple>("__keyevent@3__:expired", (sube) => { var n = sube.Body; Console.WriteLine("iiiiiiiiiiiiiiiiiiiii"); }); CSRedisCacheHelper.redis3.Subscribe(ak47); CSRedisCacheHelper.redis3.Set("uuu", "xxxx", 5); Console.ReadLine(); CSRedisCacheHelper.Set_Partition("hello", 0x01, 5); byte Chaka = CSRedisCacheHelper.Get_Partition("hello", 5); RedisTakeCardStatus xxx = new RedisTakeCardStatus(); xxx.HostNUMBER = "iiiii"; xxx.OriginalDat = new List { 0x01, 0x02, 0x03, 0xff, 0xce }; var X1 = Newtonsoft.Json.JsonConvert.SerializeObject(xxx); DataTongJi.CeShi(); byte[] NU1 = new byte[] { 0x00, 0xbb, 0xcc }; byte[] NU2 = new byte[] { 0xbb, 0xcc }; //bool GAB= ContainsSubsequence(NU1.ToList(),NU2.ToList()); Console.ReadLine(); CSRedisCacheHelper.redis5.HMSet("TestHDel", "a", "b"); CSRedisCacheHelper.redis5.Expire("TestHDel", 20); int I = CSRedisCacheHelper.redis5.HGetAll("TestHDel").Count; FanHui(); XuanZhuResponse x = new XuanZhuResponse(); x.code = "1085"; x.roomNumber = "8088"; MyHttp.SendHttpData("http://f-xcx.blv-oa.com/rcu/report", x); new Program().Run(); var uuu23 = Common.CPUData.GetCPU(); Console.WriteLine(uuu23); string[] vvv = File.ReadAllLines("234.csv"); foreach (var item in vvv) { var now = DateTime.Now; //string strn = "00:00,00:15,00:30,00:45,01:00,01:15,01:30,01:45,02:00,02:15,02:30,02:45,03:00,03:15,03:30,03:45,04:00,04:15,04:30,04:45,05:00,05:15,05:30,05:45,06:00,06:15,06:30,06:45,07:00,07:15,07:30,07:45,08:00,08:15,08:30,08:45,09:00,09:15,09:30,09:45,10:00,10:15,10:30,10:45,11:00,11:15,11:30,11:45,12:00,12:15,12:30,12:45,13:00,13:15,13:30,13:45,14:00,14:15,14:30,14:45,15:00,15:15,15:30,15:45,16:00,16:15,16:30,16:45,17:00,17:15,17:30,17:45,18:00,18:15,18:30,18:45,19:00,19:15,19:30,19:45,20:00,20:15,20:30,20:45,21:00,21:15,21:30,21:45,22:00,22:15,22:30,22:45,23:00,23:15,23:30,23:45"; foreach (string timing in item.Split(',')) { Console.WriteLine(item); DateTime dtTiming = Convert.ToDateTime(now.ToString("yyyy-MM-dd") + " " + timing);// row["Timing"].ToString()); double totalMinutes = (now - dtTiming).TotalMinutes; } } byte gh = 0x1b; string HHH789 = gh.ToString("000"); TCLCommon.SendData("1001", "1002", "111", "222", "30"); long NNN99 = CSRedisCacheHelper.Get_Partition("uuuuuuuuuuuuu", 1); MemoryCacheHelper.Set("a", "0x19", DateTimeOffset.Now.AddSeconds(5)); Thread.Sleep(6000); var QQQQQ = MemoryCacheHelper.Get("a"); VVV_VVV(); var client1 = new RestClient("https://skyworth-business.com"); var request1 = new RestRequest("/skill-api/web/sync/remoteControl", Method.POST); request1.AddHeader("authCode", "123e4567e89b12d3a456426614174003"); //request1.AddJsonBody(Newtonsoft.Json.JsonConvert.SerializeObject(WER)); //request1.AddJsonBody(WER); var Responsse = client1.Execute(request1); var AAF = Responsse.Content; Console.WriteLine(AAF); var client = new RestClient("https://pms.boonlive-rcu.com/"); //var client = new RestClient(Currentsys_address); var request = new RestRequest("api/GetRoomServiceList", Method.GET); Dictionary dic111 = new Dictionary(); dic111.Add("creatDate", "2021-03-29"); dic111.Add("roomNumber", "二楼H区"); dic111.Add("code", "1085"); string jsstr = Newtonsoft.Json.JsonConvert.SerializeObject(dic111); request.AddParameter("jsonData", jsstr); var response = client.Execute(request); string erlangstr = "中国abc"; var q23 = Encoding.UTF8.GetBytes(erlangstr); var q33 = Encoding.Unicode.GetBytes(erlangstr); var q32 = Encoding.ASCII.GetBytes(erlangstr); QianLiMa_PMS.QiYong("1008", "add"); ushort aac = 50; ushort bbc = 110; double d = (double)aac; double d2 = (double)bbc; double uuu = (d / bbc) * 100; int roundedNumber111 = (int)Math.Round(uuu); string BaiFenBi = roundedNumber111.ToString() + "%"; string Key = CacheKey.HostInfo_Key_HostNumber + "_" + "061004096203"; object obj = MemoryCacheHelper.Get(Key); if (obj != null) { Host host = obj as Host; } List uuua = new List() { new User() { username = "aaa", password = "ssss" }, new User() { username = "aaa", password = "ssss" }, new User() { username = "aaa", password = "ssss" }, new User() { username = "aaa", password = "ssss" }, new User() { username = "aaa", password = "ssss" } }; var VVV = uuua.Distinct(new User()).ToList(); string uuid = Guid.NewGuid().ToString("N"); JobRequest(); byte colorValue = 0x02; // 假设这是你想转换的字节值 FF color = (FF)colorValue; // 直接转换 byte[] osk = new byte[] { 0xAA, 0x0c, 0x01, 0x01, 0x7a, 0x74, 0x01, 0x01, 0x10, 0x01, 0x00, 0x0a }; for (int i = 0; i < 1000000; i++) { var reader = StreamReaderPool.GetReader(osk); bool nnn = reader.ReadBoolean(); bool SysLock = reader.ReadBoolean(); } Console.WriteLine("aaaaaaaaaaaaa"); for (int i = 0; i < 1000000; i++) { byte[] bbbyyy = osk.Take(3).ToArray(); Task.Factory.StartNew((state) => { var NNN = state as byte[]; //byte[] bbbyyy = NNN.Take(3).ToArray(); using (MemoryStream stream = new MemoryStream(NNN, 0, NNN.Length)) { using (BinaryReader reader = new BinaryReader(stream)) { bool nnn = reader.ReadBoolean(); //RCU是否锁定:0/否,1/是 bool SysLock = reader.ReadBoolean(); //RCU是否锁定:0/否,1/是 int CardType = reader.ReadByte(); //房卡类型:0/无人,1/有人,2/客人,3/经理,4/服务员 bool Door = reader.ReadBoolean(); //门磁开关:1/开,2/关 ushort ElecQty = reader.ReadUInt16(); //门锁电量,单位:MV int HostTemp = reader.ReadByte(); //主机温 } } }, osk); } for (int i = 0; i < 1000000; i++) { using (MemoryStream stream = new MemoryStream(osk, 0, osk.Length)) { using (BinaryReader reader = new BinaryReader(stream)) { bool nnn = reader.ReadBoolean(); //RCU是否锁定:0/否,1/是 bool SysLock = reader.ReadBoolean(); //RCU是否锁定:0/否,1/是 int CardType = reader.ReadByte(); //房卡类型:0/无人,1/有人,2/客人,3/经理,4/服务员 bool Door = reader.ReadBoolean(); //门磁开关:1/开,2/关 ushort ElecQty = reader.ReadUInt16(); //门锁电量,单位:MV int HostTemp = reader.ReadByte(); //主机温 } } } Console.WriteLine("aaaaaaaaaaaaaaa"); for (int i = 0; i < 100; i++) { Task.Factory.StartNew(() => { Console.WriteLine(i.ToString()); }); } int rrr = 0; int.TryParse("220", out rrr); double everydata = rrr / 2.55; int roundedNumber = (int)Math.Round(everydata); try { bool bka = SmartRobotTest(); Console.WriteLine(bka); Task.Factory.StartNew(() => { int aaa = 3; int bbb1 = 0; int c = aaa / bbb1; }).ContinueWith((ttt) => { if (ttt.IsFaulted) { var v = ttt.Exception.InnerExceptions; foreach (var item in v) { Console.WriteLine(item.Message); } } }); } catch (AggregateException) { Console.WriteLine(""); } int[] a = new int[] { 1, 2, 3, 4, 5 }; var sum = a.Aggregate(new List(), (acc, current) => { if (current % 2 == 0) { acc.Add(current); } return acc; }); Console.WriteLine(sum); Domain.IoTAliGenieEntity.Request req = new Domain.IoTAliGenieEntity.Request(); req.baseInfo = new Domain.IoTAliGenieEntity.BaseInfo() { appName = "xiaodu", hotelId = "1", requestId = "eeee", requestTime = 300000, roomNo = "2001", token = ")%(&$(*%&$U*(%R&$(*Y%$*(" }; req.command = new Domain.IoTAliGenieEntity.Command() { commandType = "devicecommand", devices = new List() { } }; string hhg = Newtonsoft.Json.JsonConvert.SerializeObject(req); CSRedisCacheHelper.Forever("nnn", "ddd"); string redisHostStr = "127.0.0.1:6379"; var redis = new CSRedisClient(redisHostStr);//+ ",password=,defaultDatabase=0,poolsize=500,ssl=false,writeBuffer=10240,prefix="); var redis1 = new CSRedisClient(redisHostStr + ",password=,defaultDatabase=1"); var redis2 = new CSRedisClient(redisHostStr + ",password=,defaultDatabase=2"); redis.Set("11", "22"); redis1.Set("22", "22"); redis2.Set("33", "22"); var cache = CacheFactory.Build("getStartedCache", settings => { settings.WithSystemRuntimeCacheHandle("handleName"); }); cache.Add("keyA", "valueA"); cache.Put("keyB", 23); cache.Update("keyB", v => 42); for (int i = 0; i < 100; i++) { string ll = "hhh"; switch (ll) { case "hhh": Console.WriteLine("nnnnnnnn"); break; default: break; } Console.WriteLine("1111111111111"); } DateTime dddv = DateTime.Now.ToLocalTime(); ushort iii = 15; // 假设我们有一个BitArray byte[] bbbddd = BitConverter.GetBytes(iii); BitArray bitArray = new BitArray(bbbddd); var qqq1 = bitArray.Cast().Take(4).ToArray(); var qqq2 = bitArray.Cast().Skip(4).Take(4).ToArray(); byte hhhg = CombineBitsToByte(qqq1[0], qqq1[1], qqq1[2], qqq1[3]); ushort hhh = 75; BitArray bitnew = new BitArray(hhh); foreach (bool item in bitnew) { Console.WriteLine(item); } byte bbb = (byte)hhh; TFTPReceiver tf = new TFTPReceiver(); byte[] bbbbbb = tf.CreateDataPacket(); string str = "AA 55 17 00 54 33 53 41 02 E5 94 3D 04 2B 1B 34 D0 B8 11 2B 1B C5 F9 "; str = str.Replace(" ", ""); byte[] data = TG(str); var SystemHeader = DecodeSystemHeader(data); var cmdtype = (CommandType)SystemHeader.Value.CmdType; long hotelCode = SystemHeader.Value.HostNumber.ToHotelCode();//获取酒店编码 int startIndex = StructConverter.SizeOf(SystemHeader); SearchHostPacketReply? reply = StructConverter.BytesToStruct(data, startIndex, typeof(SearchHostPacketReply)) as SearchHostPacketReply?; string mac = BitConverter.ToString(reply.Value.MAC); string version = reply.Value.Version; //string sss = "固件:BLV-C5 || Launcher_C1F_V04 || C1F_A_L4_3C_241206_NM.bin"; //string[] ddd = sss.Split(new string[] { "||" }, StringSplitOptions.None); //TimeSpan ts = DateTime.Now.ToLocalTime() - new DateTime(1970, 1, 1, 8, 0, 0, 0, DateTimeKind.Utc); //string current_timestamp = Convert.ToInt64(ts.TotalSeconds).ToString(); //KongQiReport re = new KongQiReport(); //re.hotel_code = "1003"; //re.room_no = "1002"; //re.time = "2022-12-33"; //var client1 = new RestClient("http://localhost:5026"); //var request1 = new RestRequest("/rcu/vi/airjson", Method.POST); ////request1.RequestFormat = DataFormat.Json; ////request1.AddHeader("Context-Type", "application/json"); ////string sss = Newtonsoft.Json.JsonConvert.SerializeObject(re); ////logger.Error("空气质量送了数据:" + AirReport_Address+" data: "+json); //request1.AddBody(re); //client1.ExecuteAsync(request1, (response) => //{ // string result = response.Content; //}); Console.ReadKey(); } static public bool SmartRobotTest() { string st = "11:00"; string et = "09:00"; string[] st_a = st.Split(':'); string[] et_a = et.Split(':'); int h_st = int.Parse(st_a[0]); int M_st = int.Parse(st_a[1]); int h_et = int.Parse(et_a[0]); int M_et = int.Parse(et_a[1]); int y = DateTime.Now.Year; int m = DateTime.Now.Month; int d = DateTime.Now.Day; int hh = DateTime.Now.Hour; int mm = DateTime.Now.Minute; int ss = DateTime.Now.Second; var t1 = new DateTime(y, m, d, h_st, M_st, ss); var t2 = new DateTime(y, m, d, h_et, M_et, ss); bool ShiJian = false; //正常逻辑 if (t2 >= t1) { var ti = DateTime.Now; //如果当前时间大于 起 小于 至,就代表 确实是 禁用 if (ti >= t1 && ti <= t2) { ShiJian = true; } } else { var ti = DateTime.Now; var zero_ti = new DateTime(y, m, d, 23, 59, 59); var t3 = t2.AddDays(1); if (ti < zero_ti && ti >= t1 && ti <= t3) { return true; } } bool dis = true; return dis && ShiJian; } public static byte[] TG(string hexString) { char[] hexCharacters = hexString.ToCharArray(); byte[] byteArray = new byte[hexCharacters.Length / 2]; for (int i = 0; i < byteArray.Length; i++) { string hexVal = string.Concat(hexCharacters[i * 2], hexCharacters[i * 2 + 1]); byteArray[i] = Convert.ToByte(hexVal, 16); } return byteArray; } private static SystemHeader? DecodeSystemHeader(byte[] data) { return StructConverter.BytesToStruct(data, typeof(SystemHeader)) as SystemHeader?; } } public static class StreamReaderPool { // 线程安全的对象池(按字节数组长度区分) private static readonly ConcurrentDictionary> _readers = new ConcurrentDictionary>(); // 获取或创建与指定字节数组关联的 BinaryReader public static BinaryReader GetReader(byte[] data) { var lazyReader = _readers.GetOrAdd(data.Length, length => new Lazy(() => { var stream = new MemoryStream(data, 0, length); return new BinaryReader(stream); }, LazyThreadSafetyMode.ExecutionAndPublication)); // 重置流位置以便复用 var reader = lazyReader.Value; reader.BaseStream.Position = 0; return reader; } } }