public SchemaBuilder CreateObject(string tableName, string name, string description, Action <CreateObjectCommand> userObject)
        {
            var command = new CreateObjectCommand(tableName, name, description);

            userObject(command);
            Run(command);
            return(this);
        }
Esempio n. 2
0
        public void Visit(CreateObjectCommand command)
        {
            var objectCreator = _app.BusinessObjects.GetBusinessObject <UserObjectsMD>(BoObjectTypes.oUserObjectsMD);

            try {
                objectCreator.Code              = command.Name;
                objectCreator.Name              = command.Description;
                objectCreator.TableName         = command.TableName;
                objectCreator.ObjectType        = command.ObjectType;
                objectCreator.CanFind           = YesNo(command.CanFind);
                objectCreator.CanCancel         = YesNo(command.CanCancel);
                objectCreator.CanClose          = YesNo(command.CanClose);
                objectCreator.CanDelete         = YesNo(command.CanDelete);
                objectCreator.CanLog            = YesNo(command.CanLog);
                objectCreator.CanYearTransfer   = YesNo(command.CanYearTransfor);
                objectCreator.CanArchive        = YesNo(command.CanArchive);
                objectCreator.ManageSeries      = YesNo(command.ManageSeries);
                objectCreator.UseUniqueFormType = YesNo(command.UniqueFormType);

                foreach (var name in command.ChildTables)
                {
                    objectCreator.ChildTables.TableName = name;
                    objectCreator.ChildTables.Add();
                }

                foreach (var field in command.FindFields)
                {
                    objectCreator.FindColumns.ColumnAlias = field.Key;
                    if (!string.IsNullOrEmpty(field.Value))
                    {
                        objectCreator.FindColumns.ColumnDescription = field.Value;
                    }
                    objectCreator.FindColumns.Add();
                }

                var created = objectCreator.Add();
                if (created != 0)
                {
                    string error = _app.BusinessObjects.GetLastErrorDescription();
                    throw new B1CoreException(string.Format("Error: {0} - objeto: {1}", error, command.Name));
                }
                _app.SetStatusBarSucess(string.Format("Objeto de usuário {0} criado com sucesso.", command.Name));
            }
            finally {
                _app.BusinessObjects.ReleaseObject(objectCreator);
            }
        }
        public CreateTableCommand WithObject(string objectName, Action <CreateObjectCommand> userObject)
        {
            HasObject = true;
            var command = new CreateObjectCommand(Name, objectName, Description);

            switch (TableType)
            {
            case BoUTBTableType.bott_Document:
                command.WithType(BoUDOObjType.boud_Document);
                break;

            case BoUTBTableType.bott_MasterData:
                command.WithType(BoUDOObjType.boud_MasterData);
                break;
            }
            if (userObject != null)
            {
                userObject(command);
            }
            ObjectCommand = command;
            return(this);
        }
 public CreateTableCommand(string name, string description)
     : base(name, description)
 {
     HasObject     = false;
     ObjectCommand = null;
 }
 protected void Run(CreateObjectCommand command)
 {
     _interpreter.Visit(command);
 }