private void Export_PostExecute(ExportResults results)
 {
     if (!results.Saved)
     {
         return;
     }
     MessageBox.Show("SFX Exported");
 }
        private Task <ExportResults> Export_Execute(CwavKind arg)
        {
            var cWav = ViewModel.Sounds[arg];

            return(Task <ExportResults> .Factory.StartNew(() =>
            {
                var results = new ExportResults
                {
                    Saved = false,
                    Target = arg
                };
                var svfd = new SaveFileDialog
                {
                    Filter = ThirdPartyTools.VgmStream.Present
                                 ? "DSP ADPCM Audio|*.bcwav|PCM Audio|*.wav"
                                 : "DSP ADPCM Audio|*.bcwav",
                    FileName = arg.ToString().ToLower()
                };

                var dlg = svfd.ShowDialog();
                if (dlg.HasValue && dlg.Value)
                {
                    try
                    {
                        switch (svfd.FilterIndex)
                        {
                        case 1:
                            File.WriteAllBytes(svfd.FileName, cWav.CwavData);
                            results.Path = svfd.FileName;
                            results.Saved = true;
                            break;

                        case 2:
                            File.WriteAllBytes(svfd.FileName, cWav.WavData);
                            results.Path = svfd.FileName;
                            results.Saved = true;
                            break;
                        }
                    }
                    catch
                    {
                        // Ignore
                    }
                }
                return results;
            }));
        }
        private void tsbRetrieveRecords_Click(object sender, EventArgs e)
        {
            if (ecpEntities.SelectedMetadatas.Count == 0)
            {
                MessageBox.Show(this, @"No entity selected!", @"Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            ComputeSettings();

            tabCtrl.SelectedIndexChanged         -= tabCtrl_SelectedIndexChanged;
            cbbTabSelection.SelectedIndexChanged -= cbbTabSelection_SelectedIndexChanged;

            tabCtrl.TabPages.Clear();
            cbbTabSelection.Items.Clear();

            WorkAsync(new WorkAsyncInfo
            {
                Message       = "Loading entities...",
                AsyncArgument = settings,
                IsCancelable  = true,
                Work          = (bw, evt) =>
                {
                    var exSettings = (ExportSettings)evt.Argument;

                    if (bw.CancellationPending)
                    {
                        bw.ReportProgress(0, "Cancelling...");
                        bw.CancelAsync();
                    }

                    var results = new ExportResults {
                        Settings = exSettings
                    };

                    bw.ReportProgress(0, "Retrieving selected entities views layout...");

                    // Force service to source Service before retrieving data
                    rManager.SetService(Service);
                    results.Views = rManager.RetrieveViews(exSettings.Entities);

                    foreach (var entity in exSettings.Entities)
                    {
                        bw.ReportProgress(0, $"Retrieving records for entity {entity.DisplayName?.UserLocalizedLabel?.Label ?? entity.LogicalName}...");

                        var er = new EntityResult
                        {
                            Records = rManager.RetrieveRecords(entity, exSettings)
                        };

                        results.Entities.Add(er);
                    }

                    bw.ReportProgress(0, "Retrieving many to many relationships records...");
                    results.NnRecords = rManager.RetrieveNnRecords(exSettings, results.Entities.SelectMany(a => a.Records.Entities).ToList());

                    evt.Result = results;
                },
                PostWorkCallBack = evt =>
                {
                    SendMessageToStatusBar?.Invoke(this, new StatusBarMessageEventArgs(string.Empty));

                    if (evt.Cancelled)
                    {
                        return;
                    }

                    if (evt.Error != null)
                    {
                        MessageBox.Show(this, $@"An error occured: {evt.Error.Message}", @"Error", MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                        return;
                    }

                    tsbExport.Enabled        = true;
                    tssbTransferData.Enabled = true;
                    pnlTabSelection.Visible  = true;

                    var results = (ExportResults)evt.Result;

                    var tabs = new List <TabPage>();

                    foreach (var entity in results.Entities)
                    {
                        var emd     = results.Settings.AllEntities.First(ent => ent.LogicalName == entity.Records.EntityName);
                        var tabPage = new TabPage($"{emd.DisplayName?.UserLocalizedLabel?.Label ?? emd.SchemaName} ({entity.Records.Entities.Count})");
                        tabs.Add(tabPage);

                        var layoutxml = results.Views.First(
                            v => v.GetAttributeValue <string>("returnedtypecode") == emd.LogicalName)
                                        .GetAttributeValue <string>("layoutxml");

                        var rl = new RecordsListerControl(entity.Records.Entities.ToList(), emd, layoutxml)
                        {
                            Dock = DockStyle.Fill
                        };

                        tabPage.Controls.Add(rl);
                    }

                    foreach (var entity in results.NnRecords)
                    {
                        var emd = results.Settings.AllEntities.First(ent => ent.LogicalName == entity.Records.EntityName);
                        var rel = results.Settings.AllEntities
                                  .SelectMany(ent => ent.ManyToManyRelationships)
                                  .First(r => r.IntersectEntityName == emd.LogicalName);

                        var name = $"{results.Settings.AllEntities.First(ent => ent.LogicalName == rel.Entity1LogicalName).DisplayName?.UserLocalizedLabel?.Label} / {results.Settings.AllEntities.First(ent => ent.LogicalName == rel.Entity2LogicalName).DisplayName?.UserLocalizedLabel?.Label}";

                        var tabPage = new TabPage(name);
                        tabs.Add(tabPage);

                        var rl = new RecordsListerControl(entity.Records.Entities.ToList(), results.Entities.SelectMany(rs => rs.Records.Entities).ToList(), rel, results.Settings.AllEntities)
                        {
                            Dock = DockStyle.Fill
                        };

                        tabPage.Controls.Add(rl);
                    }

                    tabCtrl.TabPages.AddRange(tabs.OrderBy(t => t.Text).ToArray());
                    cbbTabSelection.Items.AddRange(tabs.OrderBy(t => t.Text).Select(t => t.Text).Cast <object>().ToArray());

                    if (cbbTabSelection.Items.Count > 0)
                    {
                        cbbTabSelection.SelectedIndex = 0;
                    }

                    tabCtrl.SelectedIndexChanged         += tabCtrl_SelectedIndexChanged;
                    cbbTabSelection.SelectedIndexChanged += cbbTabSelection_SelectedIndexChanged;
                },
                ProgressChanged = evt =>
                {
                    SetWorkingMessage(evt.UserState.ToString());
                    SendMessageToStatusBar?.Invoke(this, new StatusBarMessageEventArgs(evt.UserState.ToString()));
                }
            });
        }
예제 #4
0
        private Task<ExportResults> Export_Execute(CwavKind arg)
        {
            var cWav = ViewModel.Sounds[arg];
            return Task<ExportResults>.Factory.StartNew(() =>
            {
                var results = new ExportResults
                {
                    Saved = false,
                    Target =  arg
                };
                var svfd = new SaveFileDialog
                {
                    Filter = ThirdPartyTools.VgmStream.Present
                                 ? "DSP ADPCM Audio|*.bcwav|PCM Audio|*.wav"
                                 : "DSP ADPCM Audio|*.bcwav",
                    FileName = arg.ToString().ToLower()
                };

                var dlg = svfd.ShowDialog();
                if (dlg.HasValue && dlg.Value)
                {
                    try
                    {
                        switch (svfd.FilterIndex)
                        {
                            case 1:
                                File.WriteAllBytes(svfd.FileName, cWav.CwavData);
                                results.Path = svfd.FileName;
                                results.Saved = true;
                                break;
                            case 2:
                                File.WriteAllBytes(svfd.FileName, cWav.WavData);
                                results.Path = svfd.FileName;
                                results.Saved = true;
                                break;
                        }
                    }
                    catch
                    {
                        // Ignore
                    }
                }
                return results;
            });
        }
예제 #5
0
 private void Export_PostExecute(ExportResults results)
 {
     if (!results.Saved)
         return;
     MessageBox.Show("SFX Exported");
 }
예제 #6
0
        private async void btnExport_Click(object sender, EventArgs e)
        {
            btnExport.Enabled = false;

            var artefacts = new AsmArtefacts();

            foreach (var selectedItem in lvwStorageAccounts.CheckedItems)
            {
                var listItem = (ListViewItem)selectedItem;
                artefacts.StorageAccounts.Add(listItem.Text);
            }

            foreach (var selectedItem in lvwVirtualNetworks.CheckedItems)
            {
                var listItem = (ListViewItem)selectedItem;
                artefacts.VirtualNetworks.Add(listItem.Text);
            }

            foreach (var selectedItem in lvwVirtualMachines.CheckedItems)
            {
                var listItem = (ListViewItem)selectedItem;
                artefacts.VirtualMachines.Add(
                    new CloudServiceVM
                {
                    CloudService   = listItem.Text,
                    VirtualMachine = listItem.SubItems[1].Text,
                });
            }

            if (!Directory.Exists(txtDestinationFolder.Text))
            {
                MessageBox.Show("The chosen output folder does not exist.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                // If save selection option is enabled
                if (app.Default.SaveSelection)
                {
                    lblStatus.Text = "BUSY: Reading saved selection";
                    _saveSelectionProvider.Save(Guid.Parse(subscriptionid), lvwVirtualNetworks, lvwStorageAccounts, lvwVirtualMachines);
                }

                var instructionsPath = Path.Combine(txtDestinationFolder.Text, "DeployInstructions.html");
                var templatePath     = Path.Combine(txtDestinationFolder.Text, "export.json");
                var blobDetailsPath  = Path.Combine(txtDestinationFolder.Text, "copyblobdetails.json");
                var templateWriter   = new StreamWriter(templatePath);
                var blobDetailWriter = new StreamWriter(blobDetailsPath);
                try
                {
                    var messages = await _templateGenerator.GenerateTemplate(subscriptionsAndTenants[subscriptionid], subscriptionid, artefacts, templateWriter, blobDetailWriter);

                    var token         = GetToken(subscriptionsAndTenants[subscriptionid], PromptBehavior.Auto);
                    var exportResults = new ExportResults(_asmRetriever, token, messages, subscriptionid, instructionsPath, templatePath, blobDetailsPath);
                    exportResults.ShowDialog(this);
                }
                catch (Exception ex)
                {
                    writeLog("btnExport_Click", "Error generating template : " + ex.ToString());
                    MessageBox.Show("Something went wrong when generating the template. Check the log file for details.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            btnExport.Enabled = true;
        }