コード例 #1
0
ファイル: Ja2DataAccess.cs プロジェクト: egorovav/Ja2Project
        public SlfInfo DownloadSlfFile(string aFileName, DateTime aDateCreated, int aDataInfoId)
        {
            this.FContext = new Ja2DataEntities();
            this.FContext.Configuration.AutoDetectChangesEnabled = false;

            string _fileName = Path.GetFileName(aFileName);

            SlfFile _slfRec = this.FContext.SlfFile
                              .Where(x => x.FileName.ToUpper() == _fileName.ToUpper() &&
                                     x.UserId == this.FUserId &&
                                     x.DateCreated > aDateCreated &&
                                     x.DataInfoId == aDataInfoId)
                              .FirstOrDefault();

            Ja2Data.SlfFile.Header _slfHeader = new Ja2Data.SlfFile.Header();
            _slfHeader.fContainsSubDirectories = _slfRec.ContainsSubDirectories;
            _slfHeader.iEntries      = _slfRec.EntriesCount;
            _slfHeader.iReserved     = _slfRec.Reserved;
            _slfHeader.iSort         = _slfRec.Sort;
            _slfHeader.iUsed         = _slfRec.Used;
            _slfHeader.iVersion      = _slfRec.Version;
            _slfHeader.LibName       = _slfRec.LibName;
            _slfHeader.PathToLibrary = _slfRec.PathToLibrary;

            List <Ja2Data.SlfFile.Record> _records = new List <Ja2Data.SlfFile.Record>(_slfRec.EntriesCount);

            foreach (SlfRecordJsd _jsdRecord in _slfRec.SlfRecordJsd)
            {
                Ja2Data.SlfFile.Record _rec = this.DownloadJsdRecord(_jsdRecord.SlfRecordJsdId);
                _records.Add(_rec);
            }

            foreach (SlfRecord _unstructuredRec in _slfRec.SlfRecord)
            {
                Ja2Data.SlfFile.Record _rec = this.DownloadUnstreucturedRecord(_unstructuredRec);
                _records.Add(_rec);
            }

            foreach (SlfRecordStci _stciRecord in _slfRec.SlfRecordStci)
            {
                Ja2Data.SlfFile.Record _rec = this.DownloadStiRecord(_stciRecord.SlfRecordId);
                _records.Add(_rec);
            }

            foreach (SlfRecordText _txtRecord in _slfRec.SlfRecordText)
            {
                Ja2Data.SlfFile.Record _rec = this.DownloadTxtRecord(_txtRecord);
                _records.Add(_rec);
            }

            Ja2Data.SlfFile _slfFile = new Ja2Data.SlfFile(_slfHeader, _records);

            _slfFile.Save(aFileName);

            return(new SlfInfo(_slfRec, 0));
        }
コード例 #2
0
ファイル: Ja2DataAccess.cs プロジェクト: egorovav/Ja2Project
        public SlfInfo(SlfFile aSlfFile, int aRowsCount)
        {
            this.DateCreated            = aSlfFile.DateCreated;
            this.UserId                 = aSlfFile.UserId;
            this.FileName               = aSlfFile.FileName;
            this.LibName                = aSlfFile.LibName;
            this.PathToLibrary          = aSlfFile.PathToLibrary;
            this.EntriesCount           = aSlfFile.EntriesCount;
            this.Used                   = aSlfFile.Used;
            this.Sort                   = aSlfFile.Sort;
            this.Version                = aSlfFile.Version;
            this.ContainsSubDirectories = aSlfFile.ContainsSubDirectories;
            this.Reserved               = aSlfFile.Reserved;

            this.RowsInserted = aRowsCount;
        }
コード例 #3
0
ファイル: Ja2DataAccess.cs プロジェクト: egorovav/Ja2Project
        private SlfFile CreateSlfFile(Ja2Data.SlfFile aSlf, int aDataInfoId)
        {
            SlfFile _newSlfFileDb = new SlfFile();

            _newSlfFileDb.ContainsSubDirectories = aSlf.ContainsSubDirectories;
            _newSlfFileDb.EntriesCount           = aSlf.Entries;
            _newSlfFileDb.LibName       = aSlf.LibName;
            _newSlfFileDb.PathToLibrary = aSlf.PathToLibrary;
            _newSlfFileDb.Reserved      = aSlf.Reserved;
            _newSlfFileDb.Sort          = aSlf.Sort;
            _newSlfFileDb.Used          = aSlf.Used;
            _newSlfFileDb.Version       = aSlf.Version;
            _newSlfFileDb.FileName      = aSlf.SlfFileName;
            _newSlfFileDb.DataInfoId    = aDataInfoId;

            _newSlfFileDb.UserId      = this.FUserId;
            _newSlfFileDb.DateCreated = DateTime.Now;

            return(_newSlfFileDb);
        }
コード例 #4
0
ファイル: Ja2DataAccess.cs プロジェクト: egorovav/Ja2Project
        public SlfInfo UploadSlfFile(string aFileName, int aDataInfoId)
        {
            Ja2Data.SlfFile _slf = new Ja2Data.SlfFile(aFileName);
            this.FSlfFile = this.CreateSlfFile(_slf, aDataInfoId);
            this.FContext.SlfFile.Add(this.FSlfFile);
            this.FContext.SaveChanges();

            this.FLoaderFactory = new LoaderFactory(_slf, this.FUserId, this.FContext);
            int _rowsCounter = 0;

            using (FileStream _input = new FileStream(aFileName, FileMode.Open))
                using (BinaryReader _reader = new BinaryReader(_input))
                {
                    foreach (SlfRecordLoader _loader in this.FLoaderFactory.Loaders)
                    {
                        _rowsCounter += _loader.Upload(_reader, this.FSlfFile.SlfFileId);
                    }
                }

            return(new SlfInfo(this.FSlfFile, _rowsCounter));
        }