Пример #1
0
        internal static SSBIConversationCollection GetConversationCollection(Database db, BrokerService bServ, Guid handle)
        {
            SqlConnection conn = null;
            int           servid;

            conn = CreateNewConnection(db);

            SqlCommand cmd = conn.CreateCommand();

            cmd.CommandText = sqlConversation;

            if (bServ != null)
            {
                servid           = bServ.ID;
                cmd.CommandText += " and se.service_id = @id";
                cmd.Parameters.Add("@id", SqlDbType.Int, 4);
                cmd.Parameters["@id"].Value = servid;
            }

            if (handle != Guid.Empty)
            {
                cmd.CommandText += " and se.conversation_handle = @h";
                cmd.Parameters.Add("@h", SqlDbType.UniqueIdentifier);
                cmd.Parameters["@h"].Value = handle;
            }

            if (conn.Database != db.Name)
            {
                conn.ChangeDatabase(db.Name);
            }

            SqlDataReader dr = cmd.ExecuteReader();
            SSBIConversationCollection scColl = new SSBIConversationCollection();

            while (dr.Read())
            {
                string srvName = dr["service"].ToString();
                if (bServ == null)
                {
                    bServ = CreateSMOService(db, srvName);
                }
                SSBIConversation sc = new SSBIConversation(bServ, dr);
                scColl.Add(sc);
            }

            conn.Close();

            return(scColl);
        }
Пример #2
0
        internal static SSBIConversationCollection GetConversationCollection(Database db, BrokerService bServ, Guid handle)
        {
            SqlConnection conn = null;
              int servid;
              conn = CreateNewConnection(db);

              SqlCommand cmd = conn.CreateCommand();
              cmd.CommandText = sqlConversation;

              if (bServ != null) {
            servid = bServ.ID;
            cmd.CommandText += " and se.service_id = @id";
            cmd.Parameters.Add("@id", SqlDbType.Int, 4);
            cmd.Parameters["@id"].Value = servid;
              }

              if (handle != Guid.Empty) {
            cmd.CommandText += " and se.conversation_handle = @h";
            cmd.Parameters.Add("@h", SqlDbType.UniqueIdentifier);
            cmd.Parameters["@h"].Value = handle;
              }

              if (conn.Database != db.Name)
            conn.ChangeDatabase(db.Name);

              SqlDataReader dr = cmd.ExecuteReader();
              SSBIConversationCollection scColl = new SSBIConversationCollection();
              while (dr.Read()) {
            string srvName = dr["service"].ToString();
            if(bServ == null)
              bServ = CreateSMOService(db, srvName);
            SSBIConversation sc = new SSBIConversation(bServ, dr);
            scColl.Add(sc);
              }

              conn.Close();

              return scColl;
        }