|
@@ -94,65 +94,65 @@ namespace WCS.Service
|
|
|
//static ConcurrentQueue<PackInfo> Packs = new ConcurrentQueue<PackInfo>();
|
|
|
private static Dictionary<string, Playerback> Clients = new Dictionary<string, Playerback>();
|
|
|
|
|
|
- //private static RedisClient Redis;
|
|
|
+ private static RedisClient Redis;
|
|
|
|
|
|
- public static RedisClient LiaotcRedis;
|
|
|
+ //public static RedisClient LiaotcRedis;
|
|
|
|
|
|
//public static RedisClient YGWMS150Redis;
|
|
|
- public static RedisClient YGWCS150Redis;
|
|
|
+ //public static RedisClient YGWCS150Redis;
|
|
|
|
|
|
static ProtocolProxy()
|
|
|
{
|
|
|
MessagePackSerializer.DefaultOptions = StandardResolver.Options.WithCompression(MessagePackCompression.Lz4Block);
|
|
|
//Redis = new RedisClient("192.168.249.120,password=123456,database=11");
|
|
|
|
|
|
- //#region 公用云服务器
|
|
|
+ #region 公用云服务器
|
|
|
|
|
|
- //Redis = new RedisClient("212.64.66.35,database=10");
|
|
|
- //Redis.Serialize = obj =>
|
|
|
- //{
|
|
|
- // var bytes = MessagePackSerializer.Serialize(obj);
|
|
|
- // return bytes;
|
|
|
- //};
|
|
|
- //Redis.DeserializeRaw = (bytes, type) =>
|
|
|
- //{
|
|
|
- // var obj = MessagePackSerializer.Deserialize(type, bytes);
|
|
|
- // return obj;
|
|
|
- //};
|
|
|
-
|
|
|
- //#endregion 公用云服务器
|
|
|
-
|
|
|
- #region 私用云服务器
|
|
|
-
|
|
|
- LiaotcRedis = new RedisClient("liaotc.com,database=10");
|
|
|
- LiaotcRedis.Serialize = obj =>
|
|
|
+ Redis = new RedisClient("212.64.66.35,database=10");
|
|
|
+ Redis.Serialize = obj =>
|
|
|
{
|
|
|
var bytes = MessagePackSerializer.Serialize(obj);
|
|
|
return bytes;
|
|
|
};
|
|
|
- LiaotcRedis.DeserializeRaw = (bytes, type) =>
|
|
|
+ Redis.DeserializeRaw = (bytes, type) =>
|
|
|
{
|
|
|
var obj = MessagePackSerializer.Deserialize(type, bytes);
|
|
|
return obj;
|
|
|
};
|
|
|
|
|
|
- #endregion 私用云服务器
|
|
|
+ #endregion 公用云服务器
|
|
|
|
|
|
- #region 永冠服务
|
|
|
+ //#region 私用云服务器
|
|
|
|
|
|
- YGWCS150Redis = new RedisClient("192.168.249.150,password=123456,database=10");
|
|
|
- YGWCS150Redis.Serialize = obj =>
|
|
|
- {
|
|
|
- var bytes = MessagePackSerializer.Serialize(obj);
|
|
|
- return bytes;
|
|
|
- };
|
|
|
- YGWCS150Redis.DeserializeRaw = (bytes, type) =>
|
|
|
- {
|
|
|
- var obj = MessagePackSerializer.Deserialize(type, bytes);
|
|
|
- return obj;
|
|
|
- };
|
|
|
+ //LiaotcRedis = new RedisClient("liaotc.com,database=10");
|
|
|
+ //LiaotcRedis.Serialize = obj =>
|
|
|
+ //{
|
|
|
+ // var bytes = MessagePackSerializer.Serialize(obj);
|
|
|
+ // return bytes;
|
|
|
+ //};
|
|
|
+ //LiaotcRedis.DeserializeRaw = (bytes, type) =>
|
|
|
+ //{
|
|
|
+ // var obj = MessagePackSerializer.Deserialize(type, bytes);
|
|
|
+ // return obj;
|
|
|
+ //};
|
|
|
+
|
|
|
+ //#endregion 私用云服务器
|
|
|
|
|
|
- #endregion 永冠服务
|
|
|
+ //#region 永冠服务
|
|
|
+
|
|
|
+ //YGWCS150Redis = new RedisClient("192.168.249.150,password=123456,database=10");
|
|
|
+ //YGWCS150Redis.Serialize = obj =>
|
|
|
+ //{
|
|
|
+ // var bytes = MessagePackSerializer.Serialize(obj);
|
|
|
+ // return bytes;
|
|
|
+ //};
|
|
|
+ //YGWCS150Redis.DeserializeRaw = (bytes, type) =>
|
|
|
+ //{
|
|
|
+ // var obj = MessagePackSerializer.Deserialize(type, bytes);
|
|
|
+ // return obj;
|
|
|
+ //};
|
|
|
+
|
|
|
+ //#endregion 永冠服务
|
|
|
}
|
|
|
|
|
|
public override void Publish(string code, WCS_PROTOCOLDATA obj)
|
|
@@ -237,72 +237,72 @@ namespace WCS.Service
|
|
|
p.SetValue(pack, coll);
|
|
|
}
|
|
|
|
|
|
- //var sw = new Stopwatch();
|
|
|
- //sw.Start();
|
|
|
- //Redis.Set(nameof(DeviceDataPack), pack);
|
|
|
- //sw.Stop();
|
|
|
- //Console.ForegroundColor = ConsoleColor.Blue;
|
|
|
- //Console.WriteLine($"Redis耗时{sw.ElapsedMilliseconds}");
|
|
|
- //Console.ResetColor();
|
|
|
-
|
|
|
- var se = new Stopwatch();
|
|
|
- se.Start();
|
|
|
- YGWCS150Redis.Set(nameof(DeviceDataPack), pack);
|
|
|
- se.Stop();
|
|
|
+ var sw = new Stopwatch();
|
|
|
+ sw.Start();
|
|
|
+ Redis.Set(nameof(DeviceDataPack), pack);
|
|
|
+ sw.Stop();
|
|
|
Console.ForegroundColor = ConsoleColor.Blue;
|
|
|
- Console.WriteLine($"YGWCS150Redis耗时{se.ElapsedMilliseconds}");
|
|
|
+ Console.WriteLine($"Redis耗时{sw.ElapsedMilliseconds}");
|
|
|
Console.ResetColor();
|
|
|
|
|
|
- var sr = new Stopwatch();
|
|
|
- sr.Start();
|
|
|
- LiaotcRedis.Set(nameof(DeviceDataPack), pack);
|
|
|
- sr.Stop();
|
|
|
- Console.ForegroundColor = ConsoleColor.Blue;
|
|
|
- Console.WriteLine($"LiaotcRedis耗时{sr.ElapsedMilliseconds}");
|
|
|
- Console.ResetColor();
|
|
|
- /////
|
|
|
- //var st = new Stopwatch();
|
|
|
- //st.Start();
|
|
|
- //Redis.RPush("Packs", pack);
|
|
|
- //st.Stop();
|
|
|
+ //var se = new Stopwatch();
|
|
|
+ //se.Start();
|
|
|
+ //YGWCS150Redis.Set(nameof(DeviceDataPack), pack);
|
|
|
+ //se.Stop();
|
|
|
//Console.ForegroundColor = ConsoleColor.Blue;
|
|
|
- //Console.WriteLine($"Redis耗时{st.ElapsedMilliseconds}");
|
|
|
+ //Console.WriteLine($"YGWCS150Redis耗时{se.ElapsedMilliseconds}");
|
|
|
//Console.ResetColor();
|
|
|
|
|
|
- var sy = new Stopwatch();
|
|
|
- sy.Start();
|
|
|
- YGWCS150Redis.RPush("Packs", pack);
|
|
|
- sy.Stop();
|
|
|
+ //var sr = new Stopwatch();
|
|
|
+ //sr.Start();
|
|
|
+ //LiaotcRedis.Set(nameof(DeviceDataPack), pack);
|
|
|
+ //sr.Stop();
|
|
|
+ //Console.ForegroundColor = ConsoleColor.Blue;
|
|
|
+ //Console.WriteLine($"LiaotcRedis耗时{sr.ElapsedMilliseconds}");
|
|
|
+ //Console.ResetColor();
|
|
|
+ /////
|
|
|
+ var st = new Stopwatch();
|
|
|
+ st.Start();
|
|
|
+ Redis.RPush("Packs", pack);
|
|
|
+ st.Stop();
|
|
|
Console.ForegroundColor = ConsoleColor.Blue;
|
|
|
- Console.WriteLine($"YGWCS150Redis耗时{sy.ElapsedMilliseconds}");
|
|
|
+ Console.WriteLine($"Redis耗时{st.ElapsedMilliseconds}");
|
|
|
Console.ResetColor();
|
|
|
|
|
|
- var su = new Stopwatch();
|
|
|
- su.Start();
|
|
|
- LiaotcRedis.RPush("Packs", pack);
|
|
|
- su.Stop();
|
|
|
- Console.ForegroundColor = ConsoleColor.Blue;
|
|
|
- Console.WriteLine($"LiaotcRedis耗时{su.ElapsedMilliseconds}");
|
|
|
- Console.ResetColor();
|
|
|
+ //var sy = new Stopwatch();
|
|
|
+ //sy.Start();
|
|
|
+ //YGWCS150Redis.RPush("Packs", pack);
|
|
|
+ //sy.Stop();
|
|
|
+ //Console.ForegroundColor = ConsoleColor.Blue;
|
|
|
+ //Console.WriteLine($"YGWCS150Redis耗时{sy.ElapsedMilliseconds}");
|
|
|
+ //Console.ResetColor();
|
|
|
+
|
|
|
+ //var su = new Stopwatch();
|
|
|
+ //su.Start();
|
|
|
+ //LiaotcRedis.RPush("Packs", pack);
|
|
|
+ //su.Stop();
|
|
|
+ //Console.ForegroundColor = ConsoleColor.Blue;
|
|
|
+ //Console.WriteLine($"LiaotcRedis耗时{su.ElapsedMilliseconds}");
|
|
|
+ //Console.ResetColor();
|
|
|
|
|
|
//Redis.RPush("Packs", pack);
|
|
|
//YGWCS150Redis.RPush("Packs", pack);
|
|
|
//LiaotcRedis.RPush("Packs", pack);
|
|
|
|
|
|
- //if (Redis.LLen("Packs") > 100000)
|
|
|
- //{
|
|
|
- // Redis.LTrim("Packs", 5000, -1);
|
|
|
- //}
|
|
|
-
|
|
|
- if (YGWCS150Redis.LLen("Packs") > 200000)
|
|
|
+ if (Redis.LLen("Packs") > 100000)
|
|
|
{
|
|
|
- YGWCS150Redis.LTrim("Packs", 20000, -1);
|
|
|
+ Redis.LTrim("Packs", 5000, -1);
|
|
|
}
|
|
|
|
|
|
- if (LiaotcRedis.LLen("Packs") > 100000)
|
|
|
- {
|
|
|
- LiaotcRedis.LTrim("Packs", 5000, -1);
|
|
|
- }
|
|
|
+ //if (YGWCS150Redis.LLen("Packs") > 200000)
|
|
|
+ //{
|
|
|
+ // YGWCS150Redis.LTrim("Packs", 20000, -1);
|
|
|
+ //}
|
|
|
+
|
|
|
+ //if (LiaotcRedis.LLen("Packs") > 100000)
|
|
|
+ //{
|
|
|
+ // LiaotcRedis.LTrim("Packs", 5000, -1);
|
|
|
+ //}
|
|
|
|
|
|
foreach (var data in AllDatas)
|
|
|
{
|