Example #1
0
        private void DeleteHost()
        {
            if (this.listViewHost.SelectedItems.Count < 1)
            {
                return;
            }
            NTServiceHostInfo c = this.listViewHost.SelectedItems[0].Tag as NTServiceHostInfo;

            Program.ConfigMgt.Config.Hosts.Remove(c);
            RefreshHostList();
        }
Example #2
0
        private void LoadSettings()
        {
            // load solution dir file

            _solutionDirPath = ConfigHelper.DismissDotDotInThePath(ConfigHelper.GetFullPath(Program.ConfigMgr.Config.IntegrationSolutionPath));
            string solutionDirFile = Path.Combine(_solutionDirPath, SolutionConfig.SolutionDirFileName);

            _solutionConfigMgr = new ConfigManager <SolutionConfig>(solutionDirFile);
            if (!_solutionConfigMgr.Load())
            {
                Program.Log.Write(_solutionConfigMgr.LastError);
                MessageBox.Show(this, string.Format("Cannot load configuration file of the integration solution from: \r\n{0}", solutionDirFile),
                                this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                this.Close();
                return;
            }

            // get NT Service status

            if (_solutionConfigMgr.Config.Hosts.Count < 1)
            {
                MessageBox.Show(this, string.Format("Cannot find any NT Service Host in the integation solution: \r\n{0}", solutionDirFile),
                                this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                this.Close();
                return;
            }

            _hostInfo = _solutionConfigMgr.Config.Hosts[0];
            ServiceStatus status = ServiceMgt.GetServiceStatus(_hostInfo.ServiceName, Program.Log);

            RefreshServiceStatus(status);

            // get Adpater status

            _serviceConfigPath = Path.Combine(_solutionDirPath, _hostInfo.ServicePath);
            string serviceConfigFile = Path.Combine(_serviceConfigPath, NTServiceHostConfig.NTServiceHostConfigFileName);

            _serviceConfigMgr = new ConfigManager <NTServiceHostConfig>(serviceConfigFile);
            if (!_serviceConfigMgr.Load())
            {
                Program.Log.Write(_serviceConfigMgr.LastError);
                MessageBox.Show(this, string.Format("Cannot load configuration file of the NT Serivce Host from: \r\n{0}", serviceConfigFile),
                                this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                this.Close();
                return;
            }

            RefreshDiagram();
            RefreshAdapterList();
            RefreshAdapterButtons();
        }
Example #3
0
        private void DeleteHost()
        {
            if (this.listViewHost.SelectedItems.Count < 1)
            {
                return;
            }
            NTServiceHostInfo h = this.listViewHost.SelectedItems[0].Tag as NTServiceHostInfo;

            if (_mInterface.Hosts.Contains(h))
            {
                _mInterface.Hosts.Remove(h);
            }
            RefreshHostList();
        }
Example #4
0
        private void AddHost()
        {
            FormMInterfaceHost frm = new FormMInterfaceHost(_mInterface);

            if (frm.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            NTServiceHostInfo h = frm.Host;

            if (h == null)
            {
                return;
            }

            _mInterface.Hosts.Add(h);
            RefreshHostList();
        }
Example #5
0
        private bool SaveSetting()
        {
            NTServiceHostInfoWraper w = this.comboBoxHost.SelectedItem as NTServiceHostInfoWraper;

            if (w == null || _mInterface == null)
            {
                return(false);
            }

            foreach (NTServiceHostInfo h in _mInterface.Hosts)
            {
                if (h.ServiceName == w.Host.ServiceName)
                {
                    MessageBox.Show(this,
                                    string.Format("The host \"{0}\" has already existed in the interface", h.ServiceName),
                                    this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.comboBoxHost.Focus();
                    return(false);
                }
            }

            _host = w.Host;
            return(true);
        }
Example #6
0
        static void UnregisterNTServiceHost()
        {
            if (ConfigMgt.Config.ServiceName == null ||
                ConfigMgt.Config.ServiceName.Length < 1)
            {
                string msg = "Cannot register an NT Service Host with empty name to the integration solution.";
                Program.Log.Write(LogType.Error, msg);
                MessageBox.Show(msg, AppName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            string sFile = Path.Combine(GetSolutionRoot(), SolutionConfig.SolutionDirFileName);
            ConfigManager <SolutionConfig> sMgt = new ConfigManager <SolutionConfig>(sFile);

            if (!sMgt.Load())
            {
                string msg = "Cannot load integration solution configuration file from " + sFile;
                Program.Log.Write(LogType.Error, msg + "\r\n" + sMgt.LastErrorInfor);
                MessageBox.Show(msg, AppName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            NTServiceHostInfo hInfo = null;

            foreach (NTServiceHostInfo hi in sMgt.Config.Hosts)
            {
                if (hi.ServiceName == ConfigMgt.Config.ServiceName)
                {
                    hInfo = hi;
                    break;
                }
            }

            if (hInfo == null)
            {
                string msg = string.Format(
                    "The NT Service Host (Name:{0}) does not exsited in the integration solution.",
                    ConfigMgt.Config.ServiceName);
                Program.Log.Write(LogType.Error, msg);
                MessageBox.Show(msg, AppName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            sMgt.Config.Hosts.Remove(hInfo);

            if (!sMgt.Save())
            {
                string msg = "Save integration solution configuration file failed.";
                Program.Log.Write(LogType.Error, msg + "\r\n" + sMgt.LastErrorInfor);
                MessageBox.Show(msg, AppName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            string successMsg = string.Format(
                "Unregister NT Service Host (Name:{0}) from the integration solution success.",
                ConfigMgt.Config.ServiceName);

            Program.Log.Write(successMsg);

            if (!_silence)
            {
                MessageBox.Show(successMsg, AppName, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Example #7
0
        static void RegisterNTServiceHost()
        {
            if (ConfigMgt.Config.ServiceName == null ||
                ConfigMgt.Config.ServiceName.Length < 1)
            {
                string msg = "Cannot register an NT Service Host with empty name to the integration solution.";
                Program.Log.Write(LogType.Error, msg);
                MessageBox.Show(msg, AppName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            string sFile = Path.Combine(GetSolutionRoot(), SolutionConfig.SolutionDirFileName);
            ConfigManager <SolutionConfig> sMgt = new ConfigManager <SolutionConfig>(sFile);

            if (!sMgt.Load())
            {
                string msg = "Cannot load integration solution configuration file from " + sFile;
                Program.Log.Write(LogType.Error, msg + "\r\n" + sMgt.LastErrorInfor);

                if (MessageBox.Show(msg + "\r\nDo you want to create a default integration solution configuration file?",
                                    AppName, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1)
                    != DialogResult.Yes)
                {
                    return;
                }

                sMgt.Config = new SolutionConfig();
                if (!sMgt.Save())
                {
                    msg = "Save integration solution configuration file failed.";
                    Program.Log.Write(LogType.Error, msg + "\r\n" + sMgt.LastErrorInfor);
                    MessageBox.Show(msg, AppName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }

            bool hasRegistered = false;

            foreach (NTServiceHostInfo hi in sMgt.Config.Hosts)
            {
                if (hi.ServiceName == ConfigMgt.Config.ServiceName)
                {
                    hasRegistered = true;
                    break;
                }
            }

            if (hasRegistered)
            {
                string msg = string.Format(
                    "The NT Service Host (Name:{0}) has already exsited in the integration solution.",
                    ConfigMgt.Config.ServiceName);
                Program.Log.Write(LogType.Error, msg);
                MessageBox.Show(msg, AppName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            NTServiceHostInfo hInfo = new NTServiceHostInfo();

            hInfo.ServiceName        = ConfigMgt.Config.ServiceName;
            hInfo.ServiceDescription = ConfigMgt.Config.Description;
            string sPath = ConfigHelper.DismissDotDotInThePath(GetSolutionRoot());
            string hPath = Path.GetDirectoryName(ConfigMgt.FileName);

            hInfo.ServicePath = ConfigHelper.GetRelativePath(sPath, hPath);
            sMgt.Config.Hosts.Add(hInfo);

            if (!sMgt.Save())
            {
                string msg = "Save integration solution configuration file failed.";
                Program.Log.Write(LogType.Error, msg + "\r\n" + sMgt.LastErrorInfor);
                MessageBox.Show(msg, AppName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            string successMsg = string.Format(
                "Register NT Service Host(Name:{0}) into the integration solution success.",
                ConfigMgt.Config.ServiceName);

            Program.Log.Write(successMsg);

            if (!_silence)
            {
                MessageBox.Show(successMsg, AppName, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Example #8
0
 public NTServiceHostInfoWraper(NTServiceHostInfo hi)
 {
     Host = hi;
 }