From 9c283c00da89516d2456e70a00fb61534c535576 Mon Sep 17 00:00:00 2001 From: tangxu <76880903@qq.com> Date: 星期一, 10 四月 2023 17:10:06 +0800 Subject: [PATCH] Merge branch 'master' --- Service/IStation.Service.LinuxTest/monitor_record/MonitorRecord.cs | 19 +-------- Application/IStation.Application.LinuxTest/test/MonitorRecord_Controller.cs | 9 +--- Component/IStation.Redis/RedisClientHelper.cs | 51 +++++-------------------- RedisCache/IStation.RedisCache.LinuxTest/monitor_record/MonitorRecordCacheHelper.cs | 5 -- 4 files changed, 17 insertions(+), 67 deletions(-) diff --git a/Application/IStation.Application.LinuxTest/test/MonitorRecord_Controller.cs b/Application/IStation.Application.LinuxTest/test/MonitorRecord_Controller.cs index ce13e41..86d0718 100644 --- a/Application/IStation.Application.LinuxTest/test/MonitorRecord_Controller.cs +++ b/Application/IStation.Application.LinuxTest/test/MonitorRecord_Controller.cs @@ -44,12 +44,9 @@ [HttpPost] public string Insert([Required] AddMonitorRecordInput input) { - if (input == null) - return default; - var model = input.Adapt<AddMonitorRecordInput, Model.MonitorRecord>(); - var bol = _service.InsertLastRecord(model, out bool redis, out string info); - - return info; + var redisHelper = new RedisClientHelper(); + var bol = redisHelper.HashSet("lxjxxx", "hashdddd", "dddddddd"); + return bol.ToString(); } diff --git a/Component/IStation.Redis/RedisClientHelper.cs b/Component/IStation.Redis/RedisClientHelper.cs index 893ff0e..1894166 100644 --- a/Component/IStation.Redis/RedisClientHelper.cs +++ b/Component/IStation.Redis/RedisClientHelper.cs @@ -73,32 +73,6 @@ RegisterEvent(); } - - - - /// <summary> - /// 闈欐�佺殑鏋勯�犲嚱鏁�, - /// 鏋勯�犲嚱鏁版槸灞炰簬绫荤殑锛岃�屼笉鏄睘浜庡疄渚嬬殑 - /// 灏辨槸璇磋繖涓瀯閫犲嚱鏁板彧浼氳鎵ц涓�娆°�備篃灏辨槸鍦ㄥ垱寤虹涓�涓疄渚嬫垨寮曠敤浠讳綍闈欐�佹垚鍛樹箣鍓嶏紝鐢�.NET鑷姩璋冪敤銆� - /// </summary> - public RedisClientHelper(string password, out string info) - { - info = string.Empty; - //var ip = "172.23.244.126:6379"; //192.168.244.126 // localhost - //192.168.244.126 - - - var ip = "192.168.244.126:6379"; - var options = ConfigurationOptions.Parse(ip);//redis 鍦板潃 - options.AbortOnConnectFail = false;//濡傛灉涓簍rue锛屽湪娌℃湁鍙敤鏈嶅姟鍣ㄦ椂锛孋onnect涓嶄細鍒涘缓杩炴帴 - options.Password = "Yxyw2021@redis";//redis 瀵嗙爜 - var con = options.ToString();// - _connMultiplexer = ConnectionMultiplexer.Connect(options);//鍒涘缓杩炴帴瀵硅薄 - RegisterEvent(); - _db = _connMultiplexer.GetDatabase(3);//鑾峰彇瀵瑰簲鏁版嵁搴� - info = ip; - } - /// <summary> /// 閲嶈浇鏋勯�犲櫒锛岃幏鍙杛edis鍐呴儴鏁版嵁搴撶殑浜や簰寮忚繛鎺� /// </summary> @@ -264,24 +238,19 @@ /// 鍦╤ash涓瀹氬�� json搴忓垪鍖� /// </summary> public bool HashSetJosn<T>(string redisKey, string hashField, T value) - { - var json = JsonHelper.Object2Json(value); - var result = _db.HashSet(redisKey, hashField, json, When.Always); - return result; - } - - /// <summary> - /// 鍦╤ash涓瀹氬�� json搴忓垪鍖� - /// </summary> - public bool HashSetJosn<T>(string redisKey, string hashField, T value, out string redisInfo) { - redisInfo = string.Empty; - var json = JsonHelper.Object2Json(value); - var result = _db.HashSet(redisKey, hashField, json); + var result = false; + try + { + var json = JsonHelper.Object2Json(value); + result = _db.HashSet(redisKey, hashField, json); + } + catch (Exception ex) + { + var a = ex.Message; + } return result; } - - /// <summary> /// 鍦╤ash 涓幏鍙栧�� json鍙嶅簭鍒楀寲 diff --git a/RedisCache/IStation.RedisCache.LinuxTest/monitor_record/MonitorRecordCacheHelper.cs b/RedisCache/IStation.RedisCache.LinuxTest/monitor_record/MonitorRecordCacheHelper.cs index a469055..0c8779a 100644 --- a/RedisCache/IStation.RedisCache.LinuxTest/monitor_record/MonitorRecordCacheHelper.cs +++ b/RedisCache/IStation.RedisCache.LinuxTest/monitor_record/MonitorRecordCacheHelper.cs @@ -15,10 +15,7 @@ { } - public MonitorRecordCacheHelper(out string info) - { - _redisClient = new RedisClientHelper("Yxyw2021@redis", out info); - } + //Redis瀹㈡埛绔緟鍔╃被瀵硅薄 diff --git a/Service/IStation.Service.LinuxTest/monitor_record/MonitorRecord.cs b/Service/IStation.Service.LinuxTest/monitor_record/MonitorRecord.cs index fe32931..811c9a7 100644 --- a/Service/IStation.Service.LinuxTest/monitor_record/MonitorRecord.cs +++ b/Service/IStation.Service.LinuxTest/monitor_record/MonitorRecord.cs @@ -44,20 +44,7 @@ #region Insert - /// <summary> - /// 鎻掑叆鏈�杩戜竴鏉¤褰� - /// </summary> - public bool InsertLastRecord(Model.MonitorRecord model, out bool redis, out string info) - { - info = "InsertLastRecord"; - redis = false; - if (model == null) - return default; - var redisHelper = new MonitorRecordCacheHelper(out info); - redisHelper.SetLastRecord(model, out redis, out info); - - return redis; - } + /// <summary> /// 鎻掑叆鏈�杩戝鏉¤褰� @@ -71,11 +58,11 @@ if (bol) { var redisHelper = new MonitorRecordCacheHelper(); - redisHelper.SetLastRecord(list,out string info); + redisHelper.SetLastRecord(list, out string info); } return bol; } - + #endregion -- Gitblit v1.9.3