예제 #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);
        }
예제 #2
0
        public void RefreshData()
        {
            String sQuery = "select id,folder,name,year,genre from mt_media";
            String sWhere = "";

            sWhere = " where type='" + txt_media_type.Text + "'";

            if (txt_genre.Text != "")
            {
                sWhere += " and upper(genre)='" + txt_genre.Text + "'";
            }

            if (txt_naziv.Text != "")
            {
                sWhere += " and upper(name) like upper('%" + txt_naziv.Text + "%')";
            }

            if (txt_year.Text != "")
            {
                sWhere += " and year like '%" + txt_year.Text + "%'";
            }


            DataTable     dt            = DataBase.executeQuery(sQuery + sWhere);
            BindingSource bindingSource = new BindingSource();

            bindingSource.DataSource = dt;
            navigator.BindingSource  = bindingSource;
            grid.DataSource          = dt;
            loadInfo();
        }
예제 #3
0
        void fillSeason()
        {
            DataTable table = DataBase.executeQuery("select distinct(season) season from mt_file where media=" + iMediaId + " order by season");

            txt_season.DataSource    = table;
            txt_season.ValueMember   = "season";
            txt_season.DisplayMember = "season";
        }
예제 #4
0
        public void RefreshData()
        {
            String sQuery = "select id,path from mt_file";
            String sWhere = " where media=" + iMediaId + " and season ='" + txt_season.Text + "'  order by path ";


            DataTable     dt            = DataBase.executeQuery(sQuery + sWhere);
            BindingSource bindingSource = new BindingSource();

            bindingSource.DataSource = dt;
            navigator.BindingSource  = bindingSource;
            grid.DataSource          = dt;
        }
예제 #5
0
        public String getMediaPath(int iMedia)
        {
            String    sPath  = "";
            String    sDrive = "";
            String    sQuery = "select f.path + '\\' + m.path,d.name  from mt_media m,mt_folder f,mt_drive d where m.folder=f.id and f.drive = d.id and m.id=";
            DataTable table  = DataBase.executeQuery(sQuery + iMedia);

            foreach (DataRow row in table.Rows)
            {
                sPath  = row.ItemArray[0].ToString();
                sDrive = getDrivePath(row.ItemArray[1].ToString());
            }
            sPath = sDrive + sPath;

            return(sPath);
        }
예제 #6
0
        public String getFilePath(int iFile)
        {
            String sPath  = "";
            String sDrive = "";

            DataTable table = DataBase.executeQuery("select f.path + '\\' + m.path + '\\' + fi.path,d.name from mt_file fi,mt_media m,mt_folder f,mt_drive d where fi.media=m.id and m.folder = f.id and f.drive=d.id and fi.id=" + iFile);

            foreach (DataRow row in table.Rows)
            {
                sPath  = row.ItemArray[0].ToString();
                sDrive = getDrivePath(row.ItemArray[1].ToString());
            }
            if (sDrive != "")
            {
                sPath = sDrive + sPath;
            }
            else
            {
                sPath = "";
            }

            return(sPath);
        }
예제 #7
0
        public void loadInfo()
        {
            if (this.grid.CurrentCell == null)
            {
                return;
            }
            int currRow = grid.CurrentCell.RowIndex;

            String sMediaName = grid.Rows[currRow].Cells["name"].Value.ToString();
            String sId        = grid.Rows[currRow].Cells["id"].Value.ToString();

            url = "http://www.google.com/search?q=imdb+\"" + formatUrl(sMediaName) + "\"&btnI";

            String    sQuery    = "select f.path + '\\' + m.path,d.name  from mt_media m,mt_folder f,mt_drive d where m.folder=f.id and f.drive = d.id and m.id=" + sId;
            DataTable dt        = DataBase.executeQuery(sQuery);
            String    mediaPath = "";
            String    sDrive    = "";

            try
            {
                mediaPath = dt.Rows[0].ItemArray[0].ToString();
                sDrive    = getDrivePath(dt.Rows[0].ItemArray[1].ToString());
            }
            catch (Exception ex)
            {
            }
            String targetDirectory = sDrive + mediaPath;

            String[] fileEntries = null;;
            if (targetDirectory != "")
            {
                fileEntries = Directory.GetFiles(targetDirectory, "*.htm*");
            }

            info.loadMovie(fileEntries, targetDirectory);
        }
예제 #8
0
        public void previewMedia()
        {
            if (this.grid.CurrentCell == null)
            {
                return;
            }
            int currRow = grid.CurrentCell.RowIndex;

            String sMediaId  = grid.Rows[currRow].Cells[0].Value.ToString();
            String sFilePath = "";
            int    fileNo    = 1;

            foreach (DataRow row in DataBase.executeQuery("select count(1) from mt_file where media= " + sMediaId).Rows)
            {
                fileNo = int.Parse(row.ItemArray[0].ToString());
            }
            if (fileNo == 1)
            {
                foreach (DataRow row in DataBase.executeQuery("select id from mt_file where media= " + sMediaId).Rows)
                {
                    sFilePath = getFilePath(int.Parse(row.ItemArray[0].ToString()));
                }
                try
                {
                    Process.Start(@sFilePath);
                }
                catch
                {
                }
            }
            else if (fileNo > 1)
            {
                FilePreview file = new FilePreview(DataBase.ConnectionString, sMediaId);
                file.ShowDialog();
            }
        }
예제 #9
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);
        }