Exemple #1
0
 private static void WriteBadgeInfo(SiteUris uris, string badgeName, SequentialTurtleWriter w)
 {
     w.StartTriple(uris.CreateBadgeUri(badgeName));
     w.AddToTriple(uris.GeneralUris.TypeProperty, uris.GeneralUris.BadgeType);
     w.AddToTriple(uris.GeneralUris.LabelProperty, badgeName);
     uris.LinkToSite(w);
 }
        private static void ConvertBadge(SiteUris uris, XmlReader r, SequentialTurtleWriter w)
        {
            if (GlobalData.Options.FullTimeInfo)
            {
                Uri subjectUri;
                if (r.MoveToAttribute("Id"))
                {
                    subjectUri = uris.CreateAssignedBadgeUri(r.Value);
                    w.StartTriple(subjectUri);
                }
                else
                {
                    r.MoveToElement();
                    ConsoleHelper.WriteErrorLine("No Id attribute found on element {0}. Skipping element.", r.ReadOuterXml());
                    return;
                }

                w.AddToTriple(uris.GeneralUris.TypeProperty, uris.GeneralUris.AssignedBadgeType);
                // link to site is not required as that information is expressed by the owner and badge
                if (r.MoveToAttribute("UserId"))
                {
                    w.AddToTriple(uris.GeneralUris.OwnerProperty, uris.CreateUserUri(r.Value));
                }
                if (r.MoveToAttribute("Name"))
                {
                    w.AddToTriple(uris.GeneralUris.BadgeProperty, uris.CreateBadgeUri(r.Value));
                    GlobalData.RegisterBadge(uris.Site, r.Value);
                }
                if (r.MoveToAttribute("Date"))
                {
                    w.AddToTriple(uris.GeneralUris.DateProperty, DateTime.Parse(r.Value, System.Globalization.CultureInfo.InvariantCulture));
                }
            }
            else
            {
                if (r.MoveToAttribute("UserId"))
                {
                    w.StartTriple(uris.CreateUserUri(r.Value));
                    if (r.MoveToAttribute("Name"))
                    {
                        w.AddToTriple(uris.GeneralUris.BadgeProperty, uris.CreateBadgeUri(r.Value));
                        GlobalData.RegisterBadge(uris.Site, r.Value);
                    }
                }
            }
        }