Example #1
0
        private void tsbUpdateConnection_Click(object sender, EventArgs e)
        {
            if (lvConnections.SelectedItems.Count == 1)
            {
                ListViewItem item = lvConnections.SelectedItems[0];

                var cForm = new ConnectionForm(false, false)
                {
                    CrmConnectionDetail = (ConnectionDetail)item.Tag,
                    StartPosition       = FormStartPosition.CenterParent
                };

                if (cForm.ShowDialog(this) == DialogResult.OK)
                {
                    item.SubItems[0].Text = cForm.CrmConnectionDetail.ConnectionName;
                    item.SubItems[1].Text = cForm.CrmConnectionDetail.ServerName;
                    item.SubItems[2].Text = cForm.CrmConnectionDetail.Organization;
                    if (item.SubItems.Count == 4)
                    {
                        item.SubItems[3].Text = cForm.CrmConnectionDetail.OrganizationVersion;
                    }
                    else
                    {
                        item.SubItems.Add(cForm.CrmConnectionDetail.OrganizationVersion);
                    }
                    item.Group = GetGroup(cForm.CrmConnectionDetail.AuthType);

                    lvConnections.Refresh();

                    ConnectionManager.Instance.SaveConnectionsFile();
                }
            }
        }
        private void tsbUpdateConnection_Click(object sender, EventArgs e)
        {
            if (lvConnections.SelectedItems.Count == 1)
            {
                ListViewItem item = lvConnections.SelectedItems[0];

                var cForm = new ConnectionForm(false, false)
                {
                    CrmConnectionDetail = (ConnectionDetail)item.Tag,
                    ConnectionList      = ConnectionList,
                    StartPosition       = FormStartPosition.CenterParent
                };

                if (cForm.ShowDialog(this) == DialogResult.OK)
                {
                    item.SubItems[0].Text = cForm.CrmConnectionDetail.ConnectionName;
                    item.SubItems[1].Text = cForm.CrmConnectionDetail.ServerName;
                    item.SubItems[2].Text = cForm.CrmConnectionDetail.OrganizationFriendlyName;
                    item.SubItems[3].Text = cForm.CrmConnectionDetail.OrganizationVersion;
                    item.SubItems[4].Text = cForm.CrmConnectionDetail.SolutionFriendlyName;

                    item.Group = GetGroup(cForm.CrmConnectionDetail.AuthType);

                    lvConnections.Refresh();

                    RefreshComboBoxSelectedConnection();
                }
            }
        }
        private void tsbNewConnection_Click(object sender, EventArgs e)
        {
            var cForm = new ConnectionForm(true, false)
            {
                ConnectionList = ConnectionList,
                StartPosition  = FormStartPosition.CenterParent
            };

            if (cForm.ShowDialog(this) == DialogResult.OK)
            {
                var newConnection = cForm.CrmConnectionDetail;
                HadCreatedNewConnection = true;

                var item = new ListViewItem(newConnection.ConnectionName);
                item.SubItems.Add(newConnection.ServerName);
                item.SubItems.Add(newConnection.Organization);
                item.SubItems.Add(newConnection.OrganizationVersion);
                item.SubItems.Add(newConnection.SolutionFriendlyName);
                item.Tag        = newConnection;
                item.Group      = GetGroup(newConnection.AuthType);
                item.ImageIndex = GetImageIndex(newConnection);

                lvConnections.Items.Add(item);
                lvConnections.SelectedItems.Clear();
                item.Selected = true;

                if (!connectionManager.ConnectionsList.Connections.Contains(newConnection))
                {
                    connectionManager.ConnectionsList.Connections.Add(newConnection);
                }

                RefreshComboBoxSelectedConnection();
            }
        }
Example #4
0
        /// <summary>
        /// Creates or updates a Crm connection
        /// </summary>
        /// <param name="isCreation">Indicates if it is a connection creation</param>
        /// <param name="connectionToUpdate">Details of the connection to update</param>
        /// <returns>Created or updated connection</returns>
        public ConnectionDetail EditConnection(bool isCreation, ConnectionDetail connectionToUpdate)
        {
            var cForm = new ConnectionForm(isCreation)
            {
                StartPosition = FormStartPosition.CenterParent
            };

            if (!isCreation)
            {
                cForm.CrmConnectionDetail = connectionToUpdate;
            }

            if (cForm.ShowDialog(_innerAppForm) == DialogResult.OK)
            {
                if (cForm.DoConnect)
                {
                    ConnectionManager.Instance.ConnectToServer(cForm.CrmConnectionDetail);
                }

                //if (!cForm.CrmConnectionDetail.PasswordIsEmpty && !cForm.CrmConnectionDetail.SavePassword)
                //{
                //    cForm.CrmConnectionDetail.ErasePassword();
                //}

                if (isCreation)
                {
                    if (ConnectionManager.Instance.ConnectionsList.Connections.FirstOrDefault(
                            d => d.ConnectionId == cForm.CrmConnectionDetail.ConnectionId) == null)
                    {
                        ConnectionManager.Instance.ConnectionsList.Connections.Add(cForm.CrmConnectionDetail);
                    }
                }
                else
                {
                    foreach (ConnectionDetail detail in ConnectionManager.Instance.ConnectionsList.Connections)
                    {
                        if (detail.ConnectionId == cForm.CrmConnectionDetail.ConnectionId)
                        {
                            detail.UpdateAfterEdit(cForm.CrmConnectionDetail);
                        }
                    }
                }

                ConnectionManager.Instance.SaveConnectionsFile();

                return(cForm.CrmConnectionDetail);
            }

            return(null);
        }
Example #5
0
        private void tsbNewConnection_Click(object sender, EventArgs e)
        {
            var cForm = new ConnectionForm(true, false)
            {
                StartPosition = FormStartPosition.CenterParent
            };

            if (cForm.ShowDialog(this) == DialogResult.OK)
            {
                var newConnection = cForm.CrmConnectionDetail;
                hadCreatedNewConnection = true;

                var item = new ListViewItem(newConnection.ConnectionName);
                item.SubItems.Add(newConnection.ServerName);
                item.SubItems.Add(newConnection.Organization);
                item.SubItems.Add(newConnection.OrganizationVersion);
                item.Tag        = newConnection;
                item.Group      = GetGroup(newConnection.AuthType);
                item.ImageIndex = GetImageIndex(newConnection);

                lvConnections.Items.Add(item);
                lvConnections.SelectedItems.Clear();
                item.Selected = true;

                lvConnections.Sort();

                if (isConnectionSelection)
                {
                    BValidateClick(sender, e);
                }

                if (ConnectionManager.Instance.ConnectionsList.Connections.FirstOrDefault(
                        d => d.ConnectionId == newConnection.ConnectionId) == null)
                {
                    ConnectionManager.Instance.ConnectionsList.Connections.Add(newConnection);
                }

                ConnectionManager.Instance.SaveConnectionsFile();
            }
        }
        private void tsbUpdateConnection_Click(object sender, EventArgs e)
        {
            if (lvConnections.SelectedItems.Count == 1)
            {
                ListViewItem item = lvConnections.SelectedItems[0];

                var cForm = new ConnectionForm(false, false)
                {
                    CrmConnectionDetail = (ConnectionDetail)item.Tag,
                    StartPosition = FormStartPosition.CenterParent
                };

                if (cForm.ShowDialog(this) == DialogResult.OK)
                {
                    item.SubItems[0].Text = cForm.CrmConnectionDetail.ConnectionName;
                    item.SubItems[1].Text = cForm.CrmConnectionDetail.ServerName;
                    item.SubItems[2].Text = cForm.CrmConnectionDetail.Organization;
                    if (item.SubItems.Count == 4)
                    {
                        item.SubItems[3].Text = cForm.CrmConnectionDetail.OrganizationVersion;
                    }
                    else
                    {
                        item.SubItems.Add(cForm.CrmConnectionDetail.OrganizationVersion);
                    }
                    item.Group = GetGroup(cForm.CrmConnectionDetail.AuthType);

                    lvConnections.Refresh();

                    ConnectionManager.Instance.SaveConnectionsFile();
                }
            }
        }
        private void tsbNewConnection_Click(object sender, EventArgs e)
        {
            var cForm = new ConnectionForm(true, false)
            {
               StartPosition = FormStartPosition.CenterParent
            };

            if (cForm.ShowDialog(this) == DialogResult.OK)
            {
                var newConnection = cForm.CrmConnectionDetail;
                hadCreatedNewConnection = true;

                var item = new ListViewItem(newConnection.ConnectionName);
                item.SubItems.Add(newConnection.ServerName);
                item.SubItems.Add(newConnection.Organization);
                item.SubItems.Add(newConnection.OrganizationVersion);
                item.Tag = newConnection;
                item.Group = GetGroup(newConnection.AuthType);
                item.ImageIndex = GetImageIndex(newConnection);

                lvConnections.Items.Add(item);
                lvConnections.SelectedItems.Clear();
                item.Selected = true;

                lvConnections.Sort();

                if (isConnectionSelection)
                {
                    BValidateClick(sender, e);
                }

                if (ConnectionManager.Instance.ConnectionsList.Connections.FirstOrDefault(
                             d => d.ConnectionId == newConnection.ConnectionId) == null)
                {
                    ConnectionManager.Instance.ConnectionsList.Connections.Add(newConnection);
                }

                ConnectionManager.Instance.SaveConnectionsFile();
            }
        }
Example #8
0
        /// <summary>
        /// Creates or updates a Crm connection
        /// </summary>
        /// <param name="isCreation">Indicates if it is a connection creation</param>
        /// <param name="connectionToUpdate">Details of the connection to update</param>
        /// <returns>Created or updated connection</returns>
        public ConnectionDetail EditConnection(bool isCreation, ConnectionDetail connectionToUpdate)
        {
            var cForm = new ConnectionForm(isCreation) { StartPosition = FormStartPosition.CenterParent };

            if (!isCreation)
            {
                cForm.CrmConnectionDetail = connectionToUpdate;
            }

            if (cForm.ShowDialog(_innerAppForm) == DialogResult.OK)
            {
                if (cForm.DoConnect)
                {
                    ConnectionManager.Instance.ConnectToServer(cForm.CrmConnectionDetail);
                }

                //if (!cForm.CrmConnectionDetail.PasswordIsEmpty && !cForm.CrmConnectionDetail.SavePassword)
                //{
                //    cForm.CrmConnectionDetail.ErasePassword();
                //}

                if (isCreation)
                {
                    if (ConnectionManager.Instance.ConnectionsList.Connections.FirstOrDefault(
                        d => d.ConnectionId == cForm.CrmConnectionDetail.ConnectionId) == null)
                    {
                        ConnectionManager.Instance.ConnectionsList.Connections.Add(cForm.CrmConnectionDetail);
                    }
                }
                else
                {
                    foreach (ConnectionDetail detail in ConnectionManager.Instance.ConnectionsList.Connections)
                    {
                        if (detail.ConnectionId == cForm.CrmConnectionDetail.ConnectionId)
                        {
                            detail.UpdateAfterEdit(cForm.CrmConnectionDetail);
                        }
                    }
                }

                ConnectionManager.Instance.SaveConnectionsFile();

                return cForm.CrmConnectionDetail;
            }

            return null;
        }
Example #9
0
        /// <summary>
        /// Creates or updates a Crm connection
        /// </summary>
        /// <param name="isCreation">Indicates if it is a connection creation</param>
        /// <param name="connectionToUpdate">Details of the connection to update</param>
        /// <returns>Created or updated connection</returns>
        public ConnectionDetail EditConnection(bool isCreation, ConnectionDetail connectionToUpdate)
        {
            var cForm = new ConnectionForm(isCreation)
            {
                StartPosition = FormStartPosition.CenterParent
            };

            if (!isCreation)
            {
                cForm.CrmConnectionDetail = connectionToUpdate;
            }

            if (cForm.ShowDialog(_innerAppForm) == DialogResult.OK)
            {
                if (isCreation)
                {
                    if (!_connectionManager.ConnectionsList.Connections.Contains(cForm.CrmConnectionDetail))
                    {
                        _connectionManager.ConnectionsList.Connections.Add(cForm.CrmConnectionDetail);
                    }
                }
                else
                {
                    foreach (ConnectionDetail detail in _connectionManager.ConnectionsList.Connections)
                    {
                        if (detail.ConnectionId == cForm.CrmConnectionDetail.ConnectionId)
                        {
                            #region Update connection details

                            detail.ConnectionName         = cForm.CrmConnectionDetail.ConnectionName;
                            detail.OrganizationServiceUrl = cForm.CrmConnectionDetail.OrganizationServiceUrl;
                            detail.CrmTicket                = cForm.CrmConnectionDetail.CrmTicket;
                            detail.IsCustomAuth             = cForm.CrmConnectionDetail.IsCustomAuth;
                            detail.Organization             = cForm.CrmConnectionDetail.Organization;
                            detail.OrganizationFriendlyName = cForm.CrmConnectionDetail.OrganizationFriendlyName;
                            detail.ServerName               = cForm.CrmConnectionDetail.ServerName;
                            detail.ServerPort               = cForm.CrmConnectionDetail.ServerPort;
                            detail.UseIfd       = cForm.CrmConnectionDetail.UseIfd;
                            detail.UseOnline    = cForm.CrmConnectionDetail.UseOnline;
                            detail.UseOsdp      = cForm.CrmConnectionDetail.UseOsdp;
                            detail.UserDomain   = cForm.CrmConnectionDetail.UserDomain;
                            detail.UserName     = cForm.CrmConnectionDetail.UserName;
                            detail.UserPassword = cForm.CrmConnectionDetail.UserPassword;
                            detail.UseSsl       = cForm.CrmConnectionDetail.UseSsl;
                            detail.HomeRealmUrl = cForm.CrmConnectionDetail.HomeRealmUrl;

                            #endregion
                        }
                    }
                }

                if (cForm.DoConnect)
                {
                    _connectionManager.ConnectToServer(cForm.CrmConnectionDetail);
                }

                _connectionManager.SaveConnectionsFile(_connectionManager.ConnectionsList);

                return(cForm.CrmConnectionDetail);
            }

            return(null);
        }