Пример #1
0
 private DataValidations DataValidation(int column = 0, ImportDataDTO importDataDTO = null, DataValidations dataValidations = null)
 {
     if (string.IsNullOrEmpty(importDataDTO.NameAndCompendium) ||
         string.IsNullOrEmpty(importDataDTO.Date) ||
         importDataDTO.Order == 0 ||
         string.IsNullOrEmpty(importDataDTO.Symbol))
     {
         dataValidations.IsCorrect = false;
         if (string.IsNullOrEmpty(importDataDTO.NameAndCompendium))
         {
             AddDataValidations(column, importDataDTO, dataValidations, (int)Type.NameAndCompendium, importDataDTO.NameAndCompendium);
         }
         if (string.IsNullOrEmpty(importDataDTO.Date))
         {
             AddDataValidations(column, importDataDTO, dataValidations, (int)Type.Date, importDataDTO.Date);
         }
         if (importDataDTO.Order == 0)
         {
             AddDataValidations(column, importDataDTO, dataValidations, (int)Type.Order, importDataDTO.Order.ToString());
         }
         if (string.IsNullOrEmpty(importDataDTO.Symbol))
         {
             AddDataValidations(column, importDataDTO, dataValidations, (int)Type.Symbol, importDataDTO.Symbol);
         }
     }
     return(dataValidations);
 }
Пример #2
0
        private void AddDataValidations(int column, ImportDataDTO importDataDTO = null, DataValidations dataValidations = null, int dataType = 0, string value = "")
        {
            var dataValidation = new DataValidationDTO();

            dataValidation.RowNumber = column;
            dataValidation.IsCorrect = false;
            dataValidation.DataType  = dataType;
            dataValidation.Value     = value;
            dataValidation.Message   = NOT_EMPTY;
            dataValidations.dataValidationDTOs.Add(dataValidation);
        }
Пример #3
0
        private ImportDataDTO GetImportDataDTO(IExcelDataReader reader, int step = 0)
        {
            var importData = new ImportDataDTO();

            for (int column = 0; column < reader.FieldCount; column++)
            {
                var value = reader.GetValue(column);
                if (column == (int)Type.Order)
                {
                    importData.Order = value != null?int.Parse(value.ToString()) : 0;
                }
                else if (column == (int)Type.Symbol)
                {
                    importData.Symbol = value != null?value.ToString() : string.Empty;
                }
                else if (column == (int)Type.Date)
                {
                    importData.Date = value != null?value.ToString() : string.Empty;
                }
                else if (column == (int)Type.NameAndCompendium)
                {
                    importData.NameAndCompendium = value != null?value.ToString() : string.Empty;
                }
                else if (column == (int)Type.Author)
                {
                    importData.Author = value != null?value.ToString() : string.Empty;
                }
                else if (column == (int)Type.Original || (column == (int)Type.Original + 1))
                {
                    if (column == (int)Type.Original)
                    {
                        importData.Original = value != null ? true : false;
                    }
                    else
                    {
                        importData.Original = value != null ? true : false;
                    }
                }
                else if (column == (int)Type.PageNumber)
                {
                    importData.PageNumber = value != null?value.ToString() : string.Empty;
                }
                else
                {
                    importData.Detail = value != null?value.ToString() : string.Empty;
                }
            }
            return(importData);
        }