Beispiel #1
0
        private void btnImportMovieData_Click(object sender, EventArgs e)
        {
            //https://stackoverflow.com/questions/1210026/return-a-value-from-an-event-is-there-a-good-practice-for-this
            //if (OnImportMovie is null) return;

            //OnImportMovie(sender, e);
            var currentPoster = DAL.TmpPoster;

            if (DAL.NewMTD != null)
            {
                if (MsgBox.Show(
                        "The previous movie details and all changes made by hand (except the poster) will be lost. Are you sure you want to continue?",
                        "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                {
                    return;
                }

                currentPoster = DAL.NewMTD.Poster;
            }

            using (var rParam = new FrmMTDFromFile(true, false)
            {
                Owner = this
            })
            {
                if (rParam.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                if (rParam.mtd == null)
                {
                    MsgBox.Show("An error occurred while determining the file (movie) details. No additional data available!", "Error", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                    return;
                }

                DAL.NewMTD = rParam.mtd;
            }

            DAL.NewMTD.Poster = currentPoster;
            DAL.TmpPoster     = null;
            ucMovieInfo1.RefreshControls(DAL.NewMTD);

            if (DAL.NewMTD.MovieStills.Count > 0)
            {
                ucMovieInfo1.SetMovieStills(DAL.NewMTD.MovieStills);
                Size = new Size(900, 625);
            }
            else
            {
                Size = new Size(900, 430);
            }

            btnSave.Enabled = true;
            //btnLoadPoster.Enabled = true;
        }
Beispiel #2
0
        private void btnRefreshEpisodeData_Click(object sender, EventArgs e)
        {
            var sesi = (SeriesEpisodesShortInfo)_prevSelectedNode.Tag;

            if (!sesi.IsEpisode)
            {
                MsgBox.Show("There are no episode related information that need to be preserved, so please remove the season and re-import.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (!Utils.Helpers.ConfirmDiscardChanges())
            {
                return;
            }

            using (var rParam = new FrmMTDFromFile(false, true)
            {
                Owner = _parent
            })
            {
                if (rParam.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                var prevInstance = pSeriesDetailsContainer.Controls.Find("ucEpisodeDetails", false);
                if (prevInstance.Any())
                {
                    Desene.DAL.CurrentMTD = rParam.mtd;
                    var opRes = SaveChanges();

                    if (opRes.Success)
                    {
                        ((ucEpisodeDetails)prevInstance[0]).LoadControls2(true);
                    }
                }
                else
                {
                    MsgBox.Show("The previous UserControl instance could not be found!", "Error", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                }
            }
        }
Beispiel #3
0
        private void btnRefreshEpisodeData_Click(object sender, EventArgs e)
        {
            if (Helpers.UnsavedChanges && !SaveChanges().Success)
            {
                return;
            }

            using (var rParam = new FrmMTDFromFile(false, true)
            {
                Owner = _parent
            })
            {
                if (rParam.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                if (rParam.mtd == null)
                {
                    MsgBox.Show("An error occurred while determining the file (movie) details. No additional data available!", "Error", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                    return;
                }

                var opRes = DAL.RemoveMovieOrEpisode(((SeriesEpisodesShortInfo)_prevSelectedNode.Tag).Id);

                if (!opRes.Success)
                {
                    MsgBox.Show(
                        string.Format("The following error occurred while removing the previous movie details:{0}{0}{1}{0}{0}The current operation cannot continue!", Environment.NewLine, opRes.CustomErrorMessage),
                        "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                rParam.mtd.DescriptionLink = DAL.CurrentMTD.DescriptionLink;
                rParam.mtd.Recommended     = DAL.CurrentMTD.Recommended;
                rParam.mtd.RecommendedLink = DAL.CurrentMTD.RecommendedLink;
                rParam.mtd.Year            = DAL.CurrentMTD.Year;
                rParam.mtd.Theme           = DAL.CurrentMTD.Theme;
                rParam.mtd.Notes           = DAL.CurrentMTD.Notes;
                rParam.mtd.Trailer         = DAL.CurrentMTD.Trailer;
                rParam.mtd.StreamLink      = DAL.CurrentMTD.StreamLink;
                rParam.mtd.Poster          = DAL.CurrentMTD.Poster;
                rParam.mtd.InsertedDate    = DAL.CurrentMTD.InsertedDate;
                rParam.mtd.LastChangeDate  = DateTime.Now;

                //not using UpdateMTD in order to avoud additional check regarding the number of streams
                opRes = DAL.InsertMTD(
                    rParam.mtd,
                    new FilesImportParams
                {
                    Year     = rParam.mtd.Year,
                    Season   = "",
                    ParentId = ((SeriesEpisodesShortInfo)_prevSelectedNode.Tag).SeriesId
                });

                if (!opRes.Success)
                {
                    MsgBox.Show(
                        string.Format("The following error occurred while inserting the new movie details into the database:{0}{0}{1}{0}{0}", Environment.NewLine, opRes.CustomErrorMessage),
                        "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                rParam.mtd.Id  = (int)opRes.AdditionalDataReturn;
                DAL.CurrentMTD = rParam.mtd;

                ReloadTreeView(((SeriesEpisodesShortInfo)_prevSelectedNode.Tag).SeriesId, rParam.mtd.Id);

                LoadSelectionDetails();
            }
        }
Beispiel #4
0
        private void btnRefreshMovieData_Click(object sender, EventArgs e)
        {
            if (Helpers.UnsavedChanges && !SaveChanges())
            {
                return;
            }

            using (var rParam = new FrmMTDFromFile(false, false)
            {
                Owner = _parent
            })
            {
                if (rParam.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                if (rParam.mtd == null)
                {
                    MsgBox.Show("An error occurred while determining the file (movie) details. No additional data available!", "Error", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                    return;
                }

                OperationResult opRes   = null;
                CSMScrapeResult csmData = null;

                if (DAL.CurrentMTD.HasRecommendedDataSaved)
                {
                    opRes = DAL.LoadCSMData(DAL.CurrentMTD.Id);
                    if (opRes.Success)
                    {
                        csmData = (CSMScrapeResult)opRes.AdditionalDataReturn;
                    }
                }

                opRes = DAL.RemoveMovieOrEpisode(_previousSelectedMsi.Id);

                if (!opRes.Success)
                {
                    MsgBox.Show(
                        string.Format("The following error occurred while removing the previous movie details:{0}{0}{1}{0}{0}The current operation cannot continue!", Environment.NewLine, opRes.CustomErrorMessage),
                        "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }


                //not using UpdateMTD in order to avoud additional check regarding the number of streams
                opRes = DAL.InsertMTD(rParam.mtd, null);

                if (!opRes.Success)
                {
                    MsgBox.Show(
                        string.Format("The following error occurred while inserting the new movie details into the database:{0}{0}{1}{0}{0}", Environment.NewLine, opRes.CustomErrorMessage),
                        "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                rParam.mtd.Id = (int)opRes.AdditionalDataReturn;
                if (csmData != null)
                {
                    DAL.SaveCommonSenseMediaData(rParam.mtd.Id, csmData);
                }

                try
                {
                    _preventEvent = true;

                    DAL.CurrentMTD = rParam.mtd;
                    var movieObj = DAL.MoviesData.FirstOrDefault(m => m.Id == _previousSelectedMsi.Id);
                    DAL.MoviesData.Remove(movieObj);

                    var msi = new MovieShortInfo
                    {
                        Id       = DAL.CurrentMTD.Id,
                        FileName = DAL.CurrentMTD.FileName,
                        //Cover = DAL.CurrentMTD.Poster,
                        HasPoster   = DAL.CurrentMTD.Poster != null,
                        HasSynopsis = !string.IsNullOrEmpty(DAL.CurrentMTD.Synopsis)
                    };

                    DAL.MoviesData.Add(msi);
                    DAL.MoviesData = new BindingList <MovieShortInfo>(DAL.MoviesData.OrderBy(o => o.FileName).ToList());
                    RefreshGrid();

                    _previousSelectedMsi = msi; //not needed?
                }
                finally
                {
                    _preventEvent = false;
                    FocusCurrentMovieInGrid(_previousSelectedMsi);
                }
            }
        }