Esempio n. 1
0
        GetTwitterSearchNetwork
        (
            DateTime oStartTime,
            String sNetworkConfigurationFilePath,
            NetworkConfigurationFileParser oNetworkConfigurationFileParser,
            out XmlDocument oXmlDocument,
            out String sNetworkFileFolderPath,
            out NetworkFileFormats eNetworkFileFormats,
            out Boolean bAutomateNodeXLWorkbook
        )
        {
            Debug.Assert(!String.IsNullOrEmpty(sNetworkConfigurationFilePath));
            Debug.Assert(oNetworkConfigurationFileParser != null);

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

            String sSearchTerm = null;

            TwitterSearchNetworkAnalyzer.WhatToInclude eWhatToInclude =
                TwitterSearchNetworkAnalyzer.WhatToInclude.None;

            Int32 iMaximumPeoplePerRequest = Int32.MaxValue;

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

                OnNetworkConfigurationFileException(oXmlException);
            }

            TwitterSearchNetworkAnalyzer oTwitterSearchNetworkAnalyzer =
                new TwitterSearchNetworkAnalyzer();

            oTwitterSearchNetworkAnalyzer.ProgressChanged +=
                new ProgressChangedEventHandler(
                    HttpNetworkAnalyzer_ProgressChanged);

            Console.WriteLine(
                "Getting the Twitter Search network specified in \"{0}\".  The"
                + " search term is \"{1}\"."
                ,
                sNetworkConfigurationFilePath,
                sSearchTerm
                );

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

                OnGetNetworkOtherException(oStartTime, oException,
                                           sNetworkConfigurationFilePath, sNetworkFileFolderPath,
                                           oTwitterSearchNetworkAnalyzer);
            }
        }
Esempio n. 2
0
        GetTwitterSearchNetwork
        (
            DateTime oStartTime,
            String sNetworkConfigurationFilePath,
            NetworkConfigurationFileParser oNetworkConfigurationFileParser,
            out XmlDocument oXmlDocument,
            out String sNetworkFileFolderPath
        )
        {
            Debug.Assert(!String.IsNullOrEmpty(sNetworkConfigurationFilePath));
            Debug.Assert(oNetworkConfigurationFileParser != null);

            oXmlDocument           = null;
            sNetworkFileFolderPath = null;

            String sSearchTerm = null;

            TwitterSearchNetworkAnalyzer.WhatToInclude eWhatToInclude =
                TwitterSearchNetworkAnalyzer.WhatToInclude.None;

            Int32 iMaximumTweets = Int32.MinValue;

            try
            {
                oNetworkConfigurationFileParser.
                GetTwitterSearchNetworkConfiguration(out sSearchTerm,
                                                     out eWhatToInclude, out iMaximumTweets,
                                                     out sNetworkFileFolderPath);
            }
            catch (XmlException oXmlException)
            {
                // (This call exits the program.)

                OnNetworkConfigurationFileException(oXmlException);
            }

            TwitterSearchNetworkAnalyzer oTwitterSearchNetworkAnalyzer =
                new TwitterSearchNetworkAnalyzer();

            SubscribeToProgressChangedEvent(oTwitterSearchNetworkAnalyzer);

            Console.WriteLine(
                "Getting the Twitter search network specified in \"{0}\".  The"
                + " search term is \"{1}\"."
                ,
                sNetworkConfigurationFilePath,
                sSearchTerm
                );

            try
            {
                oXmlDocument = oTwitterSearchNetworkAnalyzer.GetNetwork(
                    sSearchTerm, eWhatToInclude, iMaximumTweets);
            }
            catch (Exception oException)
            {
                // Note that this call might exit the program.

                oXmlDocument = OnGetNetworkException(oStartTime, oException,
                                                     sNetworkConfigurationFilePath, sNetworkFileFolderPath,
                                                     oTwitterSearchNetworkAnalyzer);
            }
        }