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 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);
        }
Example #3
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);
        }