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


C# Connection.Dispose方法代码示例

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


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

示例1: OnConnectionDisposed

        public void OnConnectionDisposed()
        {
            var consumerChannel1 = new Mock<IInboundChannel>();
            var consumer1 = new FakeConsumerBase(consumerChannel1.Object,
                                                 new Mock<IOutboundChannel>().Object,
                                                 default(Queue),
                                                 null,
                                                 null);
            var consumerChannel2 = new Mock<IInboundChannel>();
            var consumer2 = new FakeConsumerBase(consumerChannel2.Object,
                                                 new Mock<IOutboundChannel>().Object,
                                                 default(Queue),
                                                 null,
                                                 null);
            var outboundModel = new Mock<IModel>();
            var connection = new Mock<RabbitMQ.Client.IConnection>();
            var amqpConnection = new Connection(connection.Object,
                                                new List<ConsumerBase> { consumer1, consumer2 },
                                                new ReliableOutboundChannel(outboundModel.Object, null, null, null),
                                                null);
            amqpConnection.Dispose();

            connection.Verify(_ => _.Dispose(), Times.Once);
            outboundModel.Verify(_ => _.Dispose(), Times.Once);
            consumerChannel1.Verify(_ => _.Dispose(), Times.Once);
            consumerChannel2.Verify(_ => _.Dispose(), Times.Once);
        }
开发者ID:pichierri,项目名称:Carrot,代码行数:27,代码来源:ResourceManagement.cs

示例2: Button_Click_1

 private void Button_Click_1(object sender, RoutedEventArgs e)
 {
     Connection c = new Connection();
     c.NonQuery("DELETE FROM Slownik");
     
     FillDataGrid();
     c.Dispose();
 }
开发者ID:Zimex,项目名称:Tess,代码行数:8,代码来源:Dictionary.xaml.cs

示例3: Button_Click

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if(addEntryTextBox.Text!="")
            {
                Connection c = new Connection();
                c.NonQuery("INSERT INTO Slownik VALUES ('"+addEntryTextBox.Text+"') ");
                addEntryTextBox.Text = "";
                FillDataGrid();
                c.Dispose();

            }
        }
开发者ID:Zimex,项目名称:Tess,代码行数:12,代码来源:Dictionary.xaml.cs

示例4: DisposeEnablesAndResetsAllProxies

        public void DisposeEnablesAndResetsAllProxies()
        {
            var connection = new Connection(resetAllToxicsAndProxiesOnClose: true);

            var client = connection.Client();

            var proxy = client.FindProxy("one");
            proxy.Enabled = false;
            proxy.Update();

            connection.Dispose();

            var proxyCopy = client.FindProxy("one");
            Assert.True(proxyCopy.Enabled);
        }
开发者ID:OpenDataSpace,项目名称:Toxiproxy.Net,代码行数:15,代码来源:ConnectionTests.cs

示例5: FortsTrade

        public FortsTrade()
        {
            try
            {
                Plaza = new MPlaza();
                Plaza.Init();

                if (connection != null)
                    connection.Dispose();
                if (listener != null)
                    listener.Dispose();
                if (pub != null)
                    pub.Dispose();

                connection = new Connection("p2tcp://127.0.0.1:4001;app_name=FT");

                pub = new Publisher(connection, "p2mq://FORTS_SRV;category=FORTS_MSG;name=Pub;timeout=5000");

                listener = new Listener(connection, "p2mqreply://;ref=Pub;scheme=|FILE|Ini\\FutMsg.ini|FutMsg");
                listener.Handler += new Listener.MessageHandler(MessageHandlerAggr);
                lisPubReplState = "";

                ConnState = State.Closed;
                ListState = State.Closed;
                PubState = State.Closed;
                errMessage = "";
            }
            catch (Exception err)
            {
                ConnState = State.Closed;
                ListState = State.Closed;

                if (pub != null)
                    pub.Dispose();
                if (connection != null)
                    connection.Dispose();
                if (listener != null)
                    listener.Dispose();

                Plaza.Deinit();

                errMessage = err.Message;
                throw err;
            }
        }
开发者ID:Groxan,项目名称:RepVol,代码行数:45,代码来源:FortsTrade.cs

示例6: CloseConnection

 public static void CloseConnection(Connection conn)
 {
     bool isRelease = false;
     try
     {
         if (conn != null)
         {
             conn.Close();
             isRelease = true;
         }
     }
     finally
     {
         if (conn != null && !isRelease)
         {
             conn.Dispose();
             conn = null;
         }
     }
 }
开发者ID:Cloud33,项目名称:K2.Tasks-Service,代码行数:20,代码来源:K2WorkflowUtility.cs

示例7: FortsDrinks

        public FortsDrinks(int Depth)
        {
            try
            {
                Plaza = new MPlaza();
                Plaza.Init();

                if (connection != null)
                    connection.Dispose();
                if (listener != null)
                    listener.Dispose();

                connection = new Connection("p2tcp://127.0.0.1:4001;app_name=FDR");

                listener = new Listener(connection, "p2repl://FORTS_FUTAGGR" + Depth + "_REPL;scheme=|FILE|Ini\\FutAggr.ini|FutAggr");
                listener.Handler += new Listener.MessageHandler(MessageHandlerAggr);
                lisFutAggrReplState = "";

                ConnState = State.Closed;
                ListState = State.Closed;
                errMessage = "";
            }
            catch (Exception err)
            {
                ConnState = State.Closed;
                ListState = State.Closed;

                if (connection != null)
                    connection.Dispose();
                if (listener != null)
                    listener.Dispose();

                Plaza.Deinit();

                errMessage = err.Message;
                throw err;
            }
        }
开发者ID:Groxan,项目名称:RepVol,代码行数:38,代码来源:FortsDrinks.cs

示例8: SpotCommon

        public SpotCommon()
        {
            try
            {
                Plaza = new MPlaza();
                Plaza.Init();

                if (connection != null)
                    connection.Dispose();
                if (listener != null)
                    listener.Dispose();

                connection = new Connection("p2tcp://127.0.0.1:4001;app_name=SC321");

                listener = new Listener(connection, "p2repl://MCXSPOT_MDCOMMON_REPL");//;scheme=|FILE|Ini\\SpotCommon.ini|SpotCommon");
                listener.Handler += new Listener.MessageHandler(MessageHandlerInfo);
                listenerReplState = "";

                ConnState = State.Closed;
                ListState = State.Closed;
                errMessage = "";
            }
            catch (Exception err)
            {
                ConnState = State.Closed;
                ListState = State.Closed;

                if (connection != null)
                    connection.Dispose();
                if (listener != null)
                    listener.Dispose();

                Plaza.Deinit();

                errMessage = err.Message;
                throw err;
            }
        }
开发者ID:Groxan,项目名称:RepVol,代码行数:38,代码来源:SpotCommon.cs

示例9: FortsCommon

        public FortsCommon()
        {
            try
            {
                Plaza = new MPlaza();
                Plaza.Init();

                if (connection != null)
                    connection.Dispose();
                if (listener != null)
                    listener.Dispose();

                connection = new Connection("p2tcp://127.0.0.1:4001;app_name=FC");

                listener = new Listener(connection, "p2repl://FORTS_FUTCOMMON_REPL;scheme=|FILE|Ini\\FutComm.ini|FutComm");
                listener.Handler += new Listener.MessageHandler(MessageHandlerComm);
                lisFutCommReplState = "";

                ConnState = State.Closed;
                ListState = State.Closed;
                errMessage = "";
            }
            catch (Exception err)
            {
                ConnState = State.Closed;
                ListState = State.Closed;

                if (connection != null)
                    connection.Dispose();
                if (listener != null)
                    listener.Dispose();

                Plaza.Deinit();

                errMessage = err.Message;
                throw err;
            }
        }
开发者ID:Groxan,项目名称:RepVol,代码行数:38,代码来源:FortsCommon.cs

示例10: CurrDrinks

        public CurrDrinks()
        {
            try
            {
                Plaza = new MPlaza();
                Plaza.Init();

                if (connection != null)
                    connection.Dispose();
                if (listener != null)
                    listener.Dispose();

                connection = new Connection("p2tcp://127.0.0.1:4001;app_name=CDR123");

                listener = new Listener(connection, "p2repl://MCXCC_AGGR_REPL;scheme=|FILE|Ini\\CurrDrink.ini|CurrDrink");
                listener.Handler += new Listener.MessageHandler(MessageHandlerInfo);
                listenerReplState = "";

                ConnState = State.Closed;
                ListState = State.Closed;
                errMessage = "";
            }
            catch (Exception err)
            {
                ConnState = State.Closed;
                ListState = State.Closed;

                if (connection != null)
                    connection.Dispose();
                if (listener != null)
                    listener.Dispose();

                Plaza.Deinit();

                errMessage = err.Message;
                throw err;
            }
        }
开发者ID:Groxan,项目名称:RepVol,代码行数:38,代码来源:CurrDrinks.cs

示例11: GetWorklistItems

        public DataTable GetWorklistItems(Dictionary<string, object> properties, Dictionary<string, object> parameters)
        {
            bool impersonate = false;
            string impersonateUser = "";
            ConnectionSetup connectSetup = new ConnectionSetup();
            connectSetup.ConnectionString = _connectionString;

            if (properties.ContainsKey("UserName"))
            {
                if (!(string.IsNullOrEmpty(properties["UserName"].ToString())))
                {
                    connectSetup.ConnectionString = _connectionstringImpersonate;
                    impersonateUser = properties["UserName"].ToString();
                    impersonate = true;
                }
                else
                    connectSetup.ConnectionString = _connectionString;
            }

            WorklistCriteria criteria = null;
            if (properties.Count > 0)
                criteria = GetWorklistCriteria(properties);

            Connection cnn = new Connection();
            try
            {
                cnn.Open(connectSetup);
                if (impersonate)
                    cnn.ImpersonateUser(impersonateUser);

                DataTable dt = GetResultTable();

                Worklist worklist;
                if ((criteria != null) && (criteria.Filters.GetLength(0) > 0))
                    worklist = cnn.OpenWorklist(criteria);
                else
                    worklist = cnn.OpenWorklist();
                foreach (WorklistItem item in worklist)
                {
                    DataRow row = dt.NewRow();
                    row["AllocatedUser"] = item.AllocatedUser;
                    row["Data"] = item.Data;
                    row["ID"] = item.ID;
                    row["Link"] = "<hyperlink><link>" + HttpUtility.HtmlEncode(item.Data) + "</link><display>Open</display></hyperlink>";
                    row["SerialNumber"] = item.SerialNumber;
                    row["Status"] = item.Status;
                    row["ActivityID"] = item.ActivityInstanceDestination.ActID;
                    row["ActivityInstanceID"] = item.ActivityInstanceDestination.ActInstID;
                    row["ActivityName"] = item.ActivityInstanceDestination.Name;
                    row["Priority"] = item.ActivityInstanceDestination.Priority;
                    row["StartDate"] = item.EventInstance.StartDate;
                    row["ActivityInstanceDestinationID"] = item.ActivityInstanceDestination.ID;
                    row["ProcessInstanceID"] = item.ProcessInstance.ID;
                    row["ProcessFullName"] = item.ProcessInstance.FullName;
                    row["ProcessName"] = item.ProcessInstance.Name;
                    row["Folio"] = item.ProcessInstance.Folio;
                    row["EventInstanceName"] = item.EventInstance.Name;
                    dt.Rows.Add(row);
                }
                if (impersonate)
                    cnn.RevertUser();
                cnn.Close();
                cnn.Dispose();
                return dt;

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
开发者ID:hoshyK2,项目名称:K2-Worklist-Service-Broker,代码行数:71,代码来源:BasicWorklistItem.cs

示例12: ReleaseConnection

 protected virtual void ReleaseConnection(Connection connection)
 {
     if (fConnectionPool != null)
         fConnectionPool.ReleaseConnection(connection);
     else
         connection.Dispose();
 }
开发者ID:nolith,项目名称:internetpack,代码行数:7,代码来源:Client.cs

示例13: MInfo

        public MInfo(string Name = "")
        {
            try
            {
                PlazaInit = new MPlazaInit();
                PlazaInit.Init();

                mtx = new Mutex();
                Instruments = new List<Instrument>();
                Session = new SessionInfo();
                Account = new AccountInfo();
                Status = MPlazaStatus.Stoped;

                connFutInfo = new Connection("p2tcp://127.0.0.1:4001;app_name=FI" + Name);

                lisCurrInfo = new Listener(connFutInfo, "p2repl://MCXCC_INFO_REPL;scheme=|FILE|Ini\\CurrInfo.ini|CurrInfo");
                lisCurrInfo.Handler += new Listener.MessageHandler(MessageHandlerInfoCurr);
                lisCurrInfoReplState = "";

                lisSpotInfo = new Listener(connFutInfo, "p2repl://MCXSPOT_INFO_REPL;scheme=|FILE|Ini\\SpotInfo.ini|SpotInfo");
                lisSpotInfo.Handler += new Listener.MessageHandler(MessageHandlerInfoSpot);
                lisSpotInfoReplState = "";

                lisFutInfo = new Listener(connFutInfo, "p2repl://FORTS_FUTINFO_REPL;scheme=|FILE|Ini\\FutInfo.ini|FutInfo");
                lisFutInfo.Handler += new Listener.MessageHandler(MessageHandlerInfo);
                lisFutInfoReplState = "";

                lisFutPos = new Listener(connFutInfo, "p2repl://FORTS_POS_REPL;scheme=|FILE|Ini\\FutPos.ini|FutPos");
                lisFutPos.Handler += new Listener.MessageHandler(MessageHandlerPos);
                lisFutPosReplState = "";

                lisFutPart = new Listener(connFutInfo, "p2repl://FORTS_PART_REPL;scheme=|FILE|Ini\\FutPart.ini|FutPart");
                lisFutPart.Handler += new Listener.MessageHandler(MessageHandlerPart);
                lisFutPartReplState = "";

                lisFutVM = new Listener(connFutInfo, "p2repl://FORTS_VM_REPL;scheme=|FILE|Ini\\FutVM.ini|FutVM");
                lisFutVM.Handler += new Listener.MessageHandler(MessageHandlerVM);
                lisFutVMReplState = "";

                errMessage = "";
            }
            catch (Exception err)
            {
                mtx.Close();

                if (lisSpotInfo != null)
                    lisSpotInfo.Dispose();
                if (lisCurrInfo != null)
                    lisCurrInfo.Dispose();
                if (lisFutInfo != null)
                    lisFutInfo.Dispose();
                if (lisFutPos != null)
                    lisFutPos.Dispose();
                if (lisFutPart != null)
                    lisFutPart.Dispose();
                if (lisFutVM != null)
                    lisFutVM.Dispose();

                if (connFutInfo != null)
                    connFutInfo.Dispose();

                PlazaInit.Deinit();
                errMessage = err.Message;
                throw err;
            }
        }
开发者ID:Groxan,项目名称:RepVol,代码行数:66,代码来源:MInfo.cs

示例14: Execute


//.........这里部分代码省略.........
            xmlName.InnerText = originatorUserEntity["domainname"] != null ? originatorUserEntity["domainname"].ToString() : "";
            xmlItem.AppendChild(xmlName);

            xmlName = EntityDoc.CreateElement("UserDisplayName");
            xmlName.InnerText = originatorUserEntity["fullname"] != null ? originatorUserEntity["fullname"].ToString() : "";
            xmlItem.AppendChild(xmlName);

            //Add Item to main doc
            EntElement.AppendChild(xmlItem);

            EntityDoc.AppendChild(EntElement);

            //Release node objects
            EntElement = null;
            xmlName = null;

            #endregion Create XML Context

            conn = new Connection();
            //procInst = new ProcessInstance();

            try
            {
                ConnectionSetup connectSetup = new ConnectionSetup();
                connectSetup.ConnectionString = K2WorkflowServerConnectionString;

                conn.Open(connectSetup);

                if (originatorUserEntity != null && originatorUserEntity["domainname"] != null)
                { 
                    conn.ImpersonateUser(originatorUserEntity["domainname"].ToString());
                }

                //Create new process instance
                procInst = conn.CreateProcessInstance(K2ProcessName);

                //Set CRM context field value
                if (!string.IsNullOrEmpty(K2ContextXMLDataField))
                {
                    try
                    {
                        procInst.XmlFields[K2ContextXMLDataField].Value = EntityDoc.OuterXml.ToString();
                    }
                    catch (Exception ex)
                    {
                        System.Diagnostics.EventLog.WriteEntry("SourceCode.Logging.Extension.EventLogExtension", "K2 CRM Plugin - Entity Name - " + context.PrimaryEntityName.ToString() + " - " + "Error writing to XMLField " + K2ContextXMLDataField + " :::: " + ex.Message, System.Diagnostics.EventLogEntryType.Error);
                    }
                }
                if (!string.IsNullOrEmpty(K2EntityIdDataField))
                {
                    try
                    {
                        procInst.DataFields[K2EntityIdDataField].Value = context.PrimaryEntityId;
                    }
                    catch (Exception ex)
                    {
                        System.Diagnostics.EventLog.WriteEntry("SourceCode.Logging.Extension.EventLogExtension", "K2 CRM Plugin - Entity Name - " + context.PrimaryEntityName.ToString() + " - " + "Error writing to DataField " + K2EntityIdDataField + " :::: " + ex.Message, System.Diagnostics.EventLogEntryType.Error);
                    }

                }
                if (!string.IsNullOrEmpty(K2EntityNameDataField))
                {
                    try
                    {
                        procInst.DataFields[K2EntityNameDataField].Value = context.PrimaryEntityName.ToLower();
                    }
                    catch (Exception ex)
                    {
                        System.Diagnostics.EventLog.WriteEntry("SourceCode.Logging.Extension.EventLogExtension", "K2 CRM Plugin - Entity Name - " + context.PrimaryEntityName.ToString() + " - " + "Error writing to DataField " + K2EntityNameDataField + " :::: " + ex.Message, System.Diagnostics.EventLogEntryType.Error);
                    }
                }
                // start the K2 process
                conn.StartProcessInstance(procInst);

                try
                {
                    System.Diagnostics.EventLog.WriteEntry("SourceCode.Logging.Extension.EventLogExtension", "Process Started: " + K2ProcessName, System.Diagnostics.EventLogEntryType.Information);
                }
                catch { }

            }
            catch (Exception ex)
            {
                System.Diagnostics.EventLog.WriteEntry("SourceCode.Logging.Extension.EventLogExtension", "Entity Name - " + context.PrimaryEntityName.ToString() + " - " + ex.Message, System.Diagnostics.EventLogEntryType.Error);
                throw;
            }
            finally
            {
                if (service != null)
                    service = null;

                if (conn != null)
                    conn.Dispose();
                    conn = null;

                if (procInst != null)
                    procInst = null;
                EntityDoc = null;
            }
        }
开发者ID:jonnoking,项目名称:K2-Dynamics-CRM-Extensions,代码行数:101,代码来源:K2CRMWorkflowActivity.cs

示例15: MPlaza

        public MPlaza(bool Common, bool Deals, bool Drinks, bool Trade, int Depth = 5)
        {
            try
            {
                #region Init
                //CGate.Open("ini=Ini/MPlaza.ini;key=IskCq8sT1t1IlrEZjivBT5ZNlOGXoIV");
                CGate.Open("ini=Ini/MPlaza.ini;key=11111111");

                connFutInfo = new Connection("p2tcp://127.0.0.1:4001;app_name=FI");

                lisFutInfo = new Listener(connFutInfo, "p2repl://FORTS_FUTINFO_REPL;scheme=|FILE|Ini\\FutInfo.ini|FutInfo");
                lisFutInfo.Handler += new Listener.MessageHandler(MessageHandlerInfo);
                lisFutInfoReplState = "";

                lisFutPos = new Listener(connFutInfo, "p2repl://FORTS_POS_REPL;scheme=|FILE|Ini\\FutPos.ini|FutPos");
                lisFutPos.Handler += new Listener.MessageHandler(MessageHandlerPos);
                lisFutPosReplState = "";

                lisFutPart = new Listener(connFutInfo, "p2repl://FORTS_PART_REPL;scheme=|FILE|Ini\\FutPart.ini|FutPart");
                lisFutPart.Handler += new Listener.MessageHandler(MessageHandlerPart);
                lisFutPartReplState = "";

                lisFutVM = new Listener(connFutInfo, "p2repl://FORTS_VM_REPL;scheme=|FILE|Ini\\FutVM.ini|FutVM");
                lisFutVM.Handler += new Listener.MessageHandler(MessageHandlerVM);
                lisFutVMReplState = "";

                if (Common)
                {
                    connFutCommon = new Connection("p2tcp://127.0.0.1:4001;app_name=FC");
                    lisFutCommon = new Listener(connFutCommon, "p2repl://FORTS_FUTCOMMON_REPL;scheme=|FILE|Ini\\FutComm.ini|FutComm");
                    lisFutCommon.Handler += new Listener.MessageHandler(MessageHandlerComm);
                    lisFutCommReplState = "";
                }

                if (Deals)
                {
                    connFutDeals = new Connection("p2tcp://127.0.0.1:4001;app_name=FDE");
                    lisFutDeals = new Listener(connFutDeals, "p2repl://FORTS_FUTTRADE_REPL;scheme=|FILE|Ini\\FutTrade.ini|FutTrade");
                    lisFutDeals.Handler += new Listener.MessageHandler(MessageHandlerDeals);
                    lisFutDealsReplState = "";
                }

                if (Drinks)
                {
                    connFutDrinks = new Connection("p2tcp://127.0.0.1:4001;app_name=FDR");
                    lisFutDrinks = new Listener(connFutDrinks, "p2repl://FORTS_FUTAGGR" + Depth + "_REPL;scheme=|FILE|Ini\\FutAggr.ini|FutAggr");
                    lisFutDrinks.Handler += new Listener.MessageHandler(MessageHandlerDrinks);
                    lisFutDrinksReplState = "";
                }

                if (Trade)
                {
                    connFutTrade = new Connection("p2tcp://127.0.0.1:4001;app_name=FT");
                    pub = new Publisher(connFutTrade, "p2mq://FORTS_SRV;category=FORTS_MSG;name=Pub;timeout=5000");

                    lisFutTrade = new Listener(connFutTrade, "p2mqreply://;ref=Pub;scheme=|FILE|Ini\\FutMsg.ini|FutMsg");
                    lisFutTrade.Handler += new Listener.MessageHandler(MessageHandlerTrade);
                    lisPubReplState = "";
                }
                #endregion
                errMessage = "";
            }
            catch (Exception err)
            {
                #region Deinit
                if (connFutInfo != null)
                    connFutInfo.Dispose();
                if (connFutCommon != null)
                    connFutCommon.Dispose();
                if (connFutDeals != null)
                    connFutDeals.Dispose();
                if (connFutDrinks != null)
                    connFutDrinks.Dispose();
                if (connFutTrade != null)
                    connFutTrade.Dispose();

                if (pub != null)
                    pub.Dispose();

                if (lisFutInfo != null)
                    lisFutInfo.Dispose();
                if (lisFutPos != null)
                    lisFutPos.Dispose();
                if (lisFutPart != null)
                    lisFutPart.Dispose();
                if (lisFutVM != null)
                    lisFutVM.Dispose();
                if (lisFutCommon != null)
                    lisFutCommon.Dispose();
                if (lisFutDeals != null)
                    lisFutDeals.Dispose();
                if (lisFutDrinks != null)
                    lisFutDrinks.Dispose();
                if (lisFutTrade != null)
                    lisFutTrade.Dispose();

                CGate.Close();
                #endregion
                errMessage = err.Message;
                throw err;
//.........这里部分代码省略.........
开发者ID:Groxan,项目名称:RepVol,代码行数:101,代码来源:Main.cs


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