Ejemplo n.º 1
0
        void SetupContextMenuAndShow(TreeNodeMouseClickEventArgs e)
        {
            mnuCtx.Items.Clear();
            int lvl = e.Node.Level;

            if (lvl == 0)
            {
                mnuCtx.Items.AddRange(new ToolStripItem[] { mnuSubRefresh });
            }

            else if (lvl == 1)
            {
                dbServ = (SSBIServer)e.Node.Tag;
                if (!dbServ.HasLoggedIn && !dbServ.IsTryingToConnect)
                {
                    mnuCtx.Items.AddRange(new ToolStripItem[] { mnuSubOpenConn });
                }
                else if (!dbServ.HasLoggedIn && dbServ.IsTryingToConnect)
                {
                    mnuCtx.Items.AddRange(new ToolStripItem[] { mnuSubOpenConn });
                    mnuSubOpenConn.Enabled = false;
                }
            }
            else if (lvl > 1)
            {
                mnuCtx.Items.AddRange(new ToolStripItem[] { mnuSubPaste });
            }


            //foreach (ToolStripItem ti in mnuCtx.Items)
            //  ti.Enabled = true;

            tv1.ContextMenuStrip = mnuCtx;
            tv1.ContextMenuStrip.Show(tv1, e.Location);
        }
Ejemplo n.º 2
0
 public login(SSBIServer serv)
 {
     InitializeComponent();
     this.Text = "Login";
     srv_cboAuth.Items.Clear();
     srv_cboAuth.Items.Add(SSBServerAuthentication.Integrated);
     srv_cboAuth.Items.Add(SSBServerAuthentication.Mixed);
     srv_cboAuth.SelectedIndex = 0;
     srv_txtName.Text          = serv.Name;
     srv_txtName.Enabled       = false;
 }
Ejemplo n.º 3
0
 public login(SSBIServer serv)
 {
     InitializeComponent();
       this.Text = "Login";
       srv_cboAuth.Items.Clear();
       srv_cboAuth.Items.Add(SSBServerAuthentication.Integrated);
       srv_cboAuth.Items.Add(SSBServerAuthentication.Mixed);
       srv_cboAuth.SelectedIndex = 0;
       srv_txtName.Text = serv.Name;
       srv_txtName.Enabled = false;
 }
Ejemplo n.º 4
0
        void tv1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            Cursor csr = Cursor.Current;

            Cursor.Current = Cursors.WaitCursor;
            TreeNode tn = e.Node;

            level            = tn.Level;
            btnPaste.Enabled = false;

            //servers
            if (level == 0)
            {
                dbServ = null;;
                dBase  = null;
            }

            //servername
            else if (level == 1)
            {
                dbServ = (SSBIServer)tn.Tag;
            }

            //dbname
            else if (level == 2)
            {
                dbServ           = (SSBIServer)tn.Parent.Tag;
                dBase            = (Database)tn.Tag;
                btnPaste.Enabled = ctrl == null;
            }

            //ssbobject-type
            else if (level == 3)
            {
                dbServ           = (SSBIServer)tn.Parent.Parent.Tag;
                dBase            = (Database)tn.Parent.Tag;
                btnPaste.Enabled = ctrl == null;
            }

            //ssbobject-type
            else if (level == 4)
            {
                dbServ           = (SSBIServer)tn.Parent.Parent.Parent.Tag;
                dBase            = (Database)tn.Parent.Parent.Tag;
                btnPaste.Enabled = true;
                objName          = tn.Text;
            }

            Cursor.Current = csr;
        }
Ejemplo n.º 5
0
        public static void SetUpTreeView(TreeView tv1, ICollection _servers, bool addServers)
        {
            TreeNode    tn           = null;
            TreeNode    selectedNode = null;
            ICollection servColl     = null;

            if (!addServers)
            {
                if (_servers != null)
                {
                    servers = _servers;
                }

                servColl = servers;
                tv1.Nodes.Clear();
                tn = new TreeNode("Servers");
                tv1.Nodes.Add(tn);

                selectedNode = tn;
            }
            else
            {
                PopulateServArrayFromTreeView(tv1);
                tn           = tv1.Nodes[0];
                servColl     = _servers;
                selectedNode = tv1.SelectedNode;
            }

            IEnumerator senum = servColl.GetEnumerator();

            while (senum.MoveNext())
            {
                SSBIServer serv = (SSBIServer)senum.Current;
                if (addServers && servNameArray.Contains(serv.Name))
                {
                    continue;
                }
                TreeNode tnserv = new TreeNode();
                tnserv.Text = serv.Name;
                tnserv.Tag  = serv;
                tn.Nodes.Add(tnserv);
                tnserv.Nodes.Add("");
            }

            tv1.SelectedNode = selectedNode;
        }
Ejemplo n.º 6
0
        static void ConnectCompleted(SSBIServer serv, Server srv, TreeView tv, TreeNode tn, bool success, string msg)
        {
            if (tv.InvokeRequired)
            {
                tv.Invoke(new ConnectCompletedDelegate(ConnectCompleted), new object[] { serv, srv, tv, tn, success, msg });
            }
            else
            {
                try {
                    if (success)
                    {
                        serv.HasLoggedIn       = true;
                        serv.SMOServer         = srv;
                        serv.IsTryingToConnect = false;
                        tn.Tag = serv;
                        if (tn == tv.SelectedNode)
                        {
                            tn.Expand();
                        }
                    }
                    else
                    {
                        MessageBox.Show(msg);
                    }
                }

                catch (FailedOperationException fe) {
                    smo.ShowException(fe);
                }

                catch (Exception e) {
                    smo.ShowException(e);
                }


                finally {
                    //connNode = null;
                    tn.ForeColor = Color.Black;
                    //toolStripStatusLabel1.Text = "Ready!";
                    serv.IsTryingToConnect = false;
                    tn.Tag  = serv;
                    tn.Text = serv.Name;
                }
            }
        }
Ejemplo n.º 7
0
        public static void Connect(TreeView tv, TreeNode connNode)
        {
            SSBIServer srv = (SSBIServer)connNode.Tag;

            if (!srv.HasLoggedIn)
            {
                if (GetLoginCredentials(srv))
                {
                    //toolStripStatusLabel1.Text = string.Format("Connecting to: {0}", srv.Name);
                    connNode.ForeColor    = Color.Gray;
                    srv.IsTryingToConnect = true;
                    connNode.Tag          = srv;
                    connNode.Text         = srv.Name + " - Connecting";
                    ConnectAsyncDelegate cd  = new ConnectAsyncDelegate(ConnectAsync);
                    IAsyncResult         iar = cd.BeginInvoke(srv, tv, connNode, null, cd);
                }
            }
        }
Ejemplo n.º 8
0
        public Form2(SsbEnum idx, SSBIServer srv, Database db, bool toEdit, object smob)
        {
            Cursor crs = Cursor.Current;
              Cursor.Current = Cursors.WaitCursor;
              InitializeComponent();
              isEdit = toEdit;
              if (isEdit)
            formText = "Edit";
              SetupMenus();
              SetUpEventHooks();
              ssbType = idx;
              SetUpTabs(idx);
              if (smob != null)
            objToUpdate = smob;

              _state = SsbState.Cancelled;

              if (srv != null) {
            dbServ = srv;
              }

              if (ssbType == SsbEnum.EndPoint) {
            db = ((SSBIDatabase)smo.GetObject2(dbServ, null, "master", SsbEnum.Database)).DataBase;
              }

              if (db!= null) {
            dBase = db;
              }

              SetUpTab();

              //we are editing
              if (isEdit && smob != null) {
            objToUpdate = smob;
            SetUpObject(smob);
              }
              if (ssbType == SsbEnum.CreateListing && smob != null)
            isDirty = true;
              else
            isDirty = false;
              this.DialogResult = DialogResult.Cancel;
              Cursor.Current = crs;
        }
Ejemplo n.º 9
0
        static void ConnectAsync(SSBIServer srv, TreeView tv, TreeNode connNode)
        {
            Server serv = null;

            try {
                ConnectDelegate cd  = new ConnectDelegate(smo.CreateServer2);
                IAsyncResult    iar = cd.BeginInvoke(srv, null, null);
                while (!iar.IsCompleted)
                {
                    //TVSetUp.SetStatusText(tv, toolStripStatusLabel1, string.Format("Connecting to: {0}", srv.Name));
                    Thread.Sleep(50);
                }

                serv = cd.EndInvoke(iar);
                ConnectCompleted(srv, serv, tv, connNode, true, null);
            }

            catch (Exception e) {
                ConnectCompleted(srv, serv, tv, connNode, false, e.Message);
            }
        }
Ejemplo n.º 10
0
        public static bool GetLoginCredentials(SSBIServer srv)
        {
            bool res = true;

            if (!srv.HasLoggedIn)
            {
                res = false;
                login frmLogin = new login(srv);
                if (frmLogin.ShowDialog() == DialogResult.OK)
                {
                    srv.Authentication = (SSBServerAuthentication)frmLogin.srv_cboAuth.SelectedItem;
                    if (srv.Authentication == SSBServerAuthentication.Mixed)
                    {
                        srv.UserId   = frmLogin.srv_txtUid.Text;
                        srv.Password = frmLogin.srv_txtPwd.Text;
                    }
                    res = true;
                }

                frmLogin.Dispose();
            }
            return(res);
        }
Ejemplo n.º 11
0
        static void RetrieveAndLoadObjects(SSBIServer s, Database db, TreeNode tnode, SsbEnum ssbType)
        {
            ICollection coll = smo.GetSSBObjects2(s, db, ssbType);
            IEnumerator en   = coll.GetEnumerator();

            while (en.MoveNext())
            {
                TreeNode tn = new TreeNode();
                tn.Text = en.Current.ToString();
                tn.Tag  = en.Current;
                tnode.Nodes.Add(tn);
            }
            if (ssbType == SsbEnum.Queu)
            {
                TreeNode     tn  = new TreeNode();
                ServiceQueue txQ = new ServiceQueue();
                //txQ.Parent.Parent = GetDatabaseFromTag(tn.Parent);
                txQ.Name = "sys.transmission_queue";
                tn.Text  = txQ.Name;
                tn.Tag   = txQ;
                tnode.Nodes.Add(tn);
            }
        }
Ejemplo n.º 12
0
        public static Server CreateServer2(SSBIServer serv)
        {
            ServerConnection conn = new ServerConnection();
            Server           srv  = null;

            //conn.ServerInstance
            conn.ServerInstance = serv.Name;
            if (serv.Authentication == SSBServerAuthentication.Integrated)
            {
                conn.LoginSecure = true;
            }
            else
            {
                conn.LoginSecure = false;
                conn.Login       = serv.UserId;
                conn.Password    = serv.Password;
            }
            try {
                conn.Connect();
                srv            = new Server(conn);
                serv.SMOServer = srv;
                return(srv);
            }

            catch (ConnectionFailureException e) {
                throw e;
            }



            finally {
                if (srv != null && srv.ConnectionContext.SqlConnectionObject.State == ConnectionState.Open)
                {
                    srv.ConnectionContext.Disconnect();
                }
            }
        }
Ejemplo n.º 13
0
        static void ConnectAsync(SSBIServer srv, TreeView tv, TreeNode connNode)
        {
            Server serv = null;
              try {
            ConnectDelegate cd = new ConnectDelegate(smo.CreateServer2);
            IAsyncResult iar = cd.BeginInvoke(srv, null, null);
            while (!iar.IsCompleted) {
              //TVSetUp.SetStatusText(tv, toolStripStatusLabel1, string.Format("Connecting to: {0}", srv.Name));
              Thread.Sleep(50);
            }

            serv = cd.EndInvoke(iar);
            ConnectCompleted(srv, serv, tv, connNode, true, null);
              }

              catch (Exception e) {
            ConnectCompleted(srv, serv, tv, connNode, false, e.Message);
              }
        }
Ejemplo n.º 14
0
        public static bool GetLoginCredentials(SSBIServer srv)
        {
            bool res = true;
              if (!srv.HasLoggedIn) {
            res = false;
            login frmLogin = new login(srv);
            if (frmLogin.ShowDialog() == DialogResult.OK) {
              srv.Authentication = (SSBServerAuthentication)frmLogin.srv_cboAuth.SelectedItem;
              if (srv.Authentication == SSBServerAuthentication.Mixed) {
            srv.UserId = frmLogin.srv_txtUid.Text;
            srv.Password = frmLogin.srv_txtPwd.Text;
              }
              res = true;

            }

            frmLogin.Dispose();
              }
              return res;
        }
Ejemplo n.º 15
0
        public static Server CreateServer2(SSBIServer serv)
        {
            ServerConnection conn = new ServerConnection();
              Server srv = null;
              //conn.ServerInstance
              conn.ServerInstance = serv.Name;
              if(serv.Authentication == SSBServerAuthentication.Integrated)
            conn.LoginSecure = true;
              else {
            conn.LoginSecure = false;
            conn.Login = serv.UserId;
            conn.Password = serv.Password;
              }
              try {
            conn.Connect();
            srv = new Server(conn);
            serv.SMOServer = srv;
            return srv;
              }

              catch (ConnectionFailureException e) {
            throw e;

              }

              finally {
            if (srv != null && srv.ConnectionContext.SqlConnectionObject.State == ConnectionState.Open)
              srv.ConnectionContext.Disconnect();

              }
        }
Ejemplo n.º 16
0
 public Form2(SsbEnum idx, SSBIServer srv, Database db)
     : this(idx, srv, db, false, null)
 {
 }
Ejemplo n.º 17
0
 public Form2(SsbEnum idx, SSBIServer srv)
     : this(idx, srv, null)
 {
 }
Ejemplo n.º 18
0
        void tv1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            Cursor csr = Cursor.Current;
              Cursor.Current = Cursors.WaitCursor;
              TreeNode tn = e.Node;
              level = tn.Level;
              btnPaste.Enabled = false;

              //servers
              if (level == 0) {
            dbServ = null; ;
            dBase = null;
              }

              //servername
              else if (level == 1) {
            dbServ = (SSBIServer)tn.Tag;
              }

              //dbname
              else if (level == 2) {
            dbServ = (SSBIServer)tn.Parent.Tag;
            dBase = (Database)tn.Tag;
            btnPaste.Enabled = ctrl == null;
              }

              //ssbobject-type
              else if (level == 3) {
            dbServ = (SSBIServer)tn.Parent.Parent.Tag;
            dBase = (Database)tn.Parent.Tag;
            btnPaste.Enabled = ctrl == null;

              }

              //ssbobject-type
              else if (level == 4) {
            dbServ = (SSBIServer)tn.Parent.Parent.Parent.Tag;
            dBase = (Database)tn.Parent.Parent.Tag;
            btnPaste.Enabled = true;
            objName = tn.Text;

              }

              Cursor.Current = csr;
        }
Ejemplo n.º 19
0
        public static bool ExpandNodes1(TreeView tv1, TreeNode tn, bool refresh, bool filterSsb, SsbEnum sType)
        {
            SsbEnum ssbType = SsbEnum.None;

            ssbType = sType;
            SSBIServer serv = null;
            bool       res  = true;

            int lvl = tn.Level;

            try {
                if (lvl < 1)
                {
                    ssbType = SsbEnum.None;
                }

                else if (lvl == 1)
                {
                    ssbType = SsbEnum.Server;
                    serv    = (SSBIServer)tn.Tag;
                    if (!serv.HasLoggedIn)
                    {
                        res = false;
                        Connect(tv1, tn);
                    }
                    //SetUpSSBObject(tn.Tag);
                }
                else if (lvl == 2 && !filterSsb)
                {
                    ssbType = SsbEnum.Database;
                }
                else if (lvl == 2 && filterSsb)
                {
                    ssbType = sType;
                }

                else if (lvl > 2 && !filterSsb)
                {
                    ssbType = (SsbEnum)tn.Index;
                }
                else if (lvl > 2 && filterSsb)
                {
                    ssbType = sType;
                }

                if (lvl != 1)
                {
                    TVSetUp.ExpandNodes(tv1, tn, ref ssbType);
                }
                else if (lvl == 1 && serv.HasLoggedIn)
                {
                    TVSetUp.ExpandNodes(tv1, tn, ref ssbType);
                }

                //if (lvl == 3 && tabControl1.Visible)
                //  tabControl1.Visible = false;

                return(res);
            }
            catch (Exception ex) {
                smo.ShowException(ex);
                return(false);
            }
        }
Ejemplo n.º 20
0
        internal static object GetObject2(SSBIServer s, Database db, string objName, SsbEnum index)
        {
            object smob = null;
              Server serv = null;
              Database db2 = null;
              ServiceBroker sb = null;
              try {

            serv = CreateServer2(s);
            s.SMOServer = serv;
            if (db != null) {
              db2 = serv.Databases[db.Name];
              sb = serv.Databases[db2.Name].ServiceBroker;
            }

            switch (index) {

              case SsbEnum.Server:
            smob = s;
            break;

              case SsbEnum.Database:
            db2 = serv.Databases[objName];
            smob = new SSBIDatabase(db2);
            //serv.ConnectionContext.Disconnect();
            break;

              case SsbEnum.MessageType:
            smob = sb.MessageTypes[objName];
            break;

              case SsbEnum.Contract:
            smob = sb.ServiceContracts[objName];
            break;

              case SsbEnum.Service:
            smob = sb.Services[objName];
            break;

              case SsbEnum.Queu:
            if(objName == "sys.transmission_queue") {
              ServiceQueue txQ = new ServiceQueue();
              txQ.Name = "sys.transmission_queue";
              txQ.Parent = sb;
              txQ.Schema = "sys";
              smob = txQ;
            }
            else
              smob = sb.Queues[objName];
            break;

              case SsbEnum.Route:
            smob = sb.Routes[objName];
            break;

              case SsbEnum.RemoteBinding:
            smob = sb.RemoteServiceBindings[objName];
            break;

              case SsbEnum.Conversation:
            smob = smo.GetConversationCollection(db, null, new Guid(objName)).Item(0);
            break;

            }

            if (smob == null) {
              string errMsg = string.Format("Can not retrieve {0}: {1}.\nIt may have been dropped/deleted.", index.ToString(), objName);
              throw new ApplicationException(errMsg);
            }

            return smob;
              }

              catch (NullReferenceException) {
            if (serv != null && db2 == null) {
              throw new ApplicationException(string.Format("Can not connect to database: {0}.\nIt may have been dropped/deleted.", db.Name));

            }

            return null;

              }

              catch (ConnectionFailureException e) {
            throw e;
            return null;
              }
              finally {
            serv.ConnectionContext.Disconnect();

              }
        }
Ejemplo n.º 21
0
        internal static ICollection GetSSBObjects2(SSBIServer serv, Database db, SsbEnum index)
        {
            ICollection ssbColl = null;
              ServiceBroker sb = null;
              Server s = null;
              try {
            s = serv.SMOServer;
            if(s == null)
              s = CreateServer2(serv);

            if (db != null) {
              db = s.Databases[db.Name];
              sb = db.ServiceBroker;
            }

            switch (index) {
              case SsbEnum.Server:
            ssbColl = s.Databases;
            break;
              case SsbEnum.Database:
            ssbColl = s.Databases;
            break;

              case SsbEnum.MessageType:
            ssbColl = sb.MessageTypes;
            break;
              case SsbEnum.Contract:
            ssbColl = sb.ServiceContracts;
            break;
              case SsbEnum.Queu:
            ssbColl = sb.Queues;

            break;
              case SsbEnum.Service:
            ssbColl = sb.Services;
            break;
              case SsbEnum.Route:
            ssbColl = sb.Routes;
            break;
              case SsbEnum.RemoteBinding:
            ssbColl = sb.RemoteServiceBindings;
            break;

              case SsbEnum.Conversation:
            ssbColl = GetConversationCollection(db, null);

            break;
            }
            return ssbColl;

              }
              catch (Exception e) {
            throw e;
              }
              finally {

            if (s != null)
              s.ConnectionContext.Disconnect();
              }
        }
Ejemplo n.º 22
0
        internal static void ExpandNodes(TreeView tv1, TreeNode tn, ref SsbEnum ssbType)
        {
            Cursor crs = Cursor.Current;

            Cursor.Current = Cursors.WaitCursor;
            SSBIServer serv = null;
            Database   db   = null;
            //dbName = null;
            //svrName = null;
            int lvl = tn.Level;

            try {
                if (lvl > 0)
                {
                    tn.Nodes.Clear();
                }

                //get databases
                if (lvl == 1)
                {
                    serv = (SSBIServer)tn.Tag;
                    DatabaseCollection dbColl = (DatabaseCollection)smo.GetSSBObjects2(serv, null, SsbEnum.Server);
                    foreach (Database db2 in dbColl)
                    {
                        TreeNode tndb = new TreeNode();
                        tndb.Text = db2.Name;
                        tndb.Tag  = db2;
                        tndb.Nodes.Add(new TreeNode(""));
                        tn.Nodes.Add(tndb);
                    }
                }
                //set up main broker objects
                else if (lvl == 2)
                {
                    //statusStrip1.Text = "Loading SSB Objects...";
                    if (ssbType == SsbEnum.Database)
                    {
                        tn.Nodes.Add(new TreeNode("Message Types"));
                        tn.Nodes.Add(new TreeNode("Message Contracts"));
                        tn.Nodes.Add(new TreeNode("Queues"));
                        tn.Nodes.Add(new TreeNode("Services"));
                        tn.Nodes.Add(new TreeNode("Routes"));
                        tn.Nodes.Add(new TreeNode("Remote Service Bindings"));
                        tn.Nodes.Add(new TreeNode("Conversations"));
                    }
                    else
                    {
                        if (ssbType == SsbEnum.MessageType)
                        {
                            tn.Nodes.Add(new TreeNode("Message Types"));
                        }
                        else if (ssbType == SsbEnum.Contract)
                        {
                            tn.Nodes.Add(new TreeNode("Message Contracts"));
                        }
                        else if (ssbType == SsbEnum.Queu)
                        {
                            tn.Nodes.Add(new TreeNode("Queues"));
                        }
                        else if (ssbType == SsbEnum.Service)
                        {
                            tn.Nodes.Add(new TreeNode("Services"));
                        }
                        else if (ssbType == SsbEnum.Route)
                        {
                            tn.Nodes.Add(new TreeNode("Routes"));
                        }
                        else if (ssbType == SsbEnum.RemoteBinding)
                        {
                            tn.Nodes.Add(new TreeNode("Remote Service Bindings"));
                        }
                        else if (ssbType == SsbEnum.Conversation)
                        {
                            tn.Nodes.Add(new TreeNode("Conversations"));
                        }
                    }

                    foreach (TreeNode tnChild in tn.Nodes)
                    {
                        tnChild.Nodes.Add(new TreeNode(""));
                    }
                }

                //retrieve objects for chosen main SSB Object
                else if (lvl == 3)
                {
                    //statusStrip1.Text = "Loading Objects...";
                    db = GetDatabaseFromTag(tn.Parent);
                    //db = (Database)tn.Parent.Tag;
                    serv = (SSBIServer)tn.Parent.Parent.Tag;
                    RetrieveAndLoadObjects(serv, db, tn, ssbType);
                }

                else if (lvl == 4)
                {
                    //statusStrip1.Text = "Loading Objects...";
                    TreeNode tnp = tn.Parent;
                    db = GetDatabaseFromTag(tn.Parent);
                    //db = (Database)tnp.Parent.Tag;
                    serv = (SSBIServer)tnp.Parent.Parent.Tag;
                    RetrieveAndLoadObjects(serv, db, tnp, ssbType);

                    foreach (TreeNode tne in tnp.Nodes)
                    {
                        if (tne.Text == tn.Text)
                        {
                            tv1.SelectedNode = tne;
                            break;
                        }
                    }
                }

                //if (lvl != 4)
                //tv1.SelectedNode = tn;
            }
            catch (Exception ex) {
                throw ex;
            }
        }
Ejemplo n.º 23
0
        internal static ICollection GetSSBObjects2(SSBIServer serv, Database db, SsbEnum index)
        {
            ICollection   ssbColl = null;
            ServiceBroker sb      = null;
            Server        s       = null;

            try {
                s = serv.SMOServer;
                if (s == null)
                {
                    s = CreateServer2(serv);
                }


                if (db != null)
                {
                    db = s.Databases[db.Name];
                    sb = db.ServiceBroker;
                }



                switch (index)
                {
                case SsbEnum.Server:
                    ssbColl = s.Databases;
                    break;

                case SsbEnum.Database:
                    ssbColl = s.Databases;
                    break;

                case SsbEnum.MessageType:
                    ssbColl = sb.MessageTypes;
                    break;

                case SsbEnum.Contract:
                    ssbColl = sb.ServiceContracts;
                    break;

                case SsbEnum.Queu:
                    ssbColl = sb.Queues;

                    break;

                case SsbEnum.Service:
                    ssbColl = sb.Services;
                    break;

                case SsbEnum.Route:
                    ssbColl = sb.Routes;
                    break;

                case SsbEnum.RemoteBinding:
                    ssbColl = sb.RemoteServiceBindings;
                    break;

                case SsbEnum.Conversation:
                    ssbColl = GetConversationCollection(db, null);

                    break;
                }
                return(ssbColl);
            }
            catch (Exception e) {
                throw e;
            }
            finally {
                if (s != null)
                {
                    s.ConnectionContext.Disconnect();
                }
            }
        }
Ejemplo n.º 24
0
        internal static object GetObject2(SSBIServer s, Database db, string objName, SsbEnum index)
        {
            object        smob = null;
            Server        serv = null;
            Database      db2  = null;
            ServiceBroker sb   = null;

            try {
                serv        = CreateServer2(s);
                s.SMOServer = serv;
                if (db != null)
                {
                    db2 = serv.Databases[db.Name];
                    sb  = serv.Databases[db2.Name].ServiceBroker;
                }

                switch (index)
                {
                case SsbEnum.Server:
                    smob = s;
                    break;

                case SsbEnum.Database:
                    db2  = serv.Databases[objName];
                    smob = new SSBIDatabase(db2);
                    //serv.ConnectionContext.Disconnect();
                    break;

                case SsbEnum.MessageType:
                    smob = sb.MessageTypes[objName];
                    break;

                case SsbEnum.Contract:
                    smob = sb.ServiceContracts[objName];
                    break;

                case SsbEnum.Service:
                    smob = sb.Services[objName];
                    break;

                case SsbEnum.Queu:
                    if (objName == "sys.transmission_queue")
                    {
                        ServiceQueue txQ = new ServiceQueue();
                        txQ.Name   = "sys.transmission_queue";
                        txQ.Parent = sb;
                        txQ.Schema = "sys";
                        smob       = txQ;
                    }
                    else
                    {
                        smob = sb.Queues[objName];
                    }
                    break;

                case SsbEnum.Route:
                    smob = sb.Routes[objName];
                    break;

                case SsbEnum.RemoteBinding:
                    smob = sb.RemoteServiceBindings[objName];
                    break;

                case SsbEnum.Conversation:
                    smob = smo.GetConversationCollection(db, null, new Guid(objName)).Item(0);
                    break;
                }

                if (smob == null)
                {
                    string errMsg = string.Format("Can not retrieve {0}: {1}.\nIt may have been dropped/deleted.", index.ToString(), objName);
                    throw new ApplicationException(errMsg);
                }

                return(smob);
            }

            catch (NullReferenceException) {
                if (serv != null && db2 == null)
                {
                    throw new ApplicationException(string.Format("Can not connect to database: {0}.\nIt may have been dropped/deleted.", db.Name));
                }

                return(null);
            }

            catch (ConnectionFailureException e) {
                throw e;
                return(null);
            }
            finally {
                serv.ConnectionContext.Disconnect();
            }
        }
Ejemplo n.º 25
0
        static void ConnectCompleted(SSBIServer serv, Server srv, TreeView tv, TreeNode tn, bool success, string msg)
        {
            if (tv.InvokeRequired) {
            tv.Invoke(new ConnectCompletedDelegate(ConnectCompleted), new object[] { serv, srv, tv, tn, success, msg });
              }
              else {

            try {
              if (success) {
            serv.HasLoggedIn = true;
            serv.SMOServer = srv;
            serv.IsTryingToConnect = false;
            tn.Tag = serv;
            if (tn == tv.SelectedNode) {
              tn.Expand();
            }
              }
              else {
            MessageBox.Show(msg);
              }

            }

            catch (FailedOperationException fe) {
              smo.ShowException(fe);

            }

            catch (Exception e) {
              smo.ShowException(e);

            }

            finally {
              //connNode = null;
              tn.ForeColor = Color.Black;
              //toolStripStatusLabel1.Text = "Ready!";
              serv.IsTryingToConnect = false;
              tn.Tag = serv;
              tn.Text = serv.Name;
            }

              }
        }
Ejemplo n.º 26
0
 static void RetrieveAndLoadObjects(SSBIServer s, Database db, TreeNode tnode, SsbEnum ssbType)
 {
     ICollection coll = smo.GetSSBObjects2(s, db, ssbType);
       IEnumerator en = coll.GetEnumerator();
       while (en.MoveNext()) {
     TreeNode tn = new TreeNode();
     tn.Text = en.Current.ToString();
     tn.Tag = en.Current;
     tnode.Nodes.Add(tn);
       }
       if (ssbType == SsbEnum.Queu) {
     TreeNode tn = new TreeNode();
     ServiceQueue txQ = new ServiceQueue();
     //txQ.Parent.Parent = GetDatabaseFromTag(tn.Parent);
     txQ.Name = "sys.transmission_queue";
     tn.Text = txQ.Name;
     tn.Tag = txQ;
     tnode.Nodes.Add(tn);
       }
 }
Ejemplo n.º 27
0
        void SetupContextMenuAndShow(TreeNodeMouseClickEventArgs e)
        {
            mnuCtx.Items.Clear();
              int lvl = e.Node.Level;

              if(lvl == 0)
            mnuCtx.Items.AddRange(new ToolStripItem[] { mnuSubRefresh });

              else if (lvl == 1) {
              dbServ = (SSBIServer)e.Node.Tag;
              if (!dbServ.HasLoggedIn && !dbServ.IsTryingToConnect)
            mnuCtx.Items.AddRange(new ToolStripItem[] { mnuSubOpenConn });
              else if (!dbServ.HasLoggedIn && dbServ.IsTryingToConnect) {
            mnuCtx.Items.AddRange(new ToolStripItem[] { mnuSubOpenConn });
            mnuSubOpenConn.Enabled = false;
              }
            }
              else if (lvl > 1)
            mnuCtx.Items.AddRange(new ToolStripItem[] { mnuSubPaste });

              //foreach (ToolStripItem ti in mnuCtx.Items)
              //  ti.Enabled = true;

              tv1.ContextMenuStrip = mnuCtx;
              tv1.ContextMenuStrip.Show(tv1, e.Location);
        }