示例#1
0
        AppendInt32GraphMLAttributeValue
        (
            XmlNode oXmlNodeToSelectFrom,
            String sXPath,
            XmlNamespaceManager oXmlNamespaceManager,
            GraphMLXmlDocument oGraphMLXmlDocument,
            XmlNode oEdgeOrVertexXmlNode,
            String sGraphMLAttributeID
        )
        {
            Debug.Assert(oXmlNodeToSelectFrom != null);
            Debug.Assert(!String.IsNullOrEmpty(sXPath));
            Debug.Assert(oGraphMLXmlDocument != null);
            Debug.Assert(oEdgeOrVertexXmlNode != null);
            Debug.Assert(!String.IsNullOrEmpty(sGraphMLAttributeID));
            AssertValid();

            Int32 iAttributeValue;

            if (XmlUtil2.TrySelectSingleNodeAsInt32(oXmlNodeToSelectFrom, sXPath,
                                                    oXmlNamespaceManager, out iAttributeValue))
            {
                oGraphMLXmlDocument.AppendGraphMLAttributeValue(
                    oEdgeOrVertexXmlNode, sGraphMLAttributeID, iAttributeValue);

                return(true);
            }

            return(false);
        }
示例#2
0
        AppendUserInformationGraphMLAttributeValues
        (
            String sUserID,
            XmlNode oVertexXmlNode,
            GraphMLXmlDocument oGraphMLXmlDocument,
            String sApiKey,
            RequestStatistics oRequestStatistics
        )
        {
            Debug.Assert(!String.IsNullOrEmpty(sUserID));
            Debug.Assert(oVertexXmlNode != null);
            Debug.Assert(oGraphMLXmlDocument != null);
            Debug.Assert(!String.IsNullOrEmpty(sApiKey));
            Debug.Assert(oRequestStatistics != null);
            AssertValid();

            String sUrl = GetFlickrMethodUrl("flickr.people.getInfo",
                                             sApiKey, GetUserIDUrlParameter(sUserID));

            XmlDocument oXmlDocument;

            if (!TryGetXmlDocument(sUrl, oRequestStatistics, out oXmlDocument))
            {
                // Ignore errors.  The user information isn't critical.

                return;
            }

            const String XPathRoot = "rsp/person/";

            AppendStringGraphMLAttributeValue(oXmlDocument,
                                              XPathRoot + "realname/text()", null, oGraphMLXmlDocument,
                                              oVertexXmlNode, RealNameID);

            AppendInt32GraphMLAttributeValue(oXmlDocument,
                                             XPathRoot + "photos/count/text()", null, oGraphMLXmlDocument,
                                             oVertexXmlNode, TotalPhotosID);

            String sIsProfessional;

            if (XmlUtil2.TrySelectSingleNodeAsString(oXmlDocument,
                                                     XPathRoot + "@ispro", null, out sIsProfessional))
            {
                oGraphMLXmlDocument.AppendGraphMLAttributeValue(oVertexXmlNode,
                                                                IsProfessionalID,
                                                                (sIsProfessional == "0") ? "No" : "Yes"
                                                                );
            }

            // Get the URL to the user's buddy icon, which is explained here:
            //
            // http://www.flickr.com/services/api/misc.buddyicons.html

            Int32  iIconServer, iIconFarm;
            String sBuddyIconUrl;

            if (
                XmlUtil2.TrySelectSingleNodeAsInt32(oXmlDocument,
                                                    XPathRoot + "@iconserver", null, out iIconServer)
                &&
                XmlUtil2.TrySelectSingleNodeAsInt32(oXmlDocument,
                                                    XPathRoot + "@iconfarm", null, out iIconFarm)
                &&
                iIconServer > 0
                )
            {
                sBuddyIconUrl = String.Format(

                    "http://farm{0}.static.flickr.com/{1}/buddyicons/{2}.jpg"
                    ,
                    iIconFarm,
                    iIconServer,
                    sUserID
                    );
            }
            else
            {
                sBuddyIconUrl = "http://www.flickr.com/images/buddyicon.jpg";
            }

            oGraphMLXmlDocument.AppendGraphMLAttributeValue(
                oVertexXmlNode, ImageFileID, sBuddyIconUrl);

            if (AppendStringGraphMLAttributeValue(oXmlDocument,
                                                  XPathRoot + "photosurl/text()", null, oGraphMLXmlDocument,
                                                  oVertexXmlNode, MenuActionID))
            {
                oGraphMLXmlDocument.AppendGraphMLAttributeValue(oVertexXmlNode,
                                                                MenuTextID, "Open Flickr Page for This Person");
            }
        }
        GetTwitterSearchNetworkConfiguration
        (
            out String searchTerm,
            out TwitterSearchNetworkAnalyzer.WhatToInclude whatToInclude,
            out Int32 maximumStatuses,
            out String networkFileFolderPath
        )
        {
            AssertValid();
            Debug.Assert(m_oNetworkConfigurationXmlDocument != null);
            Debug.Assert(GetNetworkType() == NetworkType.TwitterSearch);

            XmlNode oTwitterSearchNetworkConfigurationNode =
                XmlUtil2.SelectRequiredSingleNode(
                    m_oNetworkConfigurationXmlDocument,
                    "/NetworkConfiguration/TwitterSearchNetworkConfiguration",
                    null);

            searchTerm = XmlUtil2.SelectRequiredSingleNodeAsString(
                oTwitterSearchNetworkConfigurationNode, "SearchTerm/text()", null);

            if (!XmlUtil2.TrySelectSingleNodeAsInt32(
                    oTwitterSearchNetworkConfigurationNode,
                    "MaximumStatuses/text()", null, out maximumStatuses))
            {
                // Older versions of NodeXL used a MaximumPeoplePerRequest value,
                // which has been replaced with MaximumStatuses.  To avoid breaking
                // older configuration files, accept either one.

                try
                {
                    maximumStatuses = XmlUtil2.SelectRequiredSingleNodeAsInt32(
                        oTwitterSearchNetworkConfigurationNode,
                        "MaximumPeoplePerRequest/text()", null);
                }
                catch
                {
                    throw new XmlException(
                              "There must be a MaximumStatuses value.  (This was called"
                              + " MaximumPeoplePerRequest in previous versions of"
                              + " NodeXL.)"
                              );
                }
            }

            whatToInclude =
                GetRequiredEnumValue <TwitterSearchNetworkAnalyzer.WhatToInclude>(

                    oTwitterSearchNetworkConfigurationNode,
                    "WhatToInclude/text()",

                    // These WhatToInclude values were removed in version
                    // 1.0.1.328.  They are now automatically included in the
                    // network.   Old configuration files might still specify them,
                    // so they need to be ignored.

                    new String[] {
                "Statuses",
                "Statistics",
                "RepliesToEdges",
                "MentionsEdges",
                "NonRepliesToNonMentionsEdges",
            },

                    "None",
                    "WhatToInclude"
                    );

            GetCommonConfiguration(oTwitterSearchNetworkConfigurationNode,
                                   out networkFileFolderPath);
        }