Exemplo n.º 1
0
        /// <summary>
        /// Disables Exchange and updates the database
        /// </summary>
        private void DisableExchange()
        {
            ExchCmds cmds = null;

            try
            {
                cmds = new ExchCmds(Config.ExchangeURI, Config.Username, Config.Password, Config.ExchangeConnectionType, Config.PrimaryDC);

                // Get a list of accepted domains
                var convertedDomains = new List<string>();
                List<Domain> domains = SQLExchange.GetAcceptedDomains(CPContext.SelectedCompanyCode);
                if (domains != null && domains.Count > 0)
                {
                    // Extracts just the domain name from the list
                    convertedDomains = (from d in domains select d.DomainName as string).ToList();
                }

                // Delete from Exchange
                cmds.Disable_Company(CPContext.SelectedCompanyCode, convertedDomains);

                // Delete from SQL
                SQLExchange.DisableExchange(CPContext.SelectedCompanyCode);

                // Update Status Message
                notification1.SetMessage(controls.notification.MessageType.Success, Resources.LocalizedText.NotificationSuccessDisableExchange);

                // Change panel
                enableExchange.Visible = true;
                disableExchange.Visible = false;
            }
            catch (Exception ex)
            {
                notification1.SetMessage(controls.notification.MessageType.Error, ex.Message);
            }
            finally
            {
                if (cmds != null)
                    cmds.Dispose();
            }
        }