public void StartPerformanceMeasure(string name, string categoryName, string subcategoryName, ExtraInfo extraInfo = null)
        {
            try
            {
                if (!AppInfoCenterConfiguration.GetConfig().PerformanceServiceConfig.PerformanceMeasureConfig.Enabled) return;
                if (HttpContext.Current == null) return;
                Dictionary<string, PerformanceInfo> info = HttpContext.Current.Items[AppInfoCenterConfiguration.Const.ContextPerformanceMeasureKey] as Dictionary<string, PerformanceInfo>;
                if (info == null) info = new Dictionary<string, PerformanceInfo>();

                if (!info.ContainsKey(name))
                {
                    info.Add(name, new PerformanceInfo
                    {
                        Name = name,
                        sw = Stopwatch.StartNew(),
                        threadTime = GetCurrentThreadTimes(),
                        PerformancePoints = new Dictionary<string, PerformancePoint>(),
                    });
                }
                HttpContext.Current.Items[AppInfoCenterConfiguration.Const.ContextPerformanceMeasureKey] = info;
            }
            catch (Exception ex)
            {
                ex.Handle(AppInfoCenterService.ModuleName, ServiceName, "StartPerformanceMeasure");
            }
        }
        private void LoadXml()
        {
            _packageDescriptions = new Dictionary<string, List<KeyValuePair<PackageDescription, ExtraInfo>>>();
            _eulaTexts = new Dictionary<string, Dictionary<Guid, string>>();

            XDocument doc = XDocumentUtils.Load(_configFilePath);

            foreach (XElement element in doc.Root.Elements("Source"))
            {
                XAttribute urlAttribute = element.Attribute("url");

                List<KeyValuePair<PackageDescription, ExtraInfo>> packageDescriptions = new List<KeyValuePair<PackageDescription, ExtraInfo>>();
                foreach (XElement packageElement in element.Elements("PackageDescription"))
                {
                    PackageDescription packageDescription = new PackageDescription();

                    packageDescription.PackageVersion = packageElement.Attribute("packageVersion").Value;
                    packageDescription.PackageFileDownloadUrl = packageElement.Attribute("packageFileDownloadUrl").Value;
                    packageDescription.Description = packageElement.Attribute("description").Value;
                    packageDescription.EulaId = (Guid)packageElement.Attribute("eulaId");
                    packageDescription.GroupName = packageElement.Attribute("groupName").Value;
                    packageDescription.Id = (Guid)packageElement.Attribute("id");
                    packageDescription.InstallationRequireLicenseFileUpdate = (bool)packageElement.Attribute("installationRequireLicenseFileUpdate");
                    packageDescription.IsFree = (bool)packageElement.Attribute("isFree");
                    packageDescription.IsTrial = (bool)packageElement.Attribute("isTrial");
                    packageDescription.LicenseRuleId = (Guid)packageElement.Attribute("licenseRuleId");
                    packageDescription.MaxCompositeVersionSupported = packageElement.Attribute("maxCompositeVersionSupported").Value;
                    packageDescription.MinCompositeVersionSupported = packageElement.Attribute("minCompositeVersionSupported").Value;
                    packageDescription.Name = packageElement.Attribute("name").Value;
                    packageDescription.PriceAmmount = (decimal)packageElement.Attribute("priceAmmount");
                    packageDescription.PriceCurrency = packageElement.Attribute("priceCurrency").Value;
                    packageDescription.ReadMoreUrl = packageElement.Attribute("readMoreUrl").Value;
                    packageDescription.TechicalDetails = packageElement.Attribute("techicalDetails").Value;
                    packageDescription.TrialPeriodDays = (int)packageElement.Attribute("trialPeriodDays");
                    packageDescription.UpgradeAgreementMandatory = (bool)packageElement.Attribute("upgradeAgreementMandatory");
                    packageDescription.Vendor = packageElement.Attribute("vendor").Value;
                    ExtraInfo extraInfo = new ExtraInfo();

                    if (packageElement.Attribute("canBeUninstalled") != null) extraInfo.CanBeUninstalled = (bool)packageElement.Attribute("canBeUninstalled");
                    if (packageElement.Attribute("flushOnCompletion") != null) extraInfo.FlushOnCompletion = (bool)packageElement.Attribute("flushOnCompletion");
                    if (packageElement.Attribute("reloadConsoleOnCompletion") != null) extraInfo.ReloadConsoleOnCompletion = (bool)packageElement.Attribute("reloadConsoleOnCompletion");

                    if (packageElement.Attribute("systemLocking") != null)
                    {
                        SystemLockingType systemLockingType;
                        packageElement.Attribute("systemLocking").TryDeserialize(out systemLockingType);
                        extraInfo.SystemLockingType = systemLockingType;
                    }

                    packageDescriptions.Add(new KeyValuePair<PackageDescription, ExtraInfo>(packageDescription, extraInfo));
                }

                _packageDescriptions.Add(element.Attribute("url").Value.ToLowerInvariant(), packageDescriptions);

                Dictionary<Guid, string> eulaTexts = new Dictionary<Guid, string>();
                foreach (XElement eulaTextElement in element.Elements("EulaText"))
                {
                    eulaTexts.Add(
                        (Guid)eulaTextElement.Attribute("id"),
                        eulaTextElement.Value
                        );
                }
                _eulaTexts.Add(element.Attribute("url").Value.ToLowerInvariant(), eulaTexts);
            }
        }
Beispiel #3
0
 public void Warning(string message, ExtraInfo extraInfo)
 {
     InternalLog(LogLevel.Warning, message, string.Empty, string.Empty, message, extraInfo);
 }
Beispiel #4
0
        /// <summary>
        /// Creates a new reviewforum in the database
        /// </summary>
        /// <param name="forumName"></param>
        /// <param name="URLFriendlyName"></param>
        /// <param name="incubateTime"></param>
        /// <param name="recommend"></param>
        /// <param name="siteID"></param>
        /// <param name="userID"></param>
        public void CreateAndInitialiseNewReviewForum(string forumName, string URLFriendlyName, int incubateTime, bool recommend,int siteID, int userID)
        {        	
	        _urlFriendlyName = URLFriendlyName;
	        _reviewForumName = forumName;

	        // Get the user information

	        if (_reviewForumName == String.Empty || _urlFriendlyName == String.Empty || _urlFriendlyName.IndexOf(" ") >= 0 || siteID <= 0 || incubateTime < 0)
	        {
                throw new DnaException("INVALID PARAMETERS - Invalid parameters in CreateAndInitialiseNewReviewForum.");

                /*
		        TDVASSERT(forumName != String.Empty ,"NULL forumname in CReviewForum::AddNewReviewForum");
		        TDVASSERT(_urlFriendlyName != String.Empty ,"NULL forumname in CReviewForum::AddNewReviewForum");
		        TDVASSERT(_urlFriendlyName.Find(" ") < 0,"Spaces found in the URL");
		        TDVASSERT(incubateTime >= 0, "Invalid incubate time in CReviewForum::AddNewReviewForum");
		        TDVASSERT(siteID > 0,"invalid siteid in CReviewForum::AddNewReviewForum");
		        TDVASSERT(userID > 0,"invalid userid in CReviewForum::AddNewReviewForum");
		        return false;*/
	        }

	        ExtraInfo extrainfo = new ExtraInfo();
	        int typeID = (int) GuideEntry.GuideEntryType.TYPEREVIEWFORUM;
            if (!extrainfo.TryCreate(typeID, ""))
	        {
                throw new DnaException("ReviewForum - InitialiseAndCreateNewReviewForum - Failed to create extrainfo for reviewforum due bad element");
	        }
	        //pass in the object -not the string!
        	
	        int reviewForumID = 0;
            string hash = String.Empty;
            string hashString = forumName + "<:>" + URLFriendlyName + "<:>" + userID + "<:>" + siteID + "<:>" + extrainfo.RootElement.OuterXml + "<:>" + incubateTime + "<:>" + recommend;

            using (IDnaDataReader dataReader = InputContext.CreateDnaDataReader("addnewreviewforum"))
            {
                dataReader.AddParameter("URLName", URLFriendlyName);
                dataReader.AddParameter("ReviewForumName", forumName);
                dataReader.AddParameter("Incubate", incubateTime);
                dataReader.AddParameter("Recommend", recommend);
                dataReader.AddParameter("SiteID", siteID);
                dataReader.AddParameter("userid", userID);
                dataReader.AddParameter("extra", extrainfo.RootElement.OuterXml);
                dataReader.AddParameter("Type", typeID);
                dataReader.AddParameter("Hash", DnaHasher.GenerateHash(hashString));
                dataReader.Execute();
                // Check to see if we found anything
                if (dataReader.HasRows && dataReader.Read())
                {
                    reviewForumID = dataReader.GetInt32NullAsZero("ReviewForumID");
                }
            }
            if (reviewForumID > 0)
            {
                _recommend = recommend;
                _incubateTime = incubateTime;
                _siteID = siteID;
                _reviewForumID = reviewForumID;

                _initialised = true;
            }
        }    
		ExtraInfo OnImageInfo()
		{
			if (extraInfo == null)
				extraInfo = new ExtraInfo();
			return extraInfo;
		}
Beispiel #6
0
 private void HandledException(Exception exception, string moduleName, string categoryName, string subcategoryName, string description, ExtraInfo extraInfo)
 {
     InternalHandle(new HandledExceptionInfo(),
         exception, moduleName, categoryName, subcategoryName, description, extraInfo);
 }
Beispiel #7
0
 private void LocalLog(ExceptionInfo info, Exception exception, string moduleName, string categoryName, string subcategoryName, string description, ExtraInfo extraInfo)
 {
     var message = new StringBuilder();
     if (info != null)
         message.Append(string.Format("异常类型:{0} ", info.GetType().Name));
     if (!string.IsNullOrEmpty(moduleName))
         message.Append(string.Format("模块名:{0} ", moduleName));
     if (!string.IsNullOrEmpty(categoryName))
         message.Append(string.Format("大类:{0} ", categoryName));
     if (!string.IsNullOrEmpty(subcategoryName))
         message.Append(string.Format("小类:{0} ", subcategoryName));
     if (!string.IsNullOrEmpty(description))
         message.Append(string.Format("描述:{0} ", description));
     if (extraInfo != null)
         message.Append(string.Format("额外信息:{0} ", extraInfo));
     message.Append(string.Format("异常信息:{0} ", exception.ToString()));
     LocalLoggingService.Error(message.ToString());
 }
Beispiel #8
0
 public void Handle(string moduleName, Exception exception, string description, ExtraInfo extraInfo)
 {
     HandledException(exception, moduleName, string.Empty, string.Empty, description, extraInfo);
 }
Beispiel #9
0
 public void Error(string moduleName, string categoryName, string subcategoryName, string message, ExtraInfo extraInfo)
 {
     InternalLog(LogLevel.Error, moduleName, categoryName, subcategoryName, message, extraInfo);
 }
Beispiel #10
0
 public void Error(string moduleName, string message, ExtraInfo extraInfo)
 {
     InternalLog(LogLevel.Error, moduleName, string.Empty, string.Empty, message, extraInfo);
 }
Beispiel #11
0
 public void Debug(string categoryName, string subcategoryName, string message, ExtraInfo extraInfo)
 {
     InternalLog(LogLevel.Debug, string.Empty, categoryName, subcategoryName, message, extraInfo);
 }
Beispiel #12
0
 public void Debug(string moduleName, string message, ExtraInfo extraInfo)
 {
     InternalLog(LogLevel.Debug, moduleName, string.Empty, string.Empty, message, extraInfo);
 }
Beispiel #13
0
 private void LocalLog(LogLevel logLevel, string moduleName, string categoryName, string subcategoryName, string message, ExtraInfo extraInfo)
 {
     var msg = new StringBuilder();
     if (!string.IsNullOrEmpty(moduleName))
         msg.Append(string.Format("模块名:{0} ", moduleName));
     if (!string.IsNullOrEmpty(categoryName))
         msg.Append(string.Format("大类:{0} ", categoryName));
     if (!string.IsNullOrEmpty(subcategoryName))
         msg.Append(string.Format("小类:{0} ", subcategoryName));
     if (extraInfo != null)
         msg.Append(string.Format("额外信息:{0} ", extraInfo));
     msg.Append(string.Format("日志信息:{0} ", message));
     LocalLoggingService.Log(logLevel, msg.ToString());
 }
Beispiel #14
0
 private void InternalLog(LogLevel logLevel, string moduleName, string categoryName, string subcategoryName, string message, ExtraInfo extraInfo)
 {
     try
     {
         if (AppInfoCenterConfiguration.GetConfig().LoggingServiceConfig.Enabled)
         {
             var strategy = GetLogStrategy(moduleName, logLevel);
             if (strategy != null)
             {
                 if (strategy.LocalLog)
                     LocalLog(logLevel, moduleName, categoryName, subcategoryName, message, extraInfo);
                 if (strategy.RemoteLog)
                 {
                     var info = new LogInfo();
                     info.LogLevel = logLevel;
                     info.ModuleName = moduleName;
                     info.CategoryName = categoryName;
                     info.SubCategoryName = subcategoryName;
                     info.Message = message;
                     info.ExtraInfo = extraInfo;
                     ProcessInfo(info);
                     MongodbService.MongodbInsertService.Insert(info);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         LocalLoggingService.Error("InternalLog出现错误,异常信息为:" + ex.ToString());
     }
 }
Beispiel #15
0
 public void Handle(Exception exception, ExtraInfo extraInfo)
 {
     HandledException(exception, string.Empty, string.Empty, string.Empty, string.Empty, extraInfo);
 }
Beispiel #16
0
 public void Handle(string categoryName, string subcategoryName, Exception exception, ExtraInfo extraInfo)
 {
     HandledException(exception, string.Empty, categoryName, subcategoryName, string.Empty, extraInfo);
 }
Beispiel #17
0
 /// <summary>
 /// Sets the extra info xml from the string and the type
 /// </summary>
 /// <param name="extraInfo"></param>
 /// <param name="type"></param>
 public void SetExtraInfo(string extraInfo, int type)
 {
     _extraInfo.RemoveAll();
     _extraInfo = CreateElement("ExtraInfo");
     ExtraInfo extraInfoObject = new ExtraInfo();
     extraInfoObject.TryCreate(type, extraInfo);
     _extraInfo.AppendChild(ImportNode(extraInfoObject.RootElement.FirstChild));
 }
Beispiel #18
0
 public void Handle(string moduleName, string categoryName, string subcategoryName, Exception exception, string description, ExtraInfo extraInfo)
 {
     HandledException(exception, moduleName, categoryName, subcategoryName, description, extraInfo);
 }
 private ExtraInfo OnImageInfo()
 {
     return _extraInfo ?? (_extraInfo = new ExtraInfo());
 }
Beispiel #20
0
        private void InternalHandle(ExceptionInfo info, Exception exception, string moduleName, string categoryName, string subcategoryName, string description, ExtraInfo extraInfo)
        {
            if (exception == null)
                return;
            try
            {
                if (AppInfoCenterConfiguration.GetConfig().ExceptionServiceConfig.Enabled)
                {
                    var strategy = GetExceptionStrategy(moduleName, info.GetType().Name, exception.GetType().Name);
                    if (strategy != null)
                    {
                        if (strategy.LocalLog)
                            LocalLog(info, exception, moduleName, categoryName, subcategoryName, description, extraInfo);
                        if (strategy.RemoteLog)
                        {
                            info.Exception = MapException(exception);
                            info.Description = description;
                            info.ExceptionTypeName = exception.GetType().FullName;
                            info.ExtraInfo = extraInfo;
                            info.ModuleName = moduleName;
                            info.CategoryName = categoryName;
                            info.SubCategoryName = subcategoryName;
                            info.ExceptionMessage = exception.Message;
                            ProcessInfo(info);
                            MongodbService.MongodbInsertService.Insert(info);
                        }

                        if (info is WebSiteUnhandledExceptionInfo && HttpContext.Current != null)
                        {
                            HttpContext.Current.Response.Clear();

                            //HttpContext.Current.Response.StatusCode = strategy.ResponseStatusCode;

                            if (!HttpContext.Current.Request.IsLocal && strategy.ClearException)
                            {
                                HttpContext.Current.Server.ClearError();

                                if (!string.IsNullOrEmpty(strategy.RedirectUrl))
                                {
                                    HttpContext.Current.Response.Redirect(string.Format("{0}/?ID={1}", strategy.RedirectUrl.TrimEnd('/'), info.ID), false);
                                }
                                else
                                {
                                    HttpContext.Current.Response.Write(string.Format(AppInfoCenterConfiguration.GetConfig().ExceptionServiceConfig.UnhandledExceptionMessage, info.ID));
                                    HttpContext.Current.Response.End();
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LocalLoggingService.Error("InternalHandle出现错误,异常信息为:" + ex.ToString());
            }
        }
Beispiel #21
0
        /// <summary>
        /// This methos gets the list of related clubs for a given article
        /// </summary>
        /// <param name="h2g2ID">The id of the article you want to get the related clubs for</param>
        public void GetRelatedClubs(int h2g2ID)
        {
            // Create a data reader to get all the clubs
            using (IDnaDataReader reader = InputContext.CreateDnaDataReader("getrelatedclubs"))
            {
                reader.AddParameter("h2g2ID", h2g2ID);
                reader.Execute();

                XmlNode relatedClubsNode = AddElementTag(RootElement, "RELATEDCLUBS");
                
                // Add each club member in turn
                while (reader.Read())
                {
                    XmlNode clubNode = AddElementTag(relatedClubsNode, "CLUBMEMBER");
                    AddIntElement(clubNode, "CLUBID", reader.GetInt32("ClubID"));
                    AddTextElement((XmlElement)clubNode, "NAME", reader.GetString("Subject"));
                    ExtraInfo clubExtraInfo = new ExtraInfo();
                    clubExtraInfo.TryCreate(reader.GetInt32("Type"),reader.GetString("ExtraInfo"));
                    clubNode.AppendChild(ImportNode(clubExtraInfo.RootElement.FirstChild));
                    if (reader.Exists("DateCreated"))
                    {
                        XmlNode dateCreatedNode = AddElementTag(clubNode, "DATECREATED");
                        dateCreatedNode.AppendChild(DnaDateTime.GetDateTimeAsElement(RootElement.OwnerDocument, reader.GetDateTime("DateCreated"), true));
                    }
                    if (reader.Exists("Lastupdated"))
                    {
                        XmlNode dateCreatedNode = AddElementTag(clubNode, "LASTUPDATE");
                        dateCreatedNode.AppendChild(DnaDateTime.GetDateTimeAsElement(RootElement.OwnerDocument, reader.GetDateTime("DateCreated"), true));
                    }

                    // NEED TO ADD EDITOR, CLUBMEMBERS, LOCAL, EXTRAINFO, STRIPPED NAME... CHECK CLUB MEMBERS
                }
            }
        }
Beispiel #22
0
        /// <summary>
        /// This method reads in the entry form the database and sets up all the member fields
        /// </summary>
        /// <param name="safeToCache">A flag to state whether or not this entry is safe to cache. Usually set to false whhen an error occures.</param>
        /// <param name="failingGracefully">A flag that states whether or not this method is failing gracefully.</param>
        private void GetEntryFromDataBase(ref bool safeToCache, ref bool failingGracefully)
        {
            // fetch all the lovely intellectual property from the database
            using (IDnaDataReader reader = InputContext.CreateDnaDataReader("getarticlecomponents2"))
            {
                // Add the entry id and execute
                reader.AddParameter("EntryID", EntryID);
                reader.Execute();

                // Make sure we got something back
                if (!reader.HasRows || !reader.Read())
                {
                    // Fail gracefully
                    XmlNode articleTag = AddElementTag(RootElement, "ARTICLE");
                    XmlNode guideTag = AddElementTag(articleTag, "GUIDE");
                    XmlNode bodyTag = AddElementTag(guideTag, "BODY");
                    AddElementTag(bodyTag, "NOENTRYYET");
                    failingGracefully = true;
                    safeToCache = false;
                }
                else
                {
                    // Go though the results untill we get the main article
                    do
                    {
                        if (reader.GetInt32("IsMainArticle") == 1)
                        {
                            // Now start reading in all the values for the entry
                            _h2g2ID = reader.GetInt32("h2g2ID");
                            _entryID = reader.GetInt32("EntryID");
                            _forumID = reader.GetInt32("ForumID");
                            _status = reader.GetInt32("Status");
                            _style = reader.GetInt32("Style");
                            _editor = reader.GetInt32("Editor");
                            _siteID = reader.GetInt32("SiteID");
                            _submittable = reader.GetTinyIntAsInt("Submittable");
                            _type = reader.GetInt32("Type");
                            if (!reader.IsDBNull("ModerationStatus"))
                            {
                                _moderationStatus = reader.GetTinyIntAsInt("ModerationStatus");
                            }
                            _subject = reader.GetString("subject");
                            _text = reader.GetString("text");
                            string extraInfo = reader.GetString("extrainfo");

                            _extraInfo = new ExtraInfo();
                            _extraInfo.TryCreate(_type, extraInfo);

                            if (reader.IsDBNull("Hidden"))
                            {
                                _hiddenStatus = 0;
                            }
                            else
                            {
                                _hiddenStatus = reader.GetInt32("Hidden");
                            }

                            _dateCreated = reader.GetDateTime("DateCreated");
                            _lastUpdated = reader.GetDateTime("LastUpdated");
                            _preProcessed = reader.GetInt32("PreProcessed");
                            _defaultCanRead = (reader.GetTinyIntAsInt("CanRead") > 0);
                            _defaultCanWrite = (reader.GetTinyIntAsInt("CanWrite") > 0);
                            _defaultCanChangePermissions = (reader.GetTinyIntAsInt("CanChangePermissions") > 0);

                            if (reader.IsDBNull("TopicID"))
                            {
                                _topicID = 0;
                            }
                            else
                            {
                                _topicID = reader.GetInt32("TopicID");
                            }

                            if (reader.IsDBNull("BoardPromoID"))
                            {
                                _boardPromoID = 0;
                            }
                            else
                            {
                                _boardPromoID = reader.GetInt32("BoardPromoID");
                            }

                            if (!reader.IsDBNull("StartDate"))
                            {
                                _dateRangeStart = reader.GetDateTime("StartDate");
                            }

                            if (!reader.IsDBNull("EndDate"))
                            {
                                _dateRangeEnd = reader.GetDateTime("EndDate");
                            }

                            if (reader.IsDBNull("TimeInterval"))
                            {
                                _rangeInterval = -1; // default value
                            }
                            else
                            {
                                _rangeInterval = reader.GetInt32("TimeInterval");
                            }
                        }
                    }
                    while (reader.Read());
                }
            }
        }
Beispiel #23
0
        /// <summary>
        /// This method gets all the related articles for a given article h2g2ID
        /// </summary>
        /// <param name="h2g2ID">The id of the article you want to get the related articles for</param>
        public void GetRelatedArticles(int h2g2ID)
        {
            // Create the datareader to get the articles
            using (IDnaDataReader reader = InputContext.CreateDnaDataReader("getrelatedarticles"))
            {
                reader.AddParameter("h2g2ID", h2g2ID);
                reader.AddParameter("CurrentSiteID", 0);
                reader.Execute();

                XmlNode relatedArticlesNode = AddElementTag(RootElement, "RELATEDARTICLES");

                // Add each article in turn
                while (reader.Read())
                {
                    XmlNode relatedArticleNode = AddElementTag(relatedArticlesNode, "ARTICLEMEMBER");
                    AddIntElement(relatedArticleNode, "H2G2ID", h2g2ID);
                    string articleName = reader.GetString("Subject");
                    AddTextElement((XmlElement)relatedArticleNode, "NAME", articleName);
                    if (_includeStrippedNames)
                    {
                        string strippedName = StringUtils.StrippedName(articleName);
                        AddTextElement((XmlElement)relatedArticleNode, "STRIPPEDNAME", strippedName);
                    }
                    XmlNode userNode = AddElementTag(relatedArticleNode, "EDITOR");
                    User articleEditor = new User(InputContext);
                    articleEditor.AddPrefixedUserXMLBlock(reader, reader.GetInt32("Editor"), "Editor", userNode);
                    int status = reader.GetInt32("Status");
                    XmlNode statusNode = AddTextElement((XmlElement)relatedArticleNode, "STATUS", GuideEntry.GetDescriptionForStatusValue(status));
                    AddAttribute(statusNode, "TYPE", status);
                    ExtraInfo articleExtraInfo = new ExtraInfo();
                    int articleType = reader.GetInt32("Type");
                    int articleHidden = 0;
                    if (reader.Exists("Hidden") && !reader.IsDBNull("Hidden"))
                    {
                        articleHidden = reader.GetInt32("Hidden");
                    }
                    
                    // Create and add the article extra info
                    articleExtraInfo.TryCreate(articleType, reader.GetString("ExtraInfo"));
                    AddInside(relatedArticleNode, articleExtraInfo);

                    if (reader.Exists("DateCreated"))
                    {
                        XmlNode dateCreatedNode = AddElementTag(relatedArticleNode, "DATECREATED");
                        dateCreatedNode.AppendChild(DnaDateTime.GetDateTimeAsElement(RootElement.OwnerDocument, reader.GetDateTime("DateCreated"), true));
                    }
                    if (reader.Exists("Lastupdated"))
                    {
                        XmlNode dateCreatedNode = AddElementTag(relatedArticleNode, "LASTUPDATE");
                        dateCreatedNode.AppendChild(DnaDateTime.GetDateTimeAsElement(RootElement.OwnerDocument, reader.GetDateTime("DateCreated"), true));
                    }

                    // NOW ADD KEYPHRASES, MEDIA ASSETS, POLLS
                }
            }
        }
Beispiel #24
0
        /// <summary>
        /// Used to make sure that the input for the guide body parses correctly as valid XML
        /// </summary>
        /// <returns>A string that represents the XML for the guide body</returns>
        private string TryParseGuideBody()
        {
            XmlDocument bodyDoc = new XmlDocument();
            XmlNode guideBody = null;
            try
            {
                // Load the body text into an XmlDoc to parse
                bodyDoc.LoadXml(Entities.GetEntities() + "<GUIDE><BODY>" + _template.UIFields["Body"].RawValue + "</BODY></GUIDE>");
                guideBody = bodyDoc.SelectSingleNode("//GUIDE");
            }
            catch (XmlException ex)
            {
                AddErrorXml("GuideXML", "The body text contains invalid XML - " + ex.Message, _typedArticleNode);
                return "";
            }

            // Create the extra info block
            int type = _template.UIFields["Type"].ValueInt;
            ExtraInfo extraInfo = new ExtraInfo();
            extraInfo.TryCreate(type, "");

            // Now add all the non required fields to the Guide
            Dictionary<string, UIField>.Enumerator validFields = _template.UIFields.GetEnumerator();
            while (validFields.MoveNext())
            {
                // Check to see if we've got a non require field
                UIField currentField = validFields.Current.Value;
                if (!currentField.Required)
                {
                    // Add the field to the extra info
                    extraInfo.AddExtraInfoTagValue(currentField.Name, currentField.ValueString);

                    // Add the element to the 
                    XmlDocument fieldDoc = new XmlDocument();
                    try
                    {
                        // Load the text into an XmlDoc to parse
                        fieldDoc.LoadXml("<" + currentField.Name.ToUpper() + ">" + currentField.RawValue + "</" + currentField.Name.ToUpper() + ">");
                        XmlNode bodyNode = bodyDoc.SelectSingleNode("//BODY");
                        XmlNode importNode = bodyDoc.ImportNode(fieldDoc.FirstChild,true);
                        bodyDoc.DocumentElement.InsertAfter(importNode, bodyNode);
                    }
                    catch (XmlException ex)
                    {
                        AddErrorXml("GuideXML", "The " + currentField.Name + " contains invalid XML - " + ex.Message, _typedArticleNode);
                        return "";
                    }
                }
            }

            // Add the guidebody to the page
            _typedArticleNode.AppendChild(_typedArticleNode.OwnerDocument.ImportNode(guideBody,true));
            AddInside(_typedArticleNode, extraInfo);

            // Get the text to insert into the database
            return guideBody.OuterXml.ToString();
        }
 public void StartPerformanceMeasure(string name, ExtraInfo extraInfo = null)
 {
     StartPerformanceMeasure(name, string.Empty, string.Empty, extraInfo);
 }
 private ExtraInfo OnImageInfo()
 {
     if (_extraInfo == null)
         _extraInfo = new ExtraInfo();
     return _extraInfo;
 }
Beispiel #27
0
 public void Info(string message, ExtraInfo extraInfo)
 {
     InternalLog(LogLevel.Info, message, string.Empty, string.Empty, message, extraInfo);
 }