void generateHourlySummary() { TimeSpan temp = new TimeSpan(nextHourlyUpdateTiming.Value.Hour, nextHourlyUpdateTiming.Value.Minute - 6, nextHourlyUpdateTiming.Value.Second); int id; Shift s = new Shift(); List <Shift> shl = shifts.getShifts(temp); DataTable dt; Availability[] availability = new Availability[lines.Count]; for (int i = 0; i < lines.Count; i++) { availability[i] = new Availability(); } foreach (Shift sl in shl) { if (sl.Name != "GEN SHIFT") { s = sl; break; } } Session se = s.getSession(temp); DateTime from = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, stringtoTS(se.StartTime).Hours, stringtoTS(se.StartTime).Minutes, stringtoTS(se.StartTime).Seconds); DateTime to = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, stringtoTS(se.EndTime).Hours, stringtoTS(se.EndTime).Minutes, stringtoTS(se.EndTime).Seconds); dt = dataAccess.GetReportData(from, to); for (int i = 0; i < dt.Rows.Count; i++) { IssueDetails issueDetail = new IssueDetails(); issueDetail.Line = (int)dt.Rows[i]["LINE"]; issueDetail.Station = (int)dt.Rows[i]["STATION"]; issueDetail.Tolerance = (int)dt.Rows[i]["Tolerance"]; issueDetail.Raised = (TimeSpan)dt.Rows[i]["Raised"]; if (dt.Rows[i]["Resolved"] == DBNull.Value) { issueDetail.Resolved = stringtoTS(se.EndTime); } else { issueDetail.Resolved = (TimeSpan)dt.Rows[i]["Resolved"]; if (issueDetail.Resolved > stringtoTS(se.EndTime)) { issueDetail.Resolved = stringtoTS(se.EndTime); } } TimeSpan ToleranceLimit = new TimeSpan(0, issueDetail.Tolerance, 0); if (issueDetail.Resolved - issueDetail.Raised > ToleranceLimit) { availability[issueDetail.Line - 1].Add(issueDetail); } } ContactCollection cl = dataAccess.getHourlyUpdateContacts(); String hourlySummary = "Hourly Summary MCB Finishing" + "\r\n"; for (int i = 0; i < 6; i++) { hourlySummary += "Line " + lines[i].ID.ToString() + ":" + getHourlyUpdateInfo(i, s.ID, se.ID) + "," + "Avl-" + (availability[i].getAvailability(stringtoTS(se.StartTime), stringtoTS(se.EndTime))).ToString() + "%"; hourlySummary += "\r\n"; } foreach (Contact c in cl) { dataAccess.insertSmsTrigger(c.Number, hourlySummary, 1, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), 5); } hourlySummary = "Hourly Summary " + "\r\n"; for (int i = 6, j = 1; i < 8; i++, j++) { hourlySummary += "RCCB Finishing Line " + j.ToString() + ":" + getHourlyUpdateInfo(i, s.ID, se.ID) + "," + "Avl-" + (availability[i].getAvailability(stringtoTS(se.StartTime), stringtoTS(se.EndTime))).ToString() + "%"; hourlySummary += "\r\n"; } for (int i = 9, j = 1; i < 11; i++, j++) { hourlySummary += "TIMNH Finishing Line " + j.ToString() + ":" + getHourlyUpdateInfo(i, s.ID, se.ID) + "," + "Avl-" + (availability[i].getAvailability(stringtoTS(se.StartTime), stringtoTS(se.EndTime))).ToString() + "%"; hourlySummary += "\r\n"; } hourlySummary += "ADDITIM Line " + getHourlyUpdateInfo(8, s.ID, se.ID) + "," + "Avl-" + (availability[8].getAvailability(stringtoTS(se.StartTime), stringtoTS(se.EndTime))).ToString() + "%"; hourlySummary += "\r\n"; foreach (Contact c in cl) { dataAccess.insertSmsTrigger(c.Number, hourlySummary, 1, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), 5); } }
public StartPage() { try { InitializeComponent(); _dbConnectionString = ConfigurationSettings.AppSettings["DBConStr"]; DataAccess.conStr = _dbConnectionString; MainMenu _mainMenu = new MainMenu(_dbConnectionString); _mainFrame.Navigate(_mainMenu); dataAccess = new DataAccess(); lines = dataAccess.getLines(); lineQ = new Queue <int>(); foreach (line l in lines) { lineQ.Enqueue(l.ID); } departmentTable = dataAccess.getDepartmentInfo(""); departmentQ = new Queue <int>(); for (int i = 0; i < departmentTable.Rows.Count; i++) { departmentQ.Enqueue((int)departmentTable.Rows[i]["id"]); } andonManager = new AndonManager(lineQ, departmentQ, AndonManager.MODE.MASTER); shifts = dataAccess.getShifts(); contacts = dataAccess.getContacts(); commandTimer = new System.Timers.Timer(30 * 1000); commandTimer.Elapsed += new System.Timers.ElapsedEventHandler(commandTimer_Elapsed); commandTimer.AutoReset = false; commandTimer.Start(); hourlyUpdateTimings = new Queue <TimeSpan>(); shiftUpdateTimings = new Queue <TimeSpan>(); String hourlyUpdateTimingsString = ConfigurationSettings.AppSettings["HourlyUpdateTimings"]; String[] hourlyUpdateTimingsList = hourlyUpdateTimingsString.Split(dataSeperator.ToCharArray()); foreach (String s in hourlyUpdateTimingsList) { String[] timings = s.Split(timingsDataSeperator.ToCharArray()); int hours = Convert.ToInt32(timings[0]); int minutes = Convert.ToInt32(timings[1]); int seconds = Convert.ToInt32(timings[2]); hourlyUpdateTimings.Enqueue(new TimeSpan(hours, minutes, seconds)); } TimeSpan[] temp = new TimeSpan[hourlyUpdateTimings.Count]; hourlyUpdateTimings.CopyTo(temp, 0); /* * foreach (TimeSpan ts in temp) * { * TimeSpan ts1 = hourlyUpdateTimings.Dequeue(); * hourlyUpdateTimings.Enqueue(ts1); * if (ts >= DateTime.Now.TimeOfDay) * { * nextHourlyUpdateTiming = ts; * break; * } * * } */ nextHourlyUpdateTiming = getNextHourlyUpdateTime(); Issues = new Dictionary <int, Issue>(); timeout = dataAccess.getEscalationTimeout(); andonManager.andonAlertEvent += new EventHandler <AndonAlertEventArgs>(andonManager_andonAlertEvent); andonManager.start(); dataAccess.updateIssueMarquee(); } catch (Exception e) { tbMsg.Text += e.Message; } }
private void PageFunction_Loaded(object sender, RoutedEventArgs e) { dataAccess = new DataAccess(_dbConnectionString); contacts = dataAccess.getContacts(); }