Exemplo n.º 1
0
        /// <summary>
        /// Add a new host to the configuration
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void hostAdd_Click(object sender, EventArgs e)
        {
            frmHost newHost = new frmHost();

            newHost.radioLocal.Checked = true;
            if (newHost.ShowDialog() == DialogResult.OK)
            {
                AddHostNode(newHost.txtName.Text);
                ChangedAfterSave = true;
                if (newHost.radioLocal.Checked)
                {
                    FAHLogStats.Instances.PathInstance xHost = new FAHLogStats.Instances.PathInstance();
                    xHost.Name = newHost.txtName.Text;
                    xHost.RemoteFAHLogFilename   = newHost.txtLogFileName.Text;
                    xHost.RemoteUnitInfoFilename = newHost.txtUnitFileName.Text;
                    xHost.Path = newHost.txtLocalPath.Text;
                    HostInstances.Add(xHost.Name, (Base)xHost);
                    HostInstances[xHost.Name].Retrieve();
                }
                else if (newHost.radioHTTP.Checked)
                {
                    FAHLogStats.Instances.HTTPInstance xHost = new FAHLogStats.Instances.HTTPInstance();
                    xHost.Name = newHost.txtName.Text;
                    xHost.RemoteFAHLogFilename   = newHost.txtLogFileName.Text;
                    xHost.RemoteUnitInfoFilename = newHost.txtUnitFileName.Text;
                    xHost.URL      = newHost.txtWebURL.Text;
                    xHost.Username = newHost.txtWebUser.Text;
                    xHost.Password = newHost.txtWebPass.Text;
                    HostInstances.Add(xHost.Name, (Base)xHost);
                    HostInstances[xHost.Name].Retrieve();
                }
                else if (newHost.radioFTP.Checked)
                {
                    FAHLogStats.Instances.FTPInstance xHost = new FAHLogStats.Instances.FTPInstance();
                    xHost.Name = newHost.txtName.Text;
                    xHost.RemoteFAHLogFilename   = newHost.txtLogFileName.Text;
                    xHost.RemoteUnitInfoFilename = newHost.txtUnitFileName.Text;
                    xHost.Server   = newHost.txtFTPServer.Text;
                    xHost.Path     = newHost.txtFTPPath.Text;
                    xHost.Username = newHost.txtFTPUser.Text;
                    xHost.Password = newHost.txtFTPPass.Text;
                    HostInstances.Add(xHost.Name, (Base)xHost);
                    HostInstances[xHost.Name].Retrieve();
                }
                refreshNeeded = true;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Edits an existing host configuration
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void hostEdit_Click(object sender, EventArgs e)
        {
            frmHost editHost = new frmHost();

            editHost.txtName.Enabled  = false;
            editHost.txtName.ReadOnly = true;
            Base Instance = HostInstances[rightClickedNode.Name];

            editHost.txtName.Text         = rightClickedNode.Name;
            editHost.txtLogFileName.Text  = Instance.RemoteFAHLogFilename;
            editHost.txtUnitFileName.Text = Instance.RemoteUnitInfoFilename;
            if (Instance.GetType().ToString() == "FAHLogStats.Instances.PathInstance")
            {
                editHost.radioLocal.Select();
                editHost.txtLocalPath.Text = ((PathInstance)Instance).Path;
            }
            else if (Instance.GetType().ToString() == "FAHLogStats.Instances.FTPInstance")
            {
                editHost.radioFTP.Select();
                editHost.txtFTPServer.Text = ((FTPInstance)Instance).Server;
                editHost.txtFTPPath.Text   = ((FTPInstance)Instance).Path;
                editHost.txtFTPUser.Text   = ((FTPInstance)Instance).Username;
                editHost.txtFTPPass.Text   = ((FTPInstance)Instance).Password;
            }
            else if (Instance.GetType().ToString() == "FAHLogStats.Instances.HTTPInstance")
            {
                editHost.radioHTTP.Select();
                editHost.txtWebURL.Text  = ((HTTPInstance)Instance).URL;
                editHost.txtWebUser.Text = ((HTTPInstance)Instance).Username;
                editHost.txtWebPass.Text = ((HTTPInstance)Instance).Password;
            }
            else
            {
                throw new NotImplementedException("The instance type was not located as expected");
            }

            if (editHost.ShowDialog() == DialogResult.OK)
            {
                ChangedAfterSave = true;
                if (editHost.radioLocal.Checked)
                {
                    FAHLogStats.Instances.PathInstance xHost = new FAHLogStats.Instances.PathInstance();
                    xHost.Name = editHost.txtName.Text;
                    xHost.RemoteFAHLogFilename   = editHost.txtLogFileName.Text;
                    xHost.RemoteUnitInfoFilename = editHost.txtUnitFileName.Text;
                    xHost.Path = editHost.txtLocalPath.Text;
                    HostInstances[xHost.Name] = (Base)xHost;
                    HostInstances[xHost.Name].Retrieve();
                }
                else if (editHost.radioHTTP.Checked)
                {
                    FAHLogStats.Instances.HTTPInstance xHost = new FAHLogStats.Instances.HTTPInstance();
                    xHost.Name = editHost.txtName.Text;
                    xHost.RemoteFAHLogFilename   = editHost.txtLogFileName.Text;
                    xHost.RemoteUnitInfoFilename = editHost.txtUnitFileName.Text;
                    xHost.URL                 = editHost.txtWebURL.Text;
                    xHost.Username            = editHost.txtWebUser.Text;
                    xHost.Password            = editHost.txtWebPass.Text;
                    HostInstances[xHost.Name] = (Base)xHost;
                    HostInstances[xHost.Name].Retrieve();
                }
                else if (editHost.radioFTP.Checked)
                {
                    FAHLogStats.Instances.FTPInstance xHost = new FAHLogStats.Instances.FTPInstance();
                    xHost.Name = editHost.txtName.Text;
                    xHost.RemoteFAHLogFilename   = editHost.txtLogFileName.Text;
                    xHost.RemoteUnitInfoFilename = editHost.txtUnitFileName.Text;
                    xHost.Server              = editHost.txtFTPServer.Text;
                    xHost.Path                = editHost.txtFTPPath.Text;
                    xHost.Username            = editHost.txtFTPUser.Text;
                    xHost.Password            = editHost.txtFTPPass.Text;
                    HostInstances[xHost.Name] = (Base)xHost;
                    HostInstances[xHost.Name].Retrieve();
                }
                refreshNeeded = true;
            }
        }