public void ProcessLogFunctionsXML(XmlDocument doc) { PLLog.Trace("Enter Method", "ODB"); try { XmlNode element = doc.DocumentElement.SelectSingleNode("//LogFunctions"); if (element == null) { return; } foreach (XmlNode node in element.ChildNodes) { switch (node.Name) { case "LogFunction": int id = int.Parse(node.Attributes.GetNamedItem("id").Value); string name = node.Attributes.GetNamedItem("name").Value; string description = node.Attributes.GetNamedItem("description").Value; LogFunction logFunction = new LogFunction(); logFunction.logfunction_id = id; logFunction.logfunction_name = name; logFunction.logfunction_description = description; odbContext.LogFunctions.InsertOnSubmit(logFunction); odbContext.SubmitChanges(); break; case "ClearAll": var rows = from r in odbContext.LogFunctions select r; foreach (LogFunction row in rows) { odbContext.LogFunctions.DeleteOnSubmit(row); } odbContext.SubmitChanges(); break; default: PLLog.Info(string.Format("Unsupported element: {0}", node.Name), "ODB"); break; } } } catch (Exception ex) { PLLog.Error(ex, "ODB"); throw; } PLLog.Trace("Exit Method", "ODB"); }
protected override void OnContinue() { long startTicks = PLLog.Info("Start", PLLOG_APPNAME, CLASS_BASE_ERRORNUMBER + 7); //OnStart(null); PLLog.Info("End", PLLOG_APPNAME, CLASS_BASE_ERRORNUMBER + 8, startTicks); }
protected override void OnPause() { long startTicks = PLLog.Info("Start", PLLOG_APPNAME, CLASS_BASE_ERRORNUMBER + 11); //OnStop(); PLLog.Info("End", PLLOG_APPNAME, CLASS_BASE_ERRORNUMBER + 12, startTicks); }
protected override void OnStop() { long startTicks = PLLog.Info("Start", PLLOG_APPNAME, CLASS_BASE_ERRORNUMBER + 9); _RequestTimer_Daily.Dispose(); _RequestTimer_IntraDay.Dispose(); PLLog.Info("End", PLLOG_APPNAME, CLASS_BASE_ERRORNUMBER + 10, startTicks); }
public void ProcessAssociationTypesXML(XmlDocument doc) { PLLog.Trace("Enter Method", "ODB"); try { XmlNode element = doc.DocumentElement.SelectSingleNode("//AssociationTypes"); if (element == null) { return; } foreach (XmlNode node in element.ChildNodes) { switch (node.Name) { case "AssociationType": int id = int.Parse(node.Attributes.GetNamedItem("id").Value); string name = node.Attributes.GetNamedItem("name").Value; string description = node.Attributes.GetNamedItem("description").Value; odbContext.AssociationTypes_Insert(id, name, description, "crhodes", ""); break; case "ClearAll": var rows = from r in odbContext.AssociationTypes select r; foreach (AssociationType row in rows) { odbContext.AssociationTypes.DeleteOnSubmit(row); } odbContext.SubmitChanges(); break; default: PLLog.Info(string.Format("Unsupported element: {0}", node.Name), "ODB"); break; } } } catch (Exception ex) { PLLog.Error(ex, "ODB"); throw; } PLLog.Trace("Exit Method", "ODB"); }
protected override void OnStart(string[] args) { long startTicks = PLLog.Info("Start", PLLOG_APPNAME, CLASS_BASE_ERRORNUMBER + 3); try { // Load the database. SQLInformation.Common.ApplicationDataSet.LoadApplicationDataSetFromDB(SQLInformation.Common.ApplicationDataSet); //Initialize the timer that handles period wake-ups _RequestTimer_Weekly = new Timer(Helper.TakeSnapShot_Weekly, null, Timeout.Infinite, Timeout.Infinite); _RequestTimer_Daily = new Timer(Helper.TakeSnapShot_Daily, null, Timeout.Infinite, Timeout.Infinite); _RequestTimer_IntraDay = new Timer(Helper.TakeSnapShot_IntraDay, null, Timeout.Infinite, Timeout.Infinite); // Set the time to begin execution and how often it repeats // Timer.Change() takes two arguments 1. When to start, 2. Period to continue. PLLog.Info(String.Format("Setting Weekly Request Timer StartTime:{0}: in:{1} Restart in:{2}", Config.Weekly_StartTime, Helper.GetTimeout("Weekly StartTime"), Helper.GetTimeout("Weekly RestartTime")), PLLOG_APPNAME, CLASS_BASE_ERRORNUMBER + 4); _RequestTimer_Weekly.Change(Helper.GetTimeout("Weekly StartTime"), Helper.GetTimeout("Weekly RestartTime")); PLLog.Info(String.Format("Setting Daily Request Timer StartTime:{0}: in:{1} Restart in:{2}", Config.Daily_StartTime, Helper.GetTimeout("Daily StartTime"), Helper.GetTimeout("Daily RestartTime")), PLLOG_APPNAME, CLASS_BASE_ERRORNUMBER + 4); _RequestTimer_Daily.Change(Helper.GetTimeout("Daily StartTime"), Helper.GetTimeout("Daily RestartTime")); PLLog.Info(String.Format("Setting IntraDay Request Timer StartTime:{0}: in:{1} Restart in:{2}", Config.IntraDay_StartTime, Helper.GetTimeout("IntraDay StartTime"), Helper.GetTimeout("IntraDay RestartTime")), PLLOG_APPNAME, CLASS_BASE_ERRORNUMBER + 4); _RequestTimer_IntraDay.Change(Helper.GetTimeout("IntraDay StartTime"), Helper.GetTimeout("IntraDay RestartTime")); } catch (Exception ex) { PLLog.Error(ex, PLLOG_APPNAME, CLASS_BASE_ERRORNUMBER + 5); } PLLog.Info("End", PLLOG_APPNAME, CLASS_BASE_ERRORNUMBER + 6, startTicks); }
private static Nullable <DateTime> ValidateExists_DateTime(string configString) { string configValue = ConfigurationManager.AppSettings[configString]; if (configValue == null) { return(null); } try { PLLog.Info(string.Format("Using CurrentDate {0} from Config File", configValue), PLLOG_APPNAME, CLASS_BASE_ERRORNUMBER + 0); return(Convert.ToDateTime(configValue)); } catch (Exception ex) { PLLog.Error(string.Format("Cannot convert {0} to DateTime {1}", configString, ex.ToString()), PLLOG_APPNAME, CLASS_BASE_ERRORNUMBER + 0); return(null); } }
private static string ValidateExists_String(string configString) { string configValue = ConfigurationManager.AppSettings[configString]; if (configValue == null) { throw new ApplicationException(string.Format("Missing Config File Information: {0}", configString)); } // TODO(crhodes): Decide if want to bother reporting that come Config item is empty. // Some settings, e.g. Email_CC can be empty. Don't throw exception or catch it in the // particular items that can be empty. For now just log to get a feel if this is important at all. // May just want to remove the next lines completely. if (configValue.Length <= 0) { PLLog.Info(string.Format("Empty Config File Information: {0}", configString), PLLOG_APPNAME, CLASS_BASE_ERRORNUMBER + 5); //throw new ApplicationException(string.Format("Empty Config File Information: {0}", configString)); } return(configValue); }
public void ProcessUsageAttributesXML(XmlDocument doc) { PLLog.Trace("Enter Method", "ODB"); try { XmlNode element = doc.DocumentElement.SelectSingleNode("//UsageAttributes"); if (element == null) { return; } foreach (XmlNode node in element.ChildNodes) { switch (node.Name) { case "UsageAttribute": int id = int.Parse(node.Attributes.GetNamedItem("id").Value); string name = node.Attributes.GetNamedItem("name").Value; string description = node.Attributes.GetNamedItem("description").Value; // For some reason this fails with exception - Message "Invalid object name 'usageAttributes'." odbContext.UsageAttributes_Insert(id, name, description, "crhodes", ""); //UsageAttribute usageAttribute = new UsageAttribute(); //usageAttribute.usageattribute_id = id; //usageAttribute.usageattribute_name = name; //usageAttribute.usageattribute_description = description; //odbContext.UsageAttributes.InsertOnSubmit(usageAttribute); //odbContext.SubmitChanges(); break; case "ClearAll": var rows = from r in odbContext.UsageAttributes select r; foreach (UsageAttribute row in rows) { odbContext.UsageAttributes.DeleteOnSubmit(row); } odbContext.SubmitChanges(); break; default: PLLog.Info(string.Format("Unsupported element: {0}", node.Name), "ODB"); break; } } } catch (Exception ex) { PLLog.Error(ex, "ODB"); throw; } PLLog.Trace("Exit Method", "ODB"); }
public void ProcessDataTypesXML(XmlDocument doc) { PLLog.Trace("Enter Method", "ODB"); try { XmlNode element = doc.DocumentElement.SelectSingleNode("//DataTypes"); if (element == null) { return; } foreach (XmlNode node in element.ChildNodes) { switch (node.Name) { case "DataType": int id = int.Parse(node.Attributes.GetNamedItem("id").Value); string name = node.Attributes.GetNamedItem("name").Value; string description = node.Attributes.GetNamedItem("description").Value; // For some reason this fails with exception: Message "Operand type clash: int is incompatible with uniqueidentifier" // Turns out it was on ActivityLog_Insert. Expected odbContext.DataTypes_Insert(id, name, description, "crhodes", ""); //DataType dataType = new DataType(); //dataType.datatype_id = id; //dataType.datatype_name = name; //dataType.datatype_description = description; //odbContext.DataTypes.InsertOnSubmit(dataType); //odbContext.SubmitChanges(); break; case "ClearAll": var rows = from r in odbContext.DataTypes select r; foreach (DataType row in rows) { odbContext.DataTypes.DeleteOnSubmit(row); } odbContext.SubmitChanges(); break; default: PLLog.Info(string.Format("Unsupported element: {0}", node.Name), "ODB"); break; } } } catch (Exception ex) { PLLog.Error(ex, "ODB"); throw; } PLLog.Trace("Exit Method", "ODB"); }