예제 #1
0
        /// <summary>
        /// Read the data from excel and process it
        /// </summary>
        public override void Read()
        {
            OleDbCommand cmd = GetReader();

            using (OleDbDataReader reader = cmd.ExecuteReader())
            {
                while (reader.Read())
                {
                    IEmployeeResult emp = ConvertToObject.Getobject(reader);
                    EmployeeValidation.Validate(emp);
                    Results.Add(emp);
                }
            }
        }
예제 #2
0
        public static void Validate(IEmployeeResult emp)
        {
            var results = new List <ValidationResult>();
            ValidationContext context = new ValidationContext(emp);
            List <string>     errors  = new List <string>();
            bool Isvalid = Validator.TryValidateObject(emp, context, results);

            if (!Isvalid)
            {
                foreach (var validationResult in results)
                {
                    errors.Add(validationResult.ErrorMessage);
                }
                emp.ErrorMessages = errors;
            }
        }
예제 #3
0
        /// <summary>
        /// Read the file rows and process it for CSV,PIPE and other delimiters
        /// </summary>
        public virtual void Read()
        {
            using (FileStream stream = new FileStream(FileName, FileMode.OpenOrCreate, FileAccess.Read))
            {
                using (StreamReader reader = new StreamReader(stream))
                {
                    string Linestring = "";// reader.ReadLine();

                    while ((Linestring = reader.ReadLine()) != null)
                    {
                        IEmployeeResult emp = ConvertToObject.Getobject(Linestring, Delimiter);
                        EmployeeValidation.Validate(emp);
                        Results.Add(emp);
                    }
                }
            }
        }