예제 #1
0
        public void Update(DbHost host)
        {
            var hostChanged = false;

            if (InternalHost != host.internal_host)
            {
                InternalHost = host.internal_host;
                hostChanged  = true;
            }

            if (PublicHost != host.public_host)
            {
                PublicHost  = host.public_host;
                hostChanged = true;
            }

            if (Role != host.role)
            {
                Role = host.role;
            }

            BootTime = host.time_boot;
            ShardId  = host.shard_id;

            if (hostChanged)
            {
                Close();
            }
        }
예제 #2
0
 public AbsDbHostSchema()
 {
     DbHost = new DbHost();
     Define();
 }
예제 #3
0
        private void OnHostDiscovered(DbHost dbHost)
        {
            var host = (GluonHost)Pool.Get(dbHost.call_sign);

            host.Update(dbHost);
        }
예제 #4
0
        /// <summary>
        /// LUA结构支持
        /// </summary>
        /// <returns></returns>
        public override void GetLuaStruct(StringBuilder code)
        {
            base.GetLuaStruct(code);
            int idx;

            idx = 0;
            code.AppendLine("['ApiItems'] ={");
            foreach (var val in ApiItems)
            {
                if (idx++ > 0)
                {
                    code.Append(',');
                }
                code.AppendLine($@"{val.GetLuaStruct()}");
            }
            code.AppendLine("},");

            idx = 0;
            code.AppendLine("['Entities'] ={");
            foreach (var val in Entities)
            {
                if (idx++ > 0)
                {
                    code.Append(',');
                }
                code.AppendLine($@"{val.GetLuaStruct()}");
            }
            code.AppendLine("},");

            code.AppendLine($@"['ReadOnly'] ={(ReadOnly.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(DataBaseObjectName))
            {
                code.AppendLine($@"['DataBaseObjectName'] = '{DataBaseObjectName.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['DataBaseObjectName'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(NameSpace))
            {
                code.AppendLine($@"['NameSpace'] = '{NameSpace.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['NameSpace'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(PagePath))
            {
                code.AppendLine($@"['PagePath'] = '{PagePath.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['PagePath'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(BusinessPath))
            {
                code.AppendLine($@"['BusinessPath'] = '{BusinessPath.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['BusinessPath'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(ClientCsPath))
            {
                code.AppendLine($@"['ClientCsPath'] = '{ClientCsPath.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['ClientCsPath'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(ModelPath))
            {
                code.AppendLine($@"['ModelPath'] = '{ModelPath.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['ModelPath'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(CodePath))
            {
                code.AppendLine($@"['CodePath'] = '{CodePath.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['CodePath'] = nil,");
            }

            code.AppendLine($@"['DbType'] ='{DbType}',");

            if (!string.IsNullOrWhiteSpace(DbHost))
            {
                code.AppendLine($@"['DbHost'] = '{DbHost.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['DbHost'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(DbSoruce))
            {
                code.AppendLine($@"['DbSoruce'] = '{DbSoruce.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['DbSoruce'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(DbPassWord))
            {
                code.AppendLine($@"['DbPassWord'] = '******',");
            }
            else
            {
                code.AppendLine($@"['DbPassWord'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(DbUser))
            {
                code.AppendLine($@"['DbUser'] = '******',");
            }
            else
            {
                code.AppendLine($@"['DbUser'] = nil,");
            }
        }