Exemplo n.º 1
0
            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 }
                      } }
                });
            }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
 public static List <ServiceInstanceInfo> InterruptUsers(ServiceInstance server) => (from t in _IntServiceInstancesInfos select t.Value.Value).ToList();
Exemplo n.º 5
0
 public static List <ServiceInstanceInfo> CurrentUsers(ServiceInstance server) => _ServiceInstances.Values.ToList();
Exemplo n.º 6
0
        private static void _CreateInstance()
        {
            ServiceInstance res = new ServiceInstance();

            _AvaServiceInstances.Add(res);
        }
Exemplo n.º 7
0
 internal static void SetServiceInstanceInfo(ServiceInstance Instance, ServiceInstanceInfo Info)
 {
     _ServiceInstances[Instance] = Info;
 }