public int Compare(object x, object y) { NotificationFile FileX = (NotificationFile)x; NotificationFile FileY = (NotificationFile)y; return(FileY.Age.CompareTo(FileX.Age)); }
public void RemoveNewFiles(int MinAgeSeconds) { for (int i = _NFiles.Count - 1; i >= 0; i--) { NotificationFile NFile = (NotificationFile)_NFiles[i]; if (NFile.Age.TotalSeconds < MinAgeSeconds) { _NFiles.RemoveAt(i); } } }
private NotificationFile GetNextNotificationFile() { NotificationFile RetVal = null; if (_NFileCache == null || _NFileCache.Count == 0) { _NFileCache = ReadAllNotificationFilesFromDisk(); } if (_NFileCache.Count > 0) { RetVal = _NFileCache.GetFileAt(0); _NFileCache.RemoveFileAt(0); } return(RetVal); }
public NotificationQueueMessage Receive() { if (_InProcessDir == null) { throw new ApplicationException( "Must use the 4 parameter contstructor to create a queue object " + "that supports the Receive() method."); } NotificationQueueMessage RetVal = null; int SleepSeconds = 0; while (RetVal == null) { NotificationFile NFile = GetNextNotificationFile(); if (NFile != null) { RetVal = new NotificationQueueMessage(NFile.Id, NFile.Type, NFile.OrderId, ReadFile(_InboxDir + NFile.Name)); File.Move(_InboxDir + NFile.Name, _InProcessDir + NFile.Name); } else { SleepSeconds = SleepSeconds * 2; if (SleepSeconds == 0) { SleepSeconds = 1; } if (SleepSeconds > 30) { SleepSeconds = 30; } Thread.Sleep(SleepSeconds * 1000); } } return(RetVal); }
public void Add(NotificationFile NFile) { _NFiles.Add(NFile); }
public void Send(NotificationQueueMessage M) { NotificationFile NFile = new NotificationFile(M.Id, M.Type, M.OrderId); WriteFile(_InboxDir + NFile.Name, M.Xml); }
public void ProcessingFailed(NotificationQueueMessage M) { NotificationFile NFile = new NotificationFile(M.Id, M.Type, M.OrderId); File.Move(_InProcessDir + NFile.Name, _FailureDir + NFile.Name); }
public void ProcessingSucceeded(NotificationQueueMessage M) { NotificationFile NFile = new NotificationFile(M.Id, M.Type, M.OrderId); File.Move(_InProcessDir + NFile.Name, _SuccessDir + NFile.Name); }