SetUp()
    {
        m_oNetworkConfigurationFileParser =
            new NetworkConfigurationFileParser();

        m_sTempFileName = Path.GetTempFileName();
    }
Beispiel #2
0
    RunProgram
    (
        string[] args
    )
    {
        String sNetworkConfigurationFilePath;

        ParseCommandLine(args, out sNetworkConfigurationFilePath);

        NetworkConfigurationFileParser oNetworkConfigurationFileParser =
            new NetworkConfigurationFileParser();

        NetworkType eNetworkType = NetworkType.TwitterSearch;

        try
        {
            oNetworkConfigurationFileParser.OpenNetworkConfigurationFile(
                sNetworkConfigurationFilePath);

            eNetworkType = oNetworkConfigurationFileParser.GetNetworkType();
        }
        catch (XmlException oXmlException)
        {
            OnNetworkConfigurationFileException(oXmlException);
        }

        XmlDocument oXmlDocument = null;
        String sNetworkFileFolderPath = null;
        DateTime oStartTime = DateTime.Now;
        NetworkFileFormats eNetworkFileFormats = NetworkFileFormats.None;
        String sNodeXLWorkbookSettingsFilePath = null;
        Boolean bAutomateNodeXLWorkbook = false;

        switch (eNetworkType)
        {
            case NetworkType.TwitterSearch:

                GetTwitterSearchNetwork(oStartTime,
                    sNetworkConfigurationFilePath,
                    oNetworkConfigurationFileParser, out oXmlDocument,
                    out sNetworkFileFolderPath, out eNetworkFileFormats,
                    out sNodeXLWorkbookSettingsFilePath,
                    out bAutomateNodeXLWorkbook);

                break;

            case NetworkType.TwitterUser:

                GetTwitterUserNetwork(oStartTime,
                    sNetworkConfigurationFilePath,
                    oNetworkConfigurationFileParser, out oXmlDocument,
                    out sNetworkFileFolderPath, out eNetworkFileFormats,
                    out sNodeXLWorkbookSettingsFilePath,
                    out bAutomateNodeXLWorkbook);

                break;

            case NetworkType.TwitterList:

                GetTwitterListNetwork(oStartTime,
                    sNetworkConfigurationFilePath,
                    oNetworkConfigurationFileParser, out oXmlDocument,
                    out sNetworkFileFolderPath, out eNetworkFileFormats,
                    out sNodeXLWorkbookSettingsFilePath,
                    out bAutomateNodeXLWorkbook);

                break;

            default:

                Debug.Assert(false);
                break;
        }

        Debug.Assert(oXmlDocument != null);

        SaveNetwork(oStartTime, oXmlDocument, sNetworkConfigurationFilePath,
            sNetworkFileFolderPath, eNetworkFileFormats,
            sNodeXLWorkbookSettingsFilePath, bAutomateNodeXLWorkbook);

        Exit(ExitCode.Success, null);
    }
Beispiel #3
0
    GetTwitterListNetwork
    (
        DateTime oStartTime,
        String sNetworkConfigurationFilePath,
        NetworkConfigurationFileParser oNetworkConfigurationFileParser,
        out XmlDocument oXmlDocument,
        out String sNetworkFileFolderPath,
        out NetworkFileFormats eNetworkFileFormats,
        out String sNodeXLWorkbookSettingsFilePath,
        out Boolean bAutomateNodeXLWorkbook
    )
    {
        Debug.Assert( !String.IsNullOrEmpty(sNetworkConfigurationFilePath) );
        Debug.Assert(oNetworkConfigurationFileParser != null);

        oXmlDocument = null;
        sNetworkFileFolderPath = null;
        eNetworkFileFormats = NetworkFileFormats.None;
        sNodeXLWorkbookSettingsFilePath = null;
        bAutomateNodeXLWorkbook = false;

        Boolean bUseListName = false;
        String sListName = null;
        ICollection<String> oScreenNames = null;

        TwitterListNetworkAnalyzer.WhatToInclude eWhatToInclude =
            TwitterListNetworkAnalyzer.WhatToInclude.None;

        try
        {
            oNetworkConfigurationFileParser.GetTwitterListNetworkConfiguration(
                out bUseListName, out sListName, out oScreenNames,
                out eWhatToInclude, out sNetworkFileFolderPath,
                out eNetworkFileFormats, out sNodeXLWorkbookSettingsFilePath,
                out bAutomateNodeXLWorkbook);
        }
        catch (XmlException oXmlException)
        {
            // (This call exits the program.)

            OnNetworkConfigurationFileException(oXmlException);
        }

        TwitterListNetworkAnalyzer oTwitterListNetworkAnalyzer =
            new TwitterListNetworkAnalyzer();

        oTwitterListNetworkAnalyzer.ProgressChanged +=
            new ProgressChangedEventHandler(
                HttpNetworkAnalyzer_ProgressChanged);

        Console.WriteLine(
            "Getting the Twitter List network specified in \"{0}\"."
            ,
            sNetworkConfigurationFilePath
            );

        try
        {
            oXmlDocument = oTwitterListNetworkAnalyzer.GetNetwork(bUseListName,
                sListName, oScreenNames, eWhatToInclude);
        }
        catch (PartialNetworkException oPartialNetworkException)
        {
            oXmlDocument = OnGetNetworkPartialNetworkException(oStartTime,
                oPartialNetworkException, sNetworkConfigurationFilePath,
                sNetworkFileFolderPath, oTwitterListNetworkAnalyzer);
        }
        catch (Exception oException)
        {
            // (This call exits the program.)

            OnGetNetworkOtherException(oStartTime, oException,
                sNetworkConfigurationFilePath, sNetworkFileFolderPath,
                oTwitterListNetworkAnalyzer);
        }
    }
Beispiel #4
0
    GetTwitterUserNetwork
    (
        DateTime oStartTime,
        String sNetworkConfigurationFilePath,
        NetworkConfigurationFileParser oNetworkConfigurationFileParser,
        out XmlDocument oXmlDocument,
        out String sNetworkFileFolderPath,
        out NetworkFileFormats eNetworkFileFormats,
        out String sNodeXLWorkbookSettingsFilePath,
        out Boolean bAutomateNodeXLWorkbook
    )
    {
        Debug.Assert( !String.IsNullOrEmpty(sNetworkConfigurationFilePath) );
        Debug.Assert(oNetworkConfigurationFileParser != null);

        oXmlDocument = null;
        sNetworkFileFolderPath = null;
        eNetworkFileFormats = NetworkFileFormats.None;
        sNodeXLWorkbookSettingsFilePath = null;
        bAutomateNodeXLWorkbook = false;

        String sScreenNameToAnalyze = null;

        TwitterUserNetworkAnalyzer.WhatToInclude eWhatToInclude =
            TwitterUserNetworkAnalyzer.WhatToInclude.None;

        NetworkLevel eNetworkLevel = NetworkLevel.One;
        Int32 iMaximumPeoplePerRequest = Int32.MaxValue;

        try
        {
            oNetworkConfigurationFileParser.GetTwitterUserNetworkConfiguration(
                out sScreenNameToAnalyze, out eWhatToInclude,
                out eNetworkLevel, out iMaximumPeoplePerRequest,
                out sNetworkFileFolderPath, out eNetworkFileFormats,
                out sNodeXLWorkbookSettingsFilePath,
                out bAutomateNodeXLWorkbook);
        }
        catch (XmlException oXmlException)
        {
            // (This call exits the program.)

            OnNetworkConfigurationFileException(oXmlException);
        }

        TwitterUserNetworkAnalyzer oTwitterUserNetworkAnalyzer =
            new TwitterUserNetworkAnalyzer();

        oTwitterUserNetworkAnalyzer.ProgressChanged +=
            new ProgressChangedEventHandler(
                HttpNetworkAnalyzer_ProgressChanged);

        Console.WriteLine(
            "Getting the Twitter User network specified in \"{0}\".  The"
            + " screen name is \"{1}\"."
            ,
            sNetworkConfigurationFilePath,
            sScreenNameToAnalyze
            );

        try
        {
            oXmlDocument = oTwitterUserNetworkAnalyzer.GetNetwork(
                sScreenNameToAnalyze, eWhatToInclude, eNetworkLevel,
                iMaximumPeoplePerRequest);
        }
        catch (PartialNetworkException oPartialNetworkException)
        {
            oXmlDocument = OnGetNetworkPartialNetworkException(oStartTime,
                oPartialNetworkException, sNetworkConfigurationFilePath,
                sNetworkFileFolderPath, oTwitterUserNetworkAnalyzer);
        }
        catch (Exception oException)
        {
            // (This call exits the program.)

            OnGetNetworkOtherException(oStartTime, oException,
                sNetworkConfigurationFilePath, sNetworkFileFolderPath,
                oTwitterUserNetworkAnalyzer);
        }
    }
        public void TearDown()
        {
            m_oNetworkConfigurationFileParser = null;

            if ( File.Exists(m_sTempFileName) )
            {
            File.Delete(m_sTempFileName);
            }
        }
 //*************************************************************************
 //  Constructor: NetworkConfigurationFileParserTest()
 //
 /// <summary>
 /// Initializes a new instance of the <see
 /// cref="NetworkConfigurationFileParserTest" /> class.
 /// </summary>
 //*************************************************************************
 public NetworkConfigurationFileParserTest()
 {
     m_oNetworkConfigurationFileParser = null;
     m_sTempFileName = null;
 }