protected override void OnClosed(EventArgs e) { _commonConfig.Save(); BindingOperations.ClearAllBindings(cmBCurrentConnection); cmBCurrentConnection.Items.DetachFromSourceCollection(); cmBCurrentConnection.DataContext = null; cmBCurrentConnection.ItemsSource = null; base.OnClosed(e); }
protected override void OnClosed(EventArgs e) { _commonConfig.Save(); (cmBCurrentConnection.SelectedItem as ConnectionData)?.Save(); BindingOperations.ClearAllBindings(cmBCurrentConnection); BindingOperations.ClearAllBindings(cmBFilter); BindingOperations.ClearAllBindings(cmBFolder); BindingOperations.ClearAllBindings(lstVwFolders); cmBFilter.Items.DetachFromSourceCollection(); cmBCurrentConnection.Items.DetachFromSourceCollection(); cmBFolder.Items.DetachFromSourceCollection(); lstVwFolders.Items.DetachFromSourceCollection(); cmBFilter.DataContext = null; cmBCurrentConnection.DataContext = null; cmBFolder.DataContext = null; cmBFilter.ItemsSource = null; cmBCurrentConnection.ItemsSource = null; cmBFolder.ItemsSource = null; lstVwFolders.ItemsSource = null; base.OnClosed(e); }
private void WriteFields() { _config.ClearOutputWindowBeforeCRMOperation = chBClearOutputWindow.IsChecked.GetValueOrDefault(); _config.DoNotPropmPublishMessage = chBDoNotPromtPublishMessage.IsChecked.GetValueOrDefault(); _config.FolderForExport = txtBFolderForExport.Text.Trim(); _config.CompareProgram = txtBCompareProgram.Text.Trim(); _config.CompareArgumentsFormat = txtBCompareArgumentsFormat.Text.Trim(); _config.CompareArgumentsThreeWayFormat = txtBCompareArgumentsThreeWayFormat.Text.Trim(); _config.TextEditorProgram = txtBTextEditorProgram.Text.Trim(); _config.FormsEventsFileName = txtBFileNameFormsEvents.Text.Trim(); _config.PluginConfigurationFileName = txtBFileNamePluginConfiguration.Text.Trim(); if (string.IsNullOrEmpty(_config.PluginConfigurationFileName)) { _config.PluginConfigurationFileName = "Plugins Configuration"; } if (string.IsNullOrEmpty(_config.FormsEventsFileName)) { _config.FormsEventsFileName = "System Forms Events"; } _config.Save(); }
public void HandleShowingWebResourcesDependentComponents(List <SelectedFile> selectedFiles) { CommonConfiguration commonConfig = CommonConfiguration.Get(); if (!HasCurrentCrmConnection(out ConnectionConfiguration crmConfig)) { return; } var connectionData = crmConfig.CurrentConnectionData; if (connectionData != null && commonConfig != null && selectedFiles.Count > 0) { CheckWishToChangeCurrentConnection(connectionData); var thread = new System.Threading.Thread(() => { try { var form = new WindowSelectFolderForExport(connectionData, commonConfig.FolderForExport, commonConfig.DefaultFileAction); if (form.ShowDialog().GetValueOrDefault()) { commonConfig.FolderForExport = form.SelectedFolder; commonConfig.DefaultFileAction = form.GetFileAction(); connectionData = form.GetConnectionData(); if (connectionData != null) { commonConfig.Save(); ActivateOutputWindow(connectionData); WriteToOutputEmptyLines(connectionData, commonConfig); CheckWishToChangeCurrentConnection(connectionData); try { Controller.ShowingWebResourcesDependentComponents(connectionData, commonConfig, selectedFiles); } catch (Exception ex) { WriteErrorToOutput(connectionData, ex); } } } } catch (Exception ex) { DTEHelper.WriteExceptionToOutput(connectionData, ex); } }); thread.SetApartmentState(System.Threading.ApartmentState.STA); thread.Start(); } }
public void HandleExportDefaultSiteMap(string selectedSiteMap) { CommonConfiguration commonConfig = CommonConfiguration.Get(); if (commonConfig != null) { string fileName = string.Format("SiteMap.{0}.xml", selectedSiteMap); var dialog = new Microsoft.Win32.SaveFileDialog() { DefaultExt = ".xml", Filter = "SiteMap (.xml)|*.xml", FilterIndex = 1, RestoreDirectory = true, FileName = fileName, InitialDirectory = commonConfig.FolderForExport, }; if (dialog.ShowDialog().GetValueOrDefault()) { commonConfig.Save(); ActivateOutputWindow(null); WriteToOutputEmptyLines(null, commonConfig); try { Uri uri = FileOperations.GetSiteMapResourceUri(selectedSiteMap); StreamResourceInfo info = Application.GetResourceStream(uri); var doc = XDocument.Load(info.Stream); info.Stream.Dispose(); var filePath = dialog.FileName; doc.Save(filePath, SaveOptions.OmitDuplicateNamespaces); this.WriteToOutput(null, string.Empty); this.WriteToOutput(null, string.Empty); this.WriteToOutput(null, string.Empty); this.WriteToOutput(null, "{0} exported.", fileName); this.WriteToOutput(null, string.Empty); this.WriteToOutputFilePathUri(null, filePath); PerformAction(null, filePath, true); } catch (Exception ex) { WriteErrorToOutput(null, ex); } } } }
private void GetConnectionConfigConfirmActionAndExecute(ConnectionData connectionData, Func <ConnectionData, string> getMessage, string title, Action <ConnectionData, CommonConfiguration> action) { CommonConfiguration commonConfig = CommonConfiguration.Get(); if (connectionData == null) { if (!HasCurrentCrmConnection(out ConnectionConfiguration crmConfig)) { return; } connectionData = crmConfig.CurrentConnectionData; } if (connectionData != null && commonConfig != null) { CheckWishToChangeCurrentConnection(connectionData); bool canMakeAction = false; if (commonConfig.DoNotPromtPublishMessage) { canMakeAction = true; } else { string message = getMessage(connectionData); var dialog = new WindowConfirmPublish(message, title, false); if (dialog.ShowDialog().GetValueOrDefault()) { commonConfig.DoNotPromtPublishMessage = dialog.DoNotPromtPublishMessage; commonConfig.Save(); canMakeAction = true; } } if (canMakeAction) { ActivateOutputWindow(connectionData); WriteToOutputEmptyLines(connectionData, commonConfig); CheckWishToChangeCurrentConnection(connectionData); try { action(connectionData, commonConfig); } catch (Exception ex) { WriteErrorToOutput(connectionData, ex); } } } }
protected override void OnClosed(EventArgs e) { base.OnClosed(e); _commonConfig.Save(); }
private void btnCreateMetadataFile_Click(object sender, RoutedEventArgs e) { _commonConfig.Save(); WindowHelper.OpenEntityMetadataWindow(this._iWriteToOutput, _service, _commonConfig, _entityName); }
public void HandleXsdSchemaExport(string[] fileNamesColl) { CommonConfiguration commonConfig = CommonConfiguration.Get(); if (commonConfig != null) { var thread = new System.Threading.Thread(() => { try { var form = new WindowSelectFolderForExport(null, commonConfig.FolderForExport, commonConfig.DefaultFileAction); if (form.ShowDialog().GetValueOrDefault()) { commonConfig.FolderForExport = form.SelectedFolder; commonConfig.DefaultFileAction = form.GetFileAction(); commonConfig.Save(); ActivateOutputWindow(null); WriteToOutputEmptyLines(null, commonConfig); try { foreach (var fileName in fileNamesColl) { Uri uri = FileOperations.GetSchemaResourceUri(fileName); StreamResourceInfo info = Application.GetResourceStream(uri); var doc = XDocument.Load(info.Stream); info.Stream.Dispose(); var filePath = Path.Combine(commonConfig.FolderForExport, fileName); doc.Save(filePath, SaveOptions.OmitDuplicateNamespaces); this.WriteToOutput(null, string.Empty); this.WriteToOutput(null, string.Empty); this.WriteToOutput(null, string.Empty); this.WriteToOutput(null, "{0} exported.", fileName); this.WriteToOutput(null, string.Empty); this.WriteToOutputFilePathUri(null, filePath); PerformAction(null, filePath, true); } } catch (Exception ex) { WriteErrorToOutput(null, ex); } } } catch (Exception ex) { DTEHelper.WriteExceptionToOutput(null, ex); } }); thread.SetApartmentState(System.Threading.ApartmentState.STA); thread.Start(); } }
public void HandleCheckingWorkflowsUsedEntities(ConnectionData connectionData, bool openExplorer) { CommonConfiguration commonConfig = CommonConfiguration.Get(); if (connectionData == null) { if (!HasCurrentCrmConnection(out ConnectionConfiguration crmConfig)) { return; } connectionData = crmConfig.CurrentConnectionData; } if (connectionData != null && commonConfig != null) { CheckWishToChangeCurrentConnection(connectionData); var thread = new System.Threading.Thread(() => { try { var form = new WindowSelectFolderForExport(connectionData, commonConfig.FolderForExport, commonConfig.DefaultFileAction); if (form.ShowDialog().GetValueOrDefault()) { commonConfig.FolderForExport = form.SelectedFolder; commonConfig.DefaultFileAction = form.GetFileAction(); connectionData = form.GetConnectionData(); if (connectionData != null) { commonConfig.Save(); ActivateOutputWindow(connectionData); WriteToOutputEmptyLines(connectionData, commonConfig); CheckWishToChangeCurrentConnection(connectionData); try { Controller.StartCheckingWorkflowsUsedEntities(connectionData, commonConfig, openExplorer); } catch (Exception ex) { WriteErrorToOutput(connectionData, ex); } } } } catch (Exception ex) { DTEHelper.WriteExceptionToOutput(connectionData, ex); } }); thread.SetApartmentState(System.Threading.ApartmentState.STA); thread.Start(); } }