Example #1
0
        public Variable(XElement xml, LinkPackage parent)
        {
            Parent = parent;

            Name = xml.AttributeValueOrDefault("name");
            DefaultValue = xml.AttributeValueOrDefault("default-value");
        }
        public CruiseControlNetBuildStatus(XElement projectElem)
        {
            Name = BuildDefinitionId = projectElem.AttributeValue("name");

            BuildStatusInfo buildStatusInfo;
            if (!_buildStatusInfo.TryGetValue(BuildDefinitionId, out buildStatusInfo))
            {
                buildStatusInfo = new BuildStatusInfo();
                _buildStatusInfo.Add(BuildDefinitionId, buildStatusInfo);
            }

            var lastBuildTimeStr = projectElem.AttributeValueOrDefault("lastBuildTime");
            DateTime dt;
            DateTime? lastBuildTime = null;
            if (DateTime.TryParse(lastBuildTimeStr, out dt))
            {
                lastBuildTime = dt;
            }

            BuildStatusEnum = ToBuildStatusEnum(projectElem.AttributeValueOrDefault("activity"), projectElem.AttributeValueOrDefault("lastBuildStatus"));
            StartedTime = GetStartedTime(buildStatusInfo, BuildStatusEnum, lastBuildTime);
            FinishedTime = GetFinishedTime(buildStatusInfo, BuildStatusEnum, lastBuildTime);
            Comment = null;
            RequestedBy = GetRequestedBy(projectElem);

            var webUrl = projectElem.AttributeValueOrDefault("webUrl");
            string lastBuildTimeAsId = ParseCruiseControlDateToId(lastBuildTimeStr);
            Url = string.Format("{0}/server/local/project/{1}/build/log{2}.xml/ViewBuildReport.aspx", webUrl, Name, lastBuildTimeAsId);
            BuildId = GetBuildIdOrDefault(projectElem, lastBuildTimeAsId);

            buildStatusInfo.LastBuildStatusEnum = BuildStatusEnum;
        }
 public TeamCityProject(string rootUrl, XElement projectXml)
 {
     RootUrl = rootUrl;
     Name = projectXml.AttributeValueOrDefault("name");
     Id = projectXml.AttributeValueOrDefault("id");
     Href = projectXml.AttributeValueOrDefault("href");
 }
 public BambooBuildDefinition(string rootUrl, XElement planXml)
 {
     RootUrl = rootUrl;
     _id = planXml.AttributeValueOrDefault("key");
     _name = planXml.AttributeValueOrDefault("name");
     var linkElem = planXml.Element("link");
     if (linkElem == null) throw new Exception("Could not get plan link");
     Url = linkElem.AttributeValueOrDefault("href");
 }
Example #5
0
        protected Path(XElement xml, LinkPackage root, IPathParent parent)
        {
            LinkPackage = root;
            Parent = parent;

            Name = xml.AttributeValueOrDefault("name");
            Id = xml.AttributeValueOrDefault("id");

            Paths = xml.Elements().Select(x => Path.Construct(x, root, this)).ToArray();
        }
        public FlickrInfo(XElement xml, string photoSetId = null, string photoPage = null)
        {
            // set basic properties (for photos and sets)
            Id = xml.AttributeValueOrDefault("id");
            Title = xml.Element("title").ElementValueNull();
            if (string.IsNullOrEmpty(Title))
            {
                // try getting from attribute value
                Title = xml.AttributeValueOrDefault("title");
            }
            Created = xml.AttributeValueOrDefault("date_create").DateTimeFromUnixTimeStamp();
            Modified = xml.AttributeValueOrDefault("date_update").DateTimeFromUnixTimeStamp();
            IsPhoto = false;

            // set photo specific properties
            if (xml.Name.LocalName.Equals("photo"))
            {
                IsPhoto = true;
                Secret = xml.AttributeValueOrDefault("secret");
                Server = xml.AttributeValueOrDefault("server");
                Farm = xml.AttributeValueOrDefault("farm");
                Description = xml.Element("description").ElementValueNull();
                PhotoSetId = photoSetId;

                if (string.IsNullOrEmpty(photoPage))
                {
                    EditUrl = xml.Element("urls").Element("url").Value;
                    Created = xml.Element("dates").AttributeValueOrDefault("taken").ExactDateTime();
                    Modified = xml.Element("dates").AttributeValueOrDefault("lastupdate").DateTimeFromUnixTimeStamp();
                }
                else
                {
                    EditUrl = string.Format(photoPage, xml.AttributeValueOrDefault("pathalias"), Id);
                    Created = xml.AttributeValueOrDefault("datetaken").ExactDateTime();
                    Modified = xml.AttributeValueOrDefault("lastupdate").DateTimeFromUnixTimeStamp();
                }
            }
        }
 private string GetBuildIdOrDefault(XElement projectElem, string defaultVal)
 {
     var lastBuildLabel = projectElem.AttributeValueOrDefault("lastBuildLabel");
     if (string.IsNullOrEmpty(lastBuildLabel) || lastBuildLabel == "UNKNOWN") return defaultVal;
     return lastBuildLabel;
 }
        public object ResolveReference(object instance, string propertyName, XElement xElement)
        {
            id nsObj = null;

            if (instance == null || string.IsNullOrEmpty(propertyName) || xElement == null)
                return null;

            NSString refId = xElement.AttributeValueOrDefault("ref", "");
            if (!string.IsNullOrWhiteSpace(refId))
            {
                bool foundRefID = Document.ListOfReferenceId.TryGetValue(refId, out nsObj);
                if (!foundRefID)
                {
                    System.Diagnostics.Debug.WriteLine(string.Format("Unknown ReferenceID {0}", refId));

                    System.Reflection.PropertyInfo prop = instance.GetType().GetProperty(propertyName);
                    Action<object> propAction = (Action<object>)Delegate.CreateDelegate(typeof(Action<object>), instance, prop.GetSetMethod());
                    Document.UnresolvedReferences.Add(refId, propAction);

                }
            }
            else
            {
                System.Diagnostics.Debug.WriteLine(string.Format("Nil Reference"));
            }

            return nsObj;
        }
 public TeamCityBuildDefinition(string rootUrl, XElement buildTypeXml)
 {
     RootUrl = rootUrl;
     _id = buildTypeXml.AttributeValueOrDefault("id");
     _name = buildTypeXml.AttributeValueOrDefault("name");
 }
 public CruiseControlNetBuildDefinition(string rootUrl, XElement projectElem)
 {
     RootUrl = rootUrl;
     _name = _id = projectElem.AttributeValueOrDefault("name");
 }
 private static void RetrieveTree(XElement root, List<Document> result)
 {
     if (root.Element("folders") != null)
     {
         foreach (var f in root.Element("folders").Elements("folder"))
         {
             if (f.Attribute("id") != null)
             {
                 var entry = new Document
                     {
                         Id = f.AttributeValueOrDefault("id"),
                         Title = f.AttributeValueOrDefault("name", "noname"),
                         Parent = root.AttributeValueOrDefault("id"),
                         IsFolder = true,
                     };
                 result.Add(entry);
             }
             RetrieveTree(f, result);
         }
     }
     if (root.Element("files") != null)
     {
         result.AddRange(root.Element("files")
                             .Elements("file")
                             .Where(f => f.Attribute("id") != null)
                             .Select(f => new Document
                                 {
                                     Id = f.AttributeValueOrDefault("id"),
                                     ContentLink = f.AttributeValueOrDefault("id"),
                                     Title = f.AttributeValueOrDefault("file_name"),
                                     Parent = root.AttributeValueOrDefault("id"),
                                     CreateOn = Utils.FromUnixTime2(long.Parse(f.AttributeValueOrDefault("created"))),
                                     IsFolder = false,
                                 })
                             .Where(d => !Global.EnableUploadFilter
                                         || FileUtility.ExtsUploadable.Contains(FileUtility.GetFileExtension(d.Title), StringComparer.CurrentCultureIgnoreCase)));
     }
 }
Example #12
0
 public Link(XElement xml, LinkPackage linkPackage)
 {
     LinkId = xml.AttributeValueOrDefault("link-id");
     TargetId = xml.AttributeValueOrDefault("target-id");
     LinkPackage = linkPackage;
 }
        private static void ExtractCommonData(Listing listing, 
            XElement document, 
            string addressDelimeter)
        {
            listing.ShouldNotBe(null);
            document.ShouldNotBe(null);

            listing.UpdatedOn = ParseReaDateTime(document.AttributeValue("modTime"));

            // We have no idea if this was created before this date, but we need to set a date
            // so we'll default it to this.
            listing.CreatedOn = listing.UpdatedOn;

            listing.AgencyId = document.ValueOrDefault("agentID");
            listing.Id = document.ValueOrDefault("uniqueID");
            var status = document.AttributeValueOrDefault("status");
            if (!string.IsNullOrWhiteSpace(status))
            {
                listing.StatusType = StatusTypeHelpers.ToStatusType(status);
            }

            listing.Title = document.ValueOrDefault("headline");
            listing.Description = document.ValueOrDefault("description");

            listing.Address = ExtractAddress(document, addressDelimeter);
            listing.Agents = ExtractAgent(document);
            listing.Inspections = ExtractInspectionTimes(document);
            listing.Images = ExtractImages(document);
            listing.FloorPlans = ExtractFloorPlans(document);
            listing.Videos = ExtractVideos(document);
            listing.Features = ExtractFeatures(document);
            listing.LandDetails = ExtractLandDetails(document);
            listing.Links = ExtractExternalLinks(document);
        }