Exemplo n.º 1
0
Arquivo: Job.cs Projeto: eyedia/idpe
        /// <summary>
        /// Feeds data into the job from an xml or CSV or FL or file name (in case of Excel or custom feeder)
        /// </summary>
        /// <param name="xmlOrCSVOrFixedLengthOrFileName"></param>
        /// <returns></returns>
        public List <string> Feed(string xmlOrCSVOrFixedLengthOrFileName)
        {
            AnyToDataTable anyToDataTable = new AnyToDataTable(this);
            List <string>  errors         = anyToDataTable.Feed(xmlOrCSVOrFixedLengthOrFileName);

            this.DataSource.IsFirstRowHeader = anyToDataTable.IsFirstRowHeader;

            if (!AddAdditionalColumns())
            {
                return(new List <string>());
            }

            this.TotalRowsToBeProcessed = this.InputData.Rows.Count;
            int skipHeaderInCsvRows = this.DataSource.IsFirstRowHeader ? 1 : 0;

            List <DataTable> chunks = InputData.Split(SymplusCoreConfigurationSection.CurrentConfig.RecordsPerThread);

            _JobSlices = new List <JobSlice>();
            int counter = 0;

            foreach (DataTable table in chunks)
            {
                JobSlice jobSlice = new JobSlice(this.JobIdentifier, counter, table, this.CSVRows.Skip(skipHeaderInCsvRows).Skip(counter * SymplusCoreConfigurationSection.CurrentConfig.RecordsPerThread).Take(SymplusCoreConfigurationSection.CurrentConfig.RecordsPerThread).ToList());
                _JobSlices.Add(jobSlice);
                counter++;
            }
            return(errors);
        }
Exemplo n.º 2
0
		/// <summary>
		/// Marks a slice of the job as complete and marks the job as completed if all slices have been completed.
		/// </summary>
		/// <param name="slice">The completed slice.</param>
		public void MarkAsComplete(JobSlice slice)
		{
			lock (_lock) {
				slices.Remove (slice);
				if (slices.Count == 0) {
					job.SetCompleted ();
				}
			}
		}
		/// <summary>
		/// Adds the specified job to the queue.
		/// </summary>
		/// <param name="job">The job.</param>
		public void Add (IAnalysisJob job)
		{
			lock (_lock) {
				var jobStatus = new JobStatus (job);
				foreach (var file in job.GetFiles()) {
					JobSlice slice = slices.FirstOrDefault (j => j.File == file);
					if (slice == null) {
						slice = new JobSlice (file);
						slices.Add (slice);
					}
					jobStatus.AddSlice (slice);
					slice.AddJob (job, jobStatus);
				}
				InvalidateSort ();
			}
		}
Exemplo n.º 4
0
Arquivo: Job.cs Projeto: eyedia/idpe
        /// <summary>
        /// Feeds data into the job from a list objects
        /// </summary>
        /// <param name="inputData">List of objects</param>
        ///<param name="overridenMapping">Comma separated additional mapping override information. For example if "EmpId" from object to be mapped with "EmployeeId" of attribute, then "EmpId=EmployeeId,Ename=EmployeeName"</param>
        /// <returns></returns>
        public List <string> Feed(List <Object> inputData, string overridenMapping)
        {
            this.DataFeededFrom = inputData;
            AnyToDataTable anyToDataTable = new AnyToDataTable(this);
            List <string>  errors         = anyToDataTable.Feed(inputData, overridenMapping);

            this.DataSource.IsFirstRowHeader = anyToDataTable.IsFirstRowHeader;
            this.TotalRowsToBeProcessed      = this.InputData.Rows.Count;
            int skipHeaderInCsvRows = this.DataSource.IsFirstRowHeader ? 1 : 0;

            List <DataTable> chunks = InputData.Split(SymplusCoreConfigurationSection.CurrentConfig.RecordsPerThread);

            _JobSlices = new List <JobSlice>();
            int counter = 0;

            foreach (DataTable table in chunks)
            {
                JobSlice jobSlice = new JobSlice(this.JobIdentifier, counter, table, this.CSVRows.Skip(skipHeaderInCsvRows).Skip(counter * SymplusCoreConfigurationSection.CurrentConfig.RecordsPerThread).Take(SymplusCoreConfigurationSection.CurrentConfig.RecordsPerThread).ToList());
                _JobSlices.Add(jobSlice);
                counter++;
            }
            return(errors);
        }
Exemplo n.º 5
0
		void AnalyzeFile (JobSlice item, IEnumerable<BaseCodeIssueProvider> codeIssueProviders)
		{
			var file = item.File;

			if (file.BuildAction != BuildAction.Compile)
				return;

			if (!(file.Project is DotNetProject))
				return;

			TextEditorData editor;
			try {
				editor = TextFileProvider.Instance.GetReadOnlyTextEditorData (file.FilePath);
			} catch (FileNotFoundException) {
				// Swallow exception and ignore this file
				return;
			}
			var document = TypeSystemService.ParseFile (file.Project, editor);
			if (document == null)
				return;

			var content = TypeSystemService.GetProjectContext (file.Project);
			var compilation = content.AddOrUpdateFiles (document.ParsedFile).CreateCompilation ();

			CSharpAstResolver resolver;
			using (var timer = ExtensionMethods.ResolveCounter.BeginTiming ()) {
				resolver = new CSharpAstResolver (compilation, document.GetAst<SyntaxTree> (), document.ParsedFile as ICSharpCode.NRefactory.CSharp.TypeSystem.CSharpUnresolvedFile);
				try {
					resolver.ApplyNavigator (new ExtensionMethods.ConstantModeResolveVisitorNavigator (ResolveVisitorNavigationMode.Resolve, null));
				} catch (Exception e) {
					LoggingService.LogError ("Error while applying navigator", e);
				}
			}
			var context = document.CreateRefactoringContextWithEditor (editor, resolver, CancellationToken.None);

			foreach (var provider in codeIssueProviders) {
				if (item.CancellationToken.IsCancellationRequested)
					break;
				IList<IAnalysisJob> jobs;
				lock (_lock)
					jobs = item.GetJobs ().ToList ();
				var jobsForProvider = jobs.Where (j => j.GetIssueProviders (file).Contains (provider)).ToList();
				try {
					var issues = provider.GetIssues (context, CancellationToken.None).ToList ();
					foreach (var job in jobsForProvider) {
						// Call AddResult even if issues.Count == 0, to enable a job implementation to keep
						// track of progress information.
						job.AddResult (file, provider, issues);
					}
				} catch (OperationCanceledException) {
					// The operation was cancelled, no-op as the user-visible parts are
					// handled elsewhere
				} catch (Exception e) {
					foreach (var job in jobsForProvider) {
						job.AddError (file, provider);
					}
				}
			}
		}
Exemplo n.º 6
0
		/// <summary>
		/// Adds another slice. This method should not be called after <see cref="MarkAsComplete"/> has been called.
		/// </summary>
		/// <param name="slice">Slice.</param>
		public void AddSlice (JobSlice slice)
		{
			lock (_lock) {
				slices.Add (slice);
			}
		}