Ejemplo n.º 1
0
 public static void EnsurePopulated()
 {
     using (MySQLContext db = new MySQLContext())
     {
         //db.Database.EnsureDeleted();
         db.Database.EnsureCreated();
     }
 }
Ejemplo n.º 2
0
 public Accomodation GetAccomodationAndCulturalExchangeList(Guid id)
 {
     using (var db = new MySQLContext(_OptionsBuilder))
     {
         return(db.Accomodation.Include(x => x.CulturalExchanges)
                .FirstOrDefault(x => x.Id == id));
     }
 }
Ejemplo n.º 3
0
 public SystemEnvironment GetEnvironmentByIdIncludeDependencys(Guid id)
 {
     using (var db = new MySQLContext(_OptionsBuilder))
     {
         return(db.Environment.Include(x => x.Students)
                .Include(x => x.CulturalExchange)
                .Include(x => x.Accomodations).FirstOrDefault(x => x.Id == id));
     }
 }
Ejemplo n.º 4
0
        public MedicalController(MySQLContext context, BlockchainService service,
                                 IHostingEnvironment hostingEnvironment)
        {
            _context            = context;
            _hostingEnvironment = hostingEnvironment;
            _blockchainService  = service;

            _blockchainService.Initialize();
        }
        public TEntity Update(TEntity obj)
        {
            using (var db = new MySQLContext(_OptionsBuilder))
            {
                var entity = db.Set <TEntity>().Update(obj);
                db.SaveChanges();

                return(entity.Entity);
            }
        }
Ejemplo n.º 6
0
        public void Update(MySQLContext db)
        {
            var scan = db.Scans.FirstOrDefault(s => s.FolderPath == FolderPath);

            if (scan != null)
            {
                scan.LastScanned = LastScanned;

                db.SaveChanges();
            }
        }
Ejemplo n.º 7
0
        public bool Exists()
        {
            bool exists = false;

            using (MySQLContext db = new MySQLContext(Logger))
            {
                exists = db.Albums.Any(a => a.FolderPath == FolderPath);
            }

            return(exists);
        }
 public ReceivePaymentCulturalExchange GetByIdIncludedDependency(Guid id)
 {
     using (var db = new MySQLContext(_OptionsBuilder))
     {
         return(db.Set <ReceivePaymentCulturalExchange>()
                .Include(x => x.Environment)
                .Include(x => x.CulturalExchange)
                .ThenInclude(x => x.Student)
                .FirstOrDefault(x => x.Id == id));
     }
 }
Ejemplo n.º 9
0
        public bool Exists()
        {
            bool exists = false;

            using (MySQLContext db = new MySQLContext(Logger))
            {
                exists = db.MediaFiles.Any(a => a.FilePath == FilePath);
            }

            return(exists);
        }
 public List <ReceivePaymentCulturalExchange> GetAllIncludedDependencys(Guid environmentId)
 {
     using (var db = new MySQLContext(_OptionsBuilder))
     {
         return(db.Set <ReceivePaymentCulturalExchange>()
                .Include(x => x.Environment)
                .Include(x => x.CulturalExchange)
                .ThenInclude(x => x.Student)
                .ToList());
     }
 }
Ejemplo n.º 11
0
        public void Add(MySQLContext db)
        {
            Data.Tables.Scans scan = new Data.Tables.Scans()
            {
                FolderPath  = FolderPath,
                LastScanned = LastScanned
            };

            db.Scans.Add(scan);
            db.SaveChanges();
        }
Ejemplo n.º 12
0
        public TEntity Insert(TEntity obj)
        {
            using (var db = new MySQLContext(_OptionsBuilder))
            {
                db.Entry(obj).State = EntityState.Added;
                var entity = db.Set <TEntity>().Add(obj);
                db.SaveChanges();

                return(entity.Entity);
            }
        }
Ejemplo n.º 13
0
        private void LoadAlbumDetails(string albumDirectory, int retry = 0)
        {
            try
            {
                AlbumDetailed album = null;

                using (MySQLContext db = new MySQLContext(Logger))
                {
                    if (Globals.VerboseLogging)
                    {
                        Logger.Info($"Loading album details for '{albumDirectory}'.");
                    }

                    var baseAlbum = db.Albums.FirstOrDefault(a => a.FolderPath == albumDirectory);

                    if (baseAlbum == null)
                    {
                        throw new Exception($"Could not locate album entry for '{albumDirectory}'.");
                    }

                    album     = GetAlbumDetails(baseAlbum, db);
                    baseAlbum = null;

                    if (Globals.VerboseLogging)
                    {
                        Logger.Info($"Caching '{albumDirectory}' details.");
                    }
                }

                AlbumDictionary[albumDirectory] = album;

                AlbumsChecked++;

                if (AlbumsChecked % int.Parse(ConfigurationManager.AppSettings["ProcessUpdateCounter"] ?? "100") == 0)
                {
                    Logger.Info($"Checked {AlbumsChecked} albums...");
                }
            }
            catch (Exception ex)
            {
                if (retry < 3)
                {
                    retry++;
                    Logger.Info($"Error loading album information: {albumDirectory}. Retrying {retry} of 3...");
                    LoadAlbumDetails(albumDirectory, retry);
                }
                else
                {
                    Logger.Error($"Error loading album information: {albumDirectory}", ex);
                }
            }
        }
 public List <ReceivePaymentCulturalExchange> GetAllIncludedDependencysByCulturalExchangeId(Guid culturalExchangeId)
 {
     using (var db = new MySQLContext(_OptionsBuilder))
     {
         return(db.Set <ReceivePaymentCulturalExchange>()
                .Include(x => x.Environment)
                .Include(x => x.CulturalExchange)
                .ThenInclude(x => x.Student)
                .Include(x => x.CulturalExchange.College)
                .ThenInclude(col => col.CollegeTime)
                .Where(x => x.CulturalExchangeId == culturalExchangeId)
                .ToList());
     }
 }
Ejemplo n.º 15
0
        public void Add(MySQLContext db)
        {
            Data.Tables.Albums album = new Data.Tables.Albums()
            {
                Album       = AlbumName,
                AlbumArtist = AlbumArtist,
                Discs       = TotalDiscs,
                Disc        = DiscNumber,
                FolderPath  = FolderPath,
                Year        = Year,
                LastScanned = DateTime.Now
            };

            db.Albums.Add(album);
            db.SaveChanges();
        }
Ejemplo n.º 16
0
        public void Update(MySQLContext db)
        {
            var album = db.Albums.FirstOrDefault(a => a.FolderPath == FolderPath);

            if (album != null)
            {
                album.FolderPath  = FolderPath;
                album.Album       = AlbumName;
                album.AlbumArtist = AlbumArtist;
                album.Discs       = TotalDiscs;
                album.Disc        = DiscNumber;
                album.Year        = Year;
                album.LastScanned = DateTime.Now;

                db.SaveChanges();
            }
        }
Ejemplo n.º 17
0
        public void CheckForErrors()
        {
            Logger.Info($"Checking for tag errors...");

            FilesChecked  = 0;
            AlbumsChecked = 0;
            ScanStart     = DateTime.Now;

            using (MySQLContext db = new MySQLContext(Logger))
            {
                foreach (var mediaFile in db.MediaFiles)
                {
                    var albumDirectory = Path.GetDirectoryName(mediaFile.FilePath) + "\\";

                    if (!AlbumDictionary.ContainsKey(albumDirectory))
                    {
                        AlbumDictionary[albumDirectory] = null;
                        AlbumActions.Add(() => LoadAlbumDetails(albumDirectory));
                    }

                    TagActions.Add(() => CheckTagDetails(mediaFile));
                }
            }

            if (!string.IsNullOrEmpty(ParallelThreads))
            {
                Logger.Info($"Running with maximum number of threads: {ParallelThreads}.");
                var tagOptions = new ParallelOptions {
                    MaxDegreeOfParallelism = int.Parse(ParallelThreads)
                };
                Logger.Info($"Loading album information.");
                Parallel.Invoke(tagOptions, AlbumActions.ToArray());
                Logger.Info($"Checking tag data.");
                Parallel.Invoke(tagOptions, TagActions.ToArray());
            }
            else
            {
                Parallel.Invoke(AlbumActions.ToArray());
                Parallel.Invoke(TagActions.ToArray());
            }

            ScanEnd = DateTime.Now;
        }
        public PersonServiceImpl(MySQLContext context)
        {
            mySQLContext = context;

            if (mySQLContext.Persons.Count() == 0)
            {
                mySQLContext.Persons.AddRange(
                    new Person {
                    FirstName = "Maria Vilma",
                    LastName  = "Louzada",
                    Address   = "110 Norte, Al. 25, Lote 2",
                    Gender    = "Feminine"
                },
                    new Person {
                    FirstName = "ANITA VAITEROSKI",
                    LastName  = "DE LIMA",
                    Address   = "Rua Armando Salles de Oliveira",
                    Gender    = "Feminine"
                },
                    new Person {
                    FirstName = "GUILHERME HENRIQUE",
                    LastName  = "BARBOSA DE MATOS",
                    Address   = "Avenida Maranhão",
                    Gender    = "Male"
                },
                    new Person {
                    FirstName = "JOSLEI ELISEU",
                    LastName  = "LIEBL",
                    Address   = "Rua Adolfo Konder",
                    Gender    = "Male"
                },
                    new Person {
                    FirstName = "LUCAS ALEF SOUZA",
                    LastName  = "DA SILVA",
                    Address   = "Avenida Curuá-Una",
                    Gender    = "Male"
                });
                mySQLContext.SaveChanges();
            }
        }
Ejemplo n.º 19
0
        public void AddOrUpdate()
        {
            if (!TagDataLoaded)
            {
                Logger.Info($"Tag data not loaded for file '{FilePath}'.");
                return;
            }

            DateTime processStart = DateTime.Now;

            using (var db = new MySQLContext(Logger))
            {
                if (!Exists(db))
                {
                    if (Globals.VerboseLogging)
                    {
                        Logger.Info($"Adding new entry for file '{FilePath}'.");
                    }

                    Add(db);
                }
                else
                {
                    if (Globals.VerboseLogging)
                    {
                        Logger.Info($"Updating entry for file '{FilePath}'.");
                    }

                    Update(db);
                }
            }

            DateTime processEnd = DateTime.Now;

            if (Globals.VerboseLogging)
            {
                Logger.Info($"'{FilePath}' AddOrUpdate completed in {(processEnd - processStart).TotalMilliseconds} milliseconds.");
            }
        }
Ejemplo n.º 20
0
        public BaseContext CreateReplicaDbContext(LoginModel model)
        {
            String      replicaConnectionString;
            BaseContext replicaDBContext;

            switch (model.ReplicaServerType)
            {
            case DatabaseConstants.SQL_SERVER:
                replicaConnectionString = SQLConnectionString.Replace("{server}", model.ReplicaServerName).Replace("{database}", model.ReplicaDatabaseName).Replace("{user id}", model.ReplicaUserName).Replace("{password}", model.ReplicaPassword);
                replicaDBContext        = new SQLContext(replicaConnectionString);
                break;

            case DatabaseConstants.MY_SQL:
                replicaConnectionString = MySQLConnectionString.Replace("{server}", model.ReplicaServerName).Replace("{database}", model.ReplicaDatabaseName).Replace("{user id}", model.ReplicaUserName).Replace("{password}", model.ReplicaPassword);
                replicaDBContext        = new MySQLContext(replicaConnectionString);
                break;

            default:
                replicaConnectionString = SQLConnectionString.Replace("{server}", model.ReplicaServerName).Replace("{database}", model.ReplicaDatabaseName).Replace("{user id}", model.ReplicaUserName).Replace("{password}", model.ReplicaPassword);
                replicaDBContext        = new SQLContext(replicaConnectionString);
                break;
            }
            return(replicaDBContext);
        }
Ejemplo n.º 21
0
        public BaseContext CreateDbContext(LoginModel model)
        {
            String      primaryConnectionString;
            BaseContext primaryDBContext;

            switch (model.PrimaryServerType)
            {
            case DatabaseConstants.SQL_SERVER:
                primaryConnectionString = SQLConnectionString.Replace("{server}", model.PrimaryServerName).Replace("{database}", model.PrimaryDatabaseName).Replace("{user id}", model.PrimaryUserName).Replace("{password}", model.PrimaryPassword);
                primaryDBContext        = new SQLContext(primaryConnectionString);
                break;

            case DatabaseConstants.MY_SQL:
                primaryConnectionString = MySQLConnectionString.Replace("{server}", model.PrimaryServerName).Replace("{database}", model.PrimaryDatabaseName).Replace("{user id}", model.PrimaryUserName).Replace("{password}", model.PrimaryPassword);
                primaryDBContext        = new MySQLContext(primaryConnectionString);
                break;

            default:
                primaryConnectionString = SQLConnectionString.Replace("{server}", model.PrimaryServerName).Replace("{database}", model.PrimaryDatabaseName).Replace("{user id}", model.PrimaryUserName).Replace("{password}", model.PrimaryPassword);
                primaryDBContext        = new SQLContext(primaryConnectionString);
                break;
            }
            return(primaryDBContext);
        }
Ejemplo n.º 22
0
        public void AddOrUpdate()
        {
            using (var db = new MySQLContext(Logger))
            {
                if (!Exists(db))
                {
                    if (Globals.VerboseLogging)
                    {
                        Logger.Info($"Adding new entry for scan of '{FolderPath}'.");
                    }

                    Add(db);
                }
                else
                {
                    if (Globals.VerboseLogging)
                    {
                        Logger.Info($"Updating entry for scan of '{FolderPath}'.");
                    }

                    Update(db);
                }
            }
        }
Ejemplo n.º 23
0
 public GroupService(MySQLContext mySQLContext)
 {
     _mySQLContext = mySQLContext;
     _converter    = new GroupConverter();
 }
Ejemplo n.º 24
0
 public UserRepository(MySQLContext context)
 {
     _context = context;
 }
Ejemplo n.º 25
0
 public PersonServiceImpl(MySQLContext mySQLContext)
 {
     _context = mySQLContext;
 }
 public WebUserRepositoryImpl(MySQLContext context)
 {
     _context = context;
 }
Ejemplo n.º 27
0
 public HomeworkRepository(MySQLContext db)
 {
     this.db = db;
 }
 public PersonRepositoryImpl(MySQLContext context)
 {
     _context = context;
 }
Ejemplo n.º 29
0
 public GenericRepository(MySQLContext context)
 {
     _context = context;
     dataset  = _context.Set <T>();
 }
Ejemplo n.º 30
0
 public PersonServiceImplementation(MySQLContext context)
 {
     //Context injection
     _contex = context;
 }
 public MysqlDBManager()
 {
     this.context = new MySQLContext();
 }