示例#1
0
        private void cmdPause_Click(object sender, EventArgs e)
        {
            if (SelectedService == null)
            {
                return;
            }

            string PauseText = "";
            int    Control   = 0;

            if (SelectedService.State.ToLower() == "paused")
            {
                PauseText = "Unpausing";
                Control   = 4;
            }
            else
            {
                PauseText = "Pausing";
                Control   = 3;
            }

            PushServiceControlReq c = new PushServiceControlReq();

            c.Service = SelectedService.Name;
            c.Control = Control;
            PushServiceControlState res = Program.net.PushServiceControl(MachineID, c);

            if (res.ResultCode != 0)
            {
                MessageBox.Show(this, PauseText + " Service " + c.Service + " threw an error: 0x" + res.ResultCode.ToString("X8") + ", " + GetServiceError(res.ResultCode), Program.Title, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            UpdateStatus();
        }
示例#2
0
        private void cmdStop_Click(object sender, EventArgs e)
        {
            if (SelectedService == null)
            {
                return;
            }
            PushServiceControlReq c = new PushServiceControlReq();

            c.Service = SelectedService.Name;
            c.Control = 1;
            PushServiceControlState res = Program.net.PushServiceControl(MachineID, c);

            if (res.ResultCode != 0)
            {
                MessageBox.Show(this, "Stopping Service " + c.Service + " threw an error: 0x" + res.ResultCode.ToString("X8") + ", " + GetServiceError(res.ResultCode), Program.Title, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            UpdateStatus();
        }
示例#3
0
        public RESTStatus ServiceControl(SQLLib sql, PushServiceControlReq req, NetworkConnectionInfo ni, string MachineID)
        {
            if (ni.HasAcl(ACLFlags.ChangeServerSettings) == false)
            {
                ni.Error   = "Access denied";
                ni.ErrorID = ErrorFlags.AccessDenied;
                return(RESTStatus.Denied);
            }

            string guid = Guid.NewGuid().ToString();

            PushData p = new PushData();

            p.Action          = "servicecontrol";
            p.ReplyID         = guid;
            p.AdditionalData1 = JsonConvert.SerializeObject(req);

            PushServiceHelper.SendPushService(MachineID, p, 0);
            PushDataResponse resp = PushServiceHelper.PopResponse(MachineID, 0, guid);

            if (resp == null)
            {
                ni.Error   = "No response";
                ni.ErrorID = ErrorFlags.NoData;
                return(RESTStatus.NoContent);
            }

            try
            {
                ServiceState = JsonConvert.DeserializeObject <PushServiceControlState>(resp.Data.ToString());
            }
            catch
            {
                ni.Error   = "Faulty data";
                ni.ErrorID = ErrorFlags.NoData;
                return(RESTStatus.NoContent);
            }
            return(RESTStatus.Success);
        }