internal static Dictionary <string, object> LocalServerState(ServiceInstance server) { var db = new AppDbContext(); db.Database.EnsureCreated(); return(new Dictionary <string, object>() { { "ServerInstance", new Dictionary <string, object> { { "Total", _AvaServiceInstances.Count + _ServiceInstances.Count }, { "Avaliable", _AvaServiceInstances.Count }, { "Current", +_ServiceInstances.Count }, { "Interupted Container", _IntServiceInstancesInfos.Count } } }, { "DbState", new Dictionary <string, object> { { "User Count", db.M_UserModels.Local.Count }, { "User Record Count", db.M_UserRecordModels.Local.Count } } } }); }
internal static void DropInstance(ServiceInstance Instance) { var info = ServiceInstanceInfo(Instance); if (!info.DisposeInfo) { if (_IntServiceInstancesInfos.ContainsKey(info.LoginHashToken)) { _IntServiceInstancesInfos.Remove(info.LoginHashToken); } _IntServiceInstancesInfos.Add(info.LoginHashToken, new KeyValuePair <DateTime, ServiceInstanceInfo>( DateTime.Now.AddMinutes(Convert.ToDouble(Config[Enums.AppConfigEnum.ServiceDropTime])), info)); } if (_AvaServiceInstances.Count < Convert.ToDouble(AppConfigs.Current[Enums.AppConfigEnum.ServiceInstanceObjectDestroylimit]) * _ServiceInstances.Count) { _AvaServiceInstances.Add(Instance); } lock (_ServiceInstances) _ServiceInstances.Remove(Instance); }
private static string _AppHashToken(ServiceInstance server) { var hashobj = new Helper.HashProvider(); var ranstrobj = new Helper.RandomGenerator(); server.HashMark = hashobj.Hash(ranstrobj.getRandomString(50)); while (true) { bool vt = true; foreach (var t in _ServiceInstances.Keys) { if (t.Info.LoginHashToken == server.HashMark) { vt = false; } } if (vt) { break; } server.HashMark = hashobj.Hash(ranstrobj.getRandomString(50)); } return(server.HashMark); }
public static List <ServiceInstanceInfo> InterruptUsers(ServiceInstance server) => (from t in _IntServiceInstancesInfos select t.Value.Value).ToList();
public static List <ServiceInstanceInfo> CurrentUsers(ServiceInstance server) => _ServiceInstances.Values.ToList();
private static void _CreateInstance() { ServiceInstance res = new ServiceInstance(); _AvaServiceInstances.Add(res); }
internal static void SetServiceInstanceInfo(ServiceInstance Instance, ServiceInstanceInfo Info) { _ServiceInstances[Instance] = Info; }