示例#1
0
        public void Handle(NetworkStream stream, RequestHeaders headers, TcpClient client)
        {
            if (client.Connected)
            {
                var terminationResponse = new TerminationResponse
                {
                    JobGuid = headers.JobGuid,
                    Status  = JobStatus.Paused
                };
                var    jsonResponse    = JsonConvert.SerializeObject(terminationResponse);
                byte[] responseMessage = Encoding.ASCII.GetBytes(jsonResponse);
                stream.Write(responseMessage, 0, responseMessage.Length);
                client.Close();
            }

            stream.Close();
            _server.Stop();
            Environment.Exit(0);
        }
示例#2
0
        protected override async Task <TerminateProcessResponse> OnTerminateByProcessNoStatusingAsync(int processId, ops.Person terminatingUser, CancellationToken cancellationToken, IDictionary <object, object> context)
        {
            try
            {
                NetworkIdentification1 terminateUser = new NetworkIdentification1
                {
                    Domain    = terminatingUser.Network.Domain,
                    NetworkId = terminatingUser.Network.Username
                };

                Binding binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport)
                {
                    SendTimeout    = new TimeSpan(0, 5, 0),
                    ReceiveTimeout = new TimeSpan(0, 5, 0)
                };

                ChannelFactory <RoutingSoap> factory = new ChannelFactory <RoutingSoap>(binding, new EndpointAddress(_client.BaseAddress));
                RoutingSoap serviceProxy             = factory.CreateChannel();

                TerminationResponse result = await serviceProxy.TerminateByProcessNoStatusingAsync(processId, terminateUser);

                factory.Close();

                TerminateProcessResponse terminateProcessResponse = new TerminateProcessResponse()
                {
                    ProcessId = processId,
                    ResultId  = result.ResultId,
                    Status    = result.Status.ToUpper()
                };

                return(terminateProcessResponse);
            }
            catch (Exception exception)
            {
                _logger.LogError($"A web service error occurred while terminating the process with id: {processId}. Reason: {exception}");
                throw;
            }
        }
示例#3
0
        public AResponse CreateResponse(string responseData)
        {
            AResponse response = null;

            try
            {
                // validate length
                if (responseData.Length < Protocol.Instance.HeaderLength)
                {
                    throw new ParserException("invalid responseData length");
                }

                // get the header
                string header = responseData.Substring(0, (int)Protocol.Instance.HeaderLength);

                switch (_messageHeaderMapper[header])
                {
                case MessageType.DisplayDevicesInfo:
                    response = new DisplayDeviceInfoResponse();
                    break;

                case MessageType.Pause:
                    response = new PauseResponse();
                    break;

                case MessageType.Play:
                    response = new PlayResponse();
                    break;

                case MessageType.Resume:
                    response = new ResumeResponse();
                    break;

                case MessageType.Seek:
                    response = new SeekResponse();
                    break;

                case MessageType.SetImage:
                    response = new SetImageResponse();
                    break;

                case MessageType.SetText:
                    response = new SetTextResponse();
                    break;

                case MessageType.RemoveAddon:
                    response = new RemoveAddonResponse();
                    break;

                case MessageType.Stop:
                    response = new StopResponse();
                    break;

                case MessageType.Termination:
                    response = new TerminationResponse();
                    break;

                case MessageType.VideoLayout:
                    response = new VideoLayoutResponse();
                    break;

                case MessageType.Volume:
                    response = new VolumeResponse();
                    break;

                case MessageType.WindowLayout:
                    response = new WindowLayoutResponse();
                    break;

                case MessageType.SoundFx:
                    response = new SoundFxResponse();
                    break;

                case MessageType.Sound3d:
                    response = new Sound3dResponse();
                    break;

                case MessageType.MidiProperties:
                    response = new MidiPropertiesResponse();
                    break;

                case MessageType.MidiOutputPortInfo:
                    response = new MidiOutputPortInfoResponse();
                    break;

                case MessageType.SetMidiOutputPort:
                    response = new SetMidiOutputPortResponse();
                    break;

                case MessageType.SetDls:
                    response = new SetDlsResponse();
                    break;

                case MessageType.SetFrequency:
                    response = new SetFrequencyResponse();
                    break;

                case MessageType.SetRate:
                    response = new SetRateResponse();
                    break;

                case MessageType.SetPlayerType:
                    response = new SetPlayerTypeResponse();
                    break;

                default:
                    throw new ParserException("invalid message header");
                }
                response.ParseFromString(responseData);
            }
            catch (System.Exception e)
            {
                throw e;
            }

            return(response);
        }