Created
September 24, 2018 01:21
-
-
Save rasikag/7e57b9dc293b51727a36ee7dbae835d3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CheckMode | |
{ | |
private readonly static Lazy<CheckMode> _instance | |
= new Lazy<CheckMode>(() => new CheckMode( | |
GlobalHost.ConnectionManager.GetHubContext<ModeChangesUpdateHub>().Clients) | |
); | |
private IHubConnectionContext<dynamic> Clients { get; set; } | |
private static SqlTableDependency<ModeTableProperties> _tableDependency; | |
public CheckMode() | |
{ | |
try | |
{ | |
var mapper = new ModelToTableMapper<ModeTableProperties>(); | |
mapper.AddMapping(s => s.IslandNumber, "intIslandNumber"); | |
mapper.AddMapping(s => s.Product, "strProduct"); | |
mapper.AddMapping(s => s.ProductID, "intProductID"); | |
mapper.AddMapping(s => s.DataMode, "strDataMode"); | |
mapper.AddMapping(s => s.ExpID, "strExpID"); | |
mapper.AddMapping(s => s.Lot, "intLot"); | |
mapper.AddMapping(s => s.ShiftNumber, "intShiftNumber"); | |
mapper.AddMapping(s => s.GoalChange, "dtmGoalChange"); | |
mapper.AddMapping(s => s.HeartBeat, "dtmHeartBeat"); | |
mapper.AddMapping(s => s.ChangeMode, "intChangeMode"); | |
mapper.AddMapping(s => s.RecipeID, "RecipeID"); | |
var updateOfModel = new UpdateOfModel<ModeTableProperties>(); | |
updateOfModel.Add(i => i.DataMode); | |
_tableDependency = new SqlTableDependency<ModeTableProperties>( | |
ConfigurationManager.ConnectionStrings["ModeCheckingConnection"].ConnectionString, | |
"Selection", | |
mapper: mapper, | |
updateOf: updateOfModel); | |
_tableDependency.OnChanged += SqlTableDependency_Changed; | |
_tableDependency.Start(300); | |
} | |
catch (Exception ex) | |
{ | |
logger.Error("Error Message: " + ex.Message + " Stack Trace: " + ex.StackTrace); | |
} | |
} | |
public static CheckMode Instance | |
{ | |
get | |
{ | |
return _instance.Value; | |
} | |
} | |
public CheckMode(IHubConnectionContext<dynamic> clients) | |
{ | |
this.Clients = clients; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment