Esempio n. 1
0
        ConnectionManager page_GetSelectedConnectionManager(object sender, ConnectionManagerMappingEventArgs args)
        {
            this.ClearErrors();

            try
            {
                ConnectionManagerElement cme = args.ConnectionManagerElement;

                if (cme != null && this.Connections != null)
                {
                    foreach (ConnectionManager cm in this.Connections)
                    {
                        if (cm.ID.Equals(cme.ID, StringComparison.OrdinalIgnoreCase))
                        {
                            args.ConnectionManagerInstance = cm;
                            return(cm);
                        }
                    }
                }

                return(null);
            }
            catch (Exception ex)
            {
                this.ReportErrors(ex);
                return(null);
            }
        }
Esempio n. 2
0
        private void LoadContainers(ConnectionManagerElement cme)
        {
            this.cmbContainerID.Items.Clear();

            ConnectionManagerMappingEventArgs args = new ConnectionManagerMappingEventArgs();

            args.ConnectionManagerElement = cme;
            ConnectionManager cm = this.GetSelectedConnectionManager(this, args);

            try
            {
                Microsoft.Samples.DataServices.Connectivity.Connection conn = cm.AcquireConnection(null) as Connection;

                if (conn != null)
                {
                    Microsoft.Samples.DataServices.Connectivity.Container[] conts = conn.GetContainers();

                    if (conts != null)
                    {
                        foreach (Microsoft.Samples.DataServices.Connectivity.Container cont in conts)
                        {
                            this.cmbContainerID.Items.Add(cont.Id);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error,
                                MessageBoxDefaultButton.Button1);
                this.cmbContainerID.Items.Clear();
                this.btnNewContainer.Enabled = false;
            }
        }
Esempio n. 3
0
        public PageValidationStatus ValidatePage(out string msg)
        {
            //to do sth to validate
            msg = string.Empty;

            //get the selected connection manager.
            ConnectionManagerMappingEventArgs args = new ConnectionManagerMappingEventArgs();

            args.ConnectionManagerElement = this.cmbCM.SelectedItem as ConnectionManagerElement;
            ConnectionManager cm = this.GetSelectedConnectionManager(this, args);

            //end of getting selected connection manager.
            if (cm != null)
            {
                //for further, we need validate the existing of ContainerName, EntityKind
                // and UsingExistingID
                if (String.IsNullOrEmpty(this.ContainerId) || string.IsNullOrEmpty(this.EntityKind) ||
                    (this.IsUsingExistingId && string.IsNullOrEmpty(this.IdColumn)))
                {
                    msg = @"One of Properties Invalid.";
                    return(PageValidationStatus.NoPageLeave);
                }
                // we also need validate the mapped columns existing
                else
                {
                    return(PageValidationStatus.Ok);
                }
            }
            else
            {
                msg = @"Specify the Connection Manager";
                return(PageValidationStatus.NoPageLeave);
            }
            //end of ValidatePage
        }
Esempio n. 4
0
        private void btnNewContainer_Click(object sender, EventArgs e)
        {
            ConnectionManagerMappingEventArgs args = new ConnectionManagerMappingEventArgs();

            args.ConnectionManagerElement = this.cmbCM.SelectedItem as ConnectionManagerElement;
            ConnectionManager cm = this.GetSelectedConnectionManager(this, args);

            Connection conn = cm.AcquireConnection(null) as Connection;

            Microsoft.Samples.DataServices.Connectivity.Container cont = conn.CreateContainer(this.ContainerId);

            if (cont != null)
            {
                this.cmbContainerID.Items.Add(this.ContainerId);
                this.cmbContainerID.SelectedIndex = this.cmbContainerID.Items.Count - 1;

                MessageBox.Show("Created new container: " + this.ContainerId);
            }
            else
            {
                MessageBox.Show("Failed to create a new container.", "Error", MessageBoxButtons.OK,
                                MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
            }
        }
Esempio n. 5
0
        ConnectionManager page_GetSelectedConnectionManager(object sender, ConnectionManagerMappingEventArgs args)
        {
            this.ClearErrors();

            try
            {
                ConnectionManagerElement cme = args.ConnectionManagerElement;

                if (cme != null && this.Connections != null)
                {
                    foreach (ConnectionManager cm in this.Connections)
                    {
                        if (cm.ID.Equals(cme.ID, StringComparison.OrdinalIgnoreCase))
                        {
                            args.ConnectionManagerInstance = cm;
                            return cm;
                        }
                    }
                }

                return null;
            }
            catch (Exception ex)
            {
                this.ReportErrors(ex);
                return null;
            }
        }
        private void btnNewContainer_Click(object sender, EventArgs e)
        {
            ConnectionManagerMappingEventArgs args = new ConnectionManagerMappingEventArgs();
            args.ConnectionManagerElement = this.cmbCM.SelectedItem as ConnectionManagerElement;
            ConnectionManager cm = this.GetSelectedConnectionManager(this, args);

            Connection conn = cm.AcquireConnection(null) as Connection;
            Microsoft.Samples.DataServices.Connectivity.Container cont = conn.CreateContainer(this.ContainerId);

            if (cont != null)
            {
                this.cmbContainerID.Items.Add(this.ContainerId);
                this.cmbContainerID.SelectedIndex = this.cmbContainerID.Items.Count - 1;

                MessageBox.Show("Created new container: " + this.ContainerId);
            }
            else
            {
                MessageBox.Show("Failed to create a new container.", "Error", MessageBoxButtons.OK,
                    MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
            }
        }
        private void LoadContainers(ConnectionManagerElement cme)
        {
            this.cmbContainerID.Items.Clear();

            ConnectionManagerMappingEventArgs args = new ConnectionManagerMappingEventArgs();
            args.ConnectionManagerElement = cme;
            ConnectionManager cm = this.GetSelectedConnectionManager(this, args);

            try
            {
                Microsoft.Samples.DataServices.Connectivity.Connection conn = cm.AcquireConnection(null) as Connection;

                if (conn != null)
                {
                    Microsoft.Samples.DataServices.Connectivity.Container[] conts = conn.GetContainers();

                    if (conts != null)
                    {
                        foreach (Microsoft.Samples.DataServices.Connectivity.Container cont in conts)
                        {
                            this.cmbContainerID.Items.Add(cont.Id);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error,
                    MessageBoxDefaultButton.Button1);
                this.cmbContainerID.Items.Clear();
                this.btnNewContainer.Enabled = false;
            }
        }
        public PageValidationStatus ValidatePage(out string msg)
        {
            //to do sth to validate
            msg = string.Empty;

            //get the selected connection manager.
            ConnectionManagerMappingEventArgs args = new ConnectionManagerMappingEventArgs();
            args.ConnectionManagerElement = this.cmbCM.SelectedItem as ConnectionManagerElement;
            ConnectionManager cm = this.GetSelectedConnectionManager(this, args);
            //end of getting selected connection manager.
            if (cm != null)
            {
                //for further, we need validate the existing of ContainerName, EntityKind
                // and UsingExistingID
                if (String.IsNullOrEmpty(this.ContainerId) || string.IsNullOrEmpty(this.EntityKind)
                    || (this.IsUsingExistingId && string.IsNullOrEmpty(this.IdColumn)))
                {
                    msg = @"One of Properties Invalid.";
                    return PageValidationStatus.NoPageLeave;
                }
                // we also need validate the mapped columns existing
                else 
                {
                    return PageValidationStatus.Ok;
                }
            }
            else
            {
                msg = @"Specify the Connection Manager";
                return PageValidationStatus.NoPageLeave;
            }
            //end of ValidatePage
        }