Ejemplo n.º 1
0
        public void view_OnWriteConfiguration(object sender, EventArgs e)
        {
            OnWriteConfigurationCalled = true;

            try
            {
                CreateProgramFolder();

                if (view.Server == null || view.Target == null)
                {
                    view.ShowErrorMessage(Resource.InvalidConfiguration);
                    return;
                }

                ExeConfigurationFileMap configFileMap = new ExeConfigurationFileMap();
                configFileMap.ExeConfigFilename = configFile;
                Configuration config = ConfigurationManager.OpenMappedExeConfiguration(configFileMap, ConfigurationUserLevel.None);

                Section = (ConfigurationSection)config.GetSection(sectionName);
                if (Section == null)
                {
                    Section = new ConfigurationSection();
                    config.Sections.Add(sectionName, Section);
                }

                Section.server.Address  = view.Server.Address ?? String.Empty;
                Section.server.Username = view.Server.Username ?? String.Empty;
                Section.server.Password = view.Server.Password ?? String.Empty;
                Section.server.Port     = view.Server.Port ?? String.Empty;

                Section.target.Address  = view.Target.Address ?? String.Empty;
                Section.target.Username = view.Target.Username ?? String.Empty;
                Section.target.Password = view.Target.Password ?? String.Empty;
                Section.target.AdministrativePassword = view.Target.AdministrativePassword ?? String.Empty;
                Section.target.SSHPort = view.Target.SSHPort ?? String.Empty;

                Section.file.SaveFolder         = view.DestinationFolder ?? String.Empty;
                Section.file.DefinitionFilename = view.DefinitionFilename ?? String.Empty;

                SaveConfiguration(config);
            }
            catch (Exception ex)
            {
                view.ShowErrorMessage(Util.FormatExceptionMessage(ex));
            }
        }
 public void ShowPage(string pageKey)
 {
     try {
         var newView = uiFactory.GetNextPage(pageKey, Settings, this);
         View.HeaderText     = pageKey;
         View.CurrentControl = newView;
     } catch (DependencyFailureException ex) {
         view.ShowErrorMessage(ex.Message);
     } catch (V1ConnectionRequiredException) {
         view.ShowErrorMessage("To open the page, valid V1 connection is required");
     }
 }