Ejemplo n.º 1
0
        GetGraphServerTwitterSearchNetwork
        (
            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;
            Int32   iStartDateInDaysBeforeToday   = Int32.MinValue;
            Int32   iMaximumStatusesGoingBackward = Int32.MinValue;
            Boolean bExpandStatusUrls             = false;
            String  sGraphServerUserName          = null;
            String  sGraphServerPassword          = null;

            try
            {
                oNetworkConfigurationFileParser.
                GetGraphServerTwitterSearchNetworkConfiguration(
                    out sSearchTerm,
                    out iStartDateInDaysBeforeToday,
                    out iMaximumStatusesGoingBackward,
                    out bExpandStatusUrls,
                    out sGraphServerUserName,
                    out sGraphServerPassword,
                    out sNetworkFileFolderPath
                    );
            }
            catch (XmlException oXmlException)
            {
                // (This call exits the program.)

                OnNetworkConfigurationFileException(oXmlException);
            }

            DateTime oMaximumStatusDateUtc = GetMaximumStatusDateUtc(
                oStartTime, iStartDateInDaysBeforeToday);

            GraphServerTwitterSearchNetworkAnalyzer
                oGraphServerTwitterSearchNetworkAnalyzer =
                new GraphServerTwitterSearchNetworkAnalyzer();

            SubscribeToProgressChangedEvent(
                oGraphServerTwitterSearchNetworkAnalyzer);

            Console.WriteLine(
                "Getting the Graph Server Twitter search network specified in"
                + " \"{0}\".  The search term is \"{1}\".  The start date is"
                + " {2}, UTC.  The maximum number of tweets going backward is {3}."
                ,
                sNetworkConfigurationFilePath,
                sSearchTerm,
                oMaximumStatusDateUtc,
                iMaximumStatusesGoingBackward
                );

            try
            {
                oXmlDocument = oGraphServerTwitterSearchNetworkAnalyzer.GetNetwork(
                    sSearchTerm, oMaximumStatusDateUtc,
                    iMaximumStatusesGoingBackward, bExpandStatusUrls,
                    sGraphServerUserName, sGraphServerPassword);
            }
            catch (Exception oException)
            {
                // Note that this call might exit the program.

                oXmlDocument = OnGetNetworkException(oStartTime, oException,
                                                     sNetworkConfigurationFilePath, sNetworkFileFolderPath,
                                                     oGraphServerTwitterSearchNetworkAnalyzer);
            }
        }
Ejemplo n.º 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;

            switch (eNetworkType)
            {
            case NetworkType.TwitterSearch:

                GetTwitterSearchNetwork(oStartTime,
                                        sNetworkConfigurationFilePath,
                                        oNetworkConfigurationFileParser, out oXmlDocument,
                                        out sNetworkFileFolderPath);

                break;

            case NetworkType.GraphServerTwitterSearch:

                GetGraphServerTwitterSearchNetwork(oStartTime,
                                                   sNetworkConfigurationFilePath,
                                                   oNetworkConfigurationFileParser, out oXmlDocument,
                                                   out sNetworkFileFolderPath);

                break;

            default:

                Debug.Assert(false);
                break;
            }

            Debug.Assert(oXmlDocument != null);

            SaveNetworkToGraphML(oStartTime, oXmlDocument,
                                 sNetworkConfigurationFilePath, sNetworkFileFolderPath);

            Exit(ExitCode.Success, null);
        }
Ejemplo n.º 3
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);
            }
        }