public GeneralPropertyPage(ServicePropertiesDlg parentDlg, IPlugInContainer container, ServiceManagerPlugin plugin, string serviceName)
        {
            InitializeComponent();

            this.pageID = "GeneralPropertyPage";
            SetPageTitle("General");
            this.serviceName = serviceName;
            this._plugin = plugin;
            this._parentDlg = parentDlg;
        }
Beispiel #2
0
        public GeneralPropertyPage(ServicePropertiesDlg parentDlg, IPlugInContainer container, ServiceManagerPlugin plugin, string serviceName)
        {
            InitializeComponent();

            this.pageID = "GeneralPropertyPage";
            SetPageTitle("General");
            this.serviceName = serviceName;
            this._plugin     = plugin;
            this._parentDlg  = parentDlg;
        }
        public void On_MenuClick(object sender, EventArgs e)
        {
            MenuItem mi = sender as MenuItem;

            if (mi.Text.Trim().Equals("&Refresh"))
            {
                treeNode.IsModified = true;
                treeNode.sc.ShowControl(treeNode);
                return;
            }
            else if (mi.Text.Trim().Equals("&Help"))
            {
                ProcessStartInfo psi = new ProcessStartInfo();
                psi.UseShellExecute = true;
                psi.FileName        = CommonResources.GetString("LAC_Help");
                psi.Verb            = "open";
                psi.WindowStyle     = ProcessWindowStyle.Normal;
                Process.Start(psi);
                return;
            }
            else if (mi.Text.Trim().Equals("&Properties"))
            {
                ServicePropertiesDlg dlg = new ServicePropertiesDlg(base.container, this, plugin, serviceInfo.serviceName.Trim());
                dlg.ShowDialog();

                if (dlg.commit)
                {
                    treeNode.IsModified = true;
                    treeNode.sc.ShowControl(treeNode);
                    return;
                }
            }
            else
            {
                if (Configurations.currentPlatform == LikewiseTargetPlatform.Windows)
                {
                    switch (mi.Text.Trim())
                    {
                    case "&Restart":
                        ServiceManagerWindowsWrapper.WMIServiceRestart(serviceInfo.serviceName);
                        break;

                    default:
                        Do_WinServiceInvoke(mi.Text.Trim());
                        break;
                    }
                }
                else
                {
                    int    iRet    = 0;
                    IntPtr pHandle = ServiceManagerInteropWrapper.ApiLwSmAcquireServiceHandle(mi.Tag as string);
                    switch (mi.Text.Trim())
                    {
                    case "&Restart":
                        if (pHandle != IntPtr.Zero)
                        {
                            iRet = ServiceManagerInteropWrapper.ApiLwSmRefreshService(pHandle);
                        }
                        break;

                    case "&Start":
                        if (pHandle != IntPtr.Zero)
                        {
                            ServiceManagerInteropWrapper.StartAllServiceDependencies(pHandle, ref iRet);
                        }
                        break;

                    case "&Stop":
                        if (pHandle != IntPtr.Zero)
                        {
                            iRet = ServiceManagerInteropWrapper.StopServiceRecursive(pHandle);
                        }
                        break;

                    default:
                        break;
                    }
                    if (iRet == (int)41202)
                    {
                        container.ShowError("The service is unable to start.\nPlease check the all its dependencies are started");
                    }
                    else if (iRet != 0)
                    {
                        container.ShowError("Failed to start the specified service: error code:" + iRet);
                    }

                    ServiceManagerInteropWrapper.ApiLwSmReleaseServiceHandle(pHandle);

                    if (iRet == 0)
                    {
                        treeNode.IsModified = true;
                        treeNode.sc.ShowControl(treeNode);
                        return;
                    }
                }
            }
        }