public static bool ReportDifference(Guid serverGUID, LogElementDTO previousLogElement, LogElementDTO nextLogElement) { var data = new TransferLogDifference() { PreviousLogElement = previousLogElement, NextLogElement = nextLogElement }; var serverRequest = new TransferElementRequest() { Type = TransferElementRequestType.ReportDifference, Data = data }; var serverRequestJSON = SerializationHelper.Serialize(serverRequest, SerializationType.Json); string error; var serverResponseJSON = PlayerCommunicationClient.SendRequest_Threading(serverGUID, serverRequestJSON, out error); TransferElementResponse serverResponse = null; if (error == null) { serverResponse = SerializationHelper.Deserialize <TransferElementResponse>(serverResponseJSON, SerializationType.Json); } if (error != null || !serverResponse.Success) { throw new Exception($"Error occured while communicating with player ({error ?? serverResponse.Message})"); } return((bool)serverResponse.Data); }
public static LogElementDTO SetHandlerLogElementAsDone(Guid serverGUID, Guid pageGUID, LogType logType, string handlerUrl, JobStatus jobStatus) //, bool async) { var async = false; var data = new TransferElementBrowserJob() { PageGUID = pageGUID, LogType = logType, HandlerUrl = handlerUrl, JobStatus = jobStatus }; var serverRequest = new TransferElementRequest() { Type = TransferElementRequestType.BrowserJobComplete, Data = data }; var serverRequestJSON = SerializationHelper.Serialize(serverRequest, SerializationType.Json); string error; var serverResponseJSON = PlayerCommunicationClient.SendRequest_Threading(serverGUID, serverRequestJSON, out error, async); if (async && serverResponseJSON == null) { return(null); } TransferElementResponse serverResponse = null; if (error == null) { serverResponse = SerializationHelper.Deserialize <TransferElementResponse>(serverResponseJSON, SerializationType.Json); } if (error != null || !serverResponse.Success) { throw new Exception($"Error occured while communicating with player ({error ?? serverResponse.Message})"); } return(serverResponse?.Data as LogElementDTO); }
public static void SendSyncSession(Guid serverGUID, Guid sessionGUID, int processId) //Process.GetCurrentProcess().Id { var data = new TransferElementSession() { ProcessGUID = sessionGUID, ProcessId = processId }; var serverRequest = new TransferElementRequest() { Type = TransferElementRequestType.SyncSession, Data = data }; var serverRequestJSON = SerializationHelper.Serialize(serverRequest, SerializationType.Json); string error; var serverResponseJSON = PlayerCommunicationClient.SendRequest_Threading(serverGUID, serverRequestJSON, out error); TransferElementResponse serverResponse = null; if (error == null) { serverResponse = SerializationHelper.Deserialize <TransferElementResponse>(serverResponseJSON, SerializationType.Json); } if (error != null || !serverResponse.Success) { throw new Exception($"Error occured while communicating with player ({error ?? serverResponse.Message})"); } }
public static void SendBrowserJob_ASYNC(TransferElementSession session, LogElementDTO logElement) { var serverRequest = new TransferElementRequest() { Type = TransferElementRequestType.BrowserJob, Data = logElement }; var serverRequestJSON = SerializationHelper.Serialize(serverRequest, SerializationType.Json); string error; var serverResponseJSON = PlayerCommunicationClient.SendRequest_Threading(session.ProcessGUID, serverRequestJSON, out error, async: true); if (serverResponseJSON == null) { return; } TransferElementResponse serverResponse = null; if (error == null) { serverResponse = SerializationHelper.Deserialize <TransferElementResponse>(serverResponseJSON, SerializationType.Json); } if (error != null || !serverResponse.Success) { throw new Exception($"Error occured while sending starting browser job ({error ?? serverResponse.Message})"); } }
public static string SendRequest_Threading(Guid serverId, string value, out string error, bool async = false) { string result = null; string errorTmp = null; var t = new Thread(() => { try { var client = new PlayerCommunicationClient(serverId); result = client.SendRequest(value); client.Close(); } catch (Exception ex) { errorTmp = ex.Message; } }); t.IsBackground = true; t.Start(); if (async) { error = null; return(null); } t.Join(60000); //wait 60sec for response error = errorTmp; return(result); }
public static FetchLogElementResponse FetchLogElementFromPlayer(Guid serverGUID, Guid?sessionGUID, Guid?pageGUID, LogType logType) { var fetchLogElement = new TransferElementFetchLogElement() { SessionGUID = sessionGUID, PageGUID = pageGUID, LogType = logType }; var serverRequest = new TransferElementRequest() { Type = TransferElementRequestType.FetchLogElement, Data = fetchLogElement }; var serverRequestJSON = SerializationHelper.Serialize(serverRequest, SerializationType.Json); string error; string serverResponseJSON = PlayerCommunicationClient.SendRequest_Threading(serverGUID, serverRequestJSON, out error); if (!String.IsNullOrWhiteSpace(error)) { throw new Exception(error); } var serverResponse = SerializationHelper.Deserialize <TransferElementResponse>(serverResponseJSON, SerializationType.Json); return((FetchLogElementResponse)serverResponse.Data); }
public static bool SendClosingSession(Guid serverGUID, Guid processGUID, int processId) { var session = new TransferElementSession() { ProcessGUID = processGUID, ProcessId = processId }; var serverRequest = new TransferElementRequest() { Type = TransferElementRequestType.ClosingSession, Data = session }; var serverRequestJSON = SerializationHelper.Serialize(serverRequest, SerializationType.Json); string error; var serverResponseJSON = PlayerCommunicationClient.SendRequest_Threading(serverGUID, serverRequestJSON, out error); if (!String.IsNullOrWhiteSpace(error)) { throw new Exception(error); } var serverResponse = SerializationHelper.Deserialize <TransferElementResponse>(serverResponseJSON, SerializationType.Json); return(!serverResponse.Success); }