public PullersEventArgs(int datasourceId, string jobId, List <SreKey> dataSourceKeys, string outputFileName, string outputFolder, string zipUniqueId, ZipFileInformation zipFileInformation) { this.DataSourceId = datasourceId; this.JobId = jobId; this.DataSourceKeys = dataSourceKeys; this.OutputFileName = outputFileName; this.OutputFolder = outputFolder; this.ZipUniqueId = zipUniqueId; this.ZipFileInformation = zipFileInformation; this.CustomData = new Dictionary <string, object>(); }
internal void InvokeFileProcessed(int datasourceId, string jobId, List <SreKey> appKeys, string fileName, string outputFolder, string zipUniqueId) { Job currentJob = null; if ((!(string.IsNullOrEmpty(jobId))) && (Registry.Instance.Entries.ContainsKey(jobId))) { currentJob = Registry.Instance.Entries[jobId] as Job; } #region Handling ZipFile ZipFileInformation zipInfo = null; if (!string.IsNullOrEmpty(zipUniqueId)) { zipInfo = Registry.Instance.ZipFiles[zipUniqueId]; if (zipInfo.TotalFiles == zipInfo.TotalProcessedFiles) { return; } else { zipInfo.TotalProcessedFiles = zipInfo.TotalProcessedFiles + 1; } } #endregion Handling ZipFile #region Handling Pusher if ((currentJob != null) && (!string.IsNullOrEmpty(currentJob.DataSource.PusherTypeFullName))) { Trace.TraceInformation("Initializing '{0}' Pusher '{1}'.", currentJob.DataSource.Name, currentJob.DataSource.PusherTypeFullName); object objPusher = null; if (currentJob.DataSource.PusherType == PusherTypes.Ftp) { objPusher = new PusherFtp(); } else if (currentJob.DataSource.PusherType == PusherTypes.DosCommands) { objPusher = new PusherDosCommands(); } else if (currentJob.DataSource.PusherType == PusherTypes.SqlQuery) { objPusher = new PusherSqlQuery(); } else if (currentJob.DataSource.PusherType == PusherTypes.Custom) { objPusher = Activator.CreateInstance(Type.GetType(currentJob.DataSource.PusherTypeFullName)); } if (objPusher != null) { if ((currentJob.Errors.Count == 0) && (currentJob.DataSource.OutputWriter.IsErrored == false)) { ((Pushers)objPusher).FileProcessed(new PullersEventArgs(datasourceId, jobId, appKeys, fileName, outputFolder, zipUniqueId, zipInfo)); Trace.TraceInformation("Pusher called!"); } else if ((currentJob.Errors.Count > 0) && (currentJob.DataSource.DataFeederType == DataFeederTypes.PullSql)) { new SqlWatcherHelper(currentJob).ExecuteRecoveryScript(); string message = "There were error(s) while processing a SQL pull cycle, the pusher was not called. Please study the error(s) and do the needful before next cycle."; message += ". The recovery script has been executed."; message = PostMan.__warningStartTag + message + PostMan.__warningEndTag; new PostMan(currentJob).Send(message, "Pusher was not called", true); } else { if (currentJob.DataSource.AllowPartial()) { ((Pushers)objPusher).FileProcessed(new PullersEventArgs(datasourceId, jobId, appKeys, fileName, outputFolder, zipUniqueId, zipInfo)); Trace.TraceInformation("Pusher called!"); } else { string message = "There were error(s) while processing, the pusher was not called. Please study the error(s) and do the needful."; Trace.TraceError(message); } } } } #endregion Handling Pusher #region Logging History if (currentJob != null) { string subFileName = null; if (!string.IsNullOrEmpty(zipUniqueId)) { subFileName = Path.GetFileName(fileName); //removing output extension if (subFileName.Contains(".")) { subFileName = subFileName.Substring(0, subFileName.LastIndexOf(".")); } } new Manager().SaveLog(currentJob.FileName, subFileName, datasourceId, currentJob.TotalRowsToBeProcessed, currentJob.TotalValid, currentJob.StartedAt, DateTime.Now, SreEnvironmentDetails()); } #endregion Logging History #region Sending Email //send email in positive scenario. If would have failed, an error email would have automatically sent. Trace.TraceInformation("A job processed, total rows to be processed = {0}, total valid rows = {1}", currentJob.TotalRowsToBeProcessed, currentJob.TotalValid); Trace.Flush(); if (currentJob != null) { string strEmailAfterFileProcessed = currentJob.DataSource.Keys.GetKeyValue(SreKeyTypes.EmailAfterFileProcessed); string strEmailAfterFileProcessedAttachInputFile = currentJob.DataSource.Keys.GetKeyValue(SreKeyTypes.EmailAfterFileProcessedAttachInputFile); string strEmailAfterFileProcessedAttachOutputFile = currentJob.DataSource.Keys.GetKeyValue(SreKeyTypes.EmailAfterFileProcessedAttachOutputFile); if (strEmailAfterFileProcessed.ParseBool()) { string strEmailAfterFileProcessedAttachOtherFiles = currentJob.DataSource.Keys.GetKeyValue(SreKeyTypes.EmailAfterFileProcessedAttachOtherFiles); string message = string.Format("A file from '{0}' was just processed with {1} record(s)!", currentJob.DataSource.Name, currentJob.TotalRowsProcessed); if (string.IsNullOrEmpty(strEmailAfterFileProcessedAttachOtherFiles)) { List <string> outFile = new List <string>(); if (strEmailAfterFileProcessedAttachOutputFile.ParseBool()) { outFile.Add(fileName); new PostMan(currentJob, false).Send(message, "File Processed", !strEmailAfterFileProcessedAttachInputFile.ParseBool(), outFile); } else { new PostMan(currentJob, false).Send(message, "File Processed", !strEmailAfterFileProcessedAttachInputFile.ParseBool(), outFile); } } else { List <string> otherFiles = new List <string>(strEmailAfterFileProcessedAttachOtherFiles.Split(",".ToCharArray())); new PostMan(currentJob, false).Send(message, "File Processed", !strEmailAfterFileProcessedAttachInputFile.ParseBool(), otherFiles); } } } #endregion Sending Email #region Handling Global Events if (currentJob.ErroredByPusher == false) { PullersEventArgs e = new PullersEventArgs(datasourceId, jobId, appKeys, fileName, outputFolder, zipUniqueId, zipInfo); Registry.Instance.GlobalEventsOnCompletes.Complete(datasourceId, e); } #endregion Handling Global Events if (currentJob != null) { currentJob.PerformanceCounter.PrintTrace(jobId); } }