Ejemplo n.º 1
0
        protected override void OnStartup(object sender, StartupEventArgs e)
        {
            try {
                IFormatterConfiguration configurations = _containter.GetInstance <IFormatterConfiguration>();

                System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

                ConfigurationSectionGroup configGroups = config.SectionGroups[Properties.Resources.APPLICATION_CONFIGURATION_SECTION];

                if (!configurations.ConfigurationExists)
                {
                    configurations.CreateConfigurationFromAppConfig();
                }

                configurations.UpdateConfigurationFileFromAppConfig();

                configurations.ValidateConfiguration();
            } catch (Exception error) {
                MessageBox.Show("Configuration Error:\n\n" + ErrorFormating.FormatException(error), "Configuration Error", MessageBoxButton.OK, MessageBoxImage.Error);
                Application.Current.Shutdown();
                return;
            }

            BackgroundWorker worker = new BackgroundWorker();

            worker.DoWork += (o, s) => CreateExcelInstance();

            worker.RunWorkerAsync();

            DisplayRootViewFor <ShellViewModel>();
        }
Ejemplo n.º 2
0
        public void Process()
        {
            if (!_productNumber.validateProductNumber())
            {
                MessageBox.Show("Invalid Product number.", "Invalid Entry", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            else if (!BomSelectionModel.HasSelectedItem())
            {
                MessageBox.Show("No BOM is selected.", "Invalid Entry", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            try {
                ConfigurationManager.RefreshSection("applicationConfiguration");

                BomFormat bomFormat = new BomFormat(_container.GetInstance <IFormatterConfiguration>(), BomSelectionModel.SelectedItem.Key, _productNumber);

                bomFormat.FormatBom();

                ProductNumber = "";
            } catch (Exception e) {
                MessageBox.Show("Error:\n\n" + ErrorFormating.FormatException(e), "Error Occured", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }