Exemplo n.º 1
0
        private void OKButton_Click(object sender, EventArgs e)
        {
            if (engineNameTxt.Text == "" || portNoTxt.Text == "")
            {
                MessageBox.Show(Localise.GetPhrase("Please enter a valid Engine Name and Engine Port Number"), Localise.GetPhrase("Invalid Name/Port"));
                return;
            }

            Ini tempIni = new Ini(GlobalDefs.TempSettingsFile);
            tempIni.Write("Engine", "RemoteServerName", engineNameTxt.Text.Trim());
            tempIni.Write("Engine", "RemoteServerPort", portNoTxt.Text.Trim());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Used to check for updates to MCEBuddy
        /// </summary>
        /// <param name="nonGUI">True if called from a thread (not GUI)</param>
        public void Check(bool nonGUI)
        {
            try
            {
                LatestVersion latestVersion;
                string        announcement     = "";
                string        announcementLink = "";
                string        donationLink     = "";
                string        facebookLink     = "";
                Ini           configIni        = new Ini(GlobalDefs.TempSettingsFile);

                // Get all the version information
                string pageOutput = WebUtility.HtmlDecode(DownloadWebPage(Crypto.Decrypt(GlobalDefs.MCEBUDDY_CHECK_NEW_VERSION), nonGUI));
                if (String.IsNullOrWhiteSpace(pageOutput))
                {
                    return;
                }

                latestVersion    = ParseVersion(pageOutput);              // Get the latest version
                announcement     = ParseAnnouncement(pageOutput);         // Get any critical announcements
                announcementLink = ParseLink(pageOutput, "Link");         // Get the link for any critical announcements
                donationLink     = ParseLink(pageOutput, "DonationLink"); // Get the link for donations
                facebookLink     = ParseLink(pageOutput, "FacebookLink"); // Get the link for donations

                // Check and write any critical announcement (always overwrite to get latest annnoucement, even if blank)
                configIni.Write("Engine", "Announcement", announcement);
                configIni.Write("Engine", "AnnouncementLink", announcementLink);
                configIni.Write("Engine", "DonationLink", donationLink);
                configIni.Write("Engine", "FacebookLink", facebookLink);

                // Check and write the version information
                if ("" == latestVersion.latestVersionString)
                {
                    Log.AppLog.WriteEntry(this, Localise.GetPhrase("Unable to get Latest Version information"), Log.LogEntryType.Warning);
                    return; //didn't get the data we were expecting
                }
                else
                {
                    Log.AppLog.WriteEntry(this, Localise.GetPhrase("MCEBuddy Latest Version") + " " + latestVersion.latestVersionString, Log.LogEntryType.Debug);
                    string currentVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
                    Log.AppLog.WriteEntry(this, Localise.GetPhrase("MCEBuddy Current Version") + " " + currentVersion, Log.LogEntryType.Debug);
                    configIni.Write("Engine", "LatestVersion", latestVersion.latestVersionString);
                }
            }
            catch
            { }
        }
Exemplo n.º 3
0
        private void WriteMonitorSettings(Ini configIni)
        {
            if (configIni == null)
                return;

            // First read and delete all Monitor tasks - start with a clean slate (incase there were previous delete monitor tasks without writing)
            string[] searchRecords = configIni.ReadString("Engine", "SearchRecords", "").Split(',');
            foreach (string searchRecord in searchRecords)
            {
                if (String.IsNullOrEmpty(searchRecord))
                    continue;

                configIni.DeleteSection(searchRecord);
            }

            // Write the Monitor Tasks Settings
            foreach (MonitorJobOptions monitorTask in mceBuddyConfSettings.monitorTasks)
            {
                string section = monitorTask.taskName;

                configIni.Write(section, "SearchPath", monitorTask.searchPath);
                monitorTask.searchPattern = monitorTask.searchPattern.Replace(GlobalDefs.DEFAULT_VIDEO_STRING, GlobalDefs.DEFAULT_VIDEO_FILE_TYPES);
                configIni.Write(section, "SearchPattern", monitorTask.searchPattern);
                configIni.Write(section, "MonitorSubdirectories", monitorTask.monitorSubdirectories);
                configIni.Write(section, "MonitorConvertedFiles", monitorTask.monitorConvertedFiles);
                configIni.Write(section, "ReMonitorRecordedFiles", monitorTask.reMonitorRecordedFiles);

                configIni.Write(section, "DomainName", monitorTask.domainName);
                configIni.Write(section, "UserName", monitorTask.userName);
                if (!String.IsNullOrEmpty(monitorTask.password))
                    configIni.Write(section, "Password", Crypto.Encrypt(monitorTask.password)); // Password is written as encrypted
            }

            WriteMonitorTasksList(configIni); // this list goes in the Engine section
        }
Exemplo n.º 4
0
        private void WriteMonitorTasksList(Ini configIni)
        {
            if (configIni == null)
                return;

            string monitorTaskNames = ""; // A list of of all the monitor task names

            // Write the Monitor Tasks Settings
            foreach (MonitorJobOptions monitorTask in mceBuddyConfSettings.monitorTasks)
            {
                string section = monitorTask.taskName;

                if (monitorTaskNames == "")
                    monitorTaskNames = section;
                else
                    monitorTaskNames += "," + section;
            }

            configIni.Write("Engine", "SearchRecords", monitorTaskNames); // this list goes in the Engine section
        }
Exemplo n.º 5
0
        private void WriteConversionSettings(Ini configIni)
        {
            if (configIni == null)
                return;

            // First read and delete all Conversion tasks - start with a clean slate (incase there were previous delete conversion tasks without writing)
            string[] conversionRecords = configIni.ReadString("Engine", "Tasks", "").Split(',');
            foreach (string conversionRecord in conversionRecords)
            {
                if (String.IsNullOrEmpty(conversionRecord))
                    continue;

                configIni.DeleteSection(conversionRecord);
            }

            // Write the Converstion Task Settings
            foreach (ConversionJobOptions conversionTask in mceBuddyConfSettings.conversionTasks)
            {
                string section = conversionTask.taskName;

                configIni.Write(section, "Profile", conversionTask.profile);
                configIni.Write(section, "DestinationPath", conversionTask.destinationPath);
                configIni.Write(section, "WorkingPath", conversionTask.workingPath);
                configIni.Write(section, "FallbackDestination", conversionTask.fallbackToSourcePath);
                configIni.Write(section, "CheckReprocessingHistory", conversionTask.checkReprocessingHistory);
                configIni.Write(section, "AddToiTunesLibrary", conversionTask.addToiTunes);
                configIni.Write(section, "AddToWMPLibrary", conversionTask.addToWMP);
                configIni.Write(section, "AutoIncrementFilename", conversionTask.autoIncrementFilename);
                configIni.Write(section, "SkipReprocessing", conversionTask.skipReprocessing);
                configIni.Write(section, "MaxWidth", conversionTask.maxWidth);
                configIni.Write(section, "FPS", conversionTask.FPS);
                configIni.Write(section, "VolumeMultiplier", conversionTask.volumeMultiplier.ToString(CultureInfo.InvariantCulture));
                configIni.Write(section, "QualityMultiplier", conversionTask.qualityMultiplier.ToString(CultureInfo.InvariantCulture));
                configIni.Write(section, "RenameBySeries", conversionTask.renameBySeries);
                configIni.Write(section, "AltRenameBySeries", conversionTask.altRenameBySeries);
                configIni.Write(section, "CustomRenameBySeries", conversionTask.customRenameBySeries);
                configIni.Write(section, "RenameOnly", conversionTask.renameOnly);
                configIni.Write(section, "DownloadSeriesDetails", conversionTask.downloadSeriesDetails);
                configIni.Write(section, "DownloadBanner", conversionTask.downloadBanner); 
                configIni.Write(section, "FileSelection", conversionTask.fileSelection);
                configIni.Write(section, "MetaSelection", conversionTask.metaShowSelection);
                configIni.Write(section, "MetaChannelSelection", conversionTask.metaNetworkSelection);
                configIni.Write(section, "MonitorTaskNames", (conversionTask.monitorTaskNames == null ? "" : String.Join(",", conversionTask.monitorTaskNames)));
                configIni.Write(section, "DRC", conversionTask.drc);
                configIni.Write(section, "AudioLanguage", conversionTask.audioLanguage);
                configIni.Write(section, "AudioOffset", conversionTask.audioOffset.ToString(CultureInfo.InvariantCulture));
                configIni.Write(section, "InsertQueueTop", conversionTask.insertQueueTop);
                configIni.Write(section, "ExtractXML", conversionTask.extractXML);
                configIni.Write(section, "WriteMetadata", conversionTask.writeMetadata);
                configIni.Write(section, "AutoDeInterlace", conversionTask.autoDeInterlace);
                configIni.Write(section, "PreferHardwareEncoding", conversionTask.preferHardwareEncoding);
                configIni.Write(section, "StereoAudio", conversionTask.stereoAudio);
                configIni.Write(section, "EncoderSelectBestAudioTrack", conversionTask.encoderSelectBestAudioTrack);
                configIni.Write(section, "DisableCropping", conversionTask.disableCropping);
                configIni.Write(section, "StartTrim", conversionTask.startTrim);
                configIni.Write(section, "EndTrim", conversionTask.endTrim);
                configIni.Write(section, "ExtractCC", conversionTask.extractCC);
                configIni.Write(section, "CCOffset", conversionTask.ccOffset.ToString(CultureInfo.InvariantCulture));
                configIni.Write(section, "EmbedSubtitlesChapters", conversionTask.embedSubtitlesChapters);
                configIni.Write(section, "PrioritizeOriginalBroadcastDateMatch", conversionTask.prioritizeOriginalBroadcastDateMatch);
                configIni.Write(section, "TaskCommercialSkipCut", conversionTask.commercialSkipCut);
                configIni.Write(section, "SkipCopyBackup", conversionTask.skipCopyBackup);
                configIni.Write(section, "SkipRemux", conversionTask.skipRemuxing);
                configIni.Write(section, "IgnoreCopyProtection", conversionTask.ignoreCopyProtection);
                configIni.Write(section, "TiVOMAKKey", conversionTask.tivoMAKKey);
                configIni.Write(section, "Enabled", conversionTask.enabled);
                configIni.Write(section, "ForceShowType", conversionTask.forceShowType.ToString());
                configIni.Write(section, "MetaShowTypeSelection", conversionTask.metaShowTypeSelection.ToString());
                configIni.Write(section, "MetaDRMTypeSelection", conversionTask.metaDRMSelection.ToString());
                configIni.Write(section, "CommercialRemoval", conversionTask.commercialRemoval.ToString());
                configIni.Write(section, "ComskipINI", conversionTask.comskipIni);
                configIni.Write(section, "DomainName", conversionTask.domainName);
                configIni.Write(section, "UserName", conversionTask.userName);
                if (!String.IsNullOrEmpty(conversionTask.password))
                    configIni.Write(section, "Password", Crypto.Encrypt(conversionTask.password)); // Password is written as encrypted

                // First wipe the MetaCorrectionEntries section clean, to remove old/redundant data and then start afresh since we don't know how many entries may exist
                configIni.DeleteSection(section + "-MetaCorrectionEntries");

                if (conversionTask.metadataCorrections == null)
                    configIni.Write(section, "MetaCorrectionsCount", 0);
                else
                {
                    configIni.Write(section, "MetaCorrectionsCount", conversionTask.metadataCorrections.Length);

                    for (int i = 0; i < conversionTask.metadataCorrections.Length; i++) // the Enteries are kept in their own section
                    {
                        configIni.Write(section + "-MetaCorrectionEntries", "OriginalTitle" + i.ToString(), conversionTask.metadataCorrections[i].originalTitle);
                        configIni.Write(section + "-MetaCorrectionEntries", "CorrectedTitle" + i.ToString(), conversionTask.metadataCorrections[i].correctedTitle);
                        configIni.Write(section + "-MetaCorrectionEntries", "TVDBSeriesId" + i.ToString(), conversionTask.metadataCorrections[i].tvdbSeriesId);
                        configIni.Write(section + "-MetaCorrectionEntries", "IMDBSeriesId" + i.ToString(), conversionTask.metadataCorrections[i].imdbSeriesId);
                    }
                }
            }

            WriteConversionTasksList(configIni); // this list goes in the Engine section
        }
Exemplo n.º 6
0
        private void WriteConversionTasksList(Ini configIni)
        {
            if (configIni == null)
                return;

            string conversionTaskNames = ""; // A list of all the conversion task names

            // Write the Converstion Task Settings
            foreach (ConversionJobOptions conversionTask in mceBuddyConfSettings.conversionTasks)
            {
                string section = conversionTask.taskName;

                if (conversionTaskNames == "")
                    conversionTaskNames = section;
                else
                    conversionTaskNames += "," + section;
            }

            configIni.Write("Engine", "Tasks", conversionTaskNames); // this list goes in the Engine section
        }
Exemplo n.º 7
0
        private void WriteGeneralSettings(Ini configIni)
        {
            if (configIni == null)
                return;

            // Write the General Settings
            configIni.Write("Engine", "DomainName", mceBuddyConfSettings.generalOptions.domainName);
            configIni.Write("Engine", "UserName", mceBuddyConfSettings.generalOptions.userName);
            if (!String.IsNullOrEmpty(mceBuddyConfSettings.generalOptions.password))
                configIni.Write("Engine", "Password", Crypto.Encrypt(mceBuddyConfSettings.generalOptions.password)); // Password is written as encrypted
            configIni.Write("Engine", "WakeHour", mceBuddyConfSettings.generalOptions.wakeHour);
            configIni.Write("Engine", "WakeMinute", mceBuddyConfSettings.generalOptions.wakeMinute);
            configIni.Write("Engine", "StartHour", mceBuddyConfSettings.generalOptions.startHour);
            configIni.Write("Engine", "StartMinute", mceBuddyConfSettings.generalOptions.startMinute);
            configIni.Write("Engine", "StopHour", mceBuddyConfSettings.generalOptions.stopHour);
            configIni.Write("Engine", "StopMinute", mceBuddyConfSettings.generalOptions.stopMinute);
            configIni.Write("Engine", "DaysOfWeek", mceBuddyConfSettings.generalOptions.daysOfWeek);
            configIni.Write("Engine", "MaxConcurrentJobs", mceBuddyConfSettings.generalOptions.maxConcurrentJobs);
            configIni.Write("Engine", "LogJobs", mceBuddyConfSettings.generalOptions.logJobs);
            configIni.Write("Engine", "LogLevel", mceBuddyConfSettings.generalOptions.logLevel);
            configIni.Write("Engine", "LogKeepDays", mceBuddyConfSettings.generalOptions.logKeepDays);
            configIni.Write("Engine", "DeleteOriginal", mceBuddyConfSettings.generalOptions.deleteOriginal);
            configIni.Write("Engine", "UseRecycleBin", mceBuddyConfSettings.generalOptions.useRecycleBin);
            configIni.Write("Engine", "ArchiveOriginal", mceBuddyConfSettings.generalOptions.archiveOriginal);
            configIni.Write("Engine", "DeleteConverted", mceBuddyConfSettings.generalOptions.deleteConverted); 
            configIni.Write("Engine", "AllowSleep", mceBuddyConfSettings.generalOptions.allowSleep);
            configIni.Write("Engine", "SuspendOnBattery", mceBuddyConfSettings.generalOptions.suspendOnBattery);
            configIni.Write("Engine", "MinimumAge", mceBuddyConfSettings.generalOptions.minimumAge);
            configIni.Write("Engine", "SendEmail", mceBuddyConfSettings.generalOptions.sendEmail);
            configIni.Write("Engine", "Locale", mceBuddyConfSettings.generalOptions.locale);
            configIni.Write("Engine", "TempWorkingPath", mceBuddyConfSettings.generalOptions.tempWorkingPath);
            configIni.Write("Engine", "ArchivePath", mceBuddyConfSettings.generalOptions.archivePath);
            configIni.Write("Engine", "FailedPath", mceBuddyConfSettings.generalOptions.failedPath);
            configIni.Write("Engine", "SpaceCheck", mceBuddyConfSettings.generalOptions.spaceCheck);
            configIni.Write("Engine", "CustomComskipPath", mceBuddyConfSettings.generalOptions.comskipPath);
            configIni.Write("Engine", "CustomProfilePath", mceBuddyConfSettings.generalOptions.customProfilePath);
            configIni.Write("Engine", "HangPeriod", mceBuddyConfSettings.generalOptions.hangTimeout);
            configIni.Write("Engine", "PollPeriod", mceBuddyConfSettings.generalOptions.pollPeriod);
            configIni.Write("Engine", "ProcessPriority", mceBuddyConfSettings.generalOptions.processPriority);
            configIni.Write("Engine", "CPUAffinity", mceBuddyConfSettings.generalOptions.CPUAffinity.ToInt32());
            configIni.Write("Engine", "EngineRunning", mceBuddyConfSettings.generalOptions.engineRunning);
            configIni.Write("Engine", "LocalServerPort", mceBuddyConfSettings.generalOptions.localServerPort);
            configIni.Write("Engine", "UPnPEnable", mceBuddyConfSettings.generalOptions.uPnPEnable);
            configIni.Write("Engine", "FirewallExceptionEnable", mceBuddyConfSettings.generalOptions.firewallExceptionEnabled);
            configIni.Write("Engine", "SubtitleSegmentOffset", mceBuddyConfSettings.generalOptions.subtitleSegmentOffset.ToString(CultureInfo.InvariantCulture));

            WriteEMailSettings(configIni);
        }
Exemplo n.º 8
0
        private void WriteEMailSettings(Ini configIni)
        {
            if (configIni == null)
                return;

            configIni.Write("Engine", "eMailServer", mceBuddyConfSettings.generalOptions.eMailSettings.eMailBasicSettings.smtpServer);
            configIni.Write("Engine", "eMailPort", mceBuddyConfSettings.generalOptions.eMailSettings.eMailBasicSettings.port);
            configIni.Write("Engine", "eMailSSL", mceBuddyConfSettings.generalOptions.eMailSettings.eMailBasicSettings.ssl);
            configIni.Write("Engine", "eMailFrom", mceBuddyConfSettings.generalOptions.eMailSettings.eMailBasicSettings.fromAddress);
            configIni.Write("Engine", "eMailTo", mceBuddyConfSettings.generalOptions.eMailSettings.eMailBasicSettings.toAddresses);
            configIni.Write("Engine", "eMailSuccess", mceBuddyConfSettings.generalOptions.eMailSettings.successEvent);
            configIni.Write("Engine", "eMailFailed", mceBuddyConfSettings.generalOptions.eMailSettings.failedEvent);
            configIni.Write("Engine", "eMailCancelled", mceBuddyConfSettings.generalOptions.eMailSettings.cancelledEvent);
            configIni.Write("Engine", "eMailStart", mceBuddyConfSettings.generalOptions.eMailSettings.startEvent);
            configIni.Write("Engine", "eMailDownloadFailed", mceBuddyConfSettings.generalOptions.eMailSettings.downloadFailedEvent);
            configIni.Write("Engine", "eMailQueue", mceBuddyConfSettings.generalOptions.eMailSettings.queueEvent);
            configIni.Write("Engine", "eMailSuccessSubject", mceBuddyConfSettings.generalOptions.eMailSettings.successSubject);
            configIni.Write("Engine", "eMailFailedSubject", mceBuddyConfSettings.generalOptions.eMailSettings.failedSubject);
            configIni.Write("Engine", "eMailCancelledSubject", mceBuddyConfSettings.generalOptions.eMailSettings.cancelledSubject);
            configIni.Write("Engine", "eMailStartSubject", mceBuddyConfSettings.generalOptions.eMailSettings.startSubject);
            configIni.Write("Engine", "eMailDownloadFailedSubject", mceBuddyConfSettings.generalOptions.eMailSettings.downloadFailedSubject);
            configIni.Write("Engine", "eMailQueueSubject", mceBuddyConfSettings.generalOptions.eMailSettings.queueSubject);
            configIni.Write("Engine", "eMailSkipBody", mceBuddyConfSettings.generalOptions.eMailSettings.skipBody);
            configIni.Write("Engine", "eMailUsername", mceBuddyConfSettings.generalOptions.eMailSettings.eMailBasicSettings.userName);
            if (!String.IsNullOrEmpty(mceBuddyConfSettings.generalOptions.eMailSettings.eMailBasicSettings.password))
                configIni.Write("Engine", "eMailPassword", Util.Crypto.Encrypt(mceBuddyConfSettings.generalOptions.eMailSettings.eMailBasicSettings.password)); // password is stored encrypted
        }
Exemplo n.º 9
0
        /// <summary>
        /// Used to check for updates to MCEBuddy
        /// </summary>
        /// <param name="nonGUI">True if called from a thread (not GUI)</param>
        public void Check(bool nonGUI)
        {
            try
            {
                LatestVersion latestVersion;
                string announcement = "";
                string announcementLink = "";
                string donationLink = "";
                string facebookLink = "";
                Ini configIni = new Ini(GlobalDefs.TempSettingsFile);

                // Get all the version information
                string pageOutput = WebUtility.HtmlDecode(DownloadWebPage(Crypto.Decrypt(GlobalDefs.MCEBUDDY_CHECK_NEW_VERSION), nonGUI));
                if (String.IsNullOrWhiteSpace(pageOutput))
                    return;

                latestVersion = ParseVersion(pageOutput); // Get the latest version
                announcement = ParseAnnouncement(pageOutput); // Get any critical announcements
                announcementLink = ParseLink(pageOutput, "Link"); // Get the link for any critical announcements
                donationLink = ParseLink(pageOutput, "DonationLink"); // Get the link for donations
                facebookLink = ParseLink(pageOutput, "FacebookLink"); // Get the link for donations

                // Check and write any critical announcement (always overwrite to get latest annnoucement, even if blank)
                configIni.Write("Engine", "Announcement", announcement);
                configIni.Write("Engine", "AnnouncementLink", announcementLink);
                configIni.Write("Engine", "DonationLink", donationLink);
                configIni.Write("Engine", "FacebookLink", facebookLink);

                // Check and write the version information
                if ("" == latestVersion.latestVersionString)
                {
                    Log.AppLog.WriteEntry(this, Localise.GetPhrase("Unable to get Latest Version information"), Log.LogEntryType.Warning);
                    return; //didn't get the data we were expecting
                }
                else
                {
                    Log.AppLog.WriteEntry(this, Localise.GetPhrase("MCEBuddy Latest Version") + " " + latestVersion.latestVersionString, Log.LogEntryType.Debug);
                    string currentVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
                    Log.AppLog.WriteEntry(this, Localise.GetPhrase("MCEBuddy Current Version") + " " + currentVersion, Log.LogEntryType.Debug);
                    configIni.Write("Engine", "LatestVersion", latestVersion.latestVersionString);
                }
            }
            catch
            { }
        }
Exemplo n.º 10
0
        private void WriteHistory(ConversionJob job)
        {
            Ini historyIni = new Ini(GlobalDefs.HistoryFile);
            GeneralOptions go = MCEBuddyConf.GlobalMCEConfig.GeneralOptions;

            bool sendEMail = go.sendEmail; // do we need to send an eMail after each job
            bool sendSuccess = go.eMailSettings.successEvent;
            bool sendFailed = go.eMailSettings.failedEvent;
            bool sendCancelled = go.eMailSettings.cancelledEvent;
            bool skipBody = go.eMailSettings.skipBody;
            string sendSuccessSubject = go.eMailSettings.successSubject;
            string sendFailedSubject = go.eMailSettings.failedSubject;
            string sendCancelledSubject = go.eMailSettings.cancelledSubject;

            string result = "Converted";
            if (job.Status.Error) result = "Error";
            if (job.Status.Cancelled) result = "Cancelled"; // Cancelled should be the last status to set because an error can be set if is cancelled

            int convCount = 0;
            while (historyIni.ReadString(job.OriginalFileName, result + "At" + convCount.ToString(System.Globalization.CultureInfo.InvariantCulture), "") != "")
                convCount++;
            historyIni.Write(job.OriginalFileName, result + "At" + convCount.ToString(System.Globalization.CultureInfo.InvariantCulture), DateTime.Now.ToString("s", System.Globalization.CultureInfo.InvariantCulture));

            switch (result)
            {
                case "Converted":
                    {
                        if (job.Status.SuccessfulSkipConversion)
                            Log.AppLog.WriteEntry(this, "Job for " + job.OriginalFileName + " Skipped ReConverting successfully using Conversion Task " + job.TaskName + " and Profile " + job.Profile, Log.LogEntryType.Information, true);
                        else
                            Log.AppLog.WriteEntry(this, "Job for " + job.OriginalFileName + " Converted successfully using Conversion Task " + job.TaskName + " and Profile " + job.Profile, Log.LogEntryType.Information, true);

                        historyIni.Write(job.OriginalFileName, "ConvertedTo" + convCount.ToString(System.Globalization.CultureInfo.InvariantCulture), job.ConvertedFile);
                        historyIni.Write(job.OriginalFileName, "ConvertedUsingProfile" + convCount.ToString(System.Globalization.CultureInfo.InvariantCulture), job.Profile);
                        historyIni.Write(job.OriginalFileName, "ConvertedUsingTask" + convCount.ToString(System.Globalization.CultureInfo.InvariantCulture), job.TaskName);
                        historyIni.Write(job.OriginalFileName, "ConvertedStart" + convCount.ToString(System.Globalization.CultureInfo.InvariantCulture), job.ConversionStartTime.ToString("s", System.Globalization.CultureInfo.InvariantCulture));

                        //Ensure converted files are not then re-converted during a scan
                        historyIni.Write(job.ConvertedFile, "Status", "OutputFromConversion"); // Status indicates destination file is output of an conversion, if the same file is added back for reconversion then it would log as converted
                        if (job.Status.SuccessfulSkipConversion)
                            historyIni.Write(job.ConvertedFile, "SkipConvertedToOutputAt" + convCount.ToString(System.Globalization.CultureInfo.InvariantCulture), job.ConversionEndTime.ToString("s", System.Globalization.CultureInfo.InvariantCulture));
                        else
                            historyIni.Write(job.ConvertedFile, "ConvertedToOutputAt" + convCount.ToString(System.Globalization.CultureInfo.InvariantCulture), job.ConversionEndTime.ToString("s", System.Globalization.CultureInfo.InvariantCulture));

                        // Send an eMail if required
                        if (sendEMail && sendSuccess)
                        {
                            string subject = Localise.GetPhrase("MCEBuddy successfully converted a video");
                            string message = Localise.GetPhrase("Source Video") + " -> " + job.OriginalFileName + "\r\n";
                            message += Localise.GetPhrase("Converted Video") + " -> " + job.ConvertedFile + "\r\n";
                            message += Localise.GetPhrase("Profile") + " -> " + job.Profile + "\r\n";
                            message += Localise.GetPhrase("Conversion Task") + " -> " + job.TaskName + "\r\n";
                            message += Localise.GetPhrase("Converted At") + " -> " + job.ConversionEndTime.ToString("s", System.Globalization.CultureInfo.InvariantCulture) + "\r\n";
                            message += Localise.GetPhrase("Time taken to convert") + " (hh:mm) -> " + (job.ConversionEndTime - job.ConversionStartTime).Hours.ToString("00") + ":" + (job.ConversionEndTime - job.ConversionStartTime).Minutes.ToString("00") + "\r\n";

                            // Check for custom subject and process
                            if (!String.IsNullOrWhiteSpace(sendSuccessSubject))
                                subject = UserCustomParams.CustomParamsReplace(sendSuccessSubject, job.WorkingPath, Path.GetDirectoryName(job.ConvertedFile), job.ConvertedFile, job.OriginalFileName, "", "", "", job.Profile, job.TaskName, job.MetaData, Log.AppLog);

                            eMailSendEngine.AddEmailToSendQueue(subject, (skipBody ? "" : message)); // Send the eMail through the email engine
                        }
                    }
                    break;

                case "Error":
                    {
                        Log.AppLog.WriteEntry(this, "Job for " + job.OriginalFileName + " has Error " + job.Status.ErrorMsg + " using Conversion Task " + job.TaskName + " and Profile " + job.Profile, Log.LogEntryType.Information, true);

                        historyIni.Write(job.OriginalFileName, "ErrorMessage" + convCount.ToString(System.Globalization.CultureInfo.InvariantCulture), job.Status.ErrorMsg);
                        historyIni.Write(job.OriginalFileName, "ErrorUsingProfile" + convCount.ToString(System.Globalization.CultureInfo.InvariantCulture), job.Profile);
                        historyIni.Write(job.OriginalFileName, "ErrorUsingTask" + convCount.ToString(System.Globalization.CultureInfo.InvariantCulture), job.TaskName);

                        // Send an eMail if required
                        if (sendEMail && sendFailed)
                        {
                            string subject = Localise.GetPhrase("MCEBuddy failed to converted a video");
                            string message = Localise.GetPhrase("Source Video") + " -> " + job.OriginalFileName + "\r\n";
                            message += Localise.GetPhrase("Profile") + " -> " + job.Profile + "\r\n";
                            message += Localise.GetPhrase("Conversion Task") + " -> " + job.TaskName + "\r\n";
                            message += Localise.GetPhrase("Error") + " -> " + job.Status.ErrorMsg + "\r\n";
                            message += Localise.GetPhrase("Failed At") + " -> " + job.ConversionEndTime.ToString("s", System.Globalization.CultureInfo.InvariantCulture) + "\r\n";

                            // Check for custom subject and process
                            if (!String.IsNullOrWhiteSpace(sendFailedSubject))
                                subject = UserCustomParams.CustomParamsReplace(sendFailedSubject, job.WorkingPath, "", job.ConvertedFile, job.OriginalFileName, "", "", "", job.Profile, job.TaskName, job.MetaData, Log.AppLog);

                            eMailSendEngine.AddEmailToSendQueue(subject, (skipBody ? "" : message)); // Send the eMail through the eMail engine
                        }
                    }
                    break;

                case "Cancelled":
                    {
                        Log.AppLog.WriteEntry(this, "Job for " + job.OriginalFileName + " Cancelled using Conversion Task " + job.TaskName + " and Profile " + job.Profile, Log.LogEntryType.Information, true);
                        historyIni.Write(job.OriginalFileName, "CancelledUsingProfile" + convCount.ToString(System.Globalization.CultureInfo.InvariantCulture), job.Profile);
                        historyIni.Write(job.OriginalFileName, "CancelledUsingTask" + convCount.ToString(System.Globalization.CultureInfo.InvariantCulture), job.TaskName);

                        // Send an eMail if required
                        if (sendEMail && sendCancelled)
                        {
                            string subject = Localise.GetPhrase("MCEBuddy cancelled a video conversion");
                            string message = Localise.GetPhrase("Source Video") + " -> " + job.OriginalFileName + "\r\n";
                            message += Localise.GetPhrase("Profile") + " -> " + job.Profile + "\r\n";
                            message += Localise.GetPhrase("Conversion Task") + " -> " + job.TaskName + "\r\n";
                            message += Localise.GetPhrase("Cancelled At") + " -> " + DateTime.Now.ToString("s", System.Globalization.CultureInfo.InvariantCulture) + "\r\n"; // It can be cancelled before it starts so end time is not a good indicator

                            // Check for custom subject and process
                            if (!String.IsNullOrWhiteSpace(sendCancelledSubject))
                                subject = UserCustomParams.CustomParamsReplace(sendCancelledSubject, job.WorkingPath, "", job.ConvertedFile, job.OriginalFileName, "", "", "", job.Profile, job.TaskName, job.MetaData, Log.AppLog);

                            eMailSendEngine.AddEmailToSendQueue(subject, (skipBody ? "" : message)); // Send the eMail through the eMail engine
                        }
                    }
                    break;

                default:
                    Log.AppLog.WriteEntry(this, "INVALID STATE (" + result + ") -> Job for " + job.OriginalFileName + " Converted using Conversion Task " + job.TaskName + " and Profile " + job.Profile, Log.LogEntryType.Error, true);

                    break;
            }

            if ( _queueManager.JobCount(job.OriginalFileName) <= 1)
            {
                // This is the last job processing this file, so write the status to the history file STATUS
                historyIni.Write(job.OriginalFileName, "Status", result); // Source file status
            }
        }
Exemplo n.º 11
0
        public void AddManualJob(string videoFilePath)
        {
            if (String.IsNullOrWhiteSpace(videoFilePath))
            {
                Log.AppLog.WriteEntry(this, "Empty filepath passed to AddManualJob", Log.LogEntryType.Error, true);
                return;
            }

            Monitor.Enter(monitorLock); // Need to ensure when this function is called, the Engine is not in Starting or stopping mode

            // Clear the status on the manually added file incase it was converted earlier or was an output of a conversion earlier, otherwise ReScan won't pick up
            Ini historyIni = new Ini(GlobalDefs.HistoryFile);
            historyIni.Write(videoFilePath, "Status", "");

            // Add to the manual queue file to pick up
            Ini manualQueueIni = new Ini(GlobalDefs.ManualQueueFile);
            manualQueueIni.Write("ManualQueue", videoFilePath, videoFilePath); // Write to a common section as key AND value since due to INI restriction only the Value can hold special characters like ];= which maybe contained in the filename, hence the Value is used to capture the "TRUE" filename (Key and Section have restrictions)

            Monitor.Exit(monitorLock); // Need to ensure when this function is called, the Engine is not in Starting or stopping mode

            _rescan = true; // Rescan the queue for new jobs
        }
Exemplo n.º 12
0
        private void StatusForm_Load(object sender, EventArgs e)
        {
            // Check for changes in screen resolution and screen changes (multi monitor support) - this HAS to be in Load and NOT in the constructor since the form has not been initiatized yet
            this.MaximumSize = Screen.FromControl(this).WorkingArea.Size; // Set the maximum size for the form based on working areas so we don't end up with dead/inaccessible locations

            // Set the version properties (Versioning is driven as Major.Minor.Build.Revision)
            MajorTitle.Text = "MCEBuddy " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.Major.ToString(System.Globalization.CultureInfo.InvariantCulture) + "." + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.Minor.ToString(System.Globalization.CultureInfo.InvariantCulture);
            if (System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.Revision == 0) // BETA versions have revision code (Major.Minor.Build.Revision) as 0
                BetaTitle.Text = "Beta " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.Build.ToString(System.Globalization.CultureInfo.InvariantCulture);
            else
                BetaTitle.Text = "Release " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.Build.ToString(System.Globalization.CultureInfo.InvariantCulture);

            Ini tempIni = new Ini(GlobalDefs.TempSettingsFile);
            // Check if this is the first time the GUI is start after an installation
            if (tempIni.ReadBoolean("GUI", "FirstStartComplete", false) == false)
            {
                MessageBox.Show(Localise.GetPhrase("Rest your mouse on any button, box or item to get Instant Help on it.\n\nFor more information on how to use, troubleshoot or get support for MCEBuddy click on the <Getting Started> link on the top right corner.\n\nDonations are always welcome :) Enjoy!\n\n  - Ramit, Derek & Goose"), Localise.GetPhrase("Welcome to MCEBuddy"));
                tempIni.Write("GUI", "FirstStartComplete", true);
            }

            // Check for server location and start the thread to keep the UI connected to the MCEBuddy engine
            string remoteServerName = tempIni.ReadString("Engine", "RemoteServerName", GlobalDefs.MCEBUDDY_SERVER_NAME);
            if (remoteServerName != GlobalDefs.MCEBUDDY_SERVER_NAME) // check if it's a remote machine
                _connectPeriod = GlobalDefs.REMOTE_ENGINE_POLL_PERIOD; // remote machine needs be pinged slower

            // If this thread is not the thread that created the control, we'll invoke a callback in a threadsafe way to fix the control
            _tryConnectThread = new Thread(TryConnect);
            _tryConnectThread.IsBackground = true; // Kill this thread if the process is closed
            _tryConnectThread.CurrentCulture = _tryConnectThread.CurrentUICulture = Localise.MCEBuddyCulture;
            _tryConnectThread.Start();

            // Start the announcement text scroll timer
            _announcementTextScrollTimer.Tick += new EventHandler(this.ScrollAnnouncementLabel);
            _announcementTextScrollTimer.Interval = 250;
            _announcementTextScrollTimer.Start();

            // Now start the core background job status thread
            backgroundUpdate.WorkerSupportsCancellation = true;
            backgroundUpdate.RunWorkerAsync();

            this.Show(); // Show the form
        }