public void Cancel() { bp.Cancel(); SubscriptionHelper.Terminate(ref this.s); PublisherMergeInner[] a = ProcessorHelper.Terminate(ref subscribers, Terminated); if (a != Terminated) { foreach (PublisherMergeInner inner in a) { inner.Cancel(); } } }
private void ExecuteServiceActions() { logger.Info("*********************************************************************************************"); logger.Info("Service execution triggered"); if (ProcessorHelper.IsExecutionCompleted(ServiceProcessors.WindowsServices.ManagementNotifications)) { logger.Info("Service execution completed already. It will not be processed again."); return; } try { if (dayOfExecution != DateTime.Today.Day) { logger.Info($"Service will not be processed today as today is not {dayOfExecution} as configured"); return; } int reportingDay = 27; if (DateTime.Today.DayOfWeek == DayOfWeek.Thursday) { reportingDay += 1; } else if (DateTime.Today.DayOfWeek == DayOfWeek.Friday) { reportingDay += 2; } ManagementNotificationsProcessor processor = new ManagementNotificationsProcessor(); processor.GenerateManagementNotifications(appTempDirectory, reportingDay); } catch (Exception exp) { logger.Error("Error while executing the service"); logger.Error(exp); } finally { logger.Info("Service execution completed"); logger.Info("*********************************************************************************************"); } }
/// <summary> /// make timer procedure /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void Timer_Elapsed(object sender, ElapsedEventArgs e) { try { Timer.Stop(); if (ServiceSettings == null) { SystemSettings = new SystemSettingsModel(); ServiceSettings = ServiceSettingHelper.InitServiceSettings(SystemSettings.SettingsPath); } ProcessorHelper.MakeProcessing(); Timer.Start(); } catch (Exception exception) { string innerException = exception.InnerException == null ? "" : exception.InnerException.Message; string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name; LogHelper.AddLog("Error in method: " + methodName + "; Exception: " + exception.Message + " Innner Exception: " + innerException); } }
bool CheckTerminated(bool d, bool empty, PublisherPublishInner[] a) { if (a == Terminated) { q.Clear(); return(true); } if (d) { Exception e = error; if (e != null) { q.Clear(); var b = ProcessorHelper.Terminate(ref subscribers, Terminated); foreach (var inner in b) { inner.OnError(e); } return(true); } else if (empty) { var b = ProcessorHelper.Terminate(ref subscribers, Terminated); foreach (var inner in b) { inner.OnComplete(); } return(true); } } return(false); }
/// <summary> /// debug mode method /// </summary> public void OnDebug() { ProcessorHelper.MakeProcessing(); }
/// <summary> /// Main process request method /// </summary> /// <param name="Request"></param> /// <returns></returns> async Task <GateResponse> IGate.Process(GateRequest Request) { try { _LastCall = DateTime.UtcNow; //Start a timer to log request processing time etc. System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); sw.Start(); //Test for ping if (Request.Kind == (int)RequestProcessorEnum._System_PingGw) { GateResponse pingResponse = new GateResponse(Request); pingResponse.JsonPayload = new GameFabric.Shared.Responses.EmptyResponse().Serialize(); pingResponse.ResultCode = (int)System.Net.HttpStatusCode.OK; return(pingResponse); } //retrieve a processor for the call IRequestProcessor processor = ProcessorHelper.GetProcessor(Request.Kind); //Just test for authentication if (processor.Authenticated && !_isAuthenticated) { GateResponse errorResponse = new GateResponse(Request); errorResponse.ResultCode = (int)HttpStatusCode.Forbidden; _ForbiddenCount++; _LastForbiddenCall = DateTime.UtcNow; return(await Task.FromResult(errorResponse)); } //Deserialize request string Payload = Request.JsonPayload; //Check for compression and decompress if needed if (Request.isCompressed) { Payload = Payload.Decompress(); } //Then deserialize IRequest embeddedRequest = (IRequest)Payload.Deserialize(ProcessorHelper.ResolveRequestProcessorRequestType(Request.Kind)); //Execute processor IResponse result = await processor.Process(embeddedRequest); // Create response GateResponse response = new GateResponse(Request); //Set the response data and compress if needed response.JsonPayload = result.Serialize(); long uncompsize = response.JsonPayload.Length; if (response.JsonPayload.Length > 512) { response.JsonPayload = response.JsonPayload.Compress(); response.isCompressed = true; } long compressedsize = response.JsonPayload.Length; //Stop timer and write stats sw.Stop(); //Write stats if (!_StatDict.ContainsKey(Request.Kind)) { _StatDict.Add(Request.Kind, new RequestStats(Request.Kind)); } _StatDict[Request.Kind].NumCalls++; _StatDict[Request.Kind].TotalTime += sw.ElapsedMilliseconds; _StatDict[Request.Kind].CompressedSize += compressedsize; _StatDict[Request.Kind].TotalSize += uncompsize; //Finalize response response.TimeTaken = sw.ElapsedMilliseconds; //Set response code response.ResultCode = (int)System.Net.HttpStatusCode.OK; this.ApplicationName.LogDebug(processor.ProcessorId.ToString(), sw.ElapsedMilliseconds.ToString()); return(response); } catch (Exception E) { this.Log(E); GateResponse errorResponse = new GateResponse(Request); errorResponse.ResultCode = (int)HttpStatusCode.InternalServerError; return(await Task.FromResult(errorResponse)); } }
bool Add(PublishProcessorInner inner) { return(ProcessorHelper.Add(ref subscribers, inner, Terminated)); }
void Remove(PublishProcessorInner inner) { ProcessorHelper.Remove(ref subscribers, inner, Terminated, Empty); }
public void Dispose() { ProcessorHelper.Terminate(ref subscribers, Terminated); arbiter.Cancel(); }
void Add(PublisherReplayInner inner) { ProcessorHelper.Add(ref subscribers, inner, Terminated); }
internal bool Remove(SingleDisposable sd) { return(ProcessorHelper.Remove(ref subscribers, sd, Terminated, Empty)); }
internal bool Add(SingleDisposable sd) { return(ProcessorHelper.Add(ref subscribers, sd, Terminated)); }