Example #1
0
        private void ImportTranslations()
        {
            SetState(false);

            WorkAsync("",
                (bw, e) =>
                {
                    var engine = new Engine();
                    engine.Import(e.Argument.ToString(), Service, bw);
                },
                e =>
                {
                    if (e.Error != null)
                    {
                        string errorMessage = CrmExceptionHelper.GetErrorMessage(e.Error, true);
                        MessageBox.Show(this, errorMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                    SetState(false);
                },
                e=>SetWorkingMessage(e.UserState.ToString()),
                txtFilePath.Text);
        }
Example #2
0
        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);
                }
            }
        }
Example #3
0
        private void ImportTranslations()
        {
            SetState(false);

            WorkAsync(new WorkAsyncInfo
            {
                Message = "",
                AsyncArgument = txtFilePath.Text,
                Work = (bw, e) =>
                {
                    var engine = new Engine();
                    engine.Import(e.Argument.ToString(), Service, bw);
                },
                PostWorkCallBack = e =>
                {
                    if (e.Error != null)
                    {
                        string errorMessage = CrmExceptionHelper.GetErrorMessage(e.Error, true);
                        MessageBox.Show(this, errorMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                    SetState(false);
                },
                ProgressChanged = e => { SetWorkingMessage(e.UserState.ToString()); }
            });
        }