예제 #1
0
        protected override void ProcessRecord()
        {
            try
            {
                var service = ConnectToCrm();

                WriteDebug("Instantiating logic...");
                var logic = new ImportLogic(service);

                WriteDebug("Loading teams...");
                var teams = logic.DeserializeTeamsFromFile(FileName);

                WriteDebug("Upserting teams...");
                logic.Import(teams);
            }
            catch (Exception ex)
            {
                ThrowTerminatingError(new ErrorRecord(ex, ex.GetType().Name, ErrorCategory.NotSpecified, null));
            }
        }
예제 #2
0
        private async Task LoadExportData()
        {
            IsBusy          = true;
            ProgressMessage = "Beginning data load to memory...";

            try
            {
                var dlg = new OpenFileDialog();
                dlg.DefaultExt = ".json";
                dlg.Filter     = "JSON Files |*.json";

                var result = dlg.ShowDialog();

                if (result == true)
                {
                    ProgressMessage = "Loading exported data...";
                    var filename = dlg.FileName;

                    var teams = await Task.Run(() =>
                    {
                        return(_importLogic.DeserializeTeamsFromFile(filename));
                    });

                    Teams = new ObservableCollection <Team>(teams);
                }
                else
                {
                    MessageBox.Show("You must select a file to deploy.");
                    return;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error was encountered while attempting to load the export. Detail: " + ex.Message);
            }
            finally
            {
                IsBusy = false;
            }
        }