Exemplo n.º 1
0
        public VisaSource GetData(ImmiData data, string row)
        {
            VisaSource source = new VisaSource();

            if (
                !this.FillData(this.VISA_CLASS, $"{nameof(this.VISA_CLASS)}", row, source, data) ||
                !this.FillData(this.CaseStatus, $"{nameof(this.CaseStatus)}", row, source, data) ||
                !this.FillData(this.EMPLOYMENT_START_DATE, $"{nameof(this.EMPLOYMENT_START_DATE)}", row, source, data) ||
                !this.FillData(this.EMPLOYMENT_END_DATE, $"{nameof(this.EMPLOYMENT_END_DATE)}", row, source, data) ||
                !this.FillData(this.NAICS_CODE, $"{nameof(this.NAICS_CODE)}", row, source, data) ||
                !this.FillData(this.TOTAL_WORKERS, $"{nameof(this.TOTAL_WORKERS)}", row, source, data) ||
                !this.FillData(this.PW_UNIT_OF_PAY, $"{nameof(this.PW_UNIT_OF_PAY)}", row, source, data) ||
                !this.FillData(this.WAGE_UNIT_OF_PAY, $"{nameof(this.WAGE_UNIT_OF_PAY)}", row, source, data) ||
                !this.FillData(this.WAGE_SOURCE, $"{nameof(this.WAGE_SOURCE)}", row, source, data)
                )
            {
                return(null);
            }

            source.CASE_NUMBER           = data.CASE_NUMBER;
            source.EMPLOYER_NAME         = data.EMPLOYER_NAME;
            source.JOB_TITLE             = data.JOB_TITLE;
            source.SOC_CODE              = data.SOC_CODE;
            source.SOC_NAME              = data.SOC_NAME;
            source.PREVAILING_WAGE       = data.PREVAILING_WAGE;
            source.WAGE_RATE_OF_PAY_FROM = data.WAGE_RATE_OF_PAY_FROM;
            return(source);
        }
Exemplo n.º 2
0
        public static void ProcessCsv(string sourceFile, string destinationPath, int maxRecords = -1)
        {
            int                processed   = 0;
            ITransformer       transformer = new CompositeTransformer(destinationPath);
            RawDataTransformer raw         = new RawDataTransformer(destinationPath);

            using (Reader <ImmiData> reader = new Reader <ImmiData>(sourceFile))
                using (Writer <Transformed> writer = new Writer <Transformed>(destinationPath + "transformed.csv"))
                {
                    transformer.Start();
                    ImmiData read;
                    while (processed != maxRecords && reader.TryReadNextRecord(out read))
                    {
                        if (raw.IsValidData(read))
                        {
                            processed++;
                            VisaSource source = raw.GetData(read, read.CASE_NUMBER);

                            if (source != null)
                            {
                                Transformed trans = new Transformed();

                                transformer.TransformRow(source, trans);
                                writer.WriteTransformed(trans);
                            }
                        }
                    }

                    writer.Flush();
                    raw.Save();
                    transformer.End();
                }
        }
Exemplo n.º 3
0
        private bool WAGE_UNIT_OF_PAY(VisaSource source, ImmiData data)
        {
            PayDuration status;

            if (!Enum.TryParse <PayDuration>(data.WAGE_UNIT_OF_PAY, true, out status))
            {
            }

            source.WAGE_UNIT_OF_PAY = status;
            return(true);
        }
Exemplo n.º 4
0
        private bool CaseStatus(VisaSource source, ImmiData data)
        {
            CaseStatus status;

            if (!Enum.TryParse <CaseStatus>(data.CASE_STATUS, true, out status))
            {
                return(false);
            }

            source.CASE_STATUS = status;
            return(true);
        }
Exemplo n.º 5
0
        private bool NAICS_CODE(VisaSource source, ImmiData data)
        {
            int status;

            if (!int.TryParse(data.NAICS_CODE, out status))
            {
                return(false);
            }

            source.NAICS_CODE = status;
            return(true);
        }
Exemplo n.º 6
0
        private bool EMPLOYMENT_START_DATE(VisaSource source, ImmiData data)
        {
            DateTime status;

            if (!DateTime.TryParse(data.EMPLOYMENT_START_DATE, out status))
            {
                source.EMPLOYMENT_START_DATE = DateTime.MinValue;
                return(true);
            }

            source.EMPLOYMENT_START_DATE = status;
            return(true);
        }
Exemplo n.º 7
0
        private bool TOTAL_WORKERS(VisaSource source, ImmiData data)
        {
            int status;

            if (!int.TryParse(data.TOTAL_WORKERS, out status))
            {
                source.TOTAL_WORKERS = 0;
                return(true);
            }

            source.TOTAL_WORKERS = status;
            return(true);
        }
Exemplo n.º 8
0
 private bool WAGE_SOURCE(VisaSource source, ImmiData data)
 {
     source.PW_SOURCE_OTHER = data.PW_SOURCE_OTHER;
     source.PW_SOURCE       = data.PW_SOURCE;
     return(true);
 }
Exemplo n.º 9
0
 private bool VISA_CLASS(VisaSource source, ImmiData data)
 {
     return(data.VISA_CLASS == "H-1B");
 }
Exemplo n.º 10
0
        private bool FillData(Func <VisaSource, ImmiData, bool> trans, string name, string row, VisaSource source, ImmiData data)
        {
            if (!trans(source, data))
            {
                this.invalids.Add(new InvalidData()
                {
                    RawData     = data,
                    Reason      = name,
                    Transformed = source,
                    Row         = row
                });

                return(false);
            }
            else
            {
                return(true);
            }
        }
Exemplo n.º 11
0
        public bool IsValidData(ImmiData data)
        {
            VisaSource source = new VisaSource();

            return(this.VISA_CLASS(source, data) && this.CaseStatus(source, data));
        }