/// <summary> /// Call the Excel content Validator /// </summary> /// <param name="s"></param> public bool ValidateFile(ForeCastFileInfo s) { CParser prs = null; CExcelDBUpdate upd = null; try { if (!ForeCastUpdatorService.CanFilebeAccessed(s.XlsFile)) { throw new Exception(s.XlsFile + " Cannot be accessed or opened by another app"); } String m_Country = this.GetCountryFromPath(s.XlsFile); String m_Segment = this.GetSegmentFromPath(s.XlsFile); System.Diagnostics.EventLog.WriteEntry("ForeCastLog", "Processing File ...." + s.XlsFile); String Prgs = (String)GlobalSettings.GetEntry("VALIDATION_SCRIPT"); String OrclConStr = (String)GlobalSettings.GetEntry("ORACLE_CONNECTION_STRING"); String ExcelConStr = "Provider=" + (String)GlobalSettings.GetEntry("EXCEL_PROVIDER"); ExcelConStr += "Data Source=" + s.XlsFile + ";"; ExcelConStr += (String)GlobalSettings.GetEntry("EXCEL_PROPERTIES"); CSemanticErrorLog.AddLine("Excel file = " + s.XlsFile); prs = new CParser(Prgs, m_Country, m_Segment); bool brs = prs.CallParser(ExcelConStr, OrclConStr); bool ret_val = true; if (brs == true) { upd = new CExcelDBUpdate(OrclConStr, prs.GetExcelReader()); ret_val = upd.UpdateAll(); if (ret_val == false) { CSemanticErrorLog.AddLine("FATAL ERROR WHILE UPDATING FORECAST DATA "); } } if (ret_val == true && brs == true) { if (GlobalSettings.allow_emails == true) { notify.TO = prs.GetEmail(); notify.Body = "Hi" + "\r\n\r\n" + "ForeCast updation status " + "\r\n" + prs.GetSemanticLog(); notify.SendToExcelEmail(0); } if (GlobalSettings.event_logging == true) { if (!System.Diagnostics.EventLog.SourceExists("ForeCastLog")) { System.Diagnostics.EventLog.CreateEventSource("ForeCastLog", "DoForeCastLog"); } System.Diagnostics.EventLog.WriteEntry("ForeCastLog", "Hi" + "\r\n\r\n" + "ForeCast updation status " + "\r\n" + prs.GetSemanticLog() + prs.GetSyntaxLog()); } if (upd != null) { upd.Cleanup(); upd = null; } if (prs != null) { prs.CloseAll(); prs = null; } return(ret_val); } else { if (GlobalSettings.event_logging == true) { if (!System.Diagnostics.EventLog.SourceExists("ForeCastLog")) { System.Diagnostics.EventLog.CreateEventSource("ForeCastLog", "DoForeCastLog"); } System.Diagnostics.EventLog.WriteEntry("ForeCastLog", "Hi" + "\r\n\r\n" + "ForeCast updation status " + "\r\n" + prs.GetSemanticLog() + prs.GetSyntaxLog()); } if (GlobalSettings.allow_emails == true) { notify.TO = prs.GetEmail(); notify.Body = "Hi" + "\r\n\r\n" + "ForeCast updation status " + "\r\n" + prs.GetSemanticLog(); notify.SendToExcelEmail(1); notify.Body = "Hi" + "\r\n\r\n" + "ForeCast updation status " + "\r\n" + prs.GetSemanticLog() + prs.GetSyntaxLog(); notify.Send(1); } if (upd != null) { upd.Cleanup(); upd = null; } if (prs != null) { prs.CloseAll(); prs = null; } return(false); } } catch (Exception e) { System.Diagnostics.EventLog.WriteEntry("ForeCastLog", e.ToString()); CSemanticErrorLog.AddLine(e.ToString()); if (GlobalSettings.event_logging == true) { if (!System.Diagnostics.EventLog.SourceExists("ForeCastLog")) { System.Diagnostics.EventLog.CreateEventSource("ForeCastLog", "DoForeCastLog"); } System.Diagnostics.EventLog.WriteEntry("ForeCastLog", "Hi" + "\r\n\r\n" + "ForeCast updation status " + "\r\n" + CSemanticErrorLog.GetLog() + CSyntaxErrorLog.GetLog()); } if (GlobalSettings.allow_emails == true) { notify.Body = "Hi" + "\r\n\r\n" + "ForeCast updation status " + "\r\n" + CSemanticErrorLog.GetLog() + CSyntaxErrorLog.GetLog(); notify.Send(1); } if (upd != null) { upd.Cleanup(); upd = null; } if (prs != null) { prs.CloseAll(); prs = null; } return(false); } }