|
@@ -94,12 +94,8 @@ namespace WCS.Service
|
|
|
//static ConcurrentQueue<PackInfo> Packs = new ConcurrentQueue<PackInfo>();
|
|
|
private static Dictionary<string, Playerback> Clients = new Dictionary<string, Playerback>();
|
|
|
|
|
|
- private static RedisClient Redis;
|
|
|
-
|
|
|
- //public static RedisClient LiaotcRedis;
|
|
|
-
|
|
|
- //public static RedisClient YGWMS150Redis;
|
|
|
- //public static RedisClient YGWCS150Redis;
|
|
|
+ //private static RedisClient Redis;
|
|
|
+ public static RedisClient YGRedis;
|
|
|
|
|
|
static ProtocolProxy()
|
|
|
{
|
|
@@ -108,51 +104,35 @@ namespace WCS.Service
|
|
|
|
|
|
#region 公用云服务器
|
|
|
|
|
|
- Redis = new RedisClient("212.64.66.35,password=Aa123456,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,password=Aa123456,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;
|
|
|
- //};
|
|
|
+ YGRedis = new RedisClient("106.15.78.3,password=Password@123$%^,database=2");
|
|
|
+ YGRedis.Serialize = obj =>
|
|
|
+ {
|
|
|
+ var bytes = MessagePackSerializer.Serialize(obj);
|
|
|
+ return bytes;
|
|
|
+ };
|
|
|
+ YGRedis.DeserializeRaw = (bytes, type) =>
|
|
|
+ {
|
|
|
+ var obj = MessagePackSerializer.Deserialize(type, bytes);
|
|
|
+ return obj;
|
|
|
+ };
|
|
|
|
|
|
- //#endregion 永冠服务
|
|
|
+ #endregion 永冠服务
|
|
|
}
|
|
|
|
|
|
public override void Publish(string code, WCS_PROTOCOLDATA obj)
|
|
@@ -214,17 +194,6 @@ namespace WCS.Service
|
|
|
try
|
|
|
{
|
|
|
var gs = AllDatas.GroupBy(v => v.Value.GetType());
|
|
|
-
|
|
|
- //Parallel.ForEach(gs, g =>
|
|
|
- //{
|
|
|
- // var value = g.Select(v => v.Value).ToArray();
|
|
|
- // var etype = g.Key;
|
|
|
- // var type = typeof(DeviceDataCollection<>).MakeGenericType(etype);
|
|
|
- // var coll = Activator.CreateInstance(type, LogicHandler.Frame, value);
|
|
|
- // Redis.Set(etype.Name, coll);
|
|
|
- // YGWCS150Redis.Set(etype.Name, coll);
|
|
|
- // LiaotcRedis.Set(etype.Name, coll);
|
|
|
- //});
|
|
|
DeviceDataPack pack = new DeviceDataPack();
|
|
|
pack.Frame = LogicHandler.Frame;
|
|
|
foreach (var g in gs)
|
|
@@ -239,70 +208,31 @@ namespace WCS.Service
|
|
|
|
|
|
var sw = new Stopwatch();
|
|
|
sw.Start();
|
|
|
- Redis.Set(nameof(DeviceDataPack), pack);
|
|
|
+ //Redis.Set(nameof(DeviceDataPack), pack);
|
|
|
+ YGRedis.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();
|
|
|
- //Console.ForegroundColor = ConsoleColor.Blue;
|
|
|
- //Console.WriteLine($"YGWCS150Redis耗时{se.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);
|
|
|
+ //Redis.RPush("Packs", pack);
|
|
|
+ YGRedis.RPush("Packs", pack);
|
|
|
st.Stop();
|
|
|
Console.ForegroundColor = ConsoleColor.Blue;
|
|
|
Console.WriteLine($"Redis耗时{st.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 (YGRedis.LLen("Packs") > 600000)
|
|
|
+ {
|
|
|
+ YGRedis.LTrim("Packs", 5000, -1);
|
|
|
+ }
|
|
|
|
|
|
foreach (var data in AllDatas)
|
|
|
{
|