4

Working on site i been handed and suddnely a couple of macros have started playing up. Macro was working fine now suddenly this error showed up can anyone help here is the code.

@using umbraco.MacroEngines
@inherits umbraco.MacroEngines.DynamicNodeContext
          @functions{

              public void SetPageTitle(string title)
              {
                  var page = HttpContext.Current.Handler as Page;
                  if (page != null){
                      page.Title = title;
                  }
              }

              public DynamicNode Homepage
              {
                  get { 
                      var homepage = Model;
                      while(homepage.NodeTypeAlias != "Homepage"){
                          homepage = homepage.Parent;
                      }

                      return homepage;
                  }
              }

              public HtmlString GetSocialMediaLink(string network, string url, string name)
              {
                  var socialMediaRepo = Library.NodeById(-1).DescendantsOrSelf("SocialMediaNetworkRepository").First();
                  var socialNetworks = new List<DynamicNode>();
                  if (socialMediaRepo != null)
                  {
                      foreach (var child in socialMediaRepo.Children)
                      {
                          if(child.NodeTypeAlias.ToLower().Equals(network.ToLower())){
                              var icon = child.HasValue("CssClass") ? String.Format("<i class=\"{0}\"></i>", child.CssClass) : String.Format("<img src=\"/imagegen.ashx?altimage=/images/assets/clear.gif&image={0}\" alt=\"{1}\"/>", child.Icon, child.Name);
                              return new HtmlString(String.Format("<a target=\"_blank\" rel=\"no-follow\" href=\"{0}\" title=\"{3} on {1}\">{2}</a>", url, child.Name, icon, name) );
                          }
                          socialNetworks.Add(child);
                      }
                  }
                  return new HtmlString("");
              }

          }
@{
if (String.IsNullOrEmpty(Request["name"])){
    return;
}
var profileId = Request["name"].Replace("-", " ").Replace("/", "");

var lawyersRepository = Library.NodeById(1316);
var isIntranet = Homepage.Name.IndexOf("intranet", StringComparison.OrdinalIgnoreCase) > -1;
var nodes = isIntranet ? lawyersRepository.Children.Where("Name.ToLower() = \"" + profileId.ToLower() + "\"") : lawyersRepository.Children.Where("!ProfileIsPrivate && Name.ToLower() = \"" + profileId.ToLower() + "\"");
if(!nodes.Any()){
    return;
}
var node = nodes.First();
if (node == null || node.NodeTypeAlias != "LawyerRepositoryItem"){
    return;
}

if (node.ProfileIsPrivate && !isIntranet){
    return;
}

PageData["PageTitle"] = Model.Name + " - " + node.Name;

SetPageTitle(Model.Name + " - " + node.Name);
var hasContactInfo = (!String.IsNullOrEmpty(node.TelephoneNumber) || !String.IsNullOrEmpty(node.EmailAddress) || !String.IsNullOrEmpty(node.OfficeLocation));
<div class="profile">
    <div class="row">
        <div class="span4 profile-content">
            <h1>@node.Name</h1>
            <h3>@node.JobTitle</h3>
            @Html.Raw(node.Biography.ToString())
        </div>
        <div class="span2">
            <div class="profile-picture">
                @{
                    if (!node.HasValue("ProfilePictureSquare")){
                        <img src="/imagegen.ashx?altimage=/images/assets/clear.gif&image=@Library.MediaById(node.ProfilePicture).umbracoFile" alt="@node.Name" />
                    }
                    else{
                        <img src="/imagegen.ashx?altimage=/images/assets/clear.gif&image=@Library.MediaById(node.ProfilePictureSquare).umbracoFile" alt="@node.Name" />
                    }
                }

            </div>
            <div class="profile-quote">
                <!--Tesimonial-->
                @RenderPage("~/macroScripts/Widgets/Widget_RandomTestimonial.cshtml", @node.Id.ToString())
            </div>
        </div>
        @if (hasContactInfo)
        {
            <div class="contact-information">
                <div class="pull-left contact-details">
                    <h4>@Dictionary.ContactInformationHeading</h4>
                    <dl class="">
                        @{
            if (node.HasValue("TelephoneNumber"))
            {
                                <dd><strong>@Dictionary.Label_TelephoneShort:</strong>  @node.TelephoneNumber</dd>
            }
            if (node.HasValue("EmailAddress"))
            {
                                <dd><strong>@Dictionary.Label_EmailShort:</strong> <a href="mailto:@node.EmailAddress?subject=@Dictionary.DefaultEmailSubjectLine">@node.EmailAddress</a></dd>
            }
            if (node.HasValue("OfficeLocation"))
            {
                var officeNode = Library.NodeById(node.OfficeLocation);
                                <dd><strong>@Dictionary.Label_Office:</strong> <a href="@officeNode.NiceUrl" title="@officeNode.Name">@officeNode.Name</a></dd>
            }
                        }
                    </dl>
                </div>
                <div class="pull-left contact-vcard">
                    <h4>
                        <a href="/vcard.ashx?contact=@node.Id" title="@Dictionary.DownloadVCard"><i class="t-icon-vcard"></i> <span>@Dictionary.DownloadVCard</span></a></h4>
                </div>
            </div>
        }
        @{
            var hasSocialMediaUrls = node.HasValue("FacebookUrl") || node.HasValue("TwitterUrl") || node.HasValue("LinkedInUrl") || node.HasValue("YouTubeUrl") || node.HasValue("BlogUrl");
            if (hasSocialMediaUrls)
            {
                <div class="profile-social-links social-links">

                    <ul class="unstyled">
                        <li><strong>@Dictionary.Connect</strong></li>
                        @if (node.HasValue("FacebookUrl"))
                        {
                            <li>@GetSocialMediaLink("facebook", node.FacebookUrl, node.Name)</li>
                        }
                        @if (node.HasValue("TwitterUrl"))
                        {
                            <li>@GetSocialMediaLink("twitter", node.TwitterUrl, node.Name)</li>
                        }
                        @if (node.HasValue("LinkedInUrl"))
                        {
                            <li>@GetSocialMediaLink("linkedin", node.LinkedInUrl, node.Name)</li>
                        }
                        @if (node.HasValue("YouTubeUrl"))
                        {
                            <li>@GetSocialMediaLink("youtube", node.YouTubeUrl, node.Name)</li>
                        }
                        @if (node.HasValue("BlogUrl"))
                        {
                            <li>@GetSocialMediaLink("blogger", node.BlogUrl, node.Name)</li>
                        }
                    </ul>

                </div>
            }
        }
    </div>
    <div class="gold-bar">
        <a href="@Dictionary.SubmitTestimonialLink@Dictionary.SubmitTestimonialLinkParameters.Replace("{Name}", node.Name)">@Dictionary.SubmitTestimonialText</a>
    </div>
</div>
        }

i have tried loading from a backup file but the problem persists.

user3103102
  • 91
  • 1
  • 8

2 Answers2

6

You will need to find out why you got this error.

If you are running in a macro AND you are in WebForms mode, you can add ?umbDebugShowTrace=true (or ?umbDebug=true) at the url. (first check if the umbracoDebugMode appsetting in the web.config is true).

If this is not working, check the App_Data/Logs/ folder for any log files. You should see the complete error there. If you have an older version, check also the umbracoLog database table.

dampee
  • 3,392
  • 1
  • 21
  • 37
  • I think the initial question was answered. You should now be able interpret the error message and fix your code. If you have other questions, search stack overflow, or ask a new question. To help you out I'll give you a hint: DynamicNodeList does not contains a method called "ANY". But you can use listVariable.Items.Any(...) – dampee Feb 03 '14 at 16:12
  • I could be wrong about this, but I'm pretty sure that up until umbraco 6, the logs were stored in the `umbracoLog` table in the database by default. You might also try looking there if you can't get umbDebugShowTrace to work and can't find the logs in `App_Data\Logs`. – bowserm Dec 08 '15 at 19:14
  • @bowserm you are right. I've updated my answer. I am not sure about the version, Didn't v6 introduced the log4net dependency? – dampee Dec 09 '15 at 10:42
0

Best thing to do is to look in /App_Data/Logs/UmbracoTraceLog.txt which will show you the logs recorded for today.

This will reveal the root of the error and full stack trace.

JDandChips
  • 9,780
  • 3
  • 30
  • 46