private void BtnExportTranslationsClick(object sender, EventArgs e) { if (lvEntities.CheckedItems.Count > 0 || chkExportGlobalOptSet.Checked || chkExportSiteMap.Checked || chkExportDashboards.Checked) { var entities = (from ListViewItem item in lvEntities.CheckedItems select((EntityMetadata)item.Tag).LogicalName).ToList(); var sfd = new SaveFileDialog { Filter = "Excel workbook|*.xlsx", Title = "Select file destination" }; if (sfd.ShowDialog(this) == DialogResult.OK) { var settings = new ExportSettings { ExportAttributes = chkExportAttributes.Checked, ExportBooleans = chkExportBooleans.Checked, ExportEntities = chkExportEntity.Checked, ExportForms = chkExportForms.Checked, ExportFormFields = chkExportFormsFields.Checked, ExportFormSections = chkExportFormsSections.Checked, ExportFormTabs = chkExportFormsTabs.Checked, ExportGlobalOptionSet = chkExportGlobalOptSet.Checked, ExportOptionSet = chkExportPicklists.Checked, ExportViews = chkExportViews.Checked, ExportCharts = chkExportCharts.Checked, ExportCustomizedRelationships = chkExportCustomizedRelationships.Checked, ExportSiteMap = chkExportSiteMap.Checked, ExportDashboards = chkExportDashboards.Checked, FilePath = sfd.FileName, Entities = entities }; SetState(true); WorkAsync(new WorkAsyncInfo { Message = "Exporting Translations...", AsyncArgument = settings, Work = (bw, evt) => { var engine = new Engine(); engine.Export((ExportSettings)evt.Argument, Service, bw); }, PostWorkCallBack = evt => { SetState(false); if (evt.Error != null) { string errorMessage = CrmExceptionHelper.GetErrorMessage(evt.Error, true); MessageBox.Show(this, errorMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }, ProgressChanged = evt => { SetWorkingMessage(evt.UserState.ToString()); } }); } } }
private void BtnExportTranslationsClick(object sender, EventArgs e) { if (lvEntities.CheckedItems.Count > 0 || chkExportGlobalOptSet.Checked || chkExportSiteMap.Checked || chkExportDashboards.Checked) { var entities = (from ListViewItem item in lvEntities.CheckedItems select((EntityMetadata)item.Tag).LogicalName) .ToList(); var sfd = new SaveFileDialog { Filter = "Excel workbook|*.xlsx", Title = "Select file destination" }; if (sfd.ShowDialog(this) == DialogResult.OK) { var settings = new ExportSettings { ExportAttributes = chkExportAttributes.Checked, ExportBooleans = chkExportBooleans.Checked, ExportEntities = chkExportEntity.Checked, ExportForms = chkExportForms.Checked, ExportFormFields = chkExportFormsFields.Checked, ExportFormSections = chkExportFormsSections.Checked, ExportFormTabs = chkExportFormsTabs.Checked, ExportGlobalOptionSet = chkExportGlobalOptSet.Checked, ExportOptionSet = chkExportPicklists.Checked, ExportViews = chkExportViews.Checked, ExportCharts = chkExportCharts.Checked, ExportCustomizedRelationships = chkExportCustomizedRelationships.Checked, ExportSiteMap = chkExportSiteMap.Checked, ExportDashboards = chkExportDashboards.Checked, FilePath = sfd.FileName, Entities = entities, ExportNames = rdbBoth.Checked || rdbNameOnly.Checked, ExportDescriptions = rdbBoth.Checked || rdbDescOnly.Checked, SolutionId = _solutionId, LanguageToExport = rdbExportSpecificLanguage.Checked ? ((Language)ccbLanguageToExport.SelectedItem).Lcid : -1 }; pnlNewProgress.Controls.Clear(); SetState(true); WorkAsync(new WorkAsyncInfo { Message = "Exporting Translations...", AsyncArgument = settings, Work = (bw, evt) => { var engine = new Engine(); engine.Export((ExportSettings)evt.Argument, Service, bw); }, PostWorkCallBack = evt => { SetState(false); if (evt.Error != null) { string errorMessage = CrmExceptionHelper.GetErrorMessage(evt.Error, true); MessageBox.Show(this, errorMessage, @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (DialogResult.Yes == MessageBox.Show(this, @"Do you want to open generated document?", @"Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { Process.Start(settings.FilePath); } } }, ProgressChanged = evt => { SetWorkingMessage(evt.UserState.ToString()); } }); } } }
private void BtnExportTranslationsClick(object sender, EventArgs e) { if (lvEntities.CheckedItems.Count > 0 || chkExportGlobalOptSet.Checked || chkExportSiteMap.Checked) { var entities = (from ListViewItem item in lvEntities.CheckedItems select ((EntityMetadata) item.Tag).LogicalName).ToList(); var sfd = new SaveFileDialog {Filter = "Excel workbook|*.xlsx", Title = "Select file destination"}; if (sfd.ShowDialog(this) == DialogResult.OK) { var settings = new ExportSettings { ExportAttributes = chkExportAttributes.Checked, ExportBooleans = chkExportBooleans.Checked, ExportEntities = chkExportEntity.Checked, ExportForms = chkExportForms.Checked, ExportFormFields = chkExportFormsFields.Checked, ExportFormSections = chkExportFormsSections.Checked, ExportFormTabs = chkExportFormsTabs.Checked, ExportGlobalOptionSet = chkExportGlobalOptSet.Checked, ExportOptionSet = chkExportPicklists.Checked, ExportViews = chkExportViews.Checked, ExportCustomizedRelationships = chkExportCustomizedRelationships.Checked, ExportSiteMap = chkExportSiteMap.Checked, FilePath = sfd.FileName, Entities = entities }; SetState(true); WorkAsync("Exporting Translations...", (bw, evt) => { var engine = new Engine(); engine.Export((ExportSettings)evt.Argument, Service, bw); }, evt => { SetState(false); if (evt.Error != null) { string errorMessage = CrmExceptionHelper.GetErrorMessage(evt.Error, true); MessageBox.Show(this, errorMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }, evt=>SetWorkingMessage(evt.UserState.ToString()), settings); } } }