示例#1
0
        public static bool ShowAnalyzerInstalled()
        {
            ShowAnalyzerLib.ShowAnalyzer sa = null;

            try
            {
                sa = new ShowAnalyzer();
                string reg = sa.GetRegistrationInfo();
                // TODO check for unregistered use - fail

                // Release the COM object and clean up otherwise it hangs later
                Marshal.FinalReleaseComObject(sa);
                sa = null;
                return(true);
            }
            catch
            {
                // Release the COM object
                if (sa != null)
                {
                    Marshal.FinalReleaseComObject(sa);
                    sa = null;
                }

                return(false);
            }
        }
示例#2
0
        private void ScanWithSA()
        {
            bool isSuspended = false;

            ShowAnalyzerLib.ShowAnalyzer sa = null;

            try
            {
                _jobStatus.PercentageComplete = 0; //reset
                _jobStatus.ETA = "";

                int    _HangPeriod     = MCEBuddyConf.GlobalMCEConfig.GeneralOptions.hangTimeout; // Default period to detect hang due to no output activity on console - 300 seconds
                double _lastPercentage = 0;

                sa = new ShowAnalyzer();
                string   fileId    = "";
                DateTime _LastTick = DateTime.Now;;

                sa.AnalyzeFile(_videoFileName, "", ref fileId);
                //sa.ChangePriority(fileId, (int) GlobObjects.Priority); // set the priority to match the users's selection - not implemented yet, throwing exception
                bool   completed  = false;
                double percentage = 0;
                string status;
                while (!completed)
                {
                    if (_jobStatus.Cancelled)
                    {
                        //Cancel the running process to release file lock and free processor
                        sa.Abort(fileId);
                        _jobLog.WriteEntry(this, Localise.GetPhrase("Cancelled ShowAnalyzer, file ->") + " " + _videoFileName, Log.LogEntryType.Error);
                        Util.FileIO.TryFileDelete(SourceEDLFilePath);  // Delete the EDL file since that is used to determine success
                        Util.FileIO.TryFileDelete(SourceEDLPFilePath); // Delete the EDL file since that is used to determine success
                        break;
                    }

                    sa.GetStatus(fileId, out percentage, out status);
                    _jobStatus.PercentageComplete = (float)(100 * percentage);

                    if (status == "done")
                    {
                        break;
                    }

                    if (!isSuspended && GlobalDefs.Pause) // Check if process has to be suspended (if not already)
                    {
                        sa.Pause(fileId);                 // Suspend it
                        _jobLog.Flush();                  // Flush the buffers
                        isSuspended = true;
                    }

                    if (isSuspended && !GlobalDefs.Pause) // Check if we need to resume the process
                    {
                        isSuspended = false;
                        sa.Resume(fileId); // Resume it
                    }

                    if (isSuspended)
                    {
                        _LastTick = DateTime.Now;              // Since during suspension there will be no output it shouldn't terminate the process
                    }
                    // Check if Showanalyzer has hung
                    if (_lastPercentage != percentage) // It has progressed
                    {
                        if (_HangPeriod > 0)
                        {
                            _LastTick = DateTime.Now;
                        }
                    }
                    else
                    {
                        if ((_HangPeriod > 0) && (DateTime.Now > _LastTick.AddSeconds(_HangPeriod)))
                        {
                            _jobLog.WriteEntry(Localise.GetPhrase("No response from process for ") + _HangPeriod + Localise.GetPhrase(" seconds, process likely hung - killing it"), Log.LogEntryType.Error);
                            sa.Abort(fileId);                              // Kill it
                            Util.FileIO.TryFileDelete(SourceEDLFilePath);  // Delete the EDL file since that is used to determine success
                            Util.FileIO.TryFileDelete(SourceEDLPFilePath); // Delete the EDL file since that is used to determine success
                            break;
                        }
                    }

                    _lastPercentage = percentage; // track the last percentage
                    System.Threading.Thread.Sleep(100);
                }

                // Release the COM object and clean up otherwise it hangs later
                try
                {
                    sa.RemoveItemFromQueue(fileId);
                }
                catch { }

                Marshal.FinalReleaseComObject(sa);
                sa = null;
            }
            catch (Exception Ex)
            {
                // Release the COM object
                if (sa != null)
                {
                    Marshal.FinalReleaseComObject(sa);
                    sa = null;
                }

                _jobLog.WriteEntry(this, Localise.GetPhrase("ShowAnalyzer failed, file ->") + " " + _videoFileName, Log.LogEntryType.Error);
                _jobLog.WriteEntry(this, "Error -> " + Ex.ToString(), Log.LogEntryType.Debug);
            }
        }
示例#3
0
        private void ScanWithSA()
        {
            bool isSuspended = false;
            ShowAnalyzerLib.ShowAnalyzer sa = null;

            try
            {
                _jobStatus.PercentageComplete = 0; //reset
                _jobStatus.ETA = "";

                int _HangPeriod = MCEBuddyConf.GlobalMCEConfig.GeneralOptions.hangTimeout; // Default period to detect hang due to no output activity on console - 300 seconds
                double _lastPercentage = 0;

                sa = new ShowAnalyzer();
                string fileId = "";
                DateTime _LastTick = DateTime.Now; ;

                sa.AnalyzeFile(_videoFileName, "", ref fileId);
                //sa.ChangePriority(fileId, (int) GlobObjects.Priority); // set the priority to match the users's selection - not implemented yet, throwing exception
                bool completed = false;
                double percentage = 0;
                string status;
                while (!completed)
                {
                    if (_jobStatus.Cancelled)
                    {
                        //Cancel the running process to release file lock and free processor
                        sa.Abort(fileId);
                        _jobLog.WriteEntry(this, Localise.GetPhrase("Cancelled ShowAnalyzer, file ->") + " " + _videoFileName, Log.LogEntryType.Error);
                        Util.FileIO.TryFileDelete(SourceEDLFilePath); // Delete the EDL file since that is used to determine success
                        Util.FileIO.TryFileDelete(SourceEDLPFilePath); // Delete the EDL file since that is used to determine success
                        break;
                    }

                    sa.GetStatus(fileId, out percentage, out status);
                    _jobStatus.PercentageComplete = (float)(100 * percentage);

                    if (status == "done")
                    {
                        break;
                    }

                    if (!isSuspended && GlobalDefs.Pause) // Check if process has to be suspended (if not already)
                    {
                        sa.Pause(fileId); // Suspend it
                        _jobLog.Flush(); // Flush the buffers
                        isSuspended = true;
                    }

                    if (isSuspended && !GlobalDefs.Pause) // Check if we need to resume the process
                    {
                        isSuspended = false;
                        sa.Resume(fileId); // Resume it
                    }

                    if (isSuspended) _LastTick = DateTime.Now; // Since during suspension there will be no output it shouldn't terminate the process

                    // Check if Showanalyzer has hung
                    if (_lastPercentage != percentage) // It has progressed
                    {
                        if (_HangPeriod > 0) _LastTick = DateTime.Now;
                    }
                    else
                    {
                        if ((_HangPeriod > 0) && (DateTime.Now > _LastTick.AddSeconds(_HangPeriod)))
                        {
                            _jobLog.WriteEntry(Localise.GetPhrase("No response from process for ") + _HangPeriod + Localise.GetPhrase(" seconds, process likely hung - killing it"), Log.LogEntryType.Error);
                            sa.Abort(fileId); // Kill it
                            Util.FileIO.TryFileDelete(SourceEDLFilePath); // Delete the EDL file since that is used to determine success
                            Util.FileIO.TryFileDelete(SourceEDLPFilePath); // Delete the EDL file since that is used to determine success
                            break;
                        }
                    }

                    _lastPercentage = percentage; // track the last percentage
                    System.Threading.Thread.Sleep(100);
                }

                // Release the COM object and clean up otherwise it hangs later
                try
                {
                    sa.RemoveItemFromQueue(fileId);
                }
                catch { }

                Marshal.FinalReleaseComObject(sa);
                sa = null;
            }
            catch (Exception Ex)
            {
                // Release the COM object
                if (sa != null)
                {
                    Marshal.FinalReleaseComObject(sa);
                    sa = null;
                }

                _jobLog.WriteEntry(this, Localise.GetPhrase("ShowAnalyzer failed, file ->") + " " + _videoFileName, Log.LogEntryType.Error);
                _jobLog.WriteEntry(this, "Error -> " + Ex.ToString(), Log.LogEntryType.Debug);
            }
        }
示例#4
0
        public static bool ShowAnalyzerInstalled()
        {
            ShowAnalyzerLib.ShowAnalyzer sa = null;

            try
            {
                sa = new ShowAnalyzer();
                string reg = sa.GetRegistrationInfo();
                // TODO check for unregistered use - fail
                
                // Release the COM object and clean up otherwise it hangs later
                Marshal.FinalReleaseComObject(sa);
                sa = null;
                return true;
            }
            catch
            {
                // Release the COM object
                if (sa != null)
                {
                    Marshal.FinalReleaseComObject(sa);
                    sa = null;
                }

                return false;
            }
        }