Ejemplo n.º 1
0
        public static bool DoExport(string sExportFormat, Session[] oSessions, Dictionary <string, object> dictOptions, EventHandler <ProgressCallbackEventArgs> ehPCEA)
        {
            if (string.IsNullOrEmpty(sExportFormat))
            {
                return(false);
            }
            TranscoderTuple tuple = oTranscoders.GetExporter(sExportFormat);

            if (tuple == null)
            {
                return(false);
            }
            bool flag = false;

            try
            {
                ISessionExporter exporter = (ISessionExporter)Activator.CreateInstance(tuple.typeFormatter);
                if (ehPCEA == null)
                {
                    ehPCEA = delegate(object sender, ProgressCallbackEventArgs oPCE) {
                        string str = (oPCE.PercentComplete > 0) ? ("Export is " + oPCE.PercentComplete + "% complete; ") : string.Empty;

                        Application.DoEvents();
                    };
                }
                flag = exporter.ExportSessions(sExportFormat, oSessions, dictOptions, ehPCEA);
                exporter.Dispose();
            }
            catch (Exception exception)
            {
                LogAddonException(exception, "Exporter for " + sExportFormat + " failed.");
                flag = false;
            }
            return(flag);
        }
Ejemplo n.º 2
0
        public static Session[] DoImport(string sImportFormat, bool bAddToSessionList, Dictionary <string, object> dictOptions, EventHandler <ProgressCallbackEventArgs> ehPCEA)
        {
            Session[] sessionArray;
            if (string.IsNullOrEmpty(sImportFormat))
            {
                return(null);
            }
            TranscoderTuple tuple = oTranscoders.GetImporter(sImportFormat);

            if (tuple == null)
            {
                return(null);
            }
            try
            {
                ISessionImporter importer = (ISessionImporter)Activator.CreateInstance(tuple.typeFormatter);
                if (ehPCEA == null)
                {
                    ehPCEA = delegate(object sender, ProgressCallbackEventArgs oPCE) {
                        string str = (oPCE.PercentComplete > 0) ? ("Import is " + oPCE.PercentComplete + "% complete; ") : string.Empty;

                        Application.DoEvents();
                    };
                }
                sessionArray = importer.ImportSessions(sImportFormat, dictOptions, ehPCEA);
                importer.Dispose();
                if (sessionArray == null)
                {
                    return(null);
                }
            }
            catch (Exception exception)
            {
                LogAddonException(exception, "Importer for " + sImportFormat + " failed.");
                sessionArray = null;
            }
            return(sessionArray);
        }