private void OnMessageArrived(object sender, IdleEventArgs args) { foreach (var message in args.Messages) { message.Seen = true; OutageMailMessage outageMessage = _mapper.MapMail(message); Console.WriteLine(outageMessage); OutageTracingModel tracingModel = _parser.Parse(outageMessage); if (tracingModel.IsValidReport) { _dispatcher.Dispatch(tracingModel.Gid); } try { _publisher.Publish( publication: new OutageEmailPublication(Topic.OUTAGE_EMAIL, new EmailToOutageMessage(tracingModel.Gid)), publisherName: "ImapIdleEmailClient" ); } catch (Exception) { Console.WriteLine("[ImapIdleEmailClient::OnMessageArrived] Sending to PubSub Engine failed."); } } ReregisterIdleHandler(); }
private void OnMessageArrived(object sender, IdleEventArgs args) { foreach (var message in args.Messages) { message.Seen = true; OutageMailMessage outageMessage = mapper.MapMail(message); Console.WriteLine(outageMessage); OutageTracingModel tracingModel = parser.Parse(outageMessage); if (tracingModel.IsValidReport) { dispatcher.Dispatch(tracingModel.Gid); } try { publisher.Publish(new OutageEmailPublication(Topic.OUTAGE_EMAIL, new EmailToOutageMessage(tracingModel.Gid)), MicroserviceNames.OmsEmailService).Wait(); } catch (Exception e) { Console.WriteLine($"[ImapIdleEmailClient::OnMessageArrived] Sending to PubSub Engine failed. Exception message: {e.Message}"); } } ReregisterIdleHandler(); }
/// <summary> /// Helper function used to fire idle events. /// </summary> /// <param name="e">The idle event arguments.</param> /// <param name="clearOnly">Only clear the action, don't fire the event.</param> private void OnIdle(IdleEventArgs e, bool clearOnly) { if (!clearOnly && Idle != null) { Idle(this, e); } }
void Channel_Idle(object sender, IdleEventArgs e) { if (_channelDoEvents) { Application.DoEvents(); } }
void Channel_Idle(object sender, IdleEventArgs e) { // e.bDoEvents = this._doEvents; // 2016/1/26 if (this._doEvents) { Application.DoEvents(); } }
void biblio_paths_Idle(object sender, IdleEventArgs e) { this._app_down.Token.ThrowIfCancellationRequested(); #if NO if (this.m_bClosed == true || this.Stopped == true) { throw new InterruptException("中断"); } #endif }
//EVENT System idle timer - On idle end public void SystemIdleTimer1_OnExitIdleState(Object sender, IdleEventArgs e) { logging.WriteToLog("SystemIdleTimer1_OnExitIdleState triggered!"); if (activeHour) { logging.WriteToLog("Active hour and system has come out of idle period of " + idleTime + " seconds. Triggering toast to user!"); BalloonTip("TEST IDLE!!", "Come out of idle state of " + idleTime, balloonTipTime, true); //Need to mark as triggered for that hour and day so hours might need to be their own class } }
void SampleCarnivore_Idle(object sender, IdleEventArgs e) { try { if (CanReproduce) { BeginReproduction(null); } if (CanEat && !IsEating) { if (_targetAnimal != null) { if (WithinEatingRange(_targetAnimal)) { BeginEating(_targetAnimal); if (IsMoving) { StopMoving(); } } else { if (!IsMoving) { BeginMoving(new MovementVector(_targetAnimal.Position, 2)); } } } else { if (!ScanForTargetAnimal()) { if (!IsMoving) { int randomX = OrganismRandom.Next(0, WorldWidth - 1); int randomY = OrganismRandom.Next(0, WorldHeight - 1); BeginMoving(new MovementVector(new Point(randomX, randomY), 2)); } } } } else { if (IsMoving) { StopMoving(); } } } catch (Exception exc) { WriteTrace(exc.ToString()); } }
void channel_Idle(object sender, IdleEventArgs e) { bool bConnected = this.Response.IsClientConnected; if (bConnected == false) { LibraryChannel channel = (LibraryChannel)sender; channel.Abort(); } // e.bDoEvents = false; }
void SampleCarnivore_Idle(object sender, IdleEventArgs e) { try { if (CanReproduce) { BeginReproduction(null); } if (CanEat && !IsEating) { if (_targetAnimal != null) { if (WithinEatingRange(_targetAnimal)) { BeginEating(_targetAnimal); if (IsMoving) StopMoving(); } else { if (!IsMoving) BeginMoving(new MovementVector(_targetAnimal.Position, 2)); } } else { if (!ScanForTargetAnimal()) { if (!IsMoving) { int randomX = OrganismRandom.Next(0, WorldWidth - 1); int randomY = OrganismRandom.Next(0, WorldHeight - 1); BeginMoving(new MovementVector(new Point(randomX, randomY), 2)); } } } } else { if (IsMoving) StopMoving(); } } catch (Exception exc) { WriteTrace(exc.ToString()); } }
private void OnMessageArrived(object sender, IdleEventArgs args) { try { foreach (var message in args.Messages) { message.Seen = true; OutageMailMessage outageMessage = mapper.MapMail(message); Logger.LogInformation($"{baseLogString} OnMessageArrived => Message: {outageMessage}"); OutageTracingModel tracingModel = parser.Parse(outageMessage); publisher.Publish(new OutageEmailPublication(Topic.OUTAGE_EMAIL, new EmailToOutageMessage(tracingModel.Gid)), MicroserviceNames.OmsEmailService).Wait(); } ReregisterIdleHandler(); } catch (Exception e) { Logger.LogError($"{baseLogString} OnMessageArrived => Exception: {e.Message}", e); } }
private void Inbox_OnNewMessagesArrived(object sender, IdleEventArgs e) { foreach (var message in e.Messages.OrderByDescending(m => m.Date ?? DateTime.Now)) { var date = message.Date ?? DateTime.Now; var from = message.From.Address; var msgSubject = message.Subject; var msgBody = message.Body.Text; var processedMessage = _messageProcessor.Process(date, from, msgSubject, msgBody); _meterReadingMessages.Insert(0, processedMessage); _appEntitiesRepo.Insert(processedMessage); if (!string.IsNullOrEmpty(processedMessage.FlatNumber)) { _appEntitiesRepo.Upsert(new SenderFlat { Sender = processedMessage.SenderAddress, FlatNumber = processedMessage.FlatNumber }); } } }
// Fired after all other events are fired during a turn void IdleEvent(object sender, IdleEventArgs e) { try { // Our Creature will reproduce as often as possible so // every turn it checks CanReproduce to know when it // is capable. If so we call BeginReproduction with // a null Dna parameter to being reproduction. if (CanReproduce) { BeginReproduction(null); } // Check to see if we are capable of eating // If we are then try to eat or find food, // else we'll just stop moving. if (CanEat && !IsEating) { // If we have a Target Plant we can try // to either eat it, or move towards it. // else we'll move to a random vector // in search of a plant. if (targetPlant != null) { // If we are within range start eating // and stop moving. Else we'll try // to move towards the plant. if (WithinEatingRange(targetPlant)) { BeginEating(targetPlant); if (IsMoving) { StopMoving(); } } else { if (!IsMoving) { BeginMoving(new MovementVector(targetPlant.Position, 2)); } } } else { // We'll try try to find a target plant // If we don't find one we'll move to // a random vector if (!ScanForTargetPlant()) { if (!IsMoving) { int RandomX = OrganismRandom.Next(0, WorldWidth - 1); int RandomY = OrganismRandom.Next(0, WorldHeight - 1); BeginMoving(new MovementVector(new Point(RandomX, RandomY), 2)); } } } } else { // Since we are Full or we are already eating // We should stop moving. if (IsMoving) { StopMoving(); } } } catch (Exception exc) { WriteTrace(exc.ToString()); } }
/// <summary> /// Helper function used to fire idle events. /// </summary> /// <param name="e">The idle event arguments.</param> /// <param name="clearOnly">Only clear the action, don't fire the event.</param> private void OnIdle(IdleEventArgs e, bool clearOnly) { if (!clearOnly && Idle != null) { Idle(this, e); } }
// Fired after all other events are fired during a turn void IdleEvent(object sender, IdleEventArgs e) { try { // Our Creature will reproduce as often as possible so // every turn it checks CanReproduce to know when it // is capable. If so we call BeginReproduction with // a null Dna parameter to being reproduction. if (CanReproduce) { BeginReproduction(null); } // If we are already doing something, then we don't // need to do something else. Lets leave the // function. if (IsAttacking || IsMoving || IsEating) { return; } // Try to find a new target if we need one. if (targetAnimal == null) { FindNewTarget(); } // If we have a target animal then lets check him out if (targetAnimal != null) { // If the target is alive, then we need to kill it // else we can immediately eat it. if (targetAnimal.IsAlive) { // If we are within attacking range, then // lets eat the creature. Else we'll // try to move into range if (WithinAttackingRange(targetAnimal)) { BeginAttacking(targetAnimal); } else { MoveToTarget(); } } else { // If the creature is dead then we can try to eat it. // If we are within eating range then we'll try to // eat the creature, else we'll move towards it. if (WithinEatingRange(targetAnimal)) { if (CanEat) { BeginEating(targetAnimal); } } else { MoveToTarget(); } } } else { // If we stop moving we conserve energy. Sometimes // this works better than running around. StopMoving(); } } catch (Exception exc) { WriteTrace(exc.ToString()); } }
private static void Inbox_OnNewMessagesArrived(object sender, IdleEventArgs e) { // Show a dialog MessageBox.Show($"A new message was downloaded in {e.Folder.Name} folder."); }
void channel_Idle(object sender, IdleEventArgs e) { Application.DoEvents(); }
void biblio_paths_Idle(object sender, IdleEventArgs e) { if (this.m_bClosed == true || this.Stopped == true) { throw new InterruptException("中断"); } }
void channel_Idle(object sender, IdleEventArgs e) { if (this.m_bClosed == true || this.Stopped == true) { LibraryChannel channel = (LibraryChannel)sender; channel.Abort(); } // e.bDoEvents = false; // System.Threading.Thread.Sleep(100); // 避免CPU资源过度耗费 }
// Fired after all other events are fired during a turn private void IdleEvent(object sender, IdleEventArgs e) { try { // Our Creature will reproduce as often as possible so // every turn it checks CanReproduce to know when it // is capable. If so we call BeginReproduction with // a null Dna parameter to being reproduction. if (CanReproduce) BeginReproduction(null); // Check to see if we are capable of eating // If we are then try to eat or find food, // else we'll just stop moving. if (CanEat && !IsEating) { // If we have a Target Plant we can try // to either eat it, or move towards it. // else we'll move to a random vector // in search of a plant. if (targetPlant != null) { // If we are within range start eating // and stop moving. Else we'll try // to move towards the plant. if (WithinEatingRange(targetPlant)) { BeginEating(targetPlant); if (IsMoving) StopMoving(); } else { if (!IsMoving) BeginMoving(new MovementVector(targetPlant.Position, 2)); } } else { // We'll try try to find a target plant // If we don't find one we'll move to // a random vector if (!ScanForTargetPlant()) { if (!IsMoving) { int RandomX = OrganismRandom.Next(0, WorldWidth - 1); int RandomY = OrganismRandom.Next(0, WorldHeight - 1); BeginMoving(new MovementVector(new Point(RandomX, RandomY), 2)); } } } } else { // Since we are Full or we are already eating // We should stop moving. if (IsMoving) StopMoving(); } } catch (Exception exc) { WriteTrace(exc.ToString()); } }
// Fired after all other events are fired during a turn void IdleEvent(object sender, IdleEventArgs e) { try { // Our Creature will reproduce as often as possible so // every turn it checks CanReproduce to know when it // is capable. If so we call BeginReproduction with // a null Dna parameter to being reproduction. if(CanReproduce) BeginReproduction(null); // If we are already doing something, then we don't // need to do something else. Lets leave the // function. if ( IsAttacking || IsMoving || IsEating ) { return; } // Try to find a new target if we need one. if(targetAnimal == null) { FindNewTarget(); } // If we have a target animal then lets check him out if(targetAnimal != null ) { // If the target is alive, then we need to kill it // else we can immediately eat it. if ( targetAnimal.IsAlive ) { // If we are within attacking range, then // lets eat the creature. Else we'll // try to move into range if ( WithinAttackingRange(targetAnimal) ) { BeginAttacking(targetAnimal); } else { MoveToTarget(); } } else { // If the creature is dead then we can try to eat it. // If we are within eating range then we'll try to // eat the creature, else we'll move towards it. if ( WithinEatingRange(targetAnimal) ) { if (CanEat) { BeginEating(targetAnimal); } } else { MoveToTarget(); } } } else { // If we stop moving we conserve energy. Sometimes // this works better than running around. StopMoving(); } } catch(Exception exc) { WriteTrace(exc.ToString()); } }
// Fired after all other events are fired during a turn private void MyAnimal_Idle(object sender, IdleEventArgs e) { try { // Reproduce as often as possible if (CanReproduce) { BeginReproduction(null); } // If we can eat and we have a target plant, eat if (CanEat) { WriteTrace("Hungry."); if (!IsEating) { WriteTrace("Not eating: Have target plant?"); if (targetPlant != null) { WriteTrace("Yes, Have target plant already."); if (WithinEatingRange(targetPlant)) { WriteTrace("Within Range, Start eating."); BeginEating(targetPlant); if (IsMoving) { WriteTrace("Stop while eating."); StopMoving(); } } else { if (!IsMoving) { WriteTrace("Move to Target Plant"); BeginMoving(new MovementVector(targetPlant.Position, 2)); } } } else { WriteTrace("Don't have target plant."); if (!ScanForTargetPlant()) { if (!IsMoving) { WriteTrace("No plant found, so pick a random point and move there"); int RandomX = OrganismRandom.Next(0, WorldWidth - 1); int RandomY = OrganismRandom.Next(0, WorldHeight - 1); BeginMoving(new MovementVector(new Point(RandomX, RandomY), 2)); } else { WriteTrace("Moving and Looking..."); } } } } else { WriteTrace("Eating."); if (IsMoving) { WriteTrace("Stop moving while eating."); StopMoving(); } } } else { WriteTrace("Full: do nothing."); if (IsMoving) { StopMoving(); } } } catch (Exception exc) { WriteTrace(exc.ToString()); } }
void biblio_paths_Idle(object sender, IdleEventArgs e) { this._app_down.Token.ThrowIfCancellationRequested(); #if NO if (this.m_bClosed == true || this.Stopped == true) { throw new InterruptException("中断"); } #endif }
// Fired after all other events are fired during a turn private void MyAnimal_Idle(object sender, IdleEventArgs e) { try { // Reproduce as often as possible if (CanReproduce) BeginReproduction(null); // If we can eat and we have a target plant, eat if (CanEat) { WriteTrace("Hungry."); if (!IsEating) { WriteTrace("Not eating: Have target plant?"); if (targetPlant != null) { WriteTrace("Yes, Have target plant already."); if (WithinEatingRange(targetPlant)) { WriteTrace("Within Range, Start eating."); BeginEating(targetPlant); if (IsMoving) { WriteTrace("Stop while eating."); StopMoving(); } } else { if (!IsMoving) { WriteTrace("Move to Target Plant"); BeginMoving(new MovementVector(targetPlant.Position, 2)); } } } else { WriteTrace("Don't have target plant."); if (!ScanForTargetPlant()) if (!IsMoving) { WriteTrace("No plant found, so pick a random point and move there"); int RandomX = OrganismRandom.Next(0, WorldWidth - 1); int RandomY = OrganismRandom.Next(0, WorldHeight - 1); BeginMoving(new MovementVector(new Point(RandomX, RandomY), 2)); } else { WriteTrace("Moving and Looking..."); } } } else { WriteTrace("Eating."); if (IsMoving) { WriteTrace("Stop moving while eating."); StopMoving(); } } } else { WriteTrace("Full: do nothing."); if (IsMoving) StopMoving(); } ShouldIMoveForMyFriend(); } catch (Exception exc) { WriteTrace(exc.ToString()); } }
//EVENT System idle timer - On idle timeout met public void SystemIdleTimer1_OnEnterIdleState(Object sender, IdleEventArgs e) { logging.WriteToLog("SystemIdleTimer1_OnEnterIdleState triggered!"); }