当前位置: 首页>>代码示例>>C#>>正文


C# IDnaDataReader.GetDoubleNullAsZero方法代码示例

本文整理汇总了C#中IDnaDataReader.GetDoubleNullAsZero方法的典型用法代码示例。如果您正苦于以下问题:C# IDnaDataReader.GetDoubleNullAsZero方法的具体用法?C# IDnaDataReader.GetDoubleNullAsZero怎么用?C# IDnaDataReader.GetDoubleNullAsZero使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDnaDataReader的用法示例。


在下文中一共展示了IDnaDataReader.GetDoubleNullAsZero方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddPrefixedUserXMLBlock

        /// <summary>
        /// Creates and adds the returned User Xml block to a given parent post node from the passed user parameters with a prefix
        /// ie the field name of OwnerUserName, OwnerFirstNames
        /// </summary>
        /// <param name="dataReader">Data reader object</param>
        /// <param name="userID">The users id</param>
        /// <param name="prefix">The prefix of the field names for a different user in the same result set</param>
        /// <param name="parent">The parent Node to add the user xml to</param>
        /// <returns>XmlNode Containing user XML from the stored procedure</returns>
        public void AddPrefixedUserXMLBlock(IDnaDataReader dataReader, int userID, string prefix, XmlNode parent)
        {
            string userName = "";
            if (dataReader.Exists(prefix + "UserName"))
            {
                userName = dataReader.GetStringNullAsEmpty(prefix + "UserName");
            }
            else if (dataReader.Exists(prefix + "Name"))
            {
                userName = dataReader.GetStringNullAsEmpty(prefix + "Name");
            }

            if (userName == String.Empty)
            {
                userName = "Member " + userID.ToString();
            }

            string identityUserId = "";
            if (dataReader.Exists(prefix + "identityUserId"))
            {
                identityUserId = dataReader.GetStringNullAsEmpty(prefix + "identityUserId");
            }

            string emailAddress = "";
            if (dataReader.Exists(prefix + "Email"))
            {
                emailAddress = dataReader.GetStringNullAsEmpty(prefix + "Email");
            }

            double zeigeistScore = 0.0;
            if (dataReader.DoesFieldExist(prefix + "ZeitgeistScore"))
            {
                zeigeistScore = dataReader.GetDoubleNullAsZero(prefix + "ZeitgeistScore");
            }

            string siteSuffix = "";
            if (dataReader.Exists(prefix + "SiteSuffix"))
            {
                siteSuffix = dataReader.GetStringNullAsEmpty(prefix + "SiteSuffix");
            }

            string area = "";
            if (dataReader.Exists(prefix + "Area"))
            {
                area = dataReader.GetStringNullAsEmpty(prefix + "Area");
            }

            string title = "";
            if (dataReader.Exists(prefix + "Title"))
            {
                title = dataReader.GetStringNullAsEmpty(prefix + "Title");
            }

            int subQuota = 0;
            if (dataReader.Exists(prefix + "SubQuota"))
            {
                subQuota = dataReader.GetInt32NullAsZero(prefix + "SubQuota");
            }

            int allocations = 0;
            if (dataReader.Exists(prefix + "Allocations"))
            {
                allocations = dataReader.GetInt32NullAsZero(prefix + "Allocations");
            }
            

            int journal = 0;
            if (dataReader.Exists(prefix + "Journal"))
            {
                journal = dataReader.GetInt32NullAsZero(prefix + "Journal");
            }

            bool isActive = false;
            if (dataReader.Exists(prefix + "Active") && !dataReader.IsDBNull(prefix + "Active"))
            {
                isActive = dataReader.GetBoolean(prefix + "Active");
            }

            DateTime dateLastNotified = DateTime.MinValue;
            if (dataReader.Exists(prefix + "DateLastNotified") && dataReader.GetValue(prefix + "DateLastNotified") != DBNull.Value)
            {
                dateLastNotified = dataReader.GetDateTime(prefix + "DateLastNotified");
            }

            DateTime dateJoined = DateTime.MinValue;
            if (dataReader.Exists(prefix + "DateJoined") && dataReader.GetValue(prefix + "DateJoined") != DBNull.Value)
            {
                dateJoined = dataReader.GetDateTime(prefix + "DateJoined");
            }
            int forumPostedTo = -1;
            if (dataReader.Exists(prefix + "ForumPostedTo"))
//.........这里部分代码省略.........
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:101,代码来源:User.cs

示例2: AddPollXml

        /// <summary>
        /// AddPollXml - Delegates responsibility of producing standard Poll Xml to the Poll Class.
        /// Only produces Poll Xml where a valid Poll exists in the resultset.
        /// </summary>
        /// <param name="dataReader">Record set containing the data</param>
        /// <param name="parent">Parent node to add the xml to</param>
        private void AddPollXml(IDnaDataReader dataReader, XmlNode parent)
        {
            if (dataReader.DoesFieldExist("CRPollID"))
            {
                int pollId = dataReader.GetInt32NullAsZero("CRPollID");
                if (pollId > 0)
                {
                    PollContentRating poll = new PollContentRating(this.InputContext, this.InputContext.ViewingUser);

                    poll.PollID = dataReader.GetInt32NullAsZero("CRPollID");
                    poll.Hidden = dataReader.GetInt32NullAsZero("Hidden") != 0;
                    int voteCount = dataReader.GetInt32NullAsZero("CRVoteCount");
                    double avgRating = dataReader.GetDoubleNullAsZero("CRAverageRating");
                    poll.SetContentRatingStatistics(voteCount, avgRating);
                    XmlNode node = poll.MakePollXML(false);
                    if (node != null)
                    {
                        parent.AppendChild(ImportNode(node));
                    }
                }
            }
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:28,代码来源:MediaAsset.cs

示例3: AddPollXml

        private void AddPollXml(IDnaDataReader dataReader, XmlNode article)
        {
            //<POLL POLLID="2311" POLLTYPE="3" HIDDEN="0">
            //    <STATISTICS AVERAGERATING="0.000000" VOTECOUNT="0" /> 
            //</POLL>

            int pollID = dataReader.GetInt32NullAsZero("CRPollID");
            if (pollID != 0)
            {
                XmlNode poll = CreateElementNode("POLL");
                AddAttribute(poll, "POLLID", pollID);
                AddAttribute(poll, "POLLTYPE", 3);
                AddAttribute(poll, "HIDDEN", 0);
                XmlNode statistics = CreateElementNode("STATISTICS");
                AddAttribute(statistics, "AVERAGERATING", dataReader.GetDoubleNullAsZero("CRAverageRating").ToString());
                AddAttribute(statistics, "VOTECOUNT", dataReader.GetInt32NullAsZero("CRVoteCount").ToString());
                poll.AppendChild(statistics);
                article.AppendChild(poll);
            }
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:20,代码来源:ArticleSubscriptionList.cs

示例4: AddArticleMemberXML

        /// <summary>
        /// Builds ARTICLEMEMBER xml based on current row in dataReader
        /// </summary>
        /// <param name="dataReader">The data reader with the data</param>
        /// <param name="articleKeyPhraseMap">The map of article key phrases</param>
        /// <returns>XML Element contain the articlemember data</returns>
        XmlElement AddArticleMemberXML(IDnaDataReader dataReader, Dictionary<int, List<Phrase>> articleKeyPhraseMap)
        {
	        ArticleMember articleMember = new ArticleMember(InputContext);

            int H2G2ID = dataReader.GetInt32NullAsZero("h2g2id");
            string name = dataReader.GetStringNullAsEmpty("subject");
            string extraInfo = dataReader.GetStringNullAsEmpty("extrainfo");

            articleMember.H2G2ID = H2G2ID;
	        articleMember.Name = name;
	        articleMember.IncludeStrippedName = true;

	        // Get and Set editor data
            articleMember.SetEditor(dataReader);

            articleMember.Status = dataReader.GetInt32NullAsZero("status");
            if (dataReader.DoesFieldExist("type"))
	        {
                articleMember.SetExtraInfo(extraInfo, dataReader.GetInt32NullAsZero("type"));
	        }
	        else
	        {
                articleMember.SetExtraInfo(extraInfo);
	        }

            articleMember.DateCreated = dataReader.GetDateTime("datecreated");
            articleMember.LastUpdated = dataReader.GetDateTime("lastupdated");
        		

	        if (InputContext.CurrentSite.IncludeCrumbtrail == 1)
	        {
                if (dataReader.DoesFieldExist("type") && dataReader.GetInt32NullAsZero("type") > 0)
                {
			        articleMember.Local = true;
		        }
	        }

            if (dataReader.DoesFieldExist("CRPollID"))
	        {
                articleMember.SetContentRatingStatistics(dataReader.GetInt32NullAsZero("CRPollID"),
                    dataReader.GetInt32NullAsZero("CRVoteCount"),
                    dataReader.GetDoubleNullAsZero("CRAverageRating"));
	        }

            if (dataReader.DoesFieldExist("MediaAssetID"))
	        {
                string caption = dataReader.GetStringNullAsEmpty("Caption");
                string extraElementXML = dataReader.GetStringNullAsEmpty("ExtraElementXML");
                string externalLinkURL = dataReader.GetStringNullAsEmpty("ExternalLinkURL");

                articleMember.SetMediaAssetInfo(dataReader.GetInt32NullAsZero("MediaAssetID"),
                                                dataReader.GetInt32NullAsZero("ContentType"),
										        caption,
                                                dataReader.GetInt32NullAsZero("MimeType"),
                                                dataReader.GetInt32NullAsZero("OwnerID"),
										        extraElementXML,
                                                dataReader.GetInt32NullAsZero("Hidden"),
										        externalLinkURL);
	        }
        	
	        bool includeKeyPhraseData = InputContext.GetSiteOptionValueBool("KeyPhrases", "ReturnInCategoryList");
	        if (includeKeyPhraseData)
	        {
                int entryId = dataReader.GetInt32NullAsZero("entryid");
		        articleMember.SetPhraseList(articleKeyPhraseMap[entryId]);
	        }
            articleMember.TryCreateXML();

            return articleMember.RootElement;
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:76,代码来源:Category.cs

示例5: GenerateArticleSearchXml


//.........这里部分代码省略.........
                        //Add Extra Info XML where it exists.
                        string extraInfo = dataReader.GetAmpersandEscapedStringNullAsEmpty("EXTRAINFO");
                        if (extraInfo != string.Empty)
                        {

                            XmlDocument extraInfoXml = new XmlDocument();
                            extraInfoXml.LoadXml(extraInfo);
                            article.AppendChild(ImportNode(extraInfoXml.FirstChild));

                        }

                        AddTextTag(article, "NUMBEROFPOSTS", dataReader.GetInt32NullAsZero("ForumPostCount"));
                        AddDateXml(dataReader, article, "LASTPOSTED", "FORUMLASTPOSTED");
                        if (!dataReader.IsDBNull("StartDate"))
                        {
                            AddDateXml(dataReader, article, "StartDate", "DATERANGESTART");
                            // Take a day from the end date as stored in the database for UI purposes. 
                            // E.g. User submits a date range of 01/09/1980 to 02/09/1980. They mean for this to represent 2 days i.e. 01/09/1980 00:00 - 03/09/1980 00:00. 
                            // This gets stored in the database but for display purposes we subtract a day from the database end date to return the 
                            // original dates submitted by the user inorder to match their expectations.
                            AddDateXml(dataReader.GetDateTime("EndDate").AddDays(-1), article, "DATERANGEEND");

                            AddTextTag(article, "TIMEINTERVAL", dataReader.GetInt32NullAsZero("TimeInterval"));
                        }


                        if (dataReader.DoesFieldExist("BookmarkCount"))
                        {
                            AddTextTag(article, "BOOKMARKCOUNT", dataReader.GetInt32NullAsZero("BookmarkCount"));
                        }

                        if (dataReader.DoesFieldExist("ZeitgeistScore"))
                        {
                            AddElement(article, "ZEITGEIST", "<SCORE>" + dataReader.GetDoubleNullAsZero("ZeitgeistScore") + "</SCORE>");
                        }

                        

                        #region LocationXML
                        //***********************************************************************
                        // Location Info
                        //***********************************************************************
                        if (dataReader.DoesFieldExist("Latitude") && !dataReader.IsDBNull("Latitude"))
                        {
                            AddTextTag(article, "LATITUDE", dataReader.GetDoubleNullAsZero("Latitude").ToString());
                            AddTextTag(article, "LONGITUDE", dataReader.GetDoubleNullAsZero("Longitude").ToString());
                            if (dataReader.DoesFieldExist("Distance"))
                            {
                                if (dataReader.GetDoubleNullAsZero("Distance") < 0.0001)
                                {
                                    AddTextTag(article, "DISTANCE", "0");
                                }
                                else
                                {
                                    AddTextTag(article, "DISTANCE", dataReader.GetDoubleNullAsZero("Distance").ToString());
                                }
                            }
                            AddTextTag(article, "LOCATIONTITLE", dataReader.GetString("LocationTitle"));
                            AddTextTag(article, "LOCATIONDESCRIPTION", dataReader.GetString("LocationDescription"));
                            AddTextTag(article, "LOCATIONZOOMLEVEL", dataReader.GetInt32NullAsZero("LocationZoomLevel").ToString());
                            AddTextTag(article, "LOCATIONUSERID", dataReader.GetInt32NullAsZero("LocationUserID").ToString());
                            AddDateXml(dataReader.GetDateTime("LocationDateCreated"), article, "LOCATIONDATECREATED");
                        }
                        //***********************************************************************
                        #endregion
                        //***********************************************************************
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:67,代码来源:ArticleSearch.cs

示例6: GenerateArticleSearchHotlistXml

        /// <summary>
        /// Adds in the key phrase hotlist 
        /// </summary>
        /// <param name="dataReader">Data set to turn into XML</param>
        /// <param name="skip">Number of articles to skip</param>
        /// <param name="show">Number of articles to show</param>
        /// <param name="contentType">Type of articles to articles to search for </param>
        /// <param name="sortBy">sortby option for the search</param>
        private void GenerateArticleSearchHotlistXml(IDnaDataReader dataReader,
            int skip,
            int show,
            int contentType,
            string sortBy)
        {
            int count = 0;
            XmlElement articleSearchHotlist = AddElementTag(RootElement, "ARTICLEHOT-PHRASES");

            AddAttribute(articleSearchHotlist, "CONTENTTYPE", contentType);
            AddAttribute(articleSearchHotlist, "SORTBY", sortBy);
            AddAttribute(articleSearchHotlist, "SKIP", skip);
            AddAttribute(articleSearchHotlist, "SHOW", show);

            if (dataReader.HasRows)
            {
                if (dataReader.Read())
                {
                    count = dataReader.GetInt32NullAsZero("Count");
                    do
                    {
                        XmlElement phrase = AddElementTag(articleSearchHotlist, "ARTICLEHOT-PHRASE");

                        string rawPhrase = dataReader.GetStringNullAsEmpty("phrase");

                        //If phrase contains token then quote.
                        string URLPhrase = rawPhrase;
                        if (rawPhrase.Contains(_token))
                        {
                            URLPhrase = "" + rawPhrase + "";
                        }

                        AddTextElement(phrase, "NAME", StringUtils.EscapeAllXml(rawPhrase));
                        AddTextElement(phrase, "TERM", Uri.EscapeDataString(URLPhrase));
                        AddTextElement(phrase, "RANK", (dataReader.GetDoubleNullAsZero("Rank")).ToString());

                    } while (dataReader.Read());
                }
            }
            AddAttribute(articleSearchHotlist, "COUNT", count.ToString());
            if (count > skip + show)
            {
                AddAttribute(articleSearchHotlist, "MORE", 1);
            }
            else
            {
                AddAttribute(articleSearchHotlist, "MORE", 0);
            }

            FileCache.PutItem(AppContext.TheAppContext.Config.CachePath, "articlekeyphrase", _cacheName, articleSearchHotlist.OuterXml);
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:59,代码来源:ArticleSearch.cs

示例7: CreateList


//.........这里部分代码省略.........

                        //TODO Use Extra Info Class will need to change SP to get out the guide entry Type
                        //ExtraInfo extraInfo = new ExtraInfo();
                        //extraInfo.TryCreate(dataReader.GetInt32NullAsZero("Type"), dataReader.GetStringNullAsEmpty("ExtraInfo"));
                        //AddInside(article, extraInfo);
                    }

                    if (dataReader.DoesFieldExist("ForumPostCount"))
                    {
                        AddIntElement(article, "FORUMPOSTCOUNT", dataReader.GetInt32NullAsZero("ForumPostCount"));
                        AddIntElement(article, "FORUMPOSTLIMIT", InputContext.GetSiteOptionValueInt("Forum", "PostLimit"));
                    }

                    if (dataReader.DoesFieldExist("StartDate") && !dataReader.IsDBNull("StartDate"))
                    {
                        AddDateXml(dataReader, article, "StartDate", "DATERANGESTART");
                    }
                    // Take a day from the end date as stored in the database for UI purposes. 
                    // E.g. User submits a date range of 01/09/1980 to 02/09/1980. They mean for this to represent 2 days i.e. 01/09/1980 00:00 - 03/09/1980 00:00. 
                    // This gets stored in the database but for display purposes we subtract a day from the database end date to return the 
                    // original dates submitted by the user inorder to match their expectations.
                    if (dataReader.DoesFieldExist("EndDate") && !dataReader.IsDBNull("EndDate"))
                    {
                        AddDateXml(dataReader.GetDateTime("EndDate").AddDays(-1), article, "DATERANGEEND");
                    }

                    if (dataReader.DoesFieldExist("TimeInterval"))
                    {
                        AddIntElement(article, "TIMEINTERVAL", dataReader.GetInt32NullAsZero("TimeInterval"));
                    }

                    if (dataReader.DoesFieldExist("LASTPOSTED"))
                    {
                        AddDateXml(dataReader, article, "LASTPOSTED", "FORUMLASTPOSTED");
                    }
                    //////////


                    if (dataReader.DoesFieldExist("BookmarkCount"))
                    {
                        AddTextTag(article, "BOOKMARKCOUNT", dataReader.GetInt32NullAsZero("BookmarkCount"));
                    }

                    if (dataReader.DoesFieldExist("ZeitgeistScore"))
                    {
                        AddElement(article, "ZEITGEIST", "<SCORE>" + dataReader.GetDoubleNullAsZero("ZeitgeistScore") + "</SCORE>");
                    }

                    #region LocationXML
                    //***********************************************************************
                    // Location Info
                    //***********************************************************************
                    if (dataReader.DoesFieldExist("Latitude") && !dataReader.IsDBNull("Latitude"))
                    {
                        AddTextTag(article, "LATITUDE", dataReader.GetDoubleNullAsZero("Latitude").ToString());
                        AddTextTag(article, "LONGITUDE", dataReader.GetDoubleNullAsZero("Longitude").ToString());
                        if (dataReader.DoesFieldExist("Distance"))
                        {
                            if (dataReader.GetDoubleNullAsZero("Distance") < 0.0001)
                            {
                                AddTextTag(article, "DISTANCE", "0");
                            }
                            else
                            {
                                AddTextTag(article, "DISTANCE", dataReader.GetDoubleNullAsZero("Distance").ToString());
                            }
                        }
                        AddTextTag(article, "LOCATIONTITLE", dataReader.GetString("LocationTitle"));
                        AddTextTag(article, "LOCATIONDESCRIPTION", dataReader.GetString("LocationDescription"));
                        AddTextTag(article, "LOCATIONZOOMLEVEL", dataReader.GetInt32NullAsZero("LocationZoomLevel").ToString());
                        AddTextTag(article, "LOCATIONUSERID", dataReader.GetInt32NullAsZero("LocationUserID").ToString());
                        AddDateXml(dataReader.GetDateTime("LocationDateCreated"), article, "LOCATIONDATECREATED");
                    }
                    //***********************************************************************
                    #endregion

                    if (dataReader.DoesFieldExist("MediaAssetID"))
                    {
                        AddMediaAssetXml(dataReader, article, dataReader.GetInt32NullAsZero("MediaAssetID"));
                    }

                    if (dataReader.DoesFieldExist("CRPollID"))
                    {
                        AddPollXml(dataReader, article);
                    }



                    count--;

                } while (count > 0 && dataReader.Read());	// dataReader.Read won't get called if count == 0

                // See if there's an extra row waiting
                if (count == 0 && dataReader.Read())
                {
                    AddAttribute(articleList, "MORE", 1);
                }
            }
            return count;
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:101,代码来源:ArticleList.cs

示例8: CreateRouteXML

        /// <summary>
        /// CreateRouteXML from a dataReader.
        /// Allows standard Route XML to be generated from different resultsets.
        /// </summary>
        /// <param name="dataReader"></param>
        /// <param name="includeLocations">Whether the locations need to be included or just route info</param>
        public void CreateRouteXML(IDnaDataReader dataReader, bool includeLocations)
        {
            int count = 0;
            XmlElement routeXML = (XmlElement) AddElementTag(RootElement, "ROUTE");

            if (dataReader.HasRows && dataReader.DoesFieldExist("RouteID"))
            {
                AddAttribute(routeXML, "ROUTEID", dataReader.GetInt32NullAsZero("RouteID").ToString());

                AddTextTag(routeXML, "ROUTETITLE", dataReader.GetStringNullAsEmpty("RouteTitle"));
                AddTextTag(routeXML, "ROUTEDESCRIPTION", dataReader.GetStringNullAsEmpty("RouteDescription"));
                AddTextTag(routeXML, "DESCRIBINGARTICLEID", dataReader.GetInt32NullAsZero("H2G2ID").ToString());
                AddTextTag(routeXML, "SUBJECT", dataReader.GetStringNullAsEmpty("Subject"));
                //AddTextTag(routeXML, "GPSTRACKDATALOCATION", dataReader.GetStringNullAsEmpty("GPSTRACKDATALOCATION"));

                if (includeLocations)
                {
                    XmlElement locations = AddElementTag(routeXML, "LOCATIONS");
                    if (dataReader.NextResult() && dataReader.Read())
                    {
                        do
                        {
                            count++;
                            XmlElement location = AddElementTag(locations, "LOCATION");
                            location.SetAttribute("LOCATIONID", dataReader.GetInt32NullAsZero("LocationID").ToString());
                            location.SetAttribute("ORDER", dataReader.GetInt32NullAsZero("Order").ToString());

                            AddTextTag(location, "LATITUDE", dataReader.GetDoubleNullAsZero("Latitude").ToString());
                            AddTextTag(location, "LONGITUDE", dataReader.GetDoubleNullAsZero("Longitude").ToString());
                            AddTextTag(location, "LOCATIONTITLE", dataReader.GetStringNullAsEmpty("LocationTitle"));
                            AddTextTag(location, "LOCATIONDESCRIPTION", dataReader.GetStringNullAsEmpty("LocationDescription"));
                            AddTextTag(location, "LOCATIONZOOMLEVEL", dataReader.GetInt32NullAsZero("LocationZoomLevel").ToString());
                            AddTextTag(location, "LOCATIONUSERID", dataReader.GetInt32NullAsZero("LocationUserID").ToString());
                            AddDateXml(dataReader.GetDateTime("LocationDateCreated"), location, "LOCATIONDATECREATED");
                        } while (dataReader.Read());
                    }
                    AddAttribute(locations, "COUNT", count.ToString());
                }
            }
        }    
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:46,代码来源:Route.cs


注:本文中的IDnaDataReader.GetDoubleNullAsZero方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。