/// <summary> /// Saves the strategy log information. /// </summary> /// <param name="instruction">The instruction.</param> /// <param name="stid">The stid.</param> /// <param name="status">The status.</param> /// <param name="machinemac">The machinemac.</param> /// <param name="equipid">The equipid.</param> public async Task SaveStrategyLogInfo(string instruction, int stid, string status, string machinemac, int equipid) { var found = false; foreach (ConnectionStringSettings c in ConfigurationManager.ConnectionStrings) { if (!found) { try { using (var context = new organisationdatabaseEntities(c.Name)) { var classid = context.classdetails.Where(x => x.ccmac == machinemac).Select(x => x.classID).FirstOrDefault(); if (classid != 0) { found = true; var newLog = new strategylog() { StrategyDescId = stid, MachineMac = classid, ExecutionTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm")), Instruction = instruction, Status = status, EquipmentId = equipid }; context.strategylogs.Add(newLog); await context.SaveChangesAsync(); } } } catch (Exception ex) { loggerFile.Debug(Environment.NewLine + DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString() + "exception in stratrgy logs: " + ex.StackTrace + " error message " + ex.InnerException); } } else { break; } } }
public void SaveStrategyLogInfo(string instruction, int stid, int descid, string status, string machinemac) { try { using (var context = new organisationdatabaseEntities()) { var newLog = new strategylog() { StrategyDescId = descid, StrategyId = stid, MachineMac = machinemac, ExecutionTime = DateTime.Now, Instruction = instruction, Status = status }; context.strategylogs.Add(newLog); } } catch (Exception ex) { File.WriteAllText(docPath, "exception in stratrgy logs: " + ex.StackTrace); } }