/// <summary> /// Main method that gathers data /// </summary> /// <param name="context">IDroneContext</param> public override void GetData(object context) { try { TwitterContext cont = context as TwitterContext; if (!Object.Equals(cont, null)) { SetContextStatus("processing", cont); //lock the thread and write to context lock (cont) cont.NextRun = XMLUtility.GetNextRunInterval(Xml); //do work if (XMLUtility.IsEnabled(Xml)) { WriteToUsageLogFile("Twitter.GetData | Thread:" + Thread.CurrentThread.ManagedThreadId.ToString(), "Started GetAllMentionsByQuery"); GetAllMentionsByQuery(cont); WriteToUsageLogFile("Twitter.GetData | Thread:" + Thread.CurrentThread.ManagedThreadId.ToString(), "Completed GetAllMentionsByQuery"); } //lock the thread and write to context SetContextStatus("waiting", cont); } RaiseProcessingCompletedEvent(new EventArgs()); } catch (Exception e) { ExceptionExtensions.LogError(e, "Drone.Twitter.Components.Twitter.GetData()"); } }
public void TwitterUtility_GetNextRunInterval() { Drone.Twitter.Components.Twitter t = new Twitter.Components.Twitter(new TwitterTestDataSource()); DateTime nextRun = XMLUtility.GetNextRunInterval(t.Xml); Assert.IsNotNull(nextRun); }
/// <summary> /// Main method that gathers data /// </summary> /// <param name="context">iDroneContext</param> public override void GetData(object context) { try { BaseContext cont = context as BaseContext; lock (cont) cont.NextRun = XMLUtility.GetNextRunInterval(Xml); if (!Object.Equals(cont, null) && GetContextStatus(cont) != "processing") { Context = cont; SetContextStatus("processing", cont); if (XMLUtility.IsEnabled(Xml)) { //do work WriteToUsageLogFile("QueueProcessor.GetData | Thread:" + Thread.CurrentThread.ManagedThreadId.ToString(), "Started QueueProcessor calls"); while (!cont.ShuttingDown) { try { int counters = 0; lock (this) counters = _processingCounter; if (_qm.HasMessages && counters == 0) { ProcessQueue(); } } catch (Exception ex) { ExceptionExtensions.LogWarning(ex, "QueueProcessor.GetData"); } Thread.Sleep(5000); } WriteToUsageLogFile("QueueProcessor.GetData | Thread:" + Thread.CurrentThread.ManagedThreadId.ToString(), "Completed QueueProcessor calls"); } SetContextStatus("waiting", cont); } RaiseProcessingCompletedEvent(new EventArgs()); } catch (Exception e) { SetContextStatus("waiting", Context); ExceptionExtensions.LogError(e, "Drone.QueueProcessor.Components.QueueProcessor.GetData()"); } }