コード例 #1
0
ファイル: frmClientSetup.cs プロジェクト: garyan2/epg123
        private bool ImportMxfFile()
        {
            var ret = true;

            UpdateStatusText("Importing remote MXF file");
            var frmRemote = new frmRemoteServers();

            frmRemote.ShowDialog();
            if (string.IsNullOrEmpty(frmRemote.mxfPath))
            {
                return(ret);
            }

            Logger.EventId = 0;
            mxfImport      = statusLogo.MxfFile = frmRemote.mxfPath;
            var importForm = new frmImport(mxfImport);

            importForm.ShowDialog();

            if (importForm.Success)
            {
                WmcStore.ActivateEpg123LineupsInStore();
                WmcRegistries.ActivateGuide();
                WmcStore.AutoMapChannels();
                WmcUtilities.ReindexDatabase();
            }
            else
            {
                MessageBox.Show("There was an error importing the MXF file.", "Import Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                UpdateStatusText("Click the 'Step 3' button to try again.");
                ret = cbAutostep.Checked = false;
            }
            statusLogo.StatusImage();
            Helper.SendPipeMessage("Import Complete");

            return(ret);
        }
コード例 #2
0
ファイル: frmClientSetup.cs プロジェクト: garyan2/epg123
        private bool OpenEpg123Configuration()
        {
            const string text    = "You have both the EPG123 executable for guide listings from Schedules Direct and the HDHR2MXF executable for guide listings from SiliconDust.\n\nDo you wish to proceed with HDHR2MXF?";
            const string caption = "Multiple Guide Sources";

            if (File.Exists(Helper.Epg123ExePath) && File.Exists(Helper.Hdhr2MxfExePath) && DialogResult.Yes == MessageBox.Show(text, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) ||
                File.Exists(Helper.Hdhr2MxfExePath) && !File.Exists(Helper.Epg123ExePath))
            {
                Hdhr2MxfSrv = true;
                UpdateStatusText("Running HDHR2MXF to create the guide ...");
                Logger.WriteVerbose("Running HDHR2MXF to create the guide ...");

                var startInfo = new ProcessStartInfo()
                {
                    FileName  = Helper.Hdhr2MxfExePath,
                    Arguments = "-update",
                };
                var hdhr2Mxf = Process.Start(startInfo);
                hdhr2Mxf.WaitForExit();

                Logger.EventId     = 0;
                statusLogo.MxfFile = Helper.Epg123MxfPath;
                if (hdhr2Mxf.ExitCode == 0)
                {
                    // use the client to import the mxf file
                    var importForm = new frmImport(Helper.Epg123MxfPath);
                    importForm.ShowDialog();

                    // kick off the reindex
                    if (importForm.Success)
                    {
                        WmcStore.ActivateEpg123LineupsInStore();
                        WmcRegistries.ActivateGuide();
                        WmcStore.AutoMapChannels();
                        WmcUtilities.ReindexDatabase();
                    }
                    else
                    {
                        MessageBox.Show("There was an error importing the MXF file.", "Import Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        UpdateStatusText("Click the 'Step 3' button to try again.");
                        return(cbAutostep.Checked = false);
                    }
                }
                else
                {
                    MessageBox.Show("There was an error using HDHR2MXF to create the MXF file.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    UpdateStatusText("Click the 'Step 3' button to try again.");
                    return(cbAutostep.Checked = false);
                }
                statusLogo.StatusImage();
                Helper.SendPipeMessage("Import Complete");

                return(true);
            }

            UpdateStatusText("Opening EPG123 Configuration GUI ...");
            Logger.WriteVerbose("Opening EPG123 Configuration GUI ...");
            Process procEpg123;

            if (Epg123Running())
            {
                var processes = Process.GetProcessesByName("epg123");
                procEpg123 = processes[0];
                if (IsIconic(procEpg123.MainWindowHandle))
                {
                    ShowWindow(procEpg123.MainWindowHandle, SW_RESTORE);
                }
            }
            else
            {
                // start epg123 configuration GUI
                procEpg123 = Process.Start(Helper.Epg123ExePath);
                procEpg123?.WaitForInputIdle(10000);
            }
            SetForegroundWindow(procEpg123.MainWindowHandle);
            UpdateStatusText("Waiting for EPG123 to close ...");
            Logger.WriteVerbose("Waiting for EPG123 to close ...");

            do
            {
                Thread.Sleep(100);
                Application.DoEvents();
            } while (!procEpg123.HasExited);

            UpdateStatusText(string.Empty);

            return(true);
        }