Пример #1
0
        static void AddIgnoredFileCountToZipFileInfo(string zipUniqueId)
        {
            if (!Registry.Instance.ZipFiles.ContainsKey(zipUniqueId))
            {
                throw new Exception(string.Format("Registry does not contain zip file information of {0}", zipUniqueId));
            }

            ZipFileInformation zipInfo = Registry.Instance.ZipFiles[zipUniqueId];

            zipInfo.TotalToBeProcessedFiles = zipInfo.TotalToBeProcessedFiles - 1;

            //Registry.Instance.ZipFiles[zipUniqueId].TotalFiles = totalFiles;
        }
Пример #2
0
 public PullersEventArgs(int datasourceId, string jobId, List <IdpeKey> 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>();
 }
Пример #3
0
        internal void InvokeFileProcessed(int datasourceId, string jobId, List <IdpeKey> appKeys, string fileName, string outputFolder, string zipUniqueId)
        {
            Trace.TraceInformation("Invoke");
            Trace.Flush();
            Trace.TraceInformation("datasourceId:{0}, JobId:{1},appkeys={2},filename={3},outputfolder={4},zipuniqueid={5}",
                                   datasourceId, jobId, appKeys.Count, fileName, outputFolder, zipUniqueId);
            Trace.Flush();

            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)))
            {
                ExtensionMethods.TraceInformation("Pullers - 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));
                        ExtensionMethods.TraceInformation("Pullers - Pusher called!");
                    }
                    else if ((currentJob.Errors.Count > 0) &&
                             (currentJob.DataSource.DataFeederType == DataFeederTypes.PullSql))
                    {
                        new SqlWatcherHelper(currentJob).ExecuteRecoveryScript();
                    }
                    else
                    {
                        if (currentJob.DataSource.AllowPartial())
                        {
                            ((Pushers)objPusher).FileProcessed(new PullersEventArgs(datasourceId, jobId, appKeys, fileName, outputFolder, zipUniqueId, zipInfo));
                            ExtensionMethods.TraceInformation("Pullers - Pusher called!");
                        }
                        else
                        {
                            string message = "Pullers - There were error(s) while processing, the pusher was not called. Please study the error(s) and do the needful.";
                            ExtensionMethods.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

            if (currentJob != null)
            {
                //send email in positive scenario. If would have failed, an error email would have automatically sent.
                ExtensionMethods.TraceInformation("Pullers - A job processed, total rows to be processed = {0}, total valid rows = {1}", currentJob.TotalRowsToBeProcessed, currentJob.TotalValid);
                Trace.Flush();
                string strEmailAfterFileProcessed = currentJob.DataSource.Keys.GetKeyValue(IdpeKeyTypes.EmailAfterFileProcessed);
                string strEmailAfterFileProcessedAttachInputFile  = currentJob.DataSource.Keys.GetKeyValue(IdpeKeyTypes.EmailAfterFileProcessedAttachInputFile);
                string strEmailAfterFileProcessedAttachOutputFile = currentJob.DataSource.Keys.GetKeyValue(IdpeKeyTypes.EmailAfterFileProcessedAttachOutputFile);

                if (strEmailAfterFileProcessed.ParseBool())
                {
                    string strEmailAfterFileProcessedAttachOtherFiles = currentJob.DataSource.Keys.GetKeyValue(IdpeKeyTypes.EmailAfterFileProcessedAttachOtherFiles);

                    string message = string.Format("Pullers - 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 != null) && (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);
            }
        }