コード例 #1
0
ファイル: DBPathes.cs プロジェクト: barneh/mptvseries
        public static DBImportPath[] GetAll()
        {
            try
            {
                // make sure the table is created - create a dummy object
                DBImportPath dummy = new DBImportPath();

                // retrieve all fields in the table
                String sqlQuery = "select * from " + cTableName + " order by " + cIndex;
                SQLiteResultSet results = DBTVSeries.Execute(sqlQuery);
                if (results.Rows.Count > 0)
                {
                    DBImportPath[] importPathes = new DBImportPath[results.Rows.Count];
                    for (int index = 0; index < results.Rows.Count; index++)
                    {
                        importPathes[index] = new DBImportPath();
                        importPathes[index].Read(ref results, index);                        
                    }
                    return importPathes;
                }
            }
            catch (Exception ex)
            {
                MPTVSeriesLog.Write("Error in DBImportPath.Get (" + ex.Message + ").");
            }
            return null;
        }
コード例 #2
0
        public static DBImportPath[] GetAll()
        {
            try
            {
                // make sure the table is created - create a dummy object
                DBImportPath dummy = new DBImportPath();

                // retrieve all fields in the table
                String          sqlQuery = "select * from " + cTableName + " order by " + cIndex;
                SQLiteResultSet results  = DBTVSeries.Execute(sqlQuery);
                if (results.Rows.Count > 0)
                {
                    DBImportPath[] importPathes = new DBImportPath[results.Rows.Count];
                    for (int index = 0; index < results.Rows.Count; index++)
                    {
                        importPathes[index] = new DBImportPath();
                        importPathes[index].Read(ref results, index);
                    }
                    return(importPathes);
                }
            }
            catch (Exception ex)
            {
                MPTVSeriesLog.Write("Error in DBImportPath.Get (" + ex.Message + ").");
            }
            return(null);
        }
コード例 #3
0
        public static void StartMonitor()
        {
            if (MonitorStarted)
            {
                return;
            }

            DBImportPath[] importPaths = DBImportPath.GetAll();
            if (importPaths != null)
            {
                foreach (DBImportPath currPath in importPaths)
                {
                    try {
                        AddWatchDrive(currPath[DBImportPath.cPath]);
                    }
                    catch (Exception e) {
                        if (e is ThreadAbortException)
                        {
                            throw e;
                        }

                        MPTVSeriesLog.Write("Failed adding " + currPath + " to the Disk Watcher!", MPTVSeriesLog.LogLevel.Debug);
                    }
                }
            }
        }
コード例 #4
0
        void OnVolumeInsertedRemoved(string volume, string serial)
        {
            MPTVSeriesLog.Write("On Volume Inserted or Removed: " + volume);

            List <String> folders = new List <String>();

            foreach (DBImportPath importPath in DBImportPath.GetAll())
            {
                string sRoot = System.IO.Path.GetPathRoot(importPath[DBImportPath.cPath]);
                if ((importPath[DBImportPath.cEnabled] != 0) && !String.IsNullOrEmpty(sRoot) && sRoot.ToLower().StartsWith(volume.ToLower()))
                {
                    MPTVSeriesLog.Write("Adding for import or remove: " + importPath[DBImportPath.cPath]);
                    folders.Add(importPath[DBImportPath.cPath]);
                }
            }

            if (folders.Count > 0)
            {
                List <PathPair> m_PreviousScanRemovableTemp = new List <PathPair>();
                m_PreviousScanRemovableTemp.AddRange(m_PreviousScanRemovable);
                foreach (String pair in folders)
                {
                    m_PreviousScanRemovableTemp.RemoveAll(item => !item.m_sFull_FileName.StartsWith(pair));
                }
                foreach (PathPair pair in m_PreviousScanRemovableTemp)
                {
                    m_PreviousScanRemovable.RemoveAll(item => item.m_sFull_FileName == pair.m_sFull_FileName);
                }

                DoFileScan(folders, ref m_PreviousScanRemovableTemp);

                m_PreviousScanRemovable.AddRange(m_PreviousScanRemovableTemp);
            }
        }
コード例 #5
0
        List <String> GetDeviceManagerWatchedFolders()
        {
            List <String> result = new List <String>();

            if (DeviceManager.watchedDrives == null)
            {
                return(result);
            }

            foreach (DBImportPath importPath in DBImportPath.GetAll())
            {
                string sRoot            = System.IO.Path.GetPathRoot(importPath[DBImportPath.cPath]);
                string importPathString = importPath[DBImportPath.cPath];
                if (!String.IsNullOrEmpty(importPathString) && (importPath[DBImportPath.cEnabled] != 0) && !String.IsNullOrEmpty(sRoot))
                {
                    foreach (String drive in DeviceManager.watchedDrives)
                    {
                        if (importPathString.StartsWith(drive) && !result.Contains(importPathString))
                        {
                            result.Add(importPathString);
                        }
                    }
                }
            }
            return(result);
        }
コード例 #6
0
ファイル: LocalParse.cs プロジェクト: framug/mptvseries
        //public static bool isOnRemovable(string filename)
        //{
        //    if (paths == null) paths = DBImportPath.GetAll();
        //    foreach (DBImportPath path in paths)
        //    {
        //        if (path[DBImportPath.cRemovable] && filename.ToLower().Contains(path[DBImportPath.cPath].ToString().ToLower())) return true;
        //    }
        //    return false;
        //}

        //public static bool needToKeepReference(string filename)
        //{
        //    if (paths == null) paths = DBImportPath.GetAll();
        //    foreach (DBImportPath path in paths)
        //    {
        //        if (path[DBImportPath.cKeepReference] && filename.ToLower().Contains(path[DBImportPath.cPath].ToString().ToLower())) return true;
        //    }
        //    return false;
        //}

        /// <summary>
        /// Gets the corresponding Import Path that the filename is attached to
        /// </summary>
        public static string getImportPath(string filename)
        {
            if (paths == null)
            {
                paths = DBImportPath.GetAll();
            }
            if (paths != null)
            {
                foreach (DBImportPath path in paths)
                {
                    string importPath = path[DBImportPath.cPath];
                    if (filename.ToLower().Contains(importPath.ToString().ToLower()))
                    {
                        return(importPath);
                    }
                }
            }
            return(null);
        }
コード例 #7
0
ファイル: LocalParse.cs プロジェクト: framug/mptvseries
        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            System.Threading.Thread.CurrentThread.Priority = System.Threading.ThreadPriority.Lowest;
            List <String> listFolders = new List <string>();

            DBImportPath[] importPathes = DBImportPath.GetAll();
            if (importPathes != null)
            {
                foreach (DBImportPath importPath in importPathes)
                {
                    if (importPath[DBImportPath.cEnabled] != 0)
                    {
                        listFolders.Add(importPath[DBImportPath.cPath]);
                    }
                }
            }
            List <PathPair> files = Filelister.GetFiles(listFolders);

            MPTVSeriesLog.Write("Found " + files.Count.ToString() + " supported video files in your import paths");
            e.Result = Parse(files);
        }
コード例 #8
0
ファイル: GUIConfiguration.cs プロジェクト: barneh/mptvseries
        private void SaveAllImportPathes()
        {
            // need to save back all the rows
            DBImportPath.ClearAll();

            foreach (DataGridViewRow row in dataGridView_ImportPathes.Rows)
            {
                if (row.Index != dataGridView_ImportPathes.NewRowIndex)
                {
                    DBImportPath importPath = new DBImportPath();
                    importPath[DBImportPath.cIndex] = row.Index.ToString();
                    foreach (DataGridViewCell cell in row.Cells)
                        if (cell.ValueType.Name == "Boolean")
                            importPath[cell.OwningColumn.Name] = (Boolean)cell.Value;
                        else
                            importPath[cell.OwningColumn.Name] = (String)cell.Value;
                    importPath.Commit();
                }
            }
        }
コード例 #9
0
ファイル: GUIConfiguration.cs プロジェクト: barneh/mptvseries
 private void dataGridView_ImportPathes_CellValueChanged(object sender, DataGridViewCellEventArgs e)
 {
     DBImportPath importPath = new DBImportPath();
     importPath[DBImportPath.cIndex] = e.RowIndex.ToString();
     foreach (DataGridViewCell cell in dataGridView_ImportPathes.Rows[e.RowIndex].Cells)
     {   
         if (cell.Value != null)
         {
             if (cell.ValueType == typeof(Boolean))
                 importPath[cell.OwningColumn.Name] = (Boolean)cell.Value;
             else
                 importPath[cell.OwningColumn.Name] = (String)cell.Value;
         }
     }
     importPath.Commit();
 }