public void Apply(StepContribution contribution) { _readSkipCount += contribution.ReadSkipCount; _writeSkipCount += contribution.WriteSkipCount; _processSkipCount += contribution.ProcessSkipCount; FilterCount += contribution.FilterCount; _readCount += contribution.ReadCount; _writeCount += contribution.WriteCount; _exitStatus = _exitStatus.And(contribution.ExitStatus); }
/// <summary> /// Equals override. /// </summary> /// <param name="obj"></param> /// <returns></returns> public override bool Equals(Object obj) { if (!(obj is StepContribution)) { return(false); } StepContribution other = (StepContribution)obj; return(ToString().Equals(other.ToString())); }
public RepeatStatus Execute(StepContribution contribution, ChunkContext chunkContext) { // Write counter to a file - Should be running for 10 seconds roughly int counter = 1000; string[] lines = new string[counter]; for (int i = 0; i < counter; i++) { lines[i] = DateTime.Now.Ticks.ToString(); Thread.Sleep(10); } File.WriteAllLines(@"C:\temp\MyDummyTasklet_out_" + DateTime.Now.Ticks + ".txt", lines); return RepeatStatus.Finished; }
/// <summary> /// Configures a <see cref="Sorter{T}"/> and executes it. /// </summary> /// <param name="contribution">ignored</param> /// <param name="chunkContext">ignored</param> /// <returns><see cref="RepeatStatus.Finished"/></returns> public new RepeatStatus Execute(StepContribution contribution, ChunkContext chunkContext) { Logger.Info("Starting ExtendedSort tasklet."); SplitSorter<byte[]> sorter = (SplitSorter<byte[]>)BuildSorter(); var stopwatch = new Stopwatch(); stopwatch.Start(); sorter.Sort(Input.Select(r => r.GetFileInfo()).ToList(), Output.GetFileInfo()); stopwatch.Stop(); Logger.Info("Total sort time: {0:F2}s", stopwatch.ElapsedMilliseconds / 1000d); contribution.ExitStatus = ExitStatus.Completed; return RepeatStatus.Finished; }
/// <summary> /// Scan remote directory for files matching the given file name pattern and download /// them, if any, to the given local directory. /// @see ITasklet#Execute /// </summary> /// <param name="contribution"></param> /// <param name="chunkContext"></param> /// <returns></returns> public RepeatStatus Execute(StepContribution contribution, ChunkContext chunkContext) { //Delegated DoExecute(); return RepeatStatus.Finished; }
public RepeatStatus Execute(StepContribution contribution, ChunkContext chunkContext) { _logger.Info("OK transition was used"); return RepeatStatus.Finished; }
/// <summary> /// Do nothing execution, since all the logic is in after step /// </summary> /// <param name="contribution"></param> /// <param name="chunkContext"></param> /// <returns></returns> public RepeatStatus Execute(StepContribution contribution, ChunkContext chunkContext) { return RepeatStatus.Finished; }
public RepeatStatus Execute(StepContribution contribution, ChunkContext chunkContext) { // open connection using (DbConnection connection = _providerFactory.CreateConnection()) { connection.ConnectionString = _connectionString; connection.Open(); string preparedCommand = PrepareCommands(Resource); DbCommand command = connection.CreateCommand(); command.CommandText = preparedCommand; int sqlDone = command.ExecuteNonQuery(); if(Logger.IsTraceEnabled) { Logger.Trace("SQL script execution end with {0} return code", sqlDone); } } return RepeatStatus.Finished; }
/// <summary> /// Configures a <see cref="Sorter{T}"/> and executes it. /// </summary> /// <param name="contribution">ignored</param> /// <param name="chunkContext">ignored</param> /// <returns><see cref="RepeatStatus.Finished"/></returns> public RepeatStatus Execute(StepContribution contribution, ChunkContext chunkContext) { Logger.Info("Starting sort tasklet."); var sorter = BuildSorter(); var stopwatch = new Stopwatch(); stopwatch.Start(); sorter.Sort(); stopwatch.Stop(); Logger.Info("Total sort time: {0:F2}s", stopwatch.ElapsedMilliseconds / 1000d); contribution.ExitStatus = ExitStatus.Completed; return RepeatStatus.Finished; }
public RepeatStatus Execute(StepContribution contribution, ChunkContext chunkContext) { _logger.Info("KO transition was used"); throw new Exception("Job failed: Wrong transition used"); }
/// <summary> /// @see ITasklet#Execute() /// </summary> /// <param name="contribution"></param> /// <param name="chunkContext"></param> /// <returns></returns> public RepeatStatus Execute(StepContribution contribution, ChunkContext chunkContext) { switch (Mode) { case FileUtilsMode.Copy: Copy(); break; case FileUtilsMode.Delete: foreach (IResource target in Targets) { if (target.Exists()) { Delete(target); } else { Error(target); } } break; case FileUtilsMode.Merge: Merge(true); break; case FileUtilsMode.MergeCopy: Merge(false); break; case FileUtilsMode.Reset: Reset(); break; default: throw new InvalidOperationException("This mode is not supported :[" + Mode + "]"); } return RepeatStatus.Finished; }
/// <summary> /// Generates the report /// @see ITasklet#Execute /// </summary> /// <param name="contribution"></param> /// <param name="chunkContext"></param> /// <returns></returns> public RepeatStatus Execute(StepContribution contribution, ChunkContext chunkContext) { LocalReport report = new LocalReport { ReportPath = ReportFile.GetFileInfo().FullName }; if (Parameters != null && Parameters.Any()) { if (Logger.IsTraceEnabled) { Logger.Trace("{0} parameter(s) were given for the report ", Parameters.Count); } report.SetParameters(Parameters.Select(p=>new ReportParameter(p.Key,p.Value))); } else { if (Logger.IsTraceEnabled) { Logger.Trace("No parameter was given for the report "); } } //DataSet DataSet ds = DbOperator.Select(Query,QueryParameterSource); //ReportDataSource ReportDataSource rds = new ReportDataSource { Name = DatasetName, Value = ds.Tables[0] }; report.DataSources.Add(rds); if (Logger.IsTraceEnabled) { Logger.Trace("Report init : DONE => Preparing to render"); } byte[] output = report.Render(ReportFormat); if (Logger.IsTraceEnabled) { Logger.Trace("Report init : rendering DONE => Preparing to serialize"); } //Create target directory if required OutFile.GetFileInfo().Directory.Create(); //dump to target file using (FileStream fs = new FileStream(OutFile.GetFileInfo().FullName, FileMode.Create)) { fs.Write(output,0,output.Length); } if (Logger.IsTraceEnabled) { Logger.Info("Report init : serialization DONE - end of ReportTasklet execute."); } return RepeatStatus.Finished; }