private Restorer() { this.context = new Context(); var stopwatch = new Stopwatch(); stopwatch.Start(); this.dirRepo = DirRepository.Load(this.context); log.Info("All dirs are loaded {0:c}", stopwatch.Elapsed); this.fileRepo = FileRepository.Load(this.context, this.dirRepo); log.Info("All files are loaded {0:c}", stopwatch.Elapsed); this.rawRepo = RawFileRepository.Load(this.context); log.Info("Raw files are loaded {0:c}", stopwatch.Elapsed); var restoreFolderName = "restore"; var restoreFolderAttempt = Path.Combine(Environment.CurrentDirectory, restoreFolderName); var attempts = 0; while (Directory.Exists(restoreFolderAttempt)) { attempts++; restoreFolderAttempt = Path.Combine(Environment.CurrentDirectory, restoreFolderName + "_" + attempts.ToString()); } this.toRestorePath = restoreFolderAttempt; Directory.CreateDirectory(toRestorePath); }
public MainPresenter(MainForm view, BookRepository bookRepository, JournalRepository journalRepository, NewspaperRepository newspaperRepository, XmlRepository xmlRepository, RawFileRepository rawFileRepository) { this.view = view; this.bookRepository = bookRepository; this.journalRepository = journalRepository; this.newspaperRepository = newspaperRepository; this.xmlRepository = xmlRepository; this.rawFileRepository = rawFileRepository; this.view.DataUpdated += OnViewDataUpdated; this.view.DeletedEntity += OnViewDeletedEntity; this.view.CreatedEntity += OnViewCreatedEntity; this.view.UpdatedEntity += OnViewUpdatedEntity; this.view.SelledEntity += OnViewSelledEntity; this.view.Exported += OnViewExported; this.view.Imported += OnViewImported; }
/// <summary> /// Insert detail into Raw File detail table /// </summary> /// <param name="runId">Run number Id</param> /// <param name="file">Raw File Name</param> /// <param name="desLoc"></param> /// <returns></returns> public bool InsertRawFileDetails(int runId, string file, string desLoc) { try { using (IRawFileRepository objRawFileRepository = new RawFileRepository()) { RawFile rawFile = new RawFile(); rawFile.RunNumberId = runId; rawFile.FileName = Path.GetFileName(file); rawFile.HotFolder = desLoc; rawFile.Status = true; objRawFileRepository.Save(rawFile); } } catch (Exception ex) { throw new Exception("Error while inserting record in Raw file : " + ex); } return(true); }