示例#1
0
        private SboGuiApiClass ConnectToGui()
        {
            var gui = new SboGuiApiClass();

            gui.Connect(connectionString);
            return(gui);
        }
示例#2
0
        /// <summary>
        /// Connects this instance.
        /// </summary>
        /// <exception cref="ConnectionException">
        /// Thrown when an error connecting to Business One occurs.
        /// </exception>
        public virtual void Connect()
        {
            try
            {
                if (Connected)
                {
                    return;
                }

                var gui = new SboGuiApiClass();
                gui.Connect(connectionString);
                Application = gui.GetApplication();

                Company = new DiCompanyClass {
                    Application = Application
                };
                var result = Company.Connect();
                if (result != 0)
                {
                    var message = $"{result} {Company.GetLastErrorDescription()}";
                    throw new ConnectionException(message);
                }

                Connected = true;
            }
            catch (COMException e)
            {
                throw ConnectionException.CreateFrom(e);
            }
        }