Example #1
0
        public void UpdateFile(string sPath, int iMedia, int iType)
        {
            String sMediaPath = getMediaPath(iMedia);

            String sFilePath = sPath.Substring(sMediaPath.Length + 1);

            //return if file is alredy in database
            foreach (DataRow row in DataBase.executeQuery("select id from mt_file where path='" + duplicateApostrof(sFilePath) + "' and media = " + iMedia).Rows)
            {
                return;
            }
            String sSeason = "";

            if (iType == 2 && hasSeasones(getPreviousFolder(sPath, 1)))
            {
                sSeason = getPreviousFolder(sPath, 1);
            }

            //insert file to database
            String sQuery = "insert into mt_file(id,media,path,fl_watched,season) values(" +
                            (getMaxId("mt_file") + 1) + "," +
                            iMedia + ",'" +
                            duplicateApostrof(sFilePath) + "','N','" +
                            sSeason +
                            "')";

            DataBase.executeNonQuery(sQuery);
        }
Example #2
0
        public void clearAll()
        {
            DialogResult dialog = MessageBox.Show("Do you realy want to clear all data?", "Information", MessageBoxButtons.YesNo);

            if (dialog == DialogResult.Yes)
            {
                DataBase.executeNonQuery("delete from mt_file");
                DataBase.executeNonQuery("delete from mt_media");
                DataBase.executeNonQuery("delete from mt_folder");
                DataBase.executeNonQuery("delete from mt_drive");
                RefreshData();
            }
        }
Example #3
0
        public int updateMedia(string sDirectory, string sStartDirectory, int iFolderId, int iMediaType, int iStructure)
        {
            int iMediaId = 0;

            String sPath;

            try
            {
                sPath = sDirectory.Substring(sDirectory.IndexOf(sStartDirectory) + sStartDirectory.Length + 1);;
            }
            catch
            {
                MessageBox.Show("In starting directory exists movies witch is not in subfolders.");
                return(-1);
            }
            String sFOlderName = sPath;

            if (sPath.LastIndexOf("\\") >= 0)
            {
                sFOlderName = sPath.Substring(sPath.LastIndexOf("\\") + 1);
            }

            if (iMediaType == 2 && hasSeasones(sFOlderName))//serija koja ima sezone
            {
                try
                {
                    sPath = sPath.Substring(0, sPath.LastIndexOf("\\"));
                }
                catch { }
            }

            //select media if exists end return MediaId
            foreach (DataRow dr in DataBase.executeQuery("select id from mt_media where path= '" + duplicateApostrof(sPath) + "' and folder = " + iFolderId).Rows)
            {
                return(int.Parse(dr.ItemArray[0].ToString()));
            }

            String sNaziv = mediaName(sPath);
            String sYear  = getYear(sPath, iMediaId, iStructure);
            String sGenre = getGenre(sPath, iMediaType, iStructure);
            String sType  = "Movies";

            if (iMediaType == 2)
            {
                sType = "Series";
            }

            //insert media
            iMediaId = getMaxId("mt_media") + 1;
            String sQuery = "insert into mt_media(id,folder,path,name,year,genre,ratings,fl_watched,type) values(" +
                            iMediaId + "," +
                            iFolderId + ",'" +
                            duplicateApostrof(sPath) + "','" +
                            duplicateApostrof(sNaziv) + "','" +
                            sYear + "','" +
                            sGenre + "', 0 ,'N','" +
                            sType +
                            "')";

            DataBase.executeNonQuery(sQuery);

            return(iMediaId);
        }