public void AddTable(string tableName, string description, SAPbobsCOM.BoUTBTableType tableType)
        {
            var oUserTablesMD = B1Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables) as SAPbobsCOM.UserTablesMD;

            try
            {
                if (!oUserTablesMD.GetByKey(tableName))
                {
                    oUserTablesMD.TableName        = tableName;
                    oUserTablesMD.TableDescription = description;
                    oUserTablesMD.TableType        = tableType;
                    if (oUserTablesMD.Add() != 0)
                    {
                        var error = B1Company.GetLastErrorDescription();
                    }
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                oUserTablesMD.ReleaseObject();
            }
        }
        public void CreateUserTable(string UserTableName, string UserTableDesc, SAPbobsCOM.BoUTBTableType UserTableType)
        {
            FindColumns        = new GenericModel();
            FindColumns.Fields = new Dictionary <string, object>();
            Log.AppendLine();
            Log.AppendLine(UserTableName);
            Log.AppendFormat("Criação/Atualização da tabela de usuário {0}: ", UserTableName);

            SAPbobsCOM.UserTablesMD oUserTableMD = (SAPbobsCOM.UserTablesMD)SBOApp.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables);
            // Remove a arroba do usertable Name
            UserTableName = UserTableName.Replace("@", "");

            bool bUpdate = oUserTableMD.GetByKey(UserTableName);

            oUserTableMD.TableName        = UserTableName;
            oUserTableMD.TableDescription = UserTableDesc;
            oUserTableMD.TableType        = UserTableType;

            if (bUpdate)
            {
                //CodErro = oUserTableMD.Update();
                CodErro = 0;
            }
            else
            {
                CodErro = oUserTableMD.Add();
            }
            this.ValidateAction();

            Marshal.ReleaseComObject(oUserTableMD);
            oUserTableMD = null;
        }
Example #3
0
 /// <summary>
 /// Table struct
 /// </summary>
 /// <param name="name"></param>
 /// <param name="description"></param>
 /// <param name="table"></param>
 /// <param name="tableType"></param>
 /// <param name="level"></param>
 /// <param name="isSystem"></param>
 /// <param name="form"></param>
 public TableStruct(string name, string description, string table, BoUTBTableType tableType, int level, bool isSystem, UserDefineSetup.Form form = UserDefineSetup.Form.None)
 {
     Name        = name;
     Description = $"{R.Namespace}: {description}";
     Table       = k.db.Factory.Scripts.Namespace(table);
     TableType   = tableType;
     IsSystem    = isSystem;
     Level       = level;
     Form        = form;
 }
        //Criar tabela de usuário

        private void AddUserTable(string Name, string Description, SAPbobsCOM.BoUTBTableType Type)
        {
            ////****************************************//**********************************
            // The UserTablesMD represents a meta-data object which allows us
            // to add\remove tables, change a table name etc.
            ////*********************//*********************//**********************************
            GC.Collect();
            SAPbobsCOM.UserTablesMD oUserTablesMD = null;
            ////*********************//*********************//**********************************
            // In any meta-data operation there should be no other object "alive"
            // but the meta-data object, otherwise the operation will fail.
            // This restriction is intended to prevent a collisions
            ////*********************//*********************//**********************************
            // the meta-data object needs to be initialized with a
            // regular UserTables object
            oUserTablesMD = ((SAPbobsCOM.UserTablesMD)(oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables)));
            ////*********************//*****************************
            // when adding user tables or fields to the SBO DB
            // use a prefix identifying your partner name space
            // this will prevent collisions between different
            // partners add-ons
            // SAP's name space prefix is "BE_"
            ////*********************//*****************************
            // set the table parameters
            oUserTablesMD.TableName        = Name;
            oUserTablesMD.TableDescription = Description;
            oUserTablesMD.TableType        = Type;
            // Add the table
            // This action add an empty table with 2 default fields
            // 'Code' and 'Name' which serve as the key
            // in order to add your own User Fields
            // see the AddUserFields.frm in this project
            // a privat, user defined, key may be added
            // see AddPrivateKey.frm in this project
            CodErroDB = oUserTablesMD.Add();
            // check for errors in the process
            if (CodErroDB != 0)
            {
                if (CodErroDB == -1)
                {
                }
                else
                {
                    oCompany.GetLastError(out CodErroDB, out MsgErroDB);
                    // SBO_Application.StatusBar.SetText("Erro ao criar Tabela [" + Name + "] --> [" + Description + "] - " + MsgErroDB + "!", SAPbouiCOM.BoMessageTime.bmt_Long, SAPbouiCOM.BoStatusBarMessageType.smt_Error);
                }
            }
            else
            {
                // SBO_Application.StatusBar.SetText("Tabela [" + Name + "] --> [" + Description + "] - Criada com Sucesso!", SAPbouiCOM.BoMessageTime.bmt_Long, SAPbouiCOM.BoStatusBarMessageType.smt_Success);
            }
            oUserTablesMD = null;
            GC.Collect(); // Release the handle to the table
        }
Example #5
0
        public bool AddTable(string TableName, string TableDescription, SAPbobsCOM.BoUTBTableType TableType)
        {
            bool outResult = false;

            try
            {
                SAPbobsCOM.UserTablesMD v_UserTableMD = default(SAPbobsCOM.UserTablesMD);

                GC.Collect();
                if (!TableExists(TableName))
                {
                    oApplication.StatusBar.SetText("Creating Table " + TableName + " ...................", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning);
                    v_UserTableMD                  = (SAPbobsCOM.UserTablesMD)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables);
                    v_UserTableMD.TableName        = TableName;
                    v_UserTableMD.TableDescription = TableDescription;
                    v_UserTableMD.TableType        = TableType;
                    v_RetVal = v_UserTableMD.Add();
                    if (v_RetVal != 0)
                    {
                        oCompany.GetLastError(out v_ErrCode, out v_ErrMsg);
                        oApplication.StatusBar.SetText("Failed to Create Table " + TableName + v_ErrCode + " " + v_ErrMsg, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error);
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(v_UserTableMD);
                        v_UserTableMD = null;
                        GC.Collect();
                        return(false);
                    }
                    else
                    {
                        oApplication.StatusBar.SetText("[@" + TableName + "] - " + TableDescription + " created successfully!!!", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success);
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(v_UserTableMD);
                        v_UserTableMD = null;
                        outResult     = true;
                        GC.Collect();
                        return(true);
                    }
                }
                else
                {
                    GC.Collect();
                    return(false);
                }
            }
            catch (Exception ex)
            {
                oApplication.StatusBar.SetText("Failed to Add Table : " + ex.Message);
            }
            finally
            {
            }
            return(outResult);
        }
Example #6
0
        private static bool AddTable(string sTableName, string sTableDescription, SAPbobsCOM.BoUTBTableType TableType)
        {
            int iError = 0;

            SAPbobsCOM.UserTablesMD oUserTablesMD;
            oUserTablesMD = (SAPbobsCOM.UserTablesMD)Conexion_SBO.m_oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables);

            oUserTablesMD.TableName        = sTableName;
            oUserTablesMD.TableDescription = sTableDescription;
            oUserTablesMD.TableType        = TableType;

            iError = oUserTablesMD.Add();
            if (iError.Equals(0))
            {
                Conexion_SBO.m_oCompany.GetLastErrorDescription();
                return(false);
            }
            else
            {
                return(true);
            }
        }
        public void AddTableSL(string tableName, string description, SAPbobsCOM.BoUTBTableType tableType)
        {
            B1ServiceLayer.SAPB1.UserTablesMD oUserTablesMD = new B1ServiceLayer.SAPB1.UserTablesMD();

            try
            {
                var result = instance.CurrentServicelayerInstance.UserTablesMD.Where(x => x.TableName == tableName);
                if (result.Count() == 0)
                {
                    oUserTablesMD.TableName        = tableName;
                    oUserTablesMD.TableDescription = description;
                    oUserTablesMD.TableType        = tableType.ToString();
                    instance.CurrentServicelayerInstance.AddToUserTablesMD(oUserTablesMD);
                }
            }
            catch (Exception ex)
            {
                if (instance != null)
                {
                    instance.CurrentServicelayerInstance.Detach(oUserTablesMD);
                }
            }
        }