Ejemplo n.º 1
0
        public void _UpdateMovieProfileInList(MovieProfile mProfile)
        {
            ListViewItem lvi = new ListViewItem(new string[] {
                mProfile.FileConnect,
                mProfile.Code,
                mProfile.Country,
                "+" + mProfile.Rating.ToString(),
                mProfile.Type,
                mProfile.Title,
                mProfile.Actress,
                mProfile.Tag
            });

            lvi.Tag = mProfile;
            for (int i = 0; i < TheList.Items.Count; i++)
            {
                if (TheList.Items[i].Tag == mProfile)
                {
                    TheList.BeginUpdate();
                    TheList.Items[i] = lvi;
                    TheList.EndUpdate();
                    break;
                }
            }
        }
Ejemplo n.º 2
0
        public static void ShowWin_MovieProfile(MovieProfile mProfile)
        {
            frmMovieProfile frm = new frmMovieProfile();

            frm.param_MovieProfile = mProfile;
            frm.Show();
        }
Ejemplo n.º 3
0
        private void ___CalculateStat_General(ptkConfig stat, MovieProfile profile)
        {
            stat[kwTotalMovieProfile] = (stat.GetInt(kwTotalMovieProfile) + 1).ToString();
            if (profile.FilePath.Length > 0)
            {
                stat[kwLocalProfile] = (stat.GetInt(kwLocalProfile) + 1).ToString();
                switch (profile.FileConnect)
                {
                case "Y":
                    stat[kwFileOnLine] = (stat.GetInt(kwFileOnLine) + 1).ToString();
                    break;

                case "N":
                    stat[kwFileOffLine] = (stat.GetInt(kwFileOffLine) + 1).ToString();
                    break;

                case "?":
                    stat[kwFileUnknow] = (stat.GetInt(kwFileUnknow) + 1).ToString();
                    break;
                }
            }
            else
            {
                stat[kwGlobalProfile] = (stat.GetInt(kwGlobalProfile) + 1).ToString();
            }
        }
Ejemplo n.º 4
0
        public static bool SaveMovieProfile(MovieProfile movieProfile)
        {
            string hKey = movieProfile.Hash;

            if (!hKey.Length.Equals(32))
            {
                that.DebugAndLog("MovieDB->SaveMovieProfile():Error! hKey.Length <> 32");
                return(false);
            }

            that.DebugAndLog("Start SaveMoveProfile(" + hKey + ")");
            // Clone movieProfile as local myProfile for safty in Save to Disk
            string filePath =
                DbPath + Path.DirectorySeparatorChar +
                hKey.Substring(0, 1) + Path.DirectorySeparatorChar
                + hKey + ".json";

            if (!_SaveMovieProfileToJSON(movieProfile, filePath))
            {
                that.DebugAndLog("MovieDB->SaveMovieProfile():Error! !_SaveMovieProfileToJSON()");
                return(false);
            }

            lock (MovieDB.hMovie.SyncRoot)
            {
                hMovie[hKey] = movieProfile;    // User real movieProfile as linking Object
            }
            return(true);
        }
Ejemplo n.º 5
0
        private static bool _SaveMovieProfileToJSON(MovieProfile profile, string filePath)
        {
            string hashKey = profile.Hash;

            if (profile.Hash.Length != 32)
            {
                that.DebugAndLog("_SaveMovieProfileToJSON()! profile.Hash.Length <> 32");
                return(false);
            }

            _MovieProfile clone    = profile.ExportProfile();
            string        jsonData = "";

            try
            {
                zLog.Write("SaveMovieProfileToJSON->Convert Profile to JSON");
                jsonData = JsonConvert.SerializeObject(clone, Formatting.Indented);
            }
            catch (Exception ex)
            {
                that.DebugAndLog("Exception Error: " + ex.Message);
                return(false);
            }
            string[] arrLines = jsonData.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);

            // Return WriteResult as main result
            that.DebugAndLog("Begin ptkTextFile.WriteStringArray(" + filePath + ")");
            return(ptkTextFile.WriteStringArray(filePath, arrLines));
        }
Ejemplo n.º 6
0
        public static void movieList_OnKeyUpMovieList(object sender, KeyEventArgs e)
        {
            ListView lv = (ListView)sender;

            if (lv.SelectedItems.Count < 1)
            {
                return;
            }

            if (e.KeyCode == Keys.Enter)
            {
                if (e.Shift)
                {
                    MovieProfile    mProfile = (MovieProfile)lv.SelectedItems[0].Tag;
                    frmMovieProfile frm      = new frmMovieProfile();
                    frm.param_MovieProfile = mProfile;
                    frm.param_MovieList    = (ucMovieList)lv.Parent;
                    frm.Show();
                }
                else
                {
                    movieList_OnDoubleClickMovieList(sender, new EventArgs());
                }
            }
        }
Ejemplo n.º 7
0
 public static string GetFilePath_MovieImage_ScreenShot2(MovieProfile profile)
 {
     if (profile.Hash.Length != 32)
     {
         return("");
     }
     return(_GetMovieImageFile_If_Exists("SS2", profile));
 }
Ejemplo n.º 8
0
 public static string GetFilePath_MovieImage_BackCover(MovieProfile profile)
 {
     if (profile.Hash.Length != 32)
     {
         return("");
     }
     return(_GetMovieImageFile_If_Exists("BCV", profile));
 }
Ejemplo n.º 9
0
 private void _Do_ViewDuplicateProfile()
 {
     if (MovieDB.hMovie.Contains(param_MovieProfile.Hash))
     {
         MovieProfile mProfile = (MovieProfile)MovieDB.hMovie[param_MovieProfile.Hash];
         that.ShowWin_MovieProfile(mProfile);
     }
 }
Ejemplo n.º 10
0
        private void __RebuildStat()
        {
            ptkConfig statGeneral = (ptkConfig)hTopic["General"];
            {
                statGeneral[kwFileOffLine]       = "0";
                statGeneral[kwFileOnLine]        = "0";
                statGeneral[kwFileUnknow]        = "0";
                statGeneral[kwGlobalProfile]     = "0";
                statGeneral[kwLocalProfile]      = "0";
                statGeneral[kwTotalMovieProfile] = "0";
            }
            ptkConfig statType      = (ptkConfig)hTopic["Type"];
            ptkConfig statCountry   = (ptkConfig)hTopic["Country"];
            ptkConfig statRating    = (ptkConfig)hTopic["Rating"];
            ptkConfig statActress   = (ptkConfig)hTopic["Actress"];
            ptkConfig statTag       = (ptkConfig)hTopic["Tag"];
            ptkConfig statFilePath  = (ptkConfig)hTopic["FilePath"];
            ptkConfig statCountPlay = (ptkConfig)hTopic["CountPlay"];

            theProgress.Visible = true;
            theProgress.Minimum = 0;
            theProgress.Value   = 0;
            theProgress.Maximum = MovieDB.hMovie.Count;

            string[] arrK = new string[MovieDB.hMovie.Count];
            MovieDB.hMovie.Keys.CopyTo(arrK, 0);
            MovieProfile profile = null;

            for (int k = 0; k < arrK.Length; k++)
            {
                lock (MovieDB.hMovie.SyncRoot)
                {
                    if (!MovieDB.hMovie.Contains(arrK[k]))
                    {
                        continue;
                    }
                    // Cloning profile for Safety in build state Process
                    profile = ptkGeneral.CloneObject <MovieProfile>((MovieProfile)MovieDB.hMovie[arrK[k]]);
                }

                ___CalculateStat_General(statGeneral, profile);
                ___CalculateStat_Type(statType, profile);
                ___CalculateStat_Country(statCountry, profile);
                ___CalculateStat_Rating(statRating, profile);
                ___CalculateStat_Actress(statActress, profile);
                ___CalculateStat_Tag(statTag, profile);
                ___CalculateStat_FilePath(statFilePath, profile);
                ___CalculateStat_CountPlay(statCountPlay, profile);

                profile = null;     // After finish Calculate stat Disponse cloning profile

                theProgress.Value++;
                this.Refresh();
            }

            theProgress.Visible = false;
        }
Ejemplo n.º 11
0
        public static void ShowWin_ImportMovieFromFile(string FilePath)
        {
            MovieProfile    newProfile = new MovieProfile(FilePath);
            frmMovieProfile frm        = new frmMovieProfile();

            frm.param_MovieProfile = newProfile;
            frm.param_isRefreshAllMovieAfterClose = true;
            frm.param_isNewImport = true;
            frm.Show();
        }
Ejemplo n.º 12
0
 private static string _BuildImageFilePath(string filePath, string subDir1, MovieProfile profile)
 {
     return(
         ImgPath + Path.DirectorySeparatorChar
         + subDir1 + Path.DirectorySeparatorChar
         + profile.Hash.Substring(0, 1) + Path.DirectorySeparatorChar
         + profile.Hash
         + Path.GetExtension(filePath)
         );
 }
Ejemplo n.º 13
0
        public static bool SaveMovieImage_ScreenShot2(string filePath, MovieProfile profile)
        {
            if (!_IsImageFile(filePath))
            {
                return(false);
            }
            string file2save = _BuildImageFilePath(filePath, "SS2", profile);

            return(_CopyFileToPathIMG(filePath, file2save));
        }
Ejemplo n.º 14
0
        public static bool SaveMovieImage_BackCover(string filePath, MovieProfile profile)
        {
            if (!_IsImageFile(filePath))
            {
                return(false);
            }
            string file2save = _BuildImageFilePath(filePath, "BCV", profile);

            return(_CopyFileToPathIMG(filePath, file2save));
        }
Ejemplo n.º 15
0
        private static bool __ReadFileDataToMovieProfile(string fileName)
        {
            string[]      lines;
            _MovieProfile clone;

            if (!ptkTextFile.ReadStringArray(fileName, out lines))
            {
                that.DebugAndLog("Error in ReadStringArray [" + fileName + "]");
                return(false);
            }
            try
            {
                clone = JsonConvert.DeserializeObject <_MovieProfile>(string.Join("", lines));
            }
            catch (Exception ex)
            {
                that.DebugAndLog("Error _ReadFileDataToMovieProfile -> Json DeserializeObject");
                zLog.Write(ex.Message);
                return(false);
            }

            if (null == clone)
            {
                that.DebugAndLog("File movie profile is ERROR! read and NULL");
                that.DebugAndLog("File name = " + fileName);
                that.DebugAndLog("Try To delete file ");
                File.Delete(fileName);
                return(false);
            }
            MovieProfile newProfile = new MovieProfile();

            if ((!newProfile.ImportProfile(clone)) || (newProfile.Hash.Length != 32))
            {
                that.DebugAndLog("Error _ReadFileDataToMovieProfile:: Cannot Import _MovieProfile");
                return(false);
            }
            if (newProfile.Hash.Length != 32)
            {
                that.DebugAndLog("Error _ReadFileDataToMovieProfile:: newProfile.Hash.Length <> 32");
                return(false);
            }

            // Check File Status if it can access of NOT?
            newProfile.CheckFileConnect();

            // Push Object to Movie
            lock (MovieDB.hMovie.SyncRoot)
            {
                hMovie[newProfile.Hash] = newProfile;
            }

            // Everyting OK
            return(true);
        }
Ejemplo n.º 16
0
        private void ___CalculateStat_FilePath(ptkConfig stat, MovieProfile profile)
        {
            if (profile.FilePath.Length.Equals(0))
            {
                return;
            }

            string strPath = Path.GetDirectoryName(profile.FilePath);

            stat[strPath] = (stat.GetInt(strPath) + 1).ToString();
        }
Ejemplo n.º 17
0
        private void ___CalculateStat_Tag(ptkConfig stat, MovieProfile profile)
        {
            if (profile.Tag.Length.Equals(0))
            {
                return;
            }

            string[] arrTag = profile.Tag.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < arrTag.Length; i++)
            {
                stat[arrTag[i]] = (stat.GetInt(arrTag[i]) + 1).ToString();
            }
        }
Ejemplo n.º 18
0
        public static void movieList_OnDoubleClickMovieList(object sender, EventArgs s)
        {
            ListView lv = (ListView)sender;

            if (lv.SelectedItems.Count > 0)
            {
                MovieProfile    mProfile = (MovieProfile)lv.SelectedItems[0].Tag;
                frmMovieProfile frm      = new frmMovieProfile();
                frm.param_MovieProfile = mProfile;
                frm.param_MovieList    = (ucMovieList)lv.Parent;
                frm.Show();
            }
        }
Ejemplo n.º 19
0
        private static string _GetMovieImageFile_If_Exists(string typeImage, MovieProfile profile)
        {
            string pathOnly =
                ImgPath + Path.DirectorySeparatorChar
                + typeImage + Path.DirectorySeparatorChar
                + profile.Hash.Substring(0, 1);

            string[] fileList = Directory.GetFiles(pathOnly, profile.Hash + ".*");
            if (fileList.Length < 1)
            {
                return("");
            }
            return(fileList[0]);
        }
Ejemplo n.º 20
0
        public static void ShowWin_ParseProfileFromDirectory(string dirName)
        {
            string[] listFile            = Directory.GetFiles(dirName, "*.*");
            int      FileInFolder        = 0;
            int      FileMovieWithHash   = 0;
            int      FileMovieHadProfile = 0;
            int      FileMovieNewProfile = 0;

            for (int i = 0; i < listFile.Length; i++)
            {
                if (!File.Exists(listFile[i]))
                {
                    continue;
                }
                FileInFolder++;
                MovieProfile profile = new MovieProfile(listFile[i]);
                if (profile.Hash.Length.Equals(32))
                {
                    FileMovieWithHash++;
                    if (MovieDB.hMovie.ContainsKey(profile.Hash))
                    {
                        FileMovieHadProfile++;

                        // Add and Replase existing profile 's filePath with new import
                        MovieProfile existingProfile = (MovieProfile)MovieDB.hMovie[profile.Hash];
                        existingProfile.FilePath = profile.FilePath;
                        if (MovieDB.SaveMovieProfile(existingProfile))
                        {
                            that.DebugAndLog("Update existing Profile [" + existingProfile.Hash + "] to MovieDB success");
                        }
                    }
                    else
                    {
                        FileMovieNewProfile++;
                        if (MovieDB.SaveMovieProfile(profile))
                        {
                            that.DebugAndLog("Save new Profile [" + profile.Hash + "] to MovieDB success");
                        }
                    }
                }
            }
            MessageBox.Show(
                "Finish Import MovieProfile from Folder:" + "\r\n" +
                "Total File in Folder = " + FileInFolder.ToString() + "\r\n" +
                "File Movie with Hash = " + FileMovieWithHash.ToString() + "\r\n" +
                "File Movie update Profile = " + FileMovieHadProfile.ToString() + "\r\n" +
                "File Movie new Profile = " + FileMovieNewProfile.ToString()
                );
        }
Ejemplo n.º 21
0
        public void _PutMovieProfileToList(MovieProfile mProfile)
        {
            ListViewItem lvi = new ListViewItem(new string[] {
                mProfile.FileConnect,
                mProfile.Code,
                mProfile.Country,
                "+" + mProfile.Rating.ToString(),
                mProfile.Type,
                mProfile.Title,
                mProfile.Actress,
                mProfile.Tag
            });

            lvi.Tag = mProfile;
            TheList.Items.Add(lvi);
        }
Ejemplo n.º 22
0
        private void _Do_UseThisFile()
        {
            if (MovieDB.hMovie.Contains(param_MovieProfile.Hash))
            {
                that.DebugAndLog("Update MovieProfile{" + param_MovieProfile.Hash + "} with Path=" + param_MovieProfile.FilePath);
                MovieProfile mProfile = (MovieProfile)MovieDB.hMovie[param_MovieProfile.Hash];
                mProfile.FilePath = param_MovieProfile.FilePath;
                if (!mProfile.RenameFileToAttribute())
                {
                    that.DebugAndLog("Error in Remame file to Attribute: " + param_MovieProfile.FilePath + ")");
                    MessageBox.Show("Error in Remame file to Attribute\r\nMaybe file is in-use?", "Error!", MessageBoxButtons.OK);
                    return;
                }
                MovieDB.SaveMovieProfile(mProfile);

                that.ShowWin_MovieProfile(mProfile);
                _Do_CloseForm();
            }
        }
Ejemplo n.º 23
0
        private void btnNext_Click(object sender, EventArgs e)
        {
            if (!btnNext.Visible)
            {
                return;
            }
            if (null == param_MovieList)
            {
                return;
            }
            MovieProfile mp = param_MovieList.GetNextMovie();

            if (null == mp)
            {
                return;
            }
            param_MovieProfile = mp;
            _Refresh_param_MovieProfile();
        }
Ejemplo n.º 24
0
        private static string _GetMovieImageFile_If_Exists(string typeImage, MovieProfile profile)
        {
            string path2Img = ImgPath;      // default path

            if (that.Config[KW.OtherImgPath].Length > 0)
            {
                path2Img = that.Config[KW.OtherImgPath];
            }

            string pathOnly =
                path2Img + Path.DirectorySeparatorChar
                + typeImage + Path.DirectorySeparatorChar
                + profile.Hash.Substring(0, 1);

            string[] fileList = Directory.GetFiles(pathOnly, profile.Hash + ".*");
            if (fileList.Length < 1)
            {
                return("");
            }
            return(fileList[0]);
        }
Ejemplo n.º 25
0
        private void tmrUpdate_Tick(object sender, EventArgs e)
        {
            tmrUpdate.Enabled = false;
            if (isCancelRequest)
            {
                this.Close();
                return;
            }

            if (tCopy != null)
            {
                if (tCopy.IsAlive)
                {
                    tmrUpdate.Enabled = true;
                    return;
                }
                else
                {
                    tCopy = null;
                }
            }

            if (curNum < listMovie.Count)
            {
                curNum++;
                if (curNum >= listMovie.Count)
                {
                    pgBar.Value         = pgBar.Maximum;
                    lblTotalCopies.Text = curNum.ToString() + " / " + listMovie.Count.ToString();
                    btnCancel.Text      = "Close";
                    this.Refresh();
                    tmrUpdate.Enabled = true;
                    that.DebugAndLog("Finish Copy ALL moview File ***");
                    return;
                }
            }
            else
            {
                if (isCancelRequest)
                {
                    this.Close();
                    return;
                }
                tmrUpdate.Enabled = true;
                return;
            }

            MovieProfile profile        = (MovieProfile)listMovie[curNum];
            string       filePath2Copy  = profile.FilePath;
            string       filePath2Write = pathToWrite + Path.DirectorySeparatorChar + Path.GetFileName(filePath2Copy);

            txtFrom.Text        = filePath2Copy;
            txtTo.Text          = filePath2Write;
            pgBar.Value         = curNum + 1;
            lblTotalCopies.Text = curNum.ToString() + " / " + listMovie.Count.ToString();
            this.Refresh();

            tCopy = new Thread(new ThreadStart(() => {
                if (File.Exists(filePath2Copy))
                {
                    try
                    {
                        that.DebugAndLog("Begin Copy RealFileInDisk [" + filePath2Copy + "] => [" + filePath2Write + "]");
                        File.Copy(filePath2Copy, filePath2Write);
                        that.DebugAndLog("... Finish Copy");
                    }
                    catch (Exception ex)
                    {
                        that.DebugAndLog("... ! Error in Copy, " + ex.Message);
                    }
                }
                else
                {
                    that.DebugAndLog("File Not Found [" + filePath2Copy + "] then SKIP !");
                }
            }));
            tCopy.IsBackground = true;
            tCopy.Start();

            tmrUpdate.Enabled = true;
        }
Ejemplo n.º 26
0
        private void ___CalculateStat_CountPlay(ptkConfig stat, MovieProfile profile)
        {
            string sCount = profile.CountPlay.ToString();

            stat[sCount] = (stat.GetInt(sCount) + 1).ToString();
        }
Ejemplo n.º 27
0
        public static void BatchDeleteLastFilePathInCurrentTab(TabPage tabToDelete)
        {
            ucMovieList movieList = null;

            foreach (Control ctl in tabToDelete.Controls)
            {
                if (ctl is ucMovieList)
                {
                    movieList = (ucMovieList)ctl;
                    break;
                }
            }
            if (movieList == null)
            {
                return;
            }

            // Begin Delete Last File Path
            List <MovieProfile> listMovie = movieList.GetListMovie();

            if (listMovie.Count > 0)
            {
                if (MessageBox.Show(
                        "Are you sure to delete " + listMovie.Count.ToString() + " movie File Path!!",
                        " Confirm?", MessageBoxButtons.OKCancel
                        ) != DialogResult.OK)
                {
                    return;
                }
            }

            // After Confirm Begin Real Delete
            int countSuccess = 0;

            for (int i = 0; i < listMovie.Count; i++)
            {
                MovieProfile profile = (MovieProfile)listMovie[i];

                //--------------------------------------------------
                string filePath2Delete = profile.FilePath;
                if (File.Exists(filePath2Delete))
                {
                    try
                    {
                        File.Delete(filePath2Delete);
                        that.DebugAndLog("Delete RealFileInDisk [" + filePath2Delete + "] Success");
                    }
                    catch (Exception ex)
                    {
                        that.DebugAndLog("Error in delete RealFileInDisk [" + filePath2Delete + "] " + ex.Message);
                    }
                }
                profile.FilePath = "";      // Delete from Object
                profile.CheckFileConnect();
                //--------------------------------------------------

                if (!MovieDB.SaveMovieProfile(profile))
                {
                    that.DebugAndLog("Error in MovieDB.SaveMovieProfile() ... Cannot Remove Last FilePath");
                }
                else
                {
                    that.DebugAndLog("Delete last File path from Movie{" + profile.Hash + "} Success");
                    countSuccess++;
                }
            }
            MessageBox.Show("Success delete " + countSuccess.ToString() + " LastFile Path from " + listMovie.Count.ToString() + " profile");
        }
Ejemplo n.º 28
0
        private void ___CalculateStat_Rating(ptkConfig stat, MovieProfile profile)
        {
            string cRating = "+" + profile.Rating.ToString();

            stat[cRating] = (stat.GetInt(cRating) + 1).ToString();
        }
Ejemplo n.º 29
0
        private void ___CalculateStat_Type(ptkConfig stat, MovieProfile profile)
        {
            string cType = profile.Type;

            stat[cType] = (stat.GetInt(cType) + 1).ToString();
        }