示例#1
0
        public void Visit(CreateTableCommand command)
        {
            var tableCreator = _app.BusinessObjects.GetBusinessObject <UserTablesMD>(BoObjectTypes.oUserTables);

            try {
                tableCreator.TableName        = command.Name;
                tableCreator.TableDescription = command.Description;
                tableCreator.TableType        = command.TableType;
                var created = tableCreator.Add();
                if (created != 0)
                {
                    string error = _app.BusinessObjects.GetLastErrorDescription();
                    throw new B1CoreException(string.Format("Error: {0} - tabela: {1}", error, command.Name));
                }
            }
            finally {
                _app.BusinessObjects.ReleaseObject(tableCreator);
            }
            foreach (var columnCommand in command.TableCommands)
            {
                Visit(columnCommand);
            }
            foreach (var indexCommand in command.IndexCommands.Values)
            {
                Visit(indexCommand);
            }
            //Mostra a mensagem antes de criar o User Object, pois este é um comando bonus e pode ser
            //criado separadamente
            _app.SetStatusBarSucess(string.Format("Tabela {0} criada com sucesso.", command.Name));

            if (command.HasObject)
            {
                Visit(command.ObjectCommand);
            }
        }