Example #1
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Name,Description,PublicationDate,WikiLink,Image")] BoxSet boxSet)
        {
            if (id != boxSet.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _db.Update(boxSet);
                    await _db.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BoxSetExists(boxSet.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(boxSet));
        }
        private void FillBoxSetTable(int boxId)
        {
            List <Tuple <string, string> > boxList = new List <Tuple <string, string> >();
            BoxSet    box   = ConfigurationDAL.GetBoxSetById(boxId);
            Cpu       cp    = ConfigurationDAL.GetCpulById(box.cupId);
            Hdd       hdd   = ConfigurationDAL.GetHddlById(box.hddId);
            VideoCard video = ConfigurationDAL.GetVideoCardlById(box.videoCardId);

            boxList.Add(new Tuple <string, string>("номер", box.id.ToString()));
            boxList.Add(new Tuple <string, string>("процесор", cp.name));
            boxList.Add(new Tuple <string, string>("процесорен производител", cp.producer));
            boxList.Add(new Tuple <string, string>("дъно", box.motherboard));
            boxList.Add(new Tuple <string, string>("рам", box.ram));
            boxList.Add(new Tuple <string, string>("видео карта", video.name));
            boxList.Add(new Tuple <string, string>("производител на видео карта", video.producer));
            boxList.Add(new Tuple <string, string>("охлаждане", box.coolingSystem));
            boxList.Add(new Tuple <string, string>("захранване", box.powerSupply));
            boxList.Add(new Tuple <string, string>("лан карта", box.expansionCards));
            boxList.Add(new Tuple <string, string>("хард диск", hdd.name));
            boxList.Add(new Tuple <string, string>("производител на хард диск", hdd.producer));
            boxList.Add(new Tuple <string, string>("преносими устройства", box.removableDevices));
            boxList.Add(new Tuple <string, string>("кутия", box.box));
            BoxSetGrid.DataSource = boxList;
            BoxSetGrid.DataBind();
        }
        public async Task <BoxSet> CreateCollection(CollectionCreationOptions options)
        {
            var name = options.Name;

            // Need to use the [boxset] suffix
            // If internet metadata is not found, or if xml saving is off there will be no collection.xml
            // This could cause it to get re-resolved as a plain folder
            var folderName = _fileSystem.GetValidFilename(name) + " [boxset]";

            var parentFolder = GetParentFolder(options.ParentId);

            if (parentFolder == null)
            {
                throw new ArgumentException();
            }

            var path = Path.Combine(parentFolder.Path, folderName);

            _iLibraryMonitor.ReportFileSystemChangeBeginning(path);

            try
            {
                Directory.CreateDirectory(path);

                var collection = new BoxSet
                {
                    Name             = name,
                    Parent           = parentFolder,
                    DisplayMediaType = "Collection",
                    Path             = path,
                    IsLocked         = options.IsLocked,
                    ProviderIds      = options.ProviderIds
                };

                await parentFolder.AddChild(collection, CancellationToken.None).ConfigureAwait(false);

                await collection.RefreshMetadata(new MetadataRefreshOptions(new DirectoryService()), CancellationToken.None)
                .ConfigureAwait(false);

                if (options.ItemIdList.Count > 0)
                {
                    await AddToCollection(collection.Id, options.ItemIdList, false);
                }

                EventHelper.FireEventIfNotNull(CollectionCreated, this, new CollectionCreatedEventArgs
                {
                    Collection = collection,
                    Options    = options
                }, _logger);

                return(collection);
            }
            finally
            {
                // Refresh handled internally
                _iLibraryMonitor.ReportFileSystemChangeComplete(path, false);
            }
        }
Example #4
0
        public async Task <IActionResult> Create([Bind("ID,Name,Description,PublicationDate,WikiLink,Image")] BoxSet boxSet)
        {
            if (ModelState.IsValid)
            {
                _db.Add(boxSet);
                await _db.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(boxSet));
        }
Example #5
0
        public int PopulateDataBase()
        {
            try
            {
                int    cpuId         = this.InsertCpu();
                int    videoId       = this.InsertVideoCard();
                int    hddId         = this.InsertHdd();
                string motherBoard   = this.boxSet.GetMotherBoard();
                string ram           = this.boxSet.GetRam();
                string coolSys       = this.boxSet.GetCoolingSystem();
                string soundCard     = this.boxSet.GetSoundCard();
                string powerSupply   = this.boxSet.GetPowerSupply();
                string expansionCard = this.boxSet.GetExpansionCard();
                string box           = this.boxSet.GetBox();
                string usb           = this.boxSet.GetRemovableDevices().Item1;
                string disk          = this.boxSet.GetRemovableDevices().Item2;
                string cardReader    = this.boxSet.GetRemovableDevices().Item3;
                string removableDev  = usb + "; " + disk + "; " + cardReader;

                CustomComputersAspEntities db = new CustomComputersAspEntities();

                BoxSet match = db.BoxSets.FirstOrDefault(b => b.cupId == cpuId && b.videoCardId == videoId && b.hddId == hddId &&
                                                         b.motherboard == motherBoard && b.ram == ram && b.coolingSystem == coolSys &&
                                                         b.powerSupply == powerSupply && b.expansionCards == expansionCard &&
                                                         b.box == box && b.removableDevices == removableDev);
                if (match == null)
                {
                    db.AddToBoxSets(new BoxSet()
                    {
                        cupId            = cpuId,
                        videoCardId      = videoId,
                        hddId            = hddId,
                        motherboard      = motherBoard,
                        ram              = ram,
                        coolingSystem    = coolSys,
                        powerSupply      = powerSupply,
                        expansionCards   = expansionCard,
                        box              = box,
                        removableDevices = removableDev,
                    });
                    db.SaveChanges();
                    match = db.BoxSets.FirstOrDefault(b => b.cupId == cpuId && b.videoCardId == videoId && b.hddId == hddId &&
                                                      b.motherboard == motherBoard && b.ram == ram && b.coolingSystem == coolSys &&
                                                      b.powerSupply == powerSupply && b.expansionCards == expansionCard &&
                                                      b.box == box && b.removableDevices == removableDev);
                }
                return(match.id);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Could not successsfully populate DataBase with BoxSet. Reason: {0}", ex.Message);
                return(0);
            }
        }
Example #6
0
 public BoxSetBuilder(string parentId)
 {
     _boxSet = new BoxSet
     {
         Id             = "123",
         ParentId       = parentId,
         Name           = "Lord of the rings",
         OfficialRating = "TV-16",
         Primary        = "primary"
     };
 }
Example #7
0
//</snippet4>
//<snippet5>
        protected override void PerformDataBinding(IEnumerable retrievedData)
        {
            base.PerformDataBinding(retrievedData);

            // If the data is retrieved from an IDataSource as an
            // IEnumerable collection, attempt to bind its values to a
            // set of TextBox controls.
            if (retrievedData != null)
            {
                foreach (object dataItem in retrievedData)
                {
                    TextBox box = new TextBox();

                    // The dataItem is not just a string, but potentially
                    // a System.Data.DataRowView or some other container.
                    // If DataTextField is set, use it to determine which
                    // field to render. Otherwise, use the first field.
                    if (DataTextField.Length > 0)
                    {
                        box.Text = DataBinder.GetPropertyValue(dataItem,
                                                               DataTextField, null);
                    }
                    else
                    {
                        PropertyDescriptorCollection props =
                            TypeDescriptor.GetProperties(dataItem);

                        // Set the "default" value of the TextBox.
                        box.Text = String.Empty;

                        // Set the true data-bound value of the TextBox,
                        // if possible.
                        if (props.Count >= 1)
                        {
                            if (null != props[0].GetValue(dataItem))
                            {
                                box.Text = props[0].GetValue(dataItem).ToString();
                            }
                        }
                    }

                    BoxSet.Add(box);
                }
            }
        }
        public async Task CreateCollection(CollectionCreationOptions options)
        {
            var name = options.Name;

            var folderName = _fileSystem.GetValidFilename(name);

            var parentFolder = _libraryManager.GetItemById(options.ParentId) as Folder;

            if (parentFolder == null)
            {
                throw new ArgumentException();
            }

            var path = Path.Combine(parentFolder.Path, folderName);

            _iLibraryMonitor.ReportFileSystemChangeBeginning(path);

            try
            {
                Directory.CreateDirectory(path);

                var collection = new BoxSet
                {
                    Name             = name,
                    Parent           = parentFolder,
                    DisplayMediaType = "Collection",
                    Path             = path,
                    DontFetchMeta    = options.IsLocked
                };

                await parentFolder.AddChild(collection, CancellationToken.None).ConfigureAwait(false);

                await collection.RefreshMetadata(new MetadataRefreshOptions(), CancellationToken.None)
                .ConfigureAwait(false);
            }
            finally
            {
                // Refresh handled internally
                _iLibraryMonitor.ReportFileSystemChangeComplete(path, false);
            }
        }
Example #9
0
        //Game Data Reads.
        public List <BoxSet> ReadBoxes(string SpreadsheetId)
        {
            var boxSetsFromGoogleSheets = new List <BoxSet>();
            //puts the values of each column(?)row? into a list of lists of objects
            IList <IList <object> > values = GetValues(SpreadsheetId, "BoxSets").Values;

            bool firstRow = true;

            if (values != null && values.Count > 0)
            {
                foreach (var row in values)
                {
                    if (firstRow)
                    {
                        //Skip Column Headers
                        firstRow = false;
                        continue;
                    }



                    BoxSet newBox = new BoxSet()
                    {
                        ID              = int.Parse(row[0].ToString()),
                        Name            = row[1].ToString(),
                        Description     = row[2].ToString(),
                        PublicationDate = row[3].ToString(),
                        WikiLink        = row[4].ToString(),
                        Image           = "default"
                    };

                    boxSetsFromGoogleSheets.Add(newBox);
                }
            }

            return(boxSetsFromGoogleSheets);
        }
Example #10
0
        public async Task <BoxSet> CreateCollection(CollectionCreationOptions options)
        {
            var name = options.Name;

            // Need to use the [boxset] suffix
            // If internet metadata is not found, or if xml saving is off there will be no collection.xml
            // This could cause it to get re-resolved as a plain folder
            var folderName = _fileSystem.GetValidFilename(name) + " [boxset]";

            var parentFolder = GetParentFolder(options.ParentId);

            if (parentFolder == null)
            {
                throw new ArgumentException();
            }

            var path = Path.Combine(parentFolder.Path, folderName);

            _iLibraryMonitor.ReportFileSystemChangeBeginning(path);

            try
            {
                _fileSystem.CreateDirectory(path);

                var collection = new BoxSet
                {
                    Name        = name,
                    Path        = path,
                    IsLocked    = options.IsLocked,
                    ProviderIds = options.ProviderIds,
                    Shares      = options.UserIds.Select(i => new Share
                    {
                        UserId  = i.ToString("N"),
                        CanEdit = true
                    }).ToList()
                };

                await parentFolder.AddChild(collection, CancellationToken.None).ConfigureAwait(false);

                if (options.ItemIdList.Count > 0)
                {
                    await AddToCollection(collection.Id, options.ItemIdList, false, new MetadataRefreshOptions(_fileSystem)
                    {
                        // The initial adding of items is going to create a local metadata file
                        // This will cause internet metadata to be skipped as a result
                        MetadataRefreshMode = MetadataRefreshMode.FullRefresh
                    });
                }
                else
                {
                    _providerManager.QueueRefresh(collection.Id, new MetadataRefreshOptions(_fileSystem), RefreshPriority.High);
                }

                EventHelper.FireEventIfNotNull(CollectionCreated, this, new CollectionCreatedEventArgs
                {
                    Collection = collection,
                    Options    = options
                }, _logger);

                return(collection);
            }
            finally
            {
                // Refresh handled internally
                _iLibraryMonitor.ReportFileSystemChangeComplete(path, false);
            }
        }
Example #11
0
        private void AddMoviesToCollection(IReadOnlyCollection <Movie> movies, string tmdbCollectionId, BoxSet boxSet)
        {
            int minimumNumberOfMovies = Plugin.Instance.PluginConfiguration.MinimumNumberOfMovies;

            if (movies.Count < minimumNumberOfMovies)
            {
                _logger.LogInformation("Minimum number of movies is {Count}, but there is/are only {MovieCount}: {MovieNames}",
                                       minimumNumberOfMovies, movies.Count, string.Join(", ", movies.Select(m => m.Name)));
                return;
            }

            // Create the box set if it doesn't exist, but don't add anything to it on creation
            if (boxSet == null)
            {
                var tmdbCollectionName = movies.First().TmdbCollectionName;
                _logger.LogInformation("Box Set for {TmdbCollectionName} ({TmdbCollectionId}) does not exist. Creating it now!", tmdbCollectionName, tmdbCollectionId);
                boxSet = _collectionManager.CreateCollection(new CollectionCreationOptions
                {
                    Name        = tmdbCollectionName,
                    ProviderIds = new Dictionary <string, string> {
                        { MetadataProviders.Tmdb.ToString(), tmdbCollectionId }
                    }
                });
            }

            var itemsToAdd = movies
                             .Where(m => !boxSet.ContainsLinkedChildByItemId(m.Id))
                             .Select(m => m.Id)
                             .ToList();

            if (!itemsToAdd.Any())
            {
                _logger.LogInformation("The movies {MovieNames} is/are already in their proper box set, {BoxSetName}",
                                       string.Join(", ", movies.Select(m => m.Name)), boxSet.Name);
                return;
            }

            _collectionManager.AddToCollection(boxSet.Id, itemsToAdd);
        }
Example #12
0
        public async Task <BoxSet> CreateCollectionAsync(CollectionCreationOptions options)
        {
            var name = options.Name;

            // Need to use the [boxset] suffix
            // If internet metadata is not found, or if xml saving is off there will be no collection.xml
            // This could cause it to get re-resolved as a plain folder
            var folderName = _fileSystem.GetValidFilename(name) + " [boxset]";

            var parentFolder = await GetCollectionsFolder(true).ConfigureAwait(false);

            if (parentFolder == null)
            {
                throw new ArgumentException();
            }

            var path = Path.Combine(parentFolder.Path, folderName);

            _iLibraryMonitor.ReportFileSystemChangeBeginning(path);

            try
            {
                Directory.CreateDirectory(path);

                var collection = new BoxSet
                {
                    Name        = name,
                    Path        = path,
                    IsLocked    = options.IsLocked,
                    ProviderIds = options.ProviderIds,
                    DateCreated = DateTime.UtcNow
                };

                parentFolder.AddChild(collection);

                if (options.ItemIdList.Count > 0)
                {
                    await AddToCollectionAsync(
                        collection.Id,
                        options.ItemIdList.Select(x => new Guid(x)),
                        false,
                        new MetadataRefreshOptions(new DirectoryService(_fileSystem))
                    {
                        // The initial adding of items is going to create a local metadata file
                        // This will cause internet metadata to be skipped as a result
                        MetadataRefreshMode = MetadataRefreshMode.FullRefresh
                    }).ConfigureAwait(false);
                }
                else
                {
                    _providerManager.QueueRefresh(collection.Id, new MetadataRefreshOptions(new DirectoryService(_fileSystem)), RefreshPriority.High);
                }

                CollectionCreated?.Invoke(this, new CollectionCreatedEventArgs
                {
                    Collection = collection,
                    Options    = options
                });

                return(collection);
            }
            finally
            {
                // Refresh handled internally
                _iLibraryMonitor.ReportFileSystemChangeComplete(path, false);
            }
        }
        public string FindId(string name, int?productionYear)
        {
            int?year = null;

            ParseName(name, out name, out year);

            if (year == null && productionYear != null)
            {
                year = productionYear;
            }

            Logger.ReportInfo("MovieDbProvider: Finding id for movie: " + name);
            string language = Kernel.Instance.ConfigData.PreferredMetaDataLanguage.ToLower();

            //if id is specified in the file name return it directly
            string justName = Item.Path != null?Item.Path.Substring(Item.Path.LastIndexOf("\\")) : "";

            string id = Helper.GetAttributeFromPath(justName, "tmdbid");

            if (id != null)
            {
                Logger.ReportInfo("MovieDbProvider: tMDb ID specified in file path.  Using: " + id);
                return(id);
            }

            //if we are a boxset - look at our first child
            BoxSet boxset = Item as BoxSet;

            if (boxset != null)
            {
                if (boxset.Children.Count > 1)
                {
                    var firstChild = boxset.Children[0];
                    Logger.ReportVerbose("MovieDbProvider - Attempting to find boxset ID from: " + firstChild.Name);
                    string childName;
                    int?   childYear;
                    ParseName(firstChild.Name, out childName, out childYear);
                    id = GetBoxsetIdFromMovie(childName, childYear, language);
                    if (id != null)
                    {
                        Logger.ReportInfo("MovieDbProvider - Found Boxset ID: " + id);
                        return(id);
                    }
                }
            }
            //nope - search for it
            id = AttemptFindId(name, year, language);
            if (id == null)
            {
                //try in english if wasn't before
                if (language != "en")
                {
                    id = AttemptFindId(name, year, "en");
                }
                else
                {
                    if (id == null)
                    {
                        // try with dot and _ turned to space
                        name = name.Replace(",", " ");
                        name = name.Replace(".", " ");
                        name = name.Replace("  ", " ");
                        name = name.Replace("_", " ");
                        name = name.Replace("-", "");
                        id   = AttemptFindId(name, year, language);
                        if (id == null && language != "en")
                        {
                            //finally again, in english
                            id = AttemptFindId(name, year, "en");
                        }
                    }
                }
            }
            return(id);
        }
 public CollectionModifiedEventArgs(BoxSet collection, IReadOnlyCollection <BaseItem> itemsChanged)
 {
     Collection   = collection;
     ItemsChanged = itemsChanged;
 }
Example #15
0
        private async Task AddMoviesToCollection(IReadOnlyCollection <Movie> movies, string tmdbCollectionId, BoxSet boxSet)
        {
            int minimumNumberOfMovies = Plugin.Instance.PluginConfiguration.MinimumNumberOfMovies;

            if (movies.Count < minimumNumberOfMovies)
            {
                _logger.LogInformation("Minimum number of movies is {Count}, but there is/are only {MovieCount}: {MovieNames}",
                                       minimumNumberOfMovies, movies.Count, string.Join(", ", movies.Select(m => m.Name)));
                return;
            }

            // Create the box set if it doesn't exist, but don't add anything to it on creation
            if (boxSet == null)
            {
                var tmdbCollectionName = GetTmdbCollectionName(movies);
                if (string.IsNullOrWhiteSpace(tmdbCollectionName))
                {
                    _logger.LogError("Can't get a proper box set name for the movies {MovieNames}. Make sure is propertly assigned to the movie info.",
                                     string.Join(", ", movies.Select(m => m.Name)));
                    return;
                }

                if (Plugin.Instance.PluginConfiguration.StripCollectionKeywords)
                {
                    tmdbCollectionName = tmdbCollectionName.Replace("Collection", String.Empty).Trim();
                }

                _logger.LogInformation("Box Set for {TmdbCollectionName} ({TmdbCollectionId}) does not exist. Creating it now!", tmdbCollectionName, tmdbCollectionId);
                boxSet = await _collectionManager.CreateCollectionAsync(new CollectionCreationOptions
                {
                    Name        = tmdbCollectionName,
                    ProviderIds = new Dictionary <string, string> {
                        { MetadataProvider.Tmdb.ToString(), tmdbCollectionId }
                    }
                }).ConfigureAwait(false);
            }

            var itemsToAdd = movies
                             .Where(m => !boxSet.ContainsLinkedChildByItemId(m.Id))
                             .Select(m => m.Id)
                             .ToList();

            if (!itemsToAdd.Any())
            {
                _logger.LogInformation("The movies {MovieNames} is/are already in their proper box set, {BoxSetName}",
                                       string.Join(", ", movies.Select(m => m.Name)), boxSet.Name);
                return;
            }

            await _collectionManager.AddToCollectionAsync(boxSet.Id, itemsToAdd).ConfigureAwait(false);
        }