Example #1
0
        public static Session[] DoImport(string sImportFormat, bool bAddToSessionList, Dictionary <string, object> dictOptions, EventHandler <ProgressCallbackEventArgs> ehPCEA)
        {
            if (string.IsNullOrEmpty(sImportFormat))
            {
                return(null);
            }
            TranscoderTuple importer = FiddlerApplication.oTranscoders.GetImporter(sImportFormat);

            if (importer == null)
            {
                return(null);
            }
            Session[] array;
            try
            {
                ISessionImporter sessionImporter = (ISessionImporter)Activator.CreateInstance(importer.typeFormatter);
                if (ehPCEA == null)
                {
                    ehPCEA = delegate(object sender, ProgressCallbackEventArgs e)
                    {
                        string text = (e.PercentComplete > 0) ? ("Import is " + e.PercentComplete + "% complete; ") : string.Empty;
                        FiddlerApplication.Log.LogFormat("{0}{1}", new object[]
                        {
                            text,
                            e.ProgressText
                        });
                        Application.DoEvents();
                    };
                }
                array = sessionImporter.ImportSessions(sImportFormat, dictOptions, ehPCEA);
                sessionImporter.Dispose();
                if (array == null)
                {
                    return(null);
                }
            }
            catch (Exception eX)
            {
                FiddlerApplication.LogAddonException(eX, "Importer for " + sImportFormat + " failed.");
                array = null;
            }
            return(array);
        }
Example #2
0
        public static bool DoExport(string sExportFormat, Session[] oSessions, Dictionary <string, object> dictOptions, EventHandler <ProgressCallbackEventArgs> ehPCEA)
        {
            if (string.IsNullOrEmpty(sExportFormat))
            {
                return(false);
            }
            TranscoderTuple exporter = FiddlerApplication.oTranscoders.GetExporter(sExportFormat);

            if (exporter == null)
            {
                FiddlerApplication.Log.LogFormat("No exporter for the format '{0}' was available.", new object[]
                {
                    sExportFormat
                });
                return(false);
            }
            bool result = false;

            try
            {
                ISessionExporter sessionExporter = (ISessionExporter)Activator.CreateInstance(exporter.typeFormatter);
                if (ehPCEA == null)
                {
                    ehPCEA = delegate(object sender, ProgressCallbackEventArgs e)
                    {
                        string text = (e.PercentComplete > 0) ? ("Export is " + e.PercentComplete + "% complete; ") : string.Empty;
                        FiddlerApplication.Log.LogFormat("{0}{1}", new object[]
                        {
                            text,
                            e.ProgressText
                        });
                    };
                }
                result = sessionExporter.ExportSessions(sExportFormat, oSessions, dictOptions, ehPCEA);
                sessionExporter.Dispose();
            }
            catch (Exception eX)
            {
                FiddlerApplication.LogAddonException(eX, "Exporter for " + sExportFormat + " failed.");
                result = false;
            }
            return(result);
        }
Example #3
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
            {
                if (CONFIG.IsMicrosoftMachine)
                {
                    logSelfHost(130);
                }
                UI.UseWaitCursor = true;
                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;
                        Log.LogFormat("{0}{1}", new object[] { str, oPCE.ProgressText });
                        Application.DoEvents();
                    };
                }
                flag = exporter.ExportSessions(sExportFormat, oSessions, dictOptions, ehPCEA);
                exporter.Dispose();
            }
            catch (Exception exception)
            {
                LogAddonException(exception, "Exporter for " + sExportFormat + " failed.");
                flag = false;
            }
            UI.UseWaitCursor = false;
            return(flag);
        }
Example #4
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
            {
                if (CONFIG.IsMicrosoftMachine)
                {
                    logSelfHost(120);
                }
                UI.UseWaitCursor = true;
                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;
                        Log.LogFormat("{0}{1}", new object[] { str, oPCE.ProgressText });
                        Application.DoEvents();
                    };
                }
                sessionArray = importer.ImportSessions(sImportFormat, dictOptions, ehPCEA);
                importer.Dispose();
                if (sessionArray == null)
                {
                    UI.UseWaitCursor = false;
                    return(null);
                }
                if (bAddToSessionList)
                {
                    try
                    {
                        UI.lvSessions.BeginUpdate();
                        foreach (Session session in sessionArray)
                        {
                            session.SetBitFlag(SessionFlags.ImportedFromOtherTool, true);
                            UI.addSession(session);
                            UI.finishSession(session);
                        }
                    }
                    finally
                    {
                        UI.lvSessions.EndUpdate();
                    }
                }
            }
            catch (Exception exception)
            {
                LogAddonException(exception, "Importer for " + sImportFormat + " failed.");
                sessionArray = null;
            }
            UI.UseWaitCursor = false;
            return(sessionArray);
        }