当前位置: 首页>>代码示例>>C#>>正文


C# Connection.Open方法代码示例

本文整理汇总了C#中Connection.Open方法的典型用法代码示例。如果您正苦于以下问题:C# Connection.Open方法的具体用法?C# Connection.Open怎么用?C# Connection.Open使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Connection的用法示例。


在下文中一共展示了Connection.Open方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
	conn = new Connection();
        string connectionstring = ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString;
        conn.Open(connectionstring); 
        Recordset Rs1 = null;
    object StationID = null;
    object UserID = null;
    object SecLevel = null;
    string Barcode = "";
    string ProductType = "";
    string CarPlate = "";
    string Message = "";

    Rs1 = new Recordset();
    StationID = Session["StationID"];
    UserID = Session["UserID"];
    SecLevel = Session["SecLevel"];
    Barcode = Request["Barcode"];
    ProductType = Request["ProductType"];
    CarPlate = Request["CarPlate"];
    Message = "ÅçÃÒ¦¨¥\\!";
    Rs1.Open(("Exec InsertCoupon '" + Barcode + "', '" + Convert.ToString(StationID) + "','" + ProductType + "','" + CarPlate + "','" + Convert.ToString(UserID) + "' "), conn, (nce.adodb.CursorType)3, (nce.adodb.LockType)1);
   
    Response.Redirect("CouponVerification.aspx?Message=" + Message + "&CarPlate=" + CarPlate + "&ProductType=" + ProductType);
    }
开发者ID:young1023,项目名称:CVS.net,代码行数:26,代码来源:Insert.aspx.cs

示例2: btnLoadPI_Click

        private void btnLoadPI_Click(object sender, EventArgs e)
        {
            try
            {
                Connection cnx = new Connection();
                cnx.Open(ConfigurationManager.AppSettings["K2ServerName"]);
                SourceCode.Workflow.Client.ProcessInstance pi = cnx.OpenProcessInstance(int.Parse(txtProcInstanceId.Text));
                txtFolio.Text = pi.Folio;
                lblStatus.Text = pi.Status1.ToString();
                txtProcessFullName.Text = pi.FullName;
                DataTable dt = new DataTable("Datafields");
                dt.Columns.Add("Name");
                dt.Columns.Add("Value");

                foreach (DataField df in pi.DataFields)
                {
                    dt.Rows.Add(new object[] { df.Name, df.Value });
                }

                displayActivity();

                dgvDatafields.DataSource = dt;
                dgvDatafields.Refresh();
                dgvDatafields.AutoResizeColumn(0);
                dgvDatafields.Columns[0].ReadOnly = true;
                dgvDatafields.AutoResizeColumn(1);

                cnx.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "PI Manager eror");
            }
        }
开发者ID:pierrot12,项目名称:K2France.PIManager,代码行数:34,代码来源:Form1.cs

示例3: Main

        static void Main(string[] args) {
            String broker = args.Length > 0 ? args[0] : "localhost:5672";
            String address = args.Length > 1 ? args[1] : "amq.topic";

            Connection connection = null;
            try {
                connection = new Connection(broker);
                connection.Open();
                Session session = connection.CreateSession();

                Receiver receiver = session.CreateReceiver(address);
                Sender sender = session.CreateSender(address);

                sender.Send(new Message("Hello world!"));

                Message message = new Message();
                message = receiver.Fetch(DurationConstants.SECOND * 1);
                Console.WriteLine("{0}", message.GetContent());
                session.Acknowledge();

                connection.Close();
            } catch (Exception e) {
                Console.WriteLine("Exception {0}.", e);
                if (null != connection)
                    connection.Close();
            }
        }
开发者ID:irinabov,项目名称:debian-qpid-cpp,代码行数:27,代码来源:csharp.example.helloworld.cs

示例4: GetConnection

        public static Connection GetConnection(ServiceContext context)
        {
            Connection conn = new Connection();

            ConnectionSetup conSetup = new ConnectionSetup();

            conSetup.ConnectionParameters.Add(ConnectionSetup.ParamKeys.Host, context[SettingVariable.ServerName]);
            conSetup.ConnectionParameters.Add(ConnectionSetup.ParamKeys.UserID, context[SettingVariable.LoginUser]);
            conSetup.ConnectionParameters.Add(ConnectionSetup.ParamKeys.Password, context[SettingVariable.LoginPassword]);
            conSetup.ConnectionParameters.Add(ConnectionSetup.ParamKeys.Port, context[SettingVariable.ClientPort]);
            conSetup.ConnectionParameters.Add(ConnectionSetup.ParamKeys.Authenticate, "true");
            conSetup.ConnectionParameters.Add(ConnectionSetup.ParamKeys.WindowsDomain, context[SettingVariable.WindowDomain]);
            conSetup.ConnectionParameters.Add(ConnectionSetup.ParamKeys.IsPrimaryLogin, "true");
            conSetup.ConnectionParameters.Add(ConnectionSetup.ParamKeys.TimeOut, context[SettingVariable.ConnectionTimeout]);

            var label = context[SettingVariable.SecurityLabelName];
            conSetup.ConnectionParameters.Add(ConnectionSetup.ParamKeys.SecurityLabelName, label);
            if (label.ToLower() != "k2")
            {
                conSetup.ConnectionParameters[ConnectionSetup.ParamKeys.Integrated] = "false";
            }

            conn.Open(context[SettingVariable.ServerName], conSetup.ConnectionString);

            return conn;
        }
开发者ID:Cloud33,项目名称:K2.Tasks-Service,代码行数:26,代码来源:K2WorkflowUtility.cs

示例5: Main

        public static void Main(string[] args)
        {
            PrepareCommands();

            m_Connection = new Connection();
            m_Connection.Open();

            //var strokes = MakeStrokeStream(m_Connection);
            //strokes.Subscribe(s => accumulateForceCurve());
            //strokes.Connect();

            Observable.Interval(TimeSpan.FromMilliseconds(500)).Subscribe(_ => Console.WriteLine(accumulateForceCurve()));

            //var Hz10 = Make10HzStream(m_Connection);
            //Hz10.Subscribe(s => Console.WriteLine(string.Format("{0} {1} {2} {3}", s.Item1, s.Item2, s.Item3, s.Item4)));
            //Hz10.Connect();

            //var Hz2 = Make2HzStream(m_Connection);
            //Hz2.Subscribe(s => Console.WriteLine(string.Format("{0} {1} {2} {3}", s.Item6, s.Item1, s.Item2, s.Item3)));
            //Hz2.Connect();

            //var e = MakeEverythingStream(m_Connection);
            //e.Subscribe(s => Console.WriteLine(string.Format("{0}", s.Item6[0])));
            //e.Connect();

            while (true)
            {
            }
            Console.WriteLine("Hello World!");
        }
开发者ID:b0urb4k1,项目名称:Concept2-Rower,代码行数:30,代码来源:Program.cs

示例6: Main

        //
        // Sample invocation: csharp.example.declare_queues.exe localhost:5672 my-queue
        //
        static int Main(string[] args) {
            string addr = "localhost:5672";
            string queue = "my-queue";

            if (args.Length > 0)
                addr = args[0];
            if (args.Length > 1)
                queue = args[1];

            Connection connection = null;
            try
            {
                connection = new Connection(addr);
                connection.Open();
                Session session = connection.CreateSession();
                String queueName = queue + "; {create: always}";
                Sender sender = session.CreateSender(queueName);
                session.Close();
                connection.Close();
                return 0;
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception {0}.", e);
                if (null != connection)
                    connection.Close();
            }
            return 1;
        }
开发者ID:irinabov,项目名称:debian-qpid-cpp,代码行数:32,代码来源:csharp.example.declare_queues.cs

示例7: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        conn = new Connection();

        string connectionstring = ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString;
        conn.Open(connectionstring);
        //For Demo
        UserIPAddress = GetIPAddress();
        //UserIPAddress = Request.ServerVariables["REMOTE_ADDR"];
        Rs1 = new Recordset();
        sql1 = "Select Station From Station Where IPAddress ='" + UserIPAddress + "'";
        Rs1 = conn.Execute(sql1);
        StationID = Rs1.Fields["Station"].Value;
        UserID = Session["UserID"];
        SecLevel = Session["SecLevel"];
        CarPlate = Request["CarPlate"];
        ProductType = Request["ProductType"];
        Message = "";
        if (Convert.ToString(SecLevel) == "")
        {
            Response.Redirect("Default.aspx");
        }
        Session.Add("SecLevel", SecLevel);
        Session.Add("UserID", UserID);
        Session.Add("StationID", StationID);
    }
开发者ID:young1023,项目名称:AjaxCVS,代码行数:26,代码来源:CouponVerification.aspx.cs

示例8: LoadWorkList

        public List<SA4Launcher.Models.WorklistItem> LoadWorkList()
        {
            Connection K2Conn = new Connection();
            SCConnectionStringBuilder K2ConnString = new SCConnectionStringBuilder();
            List<SA4Launcher.Models.WorklistItem> _currentWorkList = new List<SA4Launcher.Models.WorklistItem>();

            //Setup Connection String

            K2ConnString.Host = "Sa4DemoK2wAD";
            K2ConnString.Integrated = false;
            K2ConnString.UserID = "SA4Demo\\Tberry";
            K2ConnString.Password = "Sa42013!";
            K2ConnString.Port = 5252;
            K2ConnString.WindowsDomain = "Sa4Demo";
            K2ConnString.SecurityLabelName = "K2";
            K2ConnString.Authenticate = false;
            K2ConnString.IsPrimaryLogin = true;
            K2Conn.Open("Sa4DemoK2wAD", K2ConnString.ConnectionString.ToString());

            //TODO:  Need to add try loop with true false return
            Worklist K2WorkList = K2Conn.OpenWorklist();
            List<SA4Launcher.Models.Action> CurrentActions = new List<SA4Launcher.Models.Action>();

            if (K2WorkList != null)
            {
                _currentWorkList.Clear();
                foreach (SourceCode.Workflow.Client.WorklistItem K2worklistitem in K2WorkList)
                {
                    //Build Actions First
                    CurrentActions.Clear();
                    foreach (SourceCode.Workflow.Client.Action K2action in K2worklistitem.Actions)
                    {
                        CurrentActions.Add(new SA4Launcher.Models.Action
                        {
                            Name = K2action.Name,
                            Batchable = K2action.Batchable
                        });
                    }

                    //Load worklist items into model
                    _currentWorkList.Add(new SA4Launcher.Models.WorklistItem
                    {
                        ID = K2worklistitem.ID,
                        serialno = K2worklistitem.SerialNumber,
                        Name = K2worklistitem.ProcessInstance.Name,
                        UserName = K2worklistitem.AllocatedUser,
                        Folio = K2worklistitem.ProcessInstance.Folio,
                        StartDate = K2worklistitem.ProcessInstance.StartDate,
                        Status = K2worklistitem.Status.ToString(),
                        ViewFlow = K2worklistitem.ProcessInstance.ViewFlow,
                        Data = K2worklistitem.Data,
                        Priority = K2worklistitem.ProcessInstance.Priority,
                        Actions = CurrentActions.ToList()
                    });
                }
            }
            K2Conn.Close();
            return (_currentWorkList);
        }
开发者ID:jordanberry,项目名称:SA4Launcher,代码行数:59,代码来源:WorkListContext.cs

示例9: Main

        //
        // Sample invocation: csharp.example.drain.exe --broker localhost:5672 --timeout 30 my-queue
        //
        static int Main(string[] args) {
            Options options = new Options(args);

            Connection connection = null;
            try
            {
                connection = new Connection(options.Url, options.ConnectionOptions);
                connection.Open();
                Session session = connection.CreateSession();
                Receiver receiver = session.CreateReceiver(options.Address);
                Duration timeout = options.Forever ? 
                                   DurationConstants.FORVER : 
                                   DurationConstants.SECOND * options.Timeout;
                Message message = new Message();

                while (receiver.Fetch(ref message, timeout))
                {
                    Dictionary<string, object> properties = new Dictionary<string, object>();
                    properties = message.Properties;
                    Console.Write("Message(properties={0}, content='", 
                                  message.MapAsString(properties));

                    if ("amqp/map" == message.ContentType)
                    {
                        Dictionary<string, object> content = new Dictionary<string, object>();
                        message.GetContent(content);
                        Console.Write(message.MapAsString(content));
                    }
                    else if ("amqp/list" == message.ContentType)
                    {
                        Collection<object> content = new Collection<object>();
                        message.GetContent(content);
                        Console.Write(message.ListAsString(content));
                    }
                    else
                    {
                        Console.Write(message.GetContent());
                    }
                    Console.WriteLine("')");
                    session.Acknowledge();
                }
                receiver.Close();
                session.Close();
                connection.Close();
                return 0;
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception {0}.", e);
                if (null != connection)
                    connection.Close();
            }
            return 1;
        }
开发者ID:irinabov,项目名称:debian-qpid-cpp,代码行数:57,代码来源:csharp.example.drain.cs

示例10: Main

        static int Main(string[] args) {
            Options options = new Options(args);

            Connection connection = null;
            try
            {
                connection = new Connection(options.Url, options.ConnectionOptions);
                connection.Open();
                Session session = connection.CreateSession();
                Sender sender = session.CreateSender(options.Address);
                Message message;
                if (options.Entries.Count > 0)
                {
                    Dictionary<string, object> content = new Dictionary<string, object>();
                    SetEntries(options.Entries, content);
                    message = new Message(content);
                }
                else
                {
                    message = new Message(options.Content);
                    message.ContentType = "text/plain";
                }
                Address replyToAddr = new Address(options.ReplyTo);

                Stopwatch stopwatch = new Stopwatch();
                TimeSpan timespan = new TimeSpan(0,0,options.Timeout);
                stopwatch.Start();
                for (int count = 0;
                    (0 == options.Count || count < options.Count) &&
                    (0 == options.Timeout || stopwatch.Elapsed <= timespan);
                    count++) 
                {
                    if ("" != options.ReplyTo) message.ReplyTo = replyToAddr;
                    string id = options.Id ;
                    if ("" == id) {
                        Guid g = Guid.NewGuid();
                        id = g.ToString();
                    }
                    string spoutid = id + ":" + count;
                    message.SetProperty("spout-id", spoutid);
                    sender.Send(message);
                }
                session.Sync();
                connection.Close();
                return 0;
            } catch (Exception e) {
                Console.WriteLine("Exception {0}.", e);
                if (null != connection)
                    connection.Close();
            }
            return 1;
        }
开发者ID:irinabov,项目名称:debian-qpid-cpp,代码行数:52,代码来源:csharp.example.spout.cs

示例11: Start

    void Start()
    {
        // Create the SignalR connection
        signalRConnection = new Connection(URI);

        // set event handlers
        signalRConnection.OnNonHubMessage += signalRConnection_OnNonHubMessage;
        signalRConnection.OnStateChanged += signalRConnection_OnStateChanged;
        signalRConnection.OnError += signalRConnection_OnError;

        // Start connecting to the server
        signalRConnection.Open();
    }
开发者ID:ideadreamDefy,项目名称:Defy,代码行数:13,代码来源:SimpleStreamingSample.cs

示例12: Main

        // csharp.map.receiver example
        //
        // Send an amqp/map message to amqp:tcp:localhost:5672 amq.direct/map_example
        // The map message 
        //
        static int Main(string[] args)
        {
            string url = "amqp:tcp:localhost:5672";
            string address = "message_queue; {create: always}";
            string connectionOptions = "";

            if (args.Length > 0)
                url = args[0];
            if (args.Length > 1)
                address = args[1];
            if (args.Length > 2)
                connectionOptions = args[2];

            //
            // Create and open an AMQP connection to the broker URL
            //
            Connection connection = new Connection(url);
            connection.Open();

            //
            // Create a session and a receiver fir the direct exchange using the
            // routing key "map_example".
            //
            Session session = connection.CreateSession();
            Receiver receiver = session.CreateReceiver(address);

            //
            // Fetch the message from the broker
            //
            Message message = receiver.Fetch(DurationConstants.MINUTE);

            //
            // Extract the structured content from the message.
            //
            Dictionary<string, object> content = new Dictionary<string, object>();
            message.GetContent(content);
            Console.WriteLine("{0}", message.AsString(content));

            //
            // Acknowledge the receipt of all received messages.
            //
            session.Acknowledge();

            //
            // Close the receiver and the connection.
            //
            receiver.Close();
            connection.Close();
            return 0;
        }
开发者ID:irinabov,项目名称:debian-qpid-cpp,代码行数:55,代码来源:csharp.map.receiver.cs

示例13: Start

    void Start()
    {
        // Connect to the StatusHub hub
        signalRConnection = new Connection(URI, "StatusHub");

        // General events
        signalRConnection.OnNonHubMessage += signalRConnection_OnNonHubMessage;
        signalRConnection.OnError += signalRConnection_OnError;
        signalRConnection.OnStateChanged += signalRConnection_OnStateChanged;

        // Set up a callback for Hub events
        signalRConnection["StatusHub"].OnMethodCall += statusHub_OnMethodCall;

        // Connect to the server
        signalRConnection.Open();
    }
开发者ID:ideadreamDefy,项目名称:Defy,代码行数:16,代码来源:ConnectionStatusSample.cs

示例14: Main

        static int Main(string[] args) {
            String url = "amqp:tcp:127.0.0.1:5672";
            String connectionOptions = "";

            if (args.Length > 0)
                url = args[0];
            if (args.Length > 1)
                connectionOptions = args[1];

            Connection connection = new Connection(url, connectionOptions);
            try
            {
                connection.Open();

                Session session = connection.CreateSession();

                Sender sender = session.CreateSender("service_queue");

                Address responseQueue = new Address("#response-queue; {create:always, delete:always}");
                Receiver receiver = session.CreateReceiver(responseQueue);

                String[] s = new String[] {
                    "Twas brillig, and the slithy toves",
                    "Did gire and gymble in the wabe.",
                    "All mimsy were the borogroves,",
                    "And the mome raths outgrabe."
                };

                Message request = new Message("");
                request.ReplyTo = responseQueue;

                for (int i = 0; i < s.Length; i++) {
                    request.SetContent(s[i]);
                    sender.Send(request);
                    Message response = receiver.Fetch();
                    Console.WriteLine("{0} -> {1}", request.GetContent(), response.GetContent());
                }
                connection.Close();
                return 0;
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception {0}.", e);
                connection.Close();
            }
            return 1;
        }
开发者ID:irinabov,项目名称:debian-qpid-cpp,代码行数:47,代码来源:csharp.example.client.cs

示例15: Main

        // Direct sender example
        //
        // Send 10 messages from localhost:5672, amq.direct/key
        // Messages are assumed to be printable strings.
        //
        static int Main(string[] args)
        {
            String host = "localhost:5672";
            String addr = "amq.direct/key";
            Int32 nMsg = 10;

            if (args.Length > 0)
                host = args[0];
            if (args.Length > 1)
                addr = args[1];
            if (args.Length > 2)
                nMsg = Convert.ToInt32(args[2]);

            Console.WriteLine("csharp.direct.sender");
            Console.WriteLine("host : {0}", host);
            Console.WriteLine("addr : {0}", addr);
            Console.WriteLine("nMsg : {0}", nMsg);
            Console.WriteLine();

            Connection connection = null;
            try
            {
                connection = new Connection(host);
                connection.Open();

                if (!connection.IsOpen) {
                    Console.WriteLine("Failed to open connection to host : {0}", host);
                } else {
                    Session session = connection.CreateSession();
                    Sender sender = session.CreateSender(addr);
                    for (int i = 0; i < nMsg; i++) {
                        Message message = new Message(String.Format("Test Message {0}", i));
                        sender.Send(message);
                    }
                    session.Sync();
                    connection.Close();
                    return 0;
                }
            } catch (Exception e) {
                Console.WriteLine("Exception {0}.", e);
                if (null != connection)
                    connection.Close();
            }
            return 1;
        }
开发者ID:irinabov,项目名称:debian-qpid-cpp,代码行数:50,代码来源:csharp.direct.sender.cs


注:本文中的Connection.Open方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。