public ULCommand CreateAddProductCommand(ULConnection conn, ULTransaction transaction)
        {
            var cmd = new ULCommand(ConvertToUltraLiteQuery(_sql), conn, transaction);
            CreateParameters(cmd);

            return cmd;
        }
示例#2
0
 private ConnectionFactory()
 {
     //            var connStr = _connectionString.Replace(@"file:\", "");
     ULConnectionParms parms = new ULConnectionParms();
     parms.DatabaseOnDesktop = _connectionString;
     _connection = new ULConnection(parms.ToString());
     _connection.Open();
 }
示例#3
0
        /// <devdoc>
        /// Discovery has to be done on its own connection to allow for the case of the
        /// connection being used being enrolled in a transaction. The ULCommandBuilder.DeriveParameters
        /// method creates a new ULCommand internally to communicate to the database, and it
        /// reuses the same connection that is passed in on the command object. If this command
        /// object has a connection that is enrolled in a transaction, the DeriveParameters method does not
        /// honor that transaction, and the call fails. To avoid this, create your own connection and
        /// command, and use them.
        ///
        /// You then have to clone each of the IDataParameter objects before it can be transferred to
        /// the original command, or another exception is thrown.
        /// </devdoc>
        private ULCommand CreateNewCommandAndConnectionForDiscovery()
        {
            ULConnection clonedConnection = (ULConnection)((ICloneable)((IDbConnection)this.command.Connection)).Clone();

            clonedConnection.Open();
            ULCommand newCommand = CreateCommand(this.command.CommandText, this.command.CommandType);

            newCommand.Connection = clonedConnection;

            return(newCommand);
        }
示例#4
0
        public static async Task Main(string[] args)
        {
            ServiceProvider serviceProvider = new ServiceCollection()
                                              .AddLogging(builder => builder
                                                          .SetMinimumLevel(LogLevel.Debug)
                                                          .AddConsole()
                                                          )
                                              .BuildServiceProvider();

            Server server = new ServerBuilder(serviceProvider)
                            .UseSockets(builder => builder
                                        .ListenLocalhost(11112, connection => connection
                                                         .UseConnectionLogging("Server")
                                                         .UseConnectionHandler <DiCorConnectionHandler>()
                                                         ))
                            .Build();

            await server.StartAsync().ConfigureAwait(false);

            Client client = new ClientBuilder(serviceProvider)
                            .UseSockets()
                            .UseConnectionLogging()
                            .Build();

            await using (var connection = new ULConnection())
            {
                await connection.AssociateAsync(
                    client,
                    new IPEndPoint(IPAddress.Loopback, 11112),
                    //new DnsEndPoint("dicomserver.co.uk", 11112),
                    AssociationType.Find,
                    new CancellationTokenSource(60000).Token).ConfigureAwait(false);

                Console.WriteLine(connection.CurrentState);
            }
        }