Beispiel #1
0
        private void tSBCreateCopy_Click(object sender, RoutedEventArgs e)
        {
            if (!IsControlsEnabled)
            {
                return;
            }

            if (lstVwConnections.SelectedItems.Count == 1)
            {
                ConnectionData oldconnectionData = lstVwConnections.SelectedItems[0] as ConnectionData;

                ConnectionData connectionData = oldconnectionData.CreateCopy();

                var form = new WindowCrmConnectionCard(_iWriteToOutput, connectionData, _crmConfig.Users);

                if (form.ShowDialog().GetValueOrDefault())
                {
                    this.Dispatcher.Invoke(() =>
                    {
                        connectionData.Save();
                        connectionData.ConnectionConfiguration = this._crmConfig;
                        connectionData.LoadIntellisenseAsync();
                        connectionData.StartWatchFile();
                        this._crmConfig.Connections.Add(connectionData);
                    });
                }

                UpdateCurrentConnectionInfo();

                this._crmConfig.Save();
            }
        }
Beispiel #2
0
        private void CallEditArchiveConnection(ConnectionData connectionData)
        {
            var form = new WindowCrmConnectionCard(_iWriteToOutput, connectionData, _crmConfig.Users);

            form.ShowDialog();

            this._crmConfig.Save();
        }
Beispiel #3
0
        private void CallEditConnection(ConnectionData connectionData)
        {
            var form = new WindowCrmConnectionCard(_iWriteToOutput, connectionData, _crmConfig.Users);

            form.ShowDialog();

            UpdateCurrentConnectionInfo();

            connectionData.Save();
            this._crmConfig.Save();
        }
Beispiel #4
0
        private void OpenConnectionFormForOrganizationDetail(OrganizationDetailViewItem detail)
        {
            ConnectionData connectionData = new ConnectionData()
            {
                ConnectionId = Guid.NewGuid(),

                ConnectionConfiguration = _crmConfig,

                DiscoveryUrl    = detail.DiscoveryUri.ToString(),
                OrganizationUrl = detail.OrganizationServiceEndpoint,
                PublicUrl       = detail.WebApplicationEndpoint,
                UniqueOrgName   = detail.UniqueName,

                User = detail.User,

                OrganizationId      = detail.OrganizationId,
                FriendlyName        = detail.FriendlyName,
                OrganizationVersion = detail.OrganizationVersion,
                OrganizationState   = detail.State.ToString(),
                UrlName             = detail.UrlName,
            };

            var form = new WindowCrmConnectionCard(_iWriteToOutput, connectionData, _crmConfig.Users);

            if (form.ShowDialog().GetValueOrDefault())
            {
                this.Dispatcher.Invoke(() =>
                {
                    connectionData.Save();
                    connectionData.ConnectionConfiguration = this._crmConfig;
                    connectionData.LoadIntellisenseAsync();
                    connectionData.StartWatchFile();
                    this._crmConfig.Connections.Add(connectionData);
                });
            }

            UpdateCurrentConnectionInfo();

            this._crmConfig.Save();
        }
Beispiel #5
0
        private void tSBLoadFromFile_Click(object sender, RoutedEventArgs e)
        {
            if (!IsControlsEnabled)
            {
                return;
            }

            string selectedPath = string.Empty;
            var    t            = new Thread(() =>
            {
                try
                {
                    var openFileDialog1 = new Microsoft.Win32.OpenFileDialog
                    {
                        Filter           = "ConnectionData (.xml)|*.xml",
                        FilterIndex      = 1,
                        RestoreDirectory = true
                    };

                    if (openFileDialog1.ShowDialog().GetValueOrDefault())
                    {
                        selectedPath = openFileDialog1.FileName;
                    }
                }
                catch (Exception ex)
                {
                    _iWriteToOutput.WriteErrorToOutput(null, ex);
                    _iWriteToOutput.ActivateOutputWindow(null, this);
                }
            });

            t.SetApartmentState(ApartmentState.STA);
            t.Start();

            t.Join();

            if (string.IsNullOrEmpty(selectedPath))
            {
                return;
            }

            ConnectionData connectionData = null;

            try
            {
                connectionData = ConnectionData.GetFromPath(selectedPath);
            }
            catch (Exception ex)
            {
                _iWriteToOutput.WriteErrorToOutput(null, ex);
                _iWriteToOutput.ActivateOutputWindow(null, this);

                connectionData = null;
            }

            if (connectionData == null)
            {
                return;
            }

            connectionData.User = this._crmConfig.Users.FirstOrDefault(u => u.UserId == connectionData.UserId);

            if (this._crmConfig.Connections.Any(c => c.ConnectionId == connectionData.ConnectionId) ||
                this._crmConfig.ArchiveConnections.Any(c => c.ConnectionId == connectionData.ConnectionId) ||
                connectionData.ConnectionId == Guid.Empty
                )
            {
                connectionData.ConnectionId = Guid.NewGuid();
            }

            var form = new WindowCrmConnectionCard(_iWriteToOutput, connectionData, _crmConfig.Users);

            if (form.ShowDialog().GetValueOrDefault())
            {
                this.Dispatcher.Invoke(() =>
                {
                    connectionData.Save();
                    connectionData.ConnectionConfiguration = this._crmConfig;
                    connectionData.LoadIntellisenseAsync();
                    connectionData.StartWatchFile();
                    this._crmConfig.Connections.Add(connectionData);
                });
            }

            UpdateCurrentConnectionInfo();

            this._crmConfig.Save();
        }