Example #1
0
        /// <summary>
        /// Import a saved config file
        /// </summary>
        /// <param name="configPath">The full path to the exported config file to save</param>
        public void ImportConfigFile(string configPath)
        {
            if (log.IsDebugEnabled)
            {
                log.Debug("Attempting to import new config file from " + configPath);
            }

            if (!File.Exists(configPath))
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("Unable to import " + configPath + ", file does not exist");
                }

                throw new ArgumentException("Unable to import " + configPath + ", file does not exist");
            }
            try {
                RemoveConfigFile();
                string filePath = Path.Combine(_dataPath, "SugarCube.cfg");
                if (log.IsDebugEnabled)
                {
                    log.Debug("Attempting to copy file " + configPath + " to " + filePath);
                }

                File.Copy(configPath, filePath);
                _config = new IniFileManager(filePath, KEY, true);
            } catch (Exception ex) {
                if (log.IsErrorEnabled)
                {
                    log.Error("Unable to import config file " + configPath + ": " + ex.Message);
                }

                throw new Exception("Unable to import config file " + configPath + ": " + ex.Message);
            }
        }
Example #2
0
        public MainWindow()
        {
            InitializeComponent();
            dockPanel1.Theme = vS2012LightTheme1;
            _env             = Env.getEnv();
            _env.logger      = new Logger();

            worker = new Scsm_MMS_Worker();

            wm        = new WindowManager(dockPanel1, this);
            this.Text = "IED Explorer 0.79g Exp SCL Server & GOOSE";

            logger.LogInfo("Starting main program ...");

            ini  = new IniFileManager(System.IO.Path.GetDirectoryName(Application.ExecutablePath) + "\\mruip.ini");
            ieds = new IniFileManager(System.IO.Path.GetDirectoryName(Application.ExecutablePath) + "\\ieds.ini");
            GetMruIp();
            GetMruFiles();
            GetIedsDb();
            if (toolStripComboBox_Hostname.Items.Count > 0)
            {
                toolStripComboBox_Hostname.SelectedIndex = 0;
            }
            toolStripComboBoxLoggingLevel.Items.AddRange(Enum.GetNames(typeof(Logger.Severity)));
            toolStripComboBoxLoggingLevel.SelectedItem  = logger.Verbosity.ToString();
            toolStripButtonOpenSCL.DropDownItemClicked += new ToolStripItemClickedEventHandler(toolStripButtonOpenSCL_DropDownItemClicked);
        }
Example #3
0
        /// <summary>
        /// Execute the opreation...
        /// </summary>
        public void execute(IniFileManager manager, Deployment deployment)
        {
            var val = deployment.ExpandPaths(this.value);

            switch (this.ensureDir)
            {
            case "dir":
                UtilsSystem.EnsureDirectoryExists(val, true);
                break;

            case "file":
                UtilsSystem.EnsureDirectoryExists(val, false);
                break;
            }

            // If this is a directory or file, make sure we properly quote when
            // writting the PHP.ini, because whitespaces in a path will break
            // most settings
            if (this.ensureDir == "dir" || this.ensureDir == "file")
            {
                if (!val.StartsWith("\""))
                {
                    val = "\"" + val + "\"";
                }
            }

            if (this.multivalue)
            {
                manager.UpdateOrCreateMultivalueDirective(this.key, val, this.section ?? "AUTODEPLOY", this.comment, this.host);
            }
            else
            {
                manager.UpdateOrCreateDirective(this.key, val, this.section ?? "AUTODEPLOY", this.comment, this.host);
            }
        }
Example #4
0
        public ConfigurationService()
        {
            _currentDirectory = Environment.CurrentDirectory;

            Directory.CreateDirectory(Path
                                      .Combine(_currentDirectory, "Config"));

            _iniFilePath = Path
                           .Combine(_currentDirectory, @"Config\config.ini");

            GetSources();

            if (File.Exists(_iniFilePath))
            {
                _iniFile = new IniFileManager(_iniFilePath);

                _iniFile.Write("MicrophoneName", "None", "Microphone");
                _iniFile.Write("MicrophoneChannels", "None");
                _iniFile.Write("MicrophoneIndex", "None");

                _iniFile.Write("AudioName", _sources[0].ProductName, "Audio");
                _iniFile.Write("AudioChannels", _sources[0].Channels.ToString());
                _iniFile.Write("AudioIndex", 0.ToString());
            }
            else
            {
                _iniFile = new IniFileManager(_iniFilePath);
            }
        }
Example #5
0
        public newVersion()
        {
            InitializeComponent();
            label2.MouseEnter += Label2_MouseEnter;
            label2.MouseLeave += Label2_MouseLeave;

            FileUrl = IniFileManager.GetStringKey("updates.downloadURL");
        }
Example #6
0
    public void Change (string keyName, string keyValue)
    {
      if (Result.IsValid) {
        IniFileManager.ChangeKey (SupportSection, keyName, keyValue);
        IniFileManager.SaveChanges ();

        TSupportSettingsData.Select (keyName, keyValue);
      }
    }
Example #7
0
 public MainForm()
 {
     InitializeComponent();
     _dataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "3DWares");
     if (!Directory.Exists(_dataPath))
     {
         Directory.CreateDirectory(_dataPath);
     }
     _securityConfig = new IniFileManager(Path.Combine(_dataPath, "OrderSec.cfg"), KEY, true);
 }
Example #8
0
        public static void InitGlobalData()
        {
            Version       s    = Assembly.GetExecutingAssembly().GetName().Version;
            StringBuilder vers = new StringBuilder();

            vers.AppendFormat("{0}.{1}.{2}", s.Major.ToString(), s.Minor.ToString(), s.Revision.ToString());

            var ret = IniFileManager.GetStringKey(Path.Combine(Application.StartupPath, "version.ini"), "version.version", vers.ToString());

            Helper.ParseVersionString(ret, out VMain, out VMajor, out VMinor);
        }
Example #9
0
    TSupportSettings ()
    {
      Result = TValidationResult.CreateDefault;
      IniFileManager = TIniFileManager.CreatDefault;

      m_SupportSettingsData = TSupportSettingsData.CreateDefault;

      m_FilePath = System.Environment.CurrentDirectory;
      m_FileName = TNames.SettingsIniFileName;

      IniFileManager.SelectPath (m_FilePath, m_FileName);
    }
Example #10
0
 public MainWindowOld()
 {
     InitializeComponent();
     logger               = Logger.getLogger();
     env.mainWindow       = this;
     worker               = new Scsm_MMS_Worker(env);
     logger.OnLogMessage += new Logger.OnLogMessageDelegate(logger_OnLogMessage);
     logger.LogInfo("Starting main program ...");
     ini = new IniFileManager(System.IO.Path.GetDirectoryName(Application.ExecutablePath) + "\\mruip.ini");
     GetMruIp();
     if (toolStripComboBox_Hostname.Items.Count > 0)
     {
         toolStripComboBox_Hostname.SelectedIndex = 0;
     }
     toolStripComboBoxLoggingLevel.Items.AddRange(Enum.GetNames(typeof(Logger.Severity)));
     toolStripComboBoxLoggingLevel.SelectedItem = logger.Verbosity.ToString();
 }
Example #11
0
        /// <summary>
        /// Does the actual work of setting up the cube config, called from the constructors
        /// </summary>
        private void Setup()
        {
            if (log.IsDebugEnabled)
            {
                log.Debug("In setup, _dataPath = " + _dataPath);
            }

            if (!Directory.Exists(_dataPath))
            {
                if (log.IsInfoEnabled)
                {
                    log.Info("Created _dataPath at " + _dataPath);
                }

                Directory.CreateDirectory(_dataPath);
                ConfigFileCreated = true;
            }

            string filePath = Path.Combine(_dataPath, "SugarCube.cfg");

            if (!File.Exists(filePath))
            {
                if (log.IsInfoEnabled)
                {
                    log.Info("SugarCube.cfg not found in _dataPath, creating");
                }

                ConfigFileCreated = true;
            }
            _config = new IniFileManager(filePath, KEY, true);

            if (!File.Exists("OrderSec.cfg"))
            {
                if (log.IsInfoEnabled)
                {
                    log.Info("Order Security file not found");
                }
            }
            _orderPassword = new IniFileManager("OrderSec.cfg", KEY, true);
        }
Example #12
0
    public TShellViewModel (IShellPresentation presentation)
      : base (new TShellModel ())
    {
      TypeName = GetType ().Name;

      if (presentation.NotNull ()) {
        presentation.ViewModel = this;
      }

      m_Process = new Dictionary<TProcess.TName, Process> ();

      m_DataComm = TDataComm.CreateDefault;

      m_Communication = new TMessagingComm<TDataComm> (m_DataComm);
      m_Communication.Handle += OnCommunicationHandle; // Attach event handler for incoming messages

      var filePath = System.Environment.CurrentDirectory;
      var fileName = TNames.SettingsIniFileName;

      IniFileManager = TIniFileManager.CreatDefault;
      IniFileManager.SelectPath (filePath, fileName);
    }
Example #13
0
 void BtnImportPasswordClick(object sender, EventArgs e)
 {
     openFileDialog.Filter = "Security Config Files|*.cfg";
     if (openFileDialog.ShowDialog() == DialogResult.OK)
     {
         setUIState(DISABLED);
         string newSecurityFile = openFileDialog.FileName;
         try {
             IniFileManager test        = new IniFileManager(newSecurityFile, KEY, true);
             string         newPassword = test.getEncryptedString("SECURITY", "hcryptpass", "@@@***$$$%%%12345");
             if (newPassword == "@@@***$$$%%%12345")
             {
                 ShowError("The file '" + newSecurityFile + "' does not contain a valid encryption password.");
             }
             _securityConfig.writeEncryptedString("SECURITY", "hcryptpass", newPassword);
             tbPassword.Text = newPassword;
         } catch {
             ShowError("The file '" + newSecurityFile + "' does not appear to be a valid security config file");
         } finally {
             setUIState(ENABLED);
         }
     }
 }
Example #14
0
    public bool Validate ()
    {
      bool res = false;

      Result.CopyFrom (IniFileManager.ValidatePath ());

      // file found
      if (Result.IsValid) {
        // create new section
        if (IniFileManager.ContainsSection (SupportSection).IsFalse ()) {
          var token = IniFileManager.AddSection (SupportSection);

          foreach (var settingsName in m_SupportSettingsData.SettingsNames) {
            var keyName = settingsName;
            var keyValue = TSupportSettingsData.Request (settingsName);

            TIniFileManager.AddKey (token, keyName, keyValue);
          }

          IniFileManager.SaveChanges ();
        }

        // update support settings data
        else {
          foreach (var settingsName in m_SupportSettingsData.SettingsNames) {
            if (IniFileManager.ContainsKey (SupportSection, settingsName)) {
              var settingsValue = IniFileManager.RequestKey (SupportSection, settingsName);
              TSupportSettingsData.Select (settingsName, settingsValue);
            }
          }
        }

        res = true;
      }

      return (res);
    }
Example #15
0
        /// <summary>
        /// ボタン表示
        /// </summary>
        /// <param name="BtnCount"></param>
        /// <param name="btnType"></param>
        private void IndicateBtnList(int BtnCount, DisplayBtnType btnType)
        {
            List <string> strList = new List <string>();

            //Iniファイルから文字列リスト取得
            if (IniFileManager.ReadIniFile(btnType, out strList))
            {
                for (int i = 0; i < BtnCount; i++)
                {
                    //ボタン文字表示
                    btnList[i].Text = strList[i];
                }
            }
            else
            {
                return;
            }

            //iniファイルからボタン表示一覧取得
            for (int i = 0; i < BtnCount; i++)
            {
                btnList[i].Visible = true;
            }
        }
Example #16
0
        void BtnGenerateClick(object sender, EventArgs e)
        {
            // Check if there is an order form specified, and make sure the file exists
            if (!String.IsNullOrEmpty(tbOrderForm.Text) && !File.Exists(tbOrderForm.Text))
            {
                ShowError("The order form specified can not be found:\n" + tbOrderForm.Text);
                return;
            }

            // If there is an order form, check the password
            if (!String.IsNullOrEmpty(tbOrderForm.Text))
            {
                if (tbPass1.Text != tbPass2.Text)
                {
                    ShowError("The passwords to encrypt the order form do not match, please recheck");
                    return;
                }
            }

            // Check location of manager msi
            if (String.IsNullOrEmpty(tbInstallerPath.Text) || !File.Exists(tbInstallerPath.Text))
            {
                ShowError("You must provide a valid path to the SugarCube Manager base installer");
                return;
            }
            string msiPath = tbInstallerPath.Text;
            // We *assume* that our copy of the VisualC++ 2012 redistributable is in the same path as our core msi
            string vcPath = Path.Combine(Path.GetDirectoryName(msiPath), "vc_redist-2012.x86.exe");

            // Check location of Visual C++ redistributable
            if (String.IsNullOrEmpty(vcPath) || !File.Exists(vcPath))
            {
                ShowError("You are missing a copy of the VisualC++ 2012 Redistributable, which should be in the same location as the SugarCube Manager base installer");
                return;
            }

            // Prompt for location to save the new custom installer
            if (String.IsNullOrEmpty(tbSaveLocation.Text))
            {
                ShowError("You must choose the location to save the generated installer to");
                return;
            }
            string saveFolder = tbSaveLocation.Text;


            // Copy manager msi to save location as SugarCubeManager.msi
            File.Copy(msiPath, Path.Combine(saveFolder, "SugarCubeManager.msi"));
            // Copy VC++ redistributable to save location
            File.Copy(vcPath, Path.Combine(saveFolder, "vc_redist-2012.x86.exe"));

            // Copy order form to save location as OrderForm.pdf (or create zero-byte one)
            if (File.Exists(tbOrderForm.Text))
            {
                File.Copy(tbOrderForm.Text, Path.Combine(saveFolder, "OrderForm.pdf"));
            }
            else
            {
                FileStream orderForm = File.Create(Path.Combine(saveFolder, "OrderForm.pdf"));
                orderForm.Close();
            }

            // Create OrderSec.cfg in save location
            IniFileManager securityConfig = new IniFileManager(Path.Combine(saveFolder, "OrderSec.cfg"), KEY, true);

            securityConfig.writeEncryptedString("SECURITY", "hcryptpass", tbPass1.Text);

            // Create BrandLogo.bmp in save location
            pbImagePreview.Image.Save(Path.Combine(saveFolder, "BrandLogo.bmp"), ImageFormat.Bmp);

            // Use 7Zip to zip up SugarCubeManager.msi, OrderSec.cfg, OrderForm.pdf and BrandLogo.bmp into scmdeploy.7z
            CompressInstallerFiles(saveFolder);

            // Create the three byte arrays for the pieces of the scmsetup.exe file
            byte[] zipHeader = global::Me.ThreeDWares.SugarCube.InstallationComponents._7zSD;
            byte[] zipConfig = global::Me.ThreeDWares.SugarCube.InstallationComponents._7ZipSelfExtractorConfig;
            byte[] scmDeploy = File.ReadAllBytes(Path.Combine(saveFolder, "scmdeploy.7z"));

            // Concatenate 7zSD, 7ZipSelfExtractorConfig and scmdeploy into setup.exe
            byte[] setupExe = new byte[zipHeader.Length + zipConfig.Length + scmDeploy.Length];
            System.Buffer.BlockCopy(zipHeader, 0, setupExe, 0, zipHeader.Length);
            System.Buffer.BlockCopy(zipConfig, 0, setupExe, zipHeader.Length, zipConfig.Length);
            System.Buffer.BlockCopy(scmDeploy, 0, setupExe, zipHeader.Length + zipConfig.Length, scmDeploy.Length);
            File.WriteAllBytes(Path.Combine(saveFolder, "scmsetup.exe"), setupExe);

            // Clean up leftover files
            File.Delete(Path.Combine(saveFolder, "SugarCubeManager.msi"));
            File.Delete(Path.Combine(saveFolder, "vc_redist-2012.x86.exe"));
            File.Delete(Path.Combine(saveFolder, "OrderForm.pdf"));
            File.Delete(Path.Combine(saveFolder, "BrandLogo.bmp"));
            File.Delete(Path.Combine(saveFolder, "scmdeploy.7z"));

            // Let the use know that we are done
            string message = "The customized SugarCube Manager installer (scmsetup.exe) is avilable at:\n" + saveFolder + "\n\nIn addition, in this folder you will find your order form encryption key, OrderSec.cfg.  This file contains your OrderForm encryption/decryption password, please keep it safe within your organization.\n\nNote: Your actual order form password is encrypted in this file";

            MessageBox.Show(message, "Generation Complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Example #17
0
 TSupportSettings (string filePath, string fileName)
   : this ()
 {
   IniFileManager.SelectPath (filePath, fileName);
 }