Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <returns>
        /// Error code:
        /// 0 - no errors
        /// 1 - file doesn't exists
        /// 2 - usupported extension
        /// 3 - Ivalid header format (some 506 column names are absent or duplicated)
        /// 4 - incorrect data format in some cells
        /// 5 - invalid file format, error duirng file reading
        /// </returns>
        public Upload506FileError GetItems(string filePath, long startRecord = 0, long count = -1)
        {
            using (var fileProcessor = new Upload506FileProcessor(filePath, this))
            {
                Clear();
                FileName = filePath;
                var result = fileProcessor.GetItems(startRecord, count);
                switch (result)
                {
                case Upload506FileError.Success:
                    SetState(Upload506MasterState.ReadyForValidation);
                    break;

                case Upload506FileError.IvalidHeaderFormat:
                    SetError(result, fileProcessor.HeaderError);
                    break;

                default:
                    SetError(result);
                    break;
                }

                return(result);
            }
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <returns>
        /// Error code:
        /// 0 - no errors
        /// 1 - file doesn't exists
        /// 2 - usupported extension
        /// 3 - Ivalid header format (some 506 column names are absent or duplicated)
        /// 4 - incorrect data format in some cells
        /// 5 - invalid file format, error duirng file reading
        /// </returns>
        public void GetItems(string fileName, Stream fileStream)
        {
            using (var fileProcessor = new Upload506FileProcessor(fileStream, fileName, this))
            {
                Clear();
                FileName = fileName;
                var result = fileProcessor.GetItems();
                switch (result)
                {
                case Upload506FileError.Success:
                    SetState(Upload506MasterState.ReadyForValidation);
                    break;

                case Upload506FileError.IvalidHeaderFormat:
                    SetError(result, fileProcessor.HeaderError);
                    break;

                default:
                    SetError(result);
                    break;
                }
            }
        }