/// <summary> /// Envia documento versionado para o content /// </summary> /// <param name="file">Arquivo a ser enviado</param> private void SendRevisionDocument(string file) { var vsdoc = new VsDoc(); var documentKey = Path.GetFileNameWithoutExtension(file).ToInt(); ImportDatabase.Using(session => { var sql = "select doc_code DocCode, vsdoc_revisao VsDocRevisao from vsdoc where vsdoc_code = " + documentKey; vsdoc = session.CreateSQLQuery(sql) .SetResultTransformer(CustomResultTransformer <VsDoc> .Do()) .UniqueResult <VsDoc>(); }); var ecm6DocVersionado = this.GetEcm6VersionedDocument(documentKey); if (ecm6DocVersionado == null) { Log.App.ErrorFormat("Documento ecm6 #{0} não foi importado", vsdoc.DocCode); return; } this.ImportEcm6VersionedDocumentFile(ecm6DocVersionado, file, vsdoc); }
public static void ValidateDatabaseExistance() { for (int i = 0; i < ImportDatabase.Count; i++) { var file = ImportDatabase[i]; if (file.AssociatedFiles.Media.Count == 0 || !File.Exists(file.AssociatedFiles.Media[0].PathAndFilename)) { ImportDatabase.Remove(file); continue; } } }
public virtual Dictionary <int, TEntity> Execute(string message) { Log.App.InfoFormat(message); IList <TEntity> entities = new List <TEntity>(); Log.App.DebugFormat("Obtendo registros no ecm 6"); ImportDatabase.Using(session => { entities = this.GetEntities(session).ToList(); }); Log.App.DebugFormat("Encontrado {0} registros", entities.Count); Log.App.DebugFormat("Importando registros no Salus..."); foreach (var entity in entities) { this.ImportEntity(entity); } return(this.itemsForReference); }
private Dictionary <int, TEntity> InternalExecute(int startRow = 1, int endRow = ItemsPerPage) { var entities = new List <TEntity>(); var currentStartRow = 0; var currentEndRow = 0; try { do { currentStartRow = startRow; currentEndRow = endRow; ImportDatabase.Using(session => { Log.App.InfoFormat("Obtendo do ecm6 de {0} a {1}", startRow, endRow); entities = this.GetEntities(session, startRow, endRow); }); startRow = endRow + 1; endRow += ItemsPerPage; foreach (var entity in entities) { this.ImportEntity(entity); } }while (entities.Count > 0); } catch (GenericADOException exception) { Thread.Sleep(TimeSpan.FromMinutes(2).Milliseconds); this.InternalExecute(currentStartRow, currentEndRow); } return(this.itemsAlreadyImported); }
private Ftp2 BuildFtpClient() { Ftp2 ftp = null; ImportDatabase.Using(session => { const string Sql = @" select system_serverip Host, system_port Port, SYSTEM_SERVERUSR FtpUser, SYSTEM_SERVERPWD Password, SYSTEM_FTPROOT RootPath from system"; var ftpSettings = session.CreateSQLQuery(Sql) .SetResultTransformer(CustomResultTransformer <FtpSettings> .Do()) .UniqueResult <FtpSettings>(); ////ftp = new Ftp2( //// ftpSettings.Host, //// ftpSettings.Port, //// ftpSettings.FtpUser, //// ftpSettings.Password, //// ftpSettings.RootPath); ftp = new Ftp2( "192.168.10.105", 21, "anonymous", "anonymous", "/"); }); return(ftp); }
/// <summary> /// Converts the media path import database into a MovieModel DB. /// </summary> public static void ConvertMediaPathImportToDB() { cancelImport = false; var db = MediaPathDBFactory.GetMediaPathMoviesUnsorted(); var count = 0; MovieDBFactory.ImportProgressMaximum = db.Count; ImportDatabase.Clear(); ImportDuplicatesDatabase.Clear(); var getFiles = new string[1]; var currentGetPathFiles = string.Empty; UI.Windows7UIFactory.StartProgressState(db.Count); foreach (var file in db) { if (cancelImport) { break; } MovieDBFactory.ImportProgressCurrent = count; MovieDBFactory.ImportProgressStatus = string.Format("Processing: " + file.PathAndFileName.Replace("{", "{{").Replace("}", "}}")); if (file.Path != currentGetPathFiles) { getFiles = FileHelper.GetFilesRecursive(file.Path, "*.*").ToArray(); currentGetPathFiles = file.Path; } var videoSource = file.DefaultVideoSource; if (MovieNaming.IsBluRay(file.PathAndFileName)) { videoSource = "Bluray"; } else if (MovieNaming.IsDVD(file.PathAndFileName)) { videoSource = "DVD"; } else { var detect = Tools.IO.DetectType.FindVideoSource(file.PathAndFileName); if (!string.IsNullOrEmpty(detect)) { videoSource = detect; } } string title = MovieNaming.GetMovieName(file.PathAndFileName, file.MediaPathType); var movieModel = new MovieModel { Title = title, Year = MovieNaming.GetMovieYear(file.PathAndFileName), ScraperGroup = file.ScraperGroup, VideoSource = videoSource, NfoPathOnDisk = FindNFO(file.FilenameWithOutExt, FindFilePath(title, file), getFiles), PosterPathOnDisk = FindPoster(file.FilenameWithOutExt, FindFilePath(title, file), getFiles), FanartPathOnDisk = FindFanart(file.FilenameWithOutExt, FindFilePath(title, file), getFiles) }; if (!string.IsNullOrEmpty(movieModel.NfoPathOnDisk)) { InOut.OutFactory.LoadMovie(movieModel); movieModel.ChangedText = false; } var result = (from m in ImportDatabase where (m.Title.ToLower().Trim() == movieModel.Title.ToLower().Trim()) select m).ToList(); if (result.Count == 0) { if (!string.IsNullOrEmpty(movieModel.PosterPathOnDisk)) { movieModel.GenerateSmallPoster(movieModel.PosterPathOnDisk); movieModel.ChangedPoster = false; } if (!string.IsNullOrEmpty(movieModel.FanartPathOnDisk)) { movieModel.GenerateSmallFanart(movieModel.FanartPathOnDisk); movieModel.ChangedFanart = false; } movieModel.AssociatedFiles.AddToMediaCollection(file); // Does the movie exist in our current DB? var result2 = (from m in MovieDBFactory.MovieDatabase where (m.Title.ToLower().Trim() == movieModel.Title.ToLower().Trim()) select m).ToList(); if (result2.Count > 0) { if (movieModel.Year != null) { var r = (from m in result2 where m.Year == movieModel.Year select m).ToList(); if (r.Count > 0) { // We already have a movie with that name and year, mark as dupe ImportDuplicatesDatabase.Add(movieModel); } } else { // No year, so we can't ensure it's a dupe ImportDuplicatesDatabase.Add(movieModel); } } // Add it to the list anyway, since there's no implementation of any action on duplicates. ImportDatabase.Add(movieModel); } else { var r = (from m in result where m.Year == movieModel.Year select m).ToList(); if (Regex.IsMatch(file.PathAndFileName.ToLower(), @"(disc|disk|part|cd|vob|ifo|bup)", RegexOptions.IgnoreCase)) { // Only associate with an existing movie if its not a dupe result[0].AssociatedFiles.AddToMediaCollection(file); } else if (r.Count == 0) { // Same title, different year ImportDatabase.Add(movieModel); } else { // Dont count a disc or part as a dupe or movies with different years ImportDuplicatesDatabase.Add(movieModel); // Add it to the list anyway, since there's no implementation of any action on duplicates. ImportDatabase.Add(movieModel); } } count++; UI.Windows7UIFactory.SetProgressValue(count); } UI.Windows7UIFactory.StopProgressState(); }