Esempio n. 1
0
        /// <summary>
        /// Create Performer View Models for each performer
        /// (order albums, calculate rate and count the number of albums)
        /// </summary>
        /// <param name="performers">Pre-selected collection of performers to work with</param>
        private async Task FillPerformerViewModelsAsync(PageCollection <PerformerDto> performers)
        {
            // why not?
            GC.Collect();
            GC.WaitForPendingFinalizers();

            CreatePageNavigationPanel(performers.TotalPages);

            Performers.Clear();
            foreach (var performer in performers.Items)
            {
                var performerViewModel = Mapper.Map <PerformerViewModel>(performer);

                // Fill performer's albumlist
                var albums = await _performerService.GetPerformerAlbumsAsync(performer.Id, AlbumPattern);

                performerViewModel.Albums = Mapper.Map <ObservableCollection <AlbumViewModel> >(albums);

                // Recalculate total rate and number of albums of performer
                performerViewModel.UpdateAlbumCollectionRate(_rateCalculator);

                // Finally, add fully created performer view model to the list
                Performers.Add(performerViewModel);

                // some animation effect )))
                await Task.Delay(50);
            }
        }
        private void DoUpdatePeformers(string key, DateTime since)
        {
            var count  = Channel.get_performer_count(key, since);
            var offset = 0;

            if (count > 0)
            {
                _cachePerformers = null;
            }
            while (offset < count)
            {
                // get the next batch
                var a = Channel.get_performers(key, since, offset);
                offset += a.Length;
                foreach (var x in a)
                {
                    var id        = TicketJonesPerformer.For(x.id);
                    var performer = Performers.TryGet(id) ?? new TicketJonesPerformer
                    {
                        Document = new Document {
                            Id = id
                        },
                    };
                    performer.TicketJonesId = x.id.ToString();
                    performer.Name          = x.name;
                    performer.Category      = TicketJonesCategory.For(x.event_category_id);
                    Performers.Save(performer);
                }
            }
        }
Esempio n. 3
0
        private async void AddPerformerAsync()
        {
            // set initial information of a newly added performer
            var performer = (
                await _performerService.AddPerformerAsync(new Performer {
                Name = "Unknown"
            })
                ).Data;

            var performerViewModel = Mapper.Map <PerformerViewModel>(performer);

            var parameters = new DialogParameters
            {
                { "performer", performerViewModel },
                { "countries", await _unitOfWork.CountryRepository.GetAllAsync() }
            };

            _dialogService.ShowDialog("EditPerformerWindow", parameters, null);

            // and show only newly added performer (to focus user's attention on said performer)

            Performers.Clear();
            PageCollection.Clear();

            ActivateUpperPanel(false);
            _selectedPage = 0;

            Performers.Add(performerViewModel);
        }
Esempio n. 4
0
        public void WriteTag()
        {
            CheckValidness();

            if (tag == null)
            {
                tag = new Tag(FullPath);
            }
            tag.Clear();

            tag.Year = Year;
            tag.SetTrack(TrackNumber, Album.TotalTracks[DiscNumber - 1]);
            tag.SetDiscNum(DiscNumber, Album.TotalDisc);
            tag.TrackID    = ID;
            tag.Title      = Name;
            tag.Performers = Performers.ConvertAll <string>(
                x => x.GetName(Artist.NameFormats.First_Last_Type)).ToArray();;

            Piece.WriteToTag(tag);
            Album.WriteToTag(tag);

            tag.Write();

            //update the file size after adding/changing tag
            FileInfo f = new FileInfo(FullPath);

            Size   = (int)f.Length;
            Length = (int)System.Math.Round(tag.UltraID3.Duration.TotalSeconds, 0);
            Update();
        }
Esempio n. 5
0
        private Performers GetPerformers(string id)
        {
            List <Performers> performers = new List <Performers>();

            using (MySqlConnection conn = new MySqlConnection(connectionString))
            {
                conn.Open();
                MySqlCommand cmd = new MySqlCommand("select * from performers", conn);

                using (var reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        Performers p = new Performers
                        {
                            Id    = Convert.ToInt32(reader["id"]),
                            Name  = reader["name"].ToString(),
                            Descr = reader["Description"].ToString(),
                            Date  = DateTime.Parse(reader["date"].ToString())
                        };
                        performers.Add(p);
                    }
                }
            }

            return(performers[0]);
        }
Esempio n. 6
0
        public async Task <IActionResult> PutPerformers([FromRoute] int id, [FromBody] Performers performers)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != performers.PerformerId)
            {
                return(BadRequest());
            }

            _context.Entry(performers).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PerformersExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 7
0
 public void RefreshPerformers()
 {
     Performers.Clear();
     foreach (var performer in _boServiceClient.GetAllPerformers())
     {
         Performers.Add(performer);
     }
 }
Esempio n. 8
0
 public IActionResult PutPerformers(string GroupName, [FromBody] Performers performer)
 {
     performer.GroupName = GroupName;
     if (_performerRepo.GetPerformers().Any(x => x.GroupName == GroupName))
     {
         _performerRepo.ModifyPerformers(performer);
         return(NoContent());
     }
     return(NotFound());
 }
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (FilePath != null ? FilePath.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Title != null ? Title.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Album != null ? Album.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Performers != null ? Performers.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (AlbumArtists != null ? AlbumArtists.GetHashCode() : 0);
         return(hashCode);
     }
 }
Esempio n. 10
0
        public async Task <IActionResult> PostPerformers([FromBody] Performers performers)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Performers.Add(performers);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetPerformers", new { id = performers.PerformerId }, performers));
        }
 IDictionary <string, EventPerformer> GetPerformers()
 {
     if (null == _cachePerformers)
     {
         lock (_sync)
         {
             if (null == _cachePerformers)
             {
                 _cachePerformers = Performers.GetPerformers(GetCategories());
             }
         }
     }
     return(_cachePerformers);
 }
Esempio n. 12
0
        /// <summary>
        /// This is the handler of AlbumRateUpdated event
        /// (that can be raised in various different windows)
        /// </summary>
        /// <param name="album"></param>
        private void UpdateRate(AlbumViewModel album)
        {
            var performerOnScreen = Performers.FirstOrDefault(p => p.Id == album.PerformerId);

            if (performerOnScreen is null)
            {
                return;
            }

            var albumOnScreen = performerOnScreen.Albums.FirstOrDefault(a => a.Id == album.Id);

            albumOnScreen.Rate = album.Rate;

            UpdatePerformerRate(performerOnScreen);
        }
Esempio n. 13
0
        private async void RemoveSelectedPerformerAsync()
        {
            if (SelectedPerformer == null)
            {
                MessageBox.Show("Please select performer to remove");
                return;
            }

            var message = $"Are you sure you want to delete '{SelectedPerformer.Name}' " +
                          $"including an entire discography?";

            if (MessageBox.Show(message, "Confirmation", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
            {
                await _performerService.RemovePerformerAsync(SelectedPerformer.Id);

                Performers.Remove(SelectedPerformer);
            }
        }
Esempio n. 14
0
        private async void AddPerformerAsync()
        {
            // set initial information of a newly added performer
            var performer = (
                await _performerService.AddPerformerAsync(new Performer {
                Name = "Unknown"
            })
                ).Data;

            var performerViewModel = Mapper.Map <PerformerViewModel>(performer);

            using (var scope = App.DiContainer.BeginLifetimeScope())
            {
                var editPerformerViewModel = scope.Resolve <EditPerformerViewModel>();

                editPerformerViewModel.Performer = performerViewModel;
                editPerformerViewModel.Countries = new ObservableCollection <Country>(
                    await _unitOfWork.CountryRepository.GetAllAsync());

                var performerWindow = new EditPerformerWindow
                {
                    DataContext = editPerformerViewModel
                };

                performerWindow.ShowDialog();
            }

            // clear all performers shown in the main window
            Performers.Clear();
            PageCollection.Clear();

            ActivateUpperPanel(false);

            _selectedPage = 0;

            // and show only newly added performer (to focus user's attention on said performer)
            Performers.Add(performerViewModel);
        }
Esempio n. 15
0
        public async Task GetStudioCurrentAsync()
        {
            await Task.Run(() =>
            {
                while (Studio.Current == null)
                {
                    BepInEx.Logger.Log(LogLevel.Debug, "GetStudioCurrentAsync() while");
                    Thread.Sleep(1000);
                }

                BepInEx.Logger.Log(LogLevel.Debug, "Studio.Current get!");

                DisplayPerformers.DPerformers = new Dictionary <int, DisplayPerformers.DPerformer>();

                if (_performersOnJoinedDisposable != null)
                {
                    BepInEx.Logger.Log(LogLevel.Debug, "_performersOnJoinedDisposable.Dispose();");
                    _performersOnJoinedDisposable.Dispose();
                }

                if (_performersOnLeftDisposable != null)
                {
                    BepInEx.Logger.Log(LogLevel.Debug, "_performersOnLeftDisposable.Dispose();");
                    _performersOnLeftDisposable.Dispose();
                }

                performers = _thisStudio.Performers;

                foreach (var performer in performers)
                {
                    AddPerformer(performer);
                }

                PerformersSubscribe();
            });
        }
        private void DeleteResponsible_Click(object sender, RoutedEventArgs e)
        {
            var deleteButton = (Button)sender;

            if (deleteButton.DataContext == null)
            {
                return;
            }

            var serviceResponsibilityRow = (DataRowView)deleteButton.DataContext;
            var serviceResponsibilityId  = Convert.ToInt32(serviceResponsibilityRow["ServiceResponsibilityID"]);
            var serviceHistoryId         = Convert.ToInt32(serviceResponsibilityRow["ServiceHistoryID"]);
            var workerId = Convert.ToInt32(serviceResponsibilityRow["WorkerID"]);

            var historyRows =
                _sec.ServiceHistory.Table.AsEnumerable()
                .Where(h => Convert.ToInt32(h["ServiceHistoryID"]) == serviceHistoryId);

            if (historyRows.Any())
            {
                var historyRow = historyRows.First();
                var globalId   = historyRow["GlobalID"].ToString();
                var taskId     = Tasks.GetTaskID(globalId);

                _sec.ServiceResponsibilities.Delete(serviceResponsibilityId);
                Performers.DeletePerformer(taskId, workerId);

                if (_sec.ServiceResponsibilities.Table.AsEnumerable()
                    .All(r => r.Field <Int64>("ServiceHistoryID") != serviceHistoryId))
                {
                    // Delete ServiceHistoryRow and Task, if responsibilities are empty
                    _sec.ServiceHistory.Delete(serviceHistoryId);
                    Tasks.DeleteTask(taskId);
                }
            }
        }
Esempio n. 17
0
        public Dictionary <string, Tuple <string, string> > Diff(AudioTag other)
        {
            var output = new Dictionary <string, Tuple <string, string> >();

            if (!IsValid || !other.IsValid)
            {
                return(output);
            }

            if (Title != other.Title)
            {
                output.Add("Title", Tuple.Create(Title, other.Title));
            }

            if ((Performers != null && Performers.Any()) ^
                (other.Performers != null && other.Performers.Any()) || (
                    other.Performers != null && other.Performers.Any() &&
                    Performers != null && Performers.Any() &&
                    !Performers.SequenceEqual(other.Performers)))
            {
                var oldValue = Performers != null && Performers.Any() ? string.Join(" / ", Performers) : null;
                var newValue = other.Performers != null && other.Performers.Any() ? string.Join(" / ", other.Performers) : null;

                output.Add("Artist", Tuple.Create(oldValue, newValue));
            }

            if (Album != other.Album && other.Album != null)
            {
                output.Add("Album", Tuple.Create(Album, other.Album));
            }

            if ((AlbumArtists != null && AlbumArtists.Any()) ^
                (other.AlbumArtists != null && other.AlbumArtists.Any()) || (
                    other.AlbumArtists != null && other.AlbumArtists.Any() &&
                    AlbumArtists != null && AlbumArtists.Any() &&
                    !AlbumArtists.SequenceEqual(other.AlbumArtists)))
            {
                var oldValue = AlbumArtists != null && AlbumArtists.Any() ? string.Join(" / ", AlbumArtists) : null;
                var newValue = other.AlbumArtists != null && other.AlbumArtists.Any() ? string.Join(" / ", other.AlbumArtists) : null;

                output.Add("Album Artist", Tuple.Create(oldValue, newValue));
            }

            if (Track != other.Track)
            {
                output.Add("Track", Tuple.Create(Track.ToString(), other.Track.ToString()));
            }

            if (TrackCount != other.TrackCount)
            {
                output.Add("Track Count", Tuple.Create(TrackCount.ToString(), other.TrackCount.ToString()));
            }

            if (Disc != other.Disc)
            {
                output.Add("Disc", Tuple.Create(Disc.ToString(), other.Disc.ToString()));
            }

            if (DiscCount != other.DiscCount)
            {
                output.Add("Disc Count", Tuple.Create(DiscCount.ToString(), other.DiscCount.ToString()));
            }

            if (Media != other.Media)
            {
                output.Add("Media Format", Tuple.Create(Media, other.Media));
            }

            if (Date != other.Date)
            {
                var oldValue = Date.HasValue ? Date.Value.ToString("yyyy-MM-dd") : null;
                var newValue = other.Date.HasValue ? other.Date.Value.ToString("yyyy-MM-dd") : null;
                output.Add("Date", Tuple.Create(oldValue, newValue));
            }

            if (OriginalReleaseDate != other.OriginalReleaseDate)
            {
                // Id3v2.3 tags can only store the year, not the full date
                if (OriginalReleaseDate.HasValue &&
                    OriginalReleaseDate.Value.Month == 1 &&
                    OriginalReleaseDate.Value.Day == 1)
                {
                    if (OriginalReleaseDate.Value.Year != other.OriginalReleaseDate.Value.Year)
                    {
                        output.Add("Original Year", Tuple.Create(OriginalReleaseDate.Value.Year.ToString(), other.OriginalReleaseDate.Value.Year.ToString()));
                    }
                }
                else
                {
                    var oldValue = OriginalReleaseDate.HasValue ? OriginalReleaseDate.Value.ToString("yyyy-MM-dd") : null;
                    var newValue = other.OriginalReleaseDate.HasValue ? other.OriginalReleaseDate.Value.ToString("yyyy-MM-dd") : null;
                    output.Add("Original Release Date", Tuple.Create(oldValue, newValue));
                }
            }

            if (Publisher != other.Publisher)
            {
                output.Add("Label", Tuple.Create(Publisher, other.Publisher));
            }

            if ((Genres != null && Genres.Any()) ^
                (other.Genres != null && other.Genres.Any()) || (
                    other.Genres != null && other.Genres.Any() &&
                    Genres != null && Genres.Any() &&
                    !Genres.SequenceEqual(other.Genres)))
            {
                var oldValue = Genres != null && Genres.Any() ? string.Join(" / ", Genres) : null;
                var newValue = other.Genres != null && other.Genres.Any() ? string.Join(" / ", other.Genres) : null;

                output.Add("Genres", Tuple.Create(oldValue, newValue));
            }

            if (ImageSize != other.ImageSize)
            {
                output.Add("Image Size", Tuple.Create(ImageSize.ToString(), other.ImageSize.ToString()));
            }

            return(output);
        }
Esempio n. 18
0
        public IActionResult PostPerformers([FromBody, Bind("GroupName, PerformanceType, HourlyRate, Rating, GroupPass")] Performers performer)
        {
            _performerRepo.AddPerformers(performer);

            return(CreatedAtRoute("GetPerformers", new { GroupName = performer.GroupName }, performer));
        }
        private void AddWorker_Click(object sender, RoutedEventArgs e)
        {
            if (WorkersList.SelectedItems.Count == 0)
            {
                return;
            }
            if (_serviceJournalRow == null)
            {
                return;
            }

            // Find current history row
            var nextDate         = Convert.ToDateTime(_serviceJournalRow["NextDate"]);
            var showNotification = Convert.ToBoolean(_serviceJournalRow["ShowNotification"]);
            var historyRows      = _sec.ServiceHistory.Table.AsEnumerable().
                                   Where(r => r.Field <DateTime>("NeededConfirmationDate") == nextDate &&
                                         r.Field <Int64>("ServiceJournalID") == _serviceJournalId);

            // Variable globalId for adding new task and adding new performers
            string globalId;

            if (!historyRows.Any())
            {
                // Responsibles are not set for operation
                var dateCreated  = App.BaseClass.GetDateFromSqlServer();
                var mainWorkerId = AdministrationClass.CurrentWorkerId;
                var description  = _serviceJournalRow["Description"].ToString();
                _sec.ServiceHistory.Add(dateCreated, mainWorkerId, _serviceJournalId, description, nextDate);

                // Adding new task
                globalId = historyRows.First()["GlobalID"].ToString();
                var actionName = _serviceJournalRow["ActionName"].ToString();
                var machineId  = Convert.ToInt32(_serviceJournalRow["MachineID"]);
                var taskName   = string.Format("{0} - {1}",
                                               new IdToMachineNameConverter().Convert(machineId, typeof(string), null,
                                                                                      CultureInfo.InvariantCulture), actionName);
                Tasks.AddNewTask(globalId, taskName, mainWorkerId, dateCreated, description, TaskClass.SenderApplications.ServiceJournal, true, nextDate);
            }

            // Take current history row
            var historyRow       = historyRows.First();
            var serviceHistoryId = Convert.ToInt32(historyRow["ServiceHistoryID"]);

            globalId = historyRow["GlobalID"].ToString();
            // Take id of the task
            var taskId = Tasks.GetTaskID(globalId);


            if (!ResponsibilitiesList.HasItems)
            {
                ResponsibilitiesList.ItemsSource = _sec.ServiceResponsibilities.Table.AsEnumerable().
                                                   Where(r => Convert.ToInt32(r["ServiceHistoryID"]) == serviceHistoryId).AsDataView();
            }

            foreach (DataRowView worker in WorkersList.SelectedItems)
            {
                var workerId = Convert.ToInt32(worker["WorkerID"]);

                if (_sec.ServiceResponsibilities.Table.AsEnumerable().
                    Any(r => r.Field <Int64>("ServiceHistoryID") == serviceHistoryId &&
                        r.Field <Int64>("WorkerID") == workerId))
                {
                    continue;
                }

                // Adding responsible
                _sec.ServiceResponsibilities.Add(serviceHistoryId, workerId, showNotification);

                // Adding performer for task
                if (taskId != -1)
                {
                    Performers.AddPerformer(taskId, workerId);
                    NotificationManager.AddNotification(workerId, AdministrationClass.Modules.TasksPage, taskId);
                }
            }
        }
Esempio n. 20
0
        public static BAMDBContext getNewContext(string n)
        {
            var option  = new DbContextOptionsBuilder <BAMDBContext>().UseInMemoryDatabase(databaseName: n).Options;
            var context = new BAMDBContext(option);

            var Venue1 = new Clients()
            {
                ClientName = "Alabama Coffee",
                Location   = "Alabama",
                ClientPass = "******"
            };

            var Venue2 = new Clients()
            {
                ClientName = "Brad's Bistro",
                Location   = "Oregon",
                ClientPass = "******"
            };

            var Performer1 = new Performers()
            {
                GroupName       = "Zeal Seals",
                GroupPass       = "******",
                PerformanceType = "Rock",
                Rating          = "T",
                HourlyRate      = 200,
                TotalCost       = 10200,
            };

            var Performer2 = new Performers()
            {
                GroupName       = "Young Ones",
                GroupPass       = "******",
                PerformanceType = "Mascot",
                Rating          = "E",
                HourlyRate      = 34,
                TotalCost       = 68,
            };

            var Booking1 = new Bookings()
            {
                GroupName     = "Young Ones",
                ClientName    = "Alabama Coffee",
                Review        = "It was a fine performance",
                Score         = 4,
                BookingId     = 2,
                TimeFrame     = "2/27/20",
                Location      = "Alabama",
                BookingStatus = "Cancelled"
            };
            var Booking2 = new Bookings()
            {
                GroupName     = "Zeal Seals",
                ClientName    = "Brad's Bistro",
                Review        = "",
                Score         = 2,
                BookingId     = 3,
                TimeFrame     = "6/2/16",
                Location      = "Oregon",
                BookingStatus = "Upcoming"
            };
            var Tag1 = new Tags()
            {
                Tag       = "Loud",
                TagId     = 5,
                GroupName = "Zeal Seals"
            };
            var Tag2 = new Tags()
            {
                Tag       = "Fun",
                TagId     = 6,
                GroupName = "Zeal Seals"
            };

            context.Add(Booking1);
            context.Add(Booking2);
            context.Add(Tag1);
            context.Add(Tag2);
            context.Add(Venue1);
            context.Add(Venue2);
            context.Add(Performer1);
            context.Add(Performer2);
            return(context);
        }