Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If your class with the <code>WriteLogDataToDb()</code> declared is called <code>ClassA</code>, then do two things. Make the method <code>static</code>, and you actually have to pass some <code>LogData</code> data through it.</p> <pre><code>public class AppForm { public static 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> <p>Then in your <code>Start</code> code, you have to call <code>AppForm.WriteLogDataToDb(data)</code></p> <p><strong>Edit:</strong></p> <p>Now that these classes are in two different projects, you need to add reference so your <code>WindowsServiceHost</code> can use <code>AppForm</code>. To do this:</p> <ol> <li>Right-click > Properties on the project containing <code>AppForm</code>. On the Application tab, take note of the <code>Assembly name:</code></li> <li>Right-click the References item in <code>WindowsServiceHost</code> and choose <code>Add reference</code></li> <li>Go to the <code>Projects</code> tab</li> <li>Add the <code>Assembly name:</code> noted in step #1</li> <li>Right click <code>AppForm</code> in <code>WindowsSerivceHost</code> and <code>Resolve</code> by adding your using statement.</li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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