private static void Connect() { var connector = new COMConnector(); var settings = ConfigurationManager.ConnectionStrings .Cast <ConnectionStringSettings>() .Where(c => c.Name == "V83").FirstOrDefault(); String connectStr = settings.ConnectionString; connector.PoolCapacity = 10; connector.PoolTimeout = 60; connector.MaxConnections = 12; connection1c = connector.Connect(connectStr); }
public object Create(string connectionString) { lock (lockObject) { if (disposed) { throw new ObjectDisposedException("GlobalContextFactory"); } if (comConnector == null) { comConnector = new COMConnector(); } return(comConnector.Connect(connectionString)); } }
private void Dispose(bool disposing) { if (_disposed) { return; } if (ComConnector != null) { Marshal.ReleaseComObject(ComConnector); ComConnector = null; } _disposed = true; }
public void Dispose() { lock (lockObject) { if (disposed) { return; } disposed = true; if (comConnector != null) { comConnector.Dispose(); comConnector = null; } } }
public override void Connection() { ConnectionStatus = ConnectionStatus.Progress; try { try { _connector = new COMConnector(); } catch { throw new Exception("Ошибка инициализация компонента ActiveX \"V83.COMConnector\"..."); } try { string connectionString = $"{Settings.ComConnectionString}Usr=\"{Settings.UserName}\";Pwd =\"{Settings.UserPassword}\""; _connection = _connector.Connect(connectionString); } catch { throw new Exception("Ошибка подключения к 1С."); } try { if (Properties.Settings.Default.Preload) { LoadEmployes(true); } } catch { throw new Exception("Ошибка при получении списка сотрудников."); } ConnectionStatus = ConnectionStatus.Connected; } catch (Exception ex) { MessageBox.Show(null, ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); ConnectionStatus = ConnectionStatus.Disconnected; } }
private IWorkingProcessConnection GetWorkingProcessConnection() { var connector = new COMConnector(); var agentConnection = connector.ConnectAgent(ServerName); agentConnection.AuthenticateAgent("", ""); var cluster = agentConnection.GetClusters().GetValue(0) as IClusterInfo; agentConnection.Authenticate(cluster, "", ""); var workingProcess = agentConnection.GetWorkingProcesses(cluster).GetValue(0) as IWorkingProcessInfo; if (workingProcess != null) { var connectString = workingProcess.HostName + ":" + workingProcess.MainPort; var workingProcessConnection = connector.ConnectWorkingProcess(connectString); workingProcessConnection.AddAuthentication("", ""); return(workingProcessConnection); } else { return(null); } }
public DeviceMonitorWindow([NotNull] ApplicationConfiguration configuration, [NotNull] USBConnector usbConnector, [NotNull] COMConnector comConnector) { if (configuration == null) { throw new ArgumentNullException("configuration"); } if (usbConnector == null) { throw new ArgumentNullException("usbConnector"); } if (comConnector == null) { throw new ArgumentNullException("comConnector"); } m_configuration = configuration; m_usbConnector = usbConnector; m_comConnector = comConnector; InitializeComponent(); InitializeControls(); InitializeChart(); InitializeSeries(); InitializeContextMenus(); m_comConnector.Connected += COMConnector_Connected; m_comConnector.Disconnected += COMConnector_Disconnected; m_comConnector.MonitorDataReceived += ComConnector_MonitorDataReceived; Load += (s, e) => EnsureConnection(); Closing += (s, e) => { if (m_realClosing) { return; } StopRecording(); SaveCheckedSeries(); e.Cancel = true; m_realClosing = true; new Thread(() => { // The serial port cannot close until the DataReceived event handler stops running. // But the Invoke() call cannot complete until the UI thread goes idle and pumps the message loop. // It isn't idle, it is stuck in the Close() call. So the event handler cannot make progress because // it is stuck in the Invoke() call and your main thread cannot make progress because // it is stuck in the Close() call, deadlock city. if (m_usbConnector.IsDeviceConnected) { m_usbConnector.SetupDeviceMonitor(false); } m_comConnector.MonitorDataReceived -= ComConnector_MonitorDataReceived; m_comConnector.Connected -= COMConnector_Connected; m_comConnector.Disconnected -= COMConnector_Disconnected; if (m_isComPortConnected) { m_comConnector.Disconnect(); } UpdateUI(Close); }).Start(); }; }