Beispiel #1
0
        public LanDeskItem GetLanDeskItemByTypeAndId(string type, string id)
        {
            var ldt          = new LanDeskItemType(type);
            var queryBuilder = new QueryBuilder(ldt);
            var conditions   = new Condition {
                Operator = Operator.Equals, Property = "Id", Variable = id
            };
            var query = queryBuilder.CreateQuery(50, "Guid", conditions, LanDeskItemType.GetProperties(ldt.Name).Take(30).ToArray());
            var res   = ToLanDesk(ExecuteQuery, query).FirstOrDefault();

            if (res == null)
            {
                return(null);
            }
            var queryItem = ToLanDesk(OpenLanDeskItemSteps, res);

            if (queryItem == null)
            {
                return(null);
            }
            queryItem.attributes.Class = res.attributes.Class;
            queryItem.attributes.ConfigurationItemType = res.attributes.ConfigurationItemType;
            queryItem.attributes.CreateGroup           = res.attributes.CreateGroup;
            queryItem.attributes.CreationUser          = res.attributes.CreationUser;
            queryItem.attributes.CurrentAssignment     = res.attributes.CurrentAssignment;
            queryItem.attributes.LastUpdateUser        = res.attributes.LastUpdateUser;
            queryItem.attributes.LatestAssignmentGroup = res.attributes.LatestAssignmentGroup;
            queryItem.attributes.Lifecycle             = res.attributes.Lifecycle;
            queryItem.attributes.RaiseUser             = res.attributes.RaiseUser;
            queryItem.attributes.Status              = res.attributes.Status;
            queryItem.attributes.UpdateGroup         = res.attributes.UpdateGroup;
            queryItem.attributes._CatalogueHierarchy = res.attributes._CatalogueHierarchy;
            return(queryItem);
        }
Beispiel #2
0
        public IEnumerable <LanDeskItem> GetLanDeskItemsOfTypesForAssignedGroupsAndLatestUpdate(string[] types, string[] teams, int minutesPassed)
        {
            foreach (var typeString in types)
            {
                var type = new LanDeskItemType(typeString);
                foreach (var team in teams)
                {
                    const string format      = "MM/dd/yyyy hh:mm:ss tt";
                    var          strDate     = DateTime.Now.AddMinutes(minutesPassed).ToString(format);
                    CultureInfo  en          = new CultureInfo("en-US");
                    var          parsedBack  = DateTime.ParseExact(strDate, format, en.DateTimeFormat);
                    var          dateParsed  = parsedBack.ToString();
                    var          lanDeskItem = new LanDeskItem {
                        Type = type, attributes = { _CurrentAssignedGroup = team, LastUpdate = dateParsed }
                    };
                    var cn = new BooleanCondition
                    {
                        Condition1 = new Condition

                        {
                            Operator = Operator.Equals,
                            Property = "_CurrentAssignedGroup",
                            Variable = lanDeskItem.attributes._CurrentAssignedGroup
                        },
                        ConditionType = ConditionType.And,
                        Condition2    = new Condition
                        {
                            Operator = Operator.GreaterThan,
                            Property = "LastUpdate",
                            Variable = lanDeskItem.attributes.LastUpdate
                        }
                    };
                    var query        = new QueryBuilder(lanDeskItem.Type);
                    var fullQuery    = query.CreateQuery(0, lanDeskItem.Type.AvailableProperties[0], cn, lanDeskItem.Type.AvailableProperties.Take(30).ToArray());
                    var queryResults = ToLanDesk(ExecuteQuery, fullQuery);
                    if (queryResults == null)
                    {
                        continue;
                    }
                    foreach (var res in queryResults)
                    {
                        var queryItem = GetLanDeskItemByTypeAndGuid(res.className, res.value);
                        queryItem.attributes.Class = res.attributes.Class;
                        queryItem.attributes.ConfigurationItemType = res.attributes.ConfigurationItemType;
                        queryItem.attributes.CreateGroup           = res.attributes.CreateGroup;
                        queryItem.attributes.CreationUser          = res.attributes.CreationUser;
                        queryItem.attributes.CurrentAssignment     = res.attributes.CurrentAssignment;
                        queryItem.attributes.LastUpdateUser        = res.attributes.LastUpdateUser;
                        queryItem.attributes.LatestAssignmentGroup = res.attributes.LatestAssignmentGroup;
                        queryItem.attributes.Lifecycle             = res.attributes.Lifecycle;
                        queryItem.attributes.RaiseUser             = res.attributes.RaiseUser;
                        queryItem.attributes.Status              = res.attributes.Status;
                        queryItem.attributes.UpdateGroup         = res.attributes.UpdateGroup;
                        queryItem.attributes._CatalogueHierarchy = res.attributes._CatalogueHierarchy;
                        yield return(queryItem);
                    }
                }
            }
        }
Beispiel #3
0
 public QueryBuilder(LanDeskItemType lanDeskItemType) : this("wd/query/list.rails", lanDeskItemType)
 {
 }
Beispiel #4
0
 public QueryBuilder(string baseUrl, LanDeskItemType lanDeskItemType) : this(baseUrl, "wd/query/list.rails", lanDeskItemType)
 {
 }
Beispiel #5
0
 public QueryBuilder(string baseUrl, string relativeUrl, LanDeskItemType lanDeskItemType)
 {
     _baseUri         = new Uri(new Uri(baseUrl), new Uri(relativeUrl, UriKind.Relative));
     _lanDeskItemType = lanDeskItemType;
     _relativeUri     = relativeUrl;
 }