Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy Can't I call this method?
    text
    copied!<p>I'm trying to call a method from another class within a service, however it's saying that the method I'm trying to call doesn't exist and would like some help if possible.</p> <p>the program is a work project, which logs user inactivity as we've had issues with people not picking up the phone, code is below, this is a topshelf service that consumes messages from rabbitMQ and I want it to consume the messages and forward them to a database =]</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Diagnostics; using NLog; using IWshRuntimeLibrary; using Topshelf; using System.Data.Odbc; using EasyNetQ; using RabbitMQ; using EasyNetQ.Topology; using System.Threading.Tasks; using System.Windows.Forms; using AccessEye; namespace LogService { public class WindowsServiceHost : ServiceControl, ServiceShutdown { public static readonly Logger Logger = LogManager.GetCurrentClassLogger(); public bool Start(HostControl hostControl) { Program.bus = RabbitHutch.CreateBus("host=as01.access.local;virtualHost=DEV-Reece;username=reece;password=reece").Advanced; //var bus = RabbitHutch.CreateBus("host=as01.access.local;virtualHost=DEV-Reece;username=reece;password=reece").Advanced; var queue = Queue.Declare(true, false, true, null); var exchange = Exchange.DeclareFanout("UserActivityFanout", true, false, null); var exchangeTopic = Exchange.DeclareTopic("UserActivity", true, false, null); queue.BindTo(exchange, "#"); exchange.BindTo(exchangeTopic, "#"); Program.bus.Subscribe&lt;AccessEye.LogData&gt;(queue, (msg, messageRecInfo) =&gt; Task.Factory.StartNew(() =&gt; { WriteLogDataToDb(); Console.WriteLine(msg.Body.UserName + " -- " + msg.Body.ComputerName + " -- " + msg.Body.EventType + " -- " + msg.Body.TeamviewerId); })); return true; } </code></pre> <p>And this is the method I'm trying to call</p> <pre><code> public partial class AppForm : Form { public static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private Screensaver watcher; public Inactivity inactivity; IAdvancedBus bus; IExchange exchange; public void WriteLogDataToDb(LogData data) { using (var db = new LogService.UserActivityDataContext()) { DbLogData logData = AutoMapper.Mapper.Map&lt;LogData, DbLogData&gt;(data); int t = (int)data.EventType; EventType eventType = db.EventTypes.FirstOrDefault(r =&gt; r.Id == t); if (eventType == null) { eventType = db.EventTypes.Add(new EventType { Event = GetEnumDescriptionAttributeValue(data.EventType), Id = (int)data.EventType }); db.SaveChanges(); } logData.EventTypeId = eventType.Id; db.LogEvents.Add(logData); db.SaveChanges(); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload