public static void SetLogElementAsDone(Guid serverGUID, Guid?sessionGUID, Guid?pageGUID, Guid?logElementGUID, JobStatus jobStatus) //, bool async) { var async = false; var data = new TransferElementBrowserJob() { SessionGUID = sessionGUID, PageGUID = pageGUID, LogElementGUID = logElementGUID, 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; } 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 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 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 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 string ProcessData(string value) { var serverRequest = SerializationHelper.Deserialize <TransferElementRequest>(value, SerializationType.Json); var serverResponse = new TransferElementResponse() { Success = true }; switch (serverRequest.Type) { case TransferElementRequestType.SyncSession: { var session = (TransferElementSession)serverRequest.Data; if (OnSyncSession != null) { serverResponse = OnSyncSession(session); } break; } case TransferElementRequestType.ClosingSession: { var session = (TransferElementSession)serverRequest.Data; if (OnClosingSession != null) { serverResponse = OnClosingSession(session); } break; } case TransferElementRequestType.FetchLogElement: { var fetchLogElement = (TransferElementFetchLogElement)serverRequest.Data; if (OnFetchLogElement != null) { serverResponse = OnFetchLogElement(fetchLogElement); } break; } case TransferElementRequestType.BrowserJobComplete: { var browserJob = (TransferElementBrowserJob)serverRequest.Data; if (OnBrowserJobComplete != null) { serverResponse = OnBrowserJobComplete(browserJob); } break; } case TransferElementRequestType.BrowserJob: { var logElement = (LogElementDTO)serverRequest.Data; if (OnBrowserJob != null) { serverResponse = OnBrowserJob(logElement); } break; } case TransferElementRequestType.LogElementHistory: { var logElementHistory = (TransferLogElementHistory)serverRequest.Data; if (OnLogElementHistory != null) { serverResponse = OnLogElementHistory(logElementHistory.PreviousLogElement, logElementHistory.NextLogElement, logElementHistory.AdditionalData); } break; } case TransferElementRequestType.ReportDifference: { var logElementHistory = (TransferLogDifference)serverRequest.Data; if (OnLogElementDifference != null) { serverResponse = OnLogElementDifference(logElementHistory.PreviousLogElement, logElementHistory.NextLogElement); } break; } default: { serverResponse.Success = false; serverResponse.Message = "Type Not Implemented"; break; } } //var callback = OperationContext.Current.GetCallbackChannel<INamedPipeCallbackService>(); //callback.NotifyClient(); return(SerializationHelper.Serialize(serverResponse, SerializationType.Json)); }