public void DisplayEntityColumnsAndData(string appName)
        {
            //Look at these results to see what
            //fields are available for use in a Filter.

            var request = new ListObjects
            {
                AppName   = appName,
                PageIndex = 0,
                PageSize  = 1
            };

            var response = ApiClient.ListObjects(request);

            Assert.That(response, Is.Not.Null);
            Assert.That(response.Properties, Is.Not.Null.And.Not.Empty);
            Assert.That(response.Items, Is.Not.Null);
            Assert.That(response.Items.Count, Is.LessThanOrEqualTo(request.PageSize));

            if (response.Items.Count > 0)
            {
                Assert.That(response.Items.First().StoreId, Is.EqualTo(response.Items.First()["_StoreId"]));
            }


            var message = FormatListObjectsResponse(request, response);

            Console.WriteLine(message);
            Console.WriteLine();
        }
 public void TryClearAllFilters()
 {
     try
         {
             if (Worksheet.AutoFilter != null)
             {
                 Worksheet.AutoFilterMode = false;
             }
         }
         catch(Exception ex)
         {
             //Log.Error(string.Format("Clear filters encountered an issue. Sheet: {0}", Name));
         }
         try
         {
             ListObjects listObjects = Worksheet.ListObjects;
             foreach(ListObject listObject in listObjects)
             {
                 listObject.AutoFilter.ShowAllData();
             }
         }
         catch (Exception ex)
         {
             //Log.Error(string.Format("Clear table filters encountered an issue. Sheet: {0}", Name));
         }
 }
Exemple #3
0
        /// <summary>
        ///     Formats a <see cref="ListObjectsResponse" /> to show returned properties and data returned by
        ///     <see cref="IRqlBusinessApiClient.ListObjects" />.
        ///     Useful for discoverying which fields are available for the purposes of building a SQL filter.
        /// </summary>
        /// <param name="request">the <see cref="ListObjects"/> request instance</param>
        /// <param name="response">the <see cref="ListObjectsResponse"/> response instance</param>
        /// <returns></returns>
        protected string FormatListObjectsResponse(ListObjects request, ListObjectsResponse response)
        {
            var message = new StringBuilder();

            message.AppendFormat("ListObjects for: {0}", request.AppName)
            .AppendFormat(" returned {0} Entity Properties and {1} row(s).",
                          response.Properties.Count, response.Items.Count)
            .AppendLine()
            .AppendLine("Properties:")
            .AppendFormat("\t{0}",
                          string.Join(", ", response.Properties.Select(p => p == "_StoreId" ? "StoreId" : p)))
            .AppendLine();

            //Note: any property name starting w/ underscore is a special property name, not actual usable in a filter.

            if (response.Items.Count > 0)
            {
                message.AppendLine("Properties and values:");
                response.Items.ForEach(item =>
                {
                    message.AppendFormat("\t{0}", string.Join(", ",
                                                              response.Properties.Select(propertyName =>
                                                                                         string.Format("{0} = {1}", propertyName, item[propertyName]))));
                });
            }

            return(message.ToString());
        }
 void FormatAsTable(string TableName, string TableStyleName)
 {
     listObjects = ws.ListObjects;
     listObjects.Add(XlListObjectSourceType.xlSrcRange, tableColumns, System.Type.Missing, XlYesNoGuess.xlGuess, System.Type.Missing).Name = TableName;
     tableColumns.Select();
     listObjects[TableName].TableStyle = TableStyleName;
 }
Exemple #5
0
        public ListObjectsResponse ListObjects(ListObjectsRequest request)
        {
            EnsureAbsoluteUri(request);
            var command = new ListObjects(_userId, _secret, _builder, _authenticator)
            {
                Parameters = request
            };

            return((ListObjectsResponse)((ICommandExecutor)this).Execute(command));
        }
        public ActionResult <AddScheduleTargetResponse> Post(AddScheduleTarget request)
        {
            if (request.Schedules == null || request.Schedules.Length == 0)
            {
                return(BadRequest("Schedules array is empty."));
            }
            AddScheduleTargetResponse    ret  = new AddScheduleTargetResponse();
            List <GXScheduleToAttribute> list = new List <GXScheduleToAttribute>();

            foreach (UInt64 s in request.Schedules)
            {
                if (request.DeviceId != 0)
                {
                    ListObjects req = new ListObjects();
                    req.DeviceId = request.DeviceId;
                    req.Targets  = TargetType.Object | TargetType.Attribute;
                    req.Objects  = request.Objects;
                    using (System.Net.Http.HttpResponseMessage response = Helpers.client.PostAsJsonAsync(this.Request.Scheme + "://" + this.Request.Host + "/api/object/ListObjects", req).Result)
                    {
                        Helpers.CheckStatus(response);
                        ListObjectsResponse objs = response.Content.ReadAsAsync <ListObjectsResponse>().Result;
                        foreach (GXObject obj in objs.Items)
                        {
                            if (obj.Attributes != null)
                            {
                                foreach (GXAttribute a in obj.Attributes)
                                {
                                    list.Add(new GXScheduleToAttribute()
                                    {
                                        ScheduleId = s, AttributeId = a.Id
                                    });
                                }
                            }
                        }
                    }
                }
                else if (request.Objects != null && request.Objects.Length != 0)
                {
                    foreach (GXObject o in request.Objects)
                    {
                        foreach (GXAttribute a in o.Attributes)
                        {
                            list.Add(new GXScheduleToAttribute()
                            {
                                ScheduleId = s, AttributeId = a.Id
                            });
                        }
                    }
                }
            }
            host.Connection.Insert(GXInsertArgs.InsertRange(list));
            host.SetChange(TargetType.Schedule, DateTime.Now);
            return(ret);
        }
Exemple #7
0
        public void ListUsersByFilter(string filter)
        {
            var request = new ListObjects
            {
                AppName = UserAppName,
                Filter  = filter
            };

            var response = ApiClient.ListObjects(request);

            var message = FormatListObjectsResponse(request, response);

            Console.WriteLine(message);
        }
Exemple #8
0
        public void ListActiveUserNames()
        {
            var request = new ListObjects
            {
                AppName    = UserAppName,
                Filter     = "Status = 'Approved'",
                Properties = new List <string> {
                    "User_Name"
                }
            };

            var response = ApiClient.ListObjects(request);

            var activeUserNames = response.Items
                                  .Select(i => i["User_Name"])
                                  .ToList();

            CollectionAssert.IsNotEmpty(activeUserNames);
            CollectionAssert.Contains(activeUserNames, Credential.UserName);

            //TODO: mark the ones that should be active as deleted.
        }
        public void Fill(IEnumerable objects, bool shouldSaveState)
        {
            if (shouldSaveState)
            {
                SaveState();
            }

            GridProperties.SelectedObject = null;
            ListObjects.BeginUpdate();
            ListObjects.Items.Clear();
            foreach (object o in objects)
            {
                ListObjects.Items.Add(o);
            }
            ListObjects.EndUpdate();

            if (ListObjects.Items.Count > 0)
            {
                ListObjects.SelectedIndex = 0;
            }

            UpdateEnabled();
        }
Exemple #10
0
        internal static ListObject GetListObject(Range targetRange)
        {
            ExcelUIThreadProtecter.CheckIsExcelUIMainThread();
            ListObject result = null;

            if (targetRange != null)
            {
                Worksheet   ws            = targetRange.Worksheet;
                ListObjects allListObject = ws.ListObjects;
                ListObject  item          = null;
                Range       itemRange     = null;
                for (int i = 1; i <= allListObject.Count; i++)     //VB start from 1
                {
                    item      = allListObject[i];
                    itemRange = GetListObjectRange(item);
                    if (IsRangeOverlap(itemRange, targetRange) == true)
                    {
                        result = item;
                        break;
                    }
                }
            }
            return(result);
        }
Exemple #11
0
 private void RemoveHiddenObject()
 {
     ListObjects.Add(SelectedHiddenObject);
     HiddenObjects.Remove(SelectedHiddenObject);
     SelectedHiddenObject = null;
 }
Exemple #12
0
 private void AddObjectToHidden()
 {
     HiddenObjects.Add(SelectedObject);
     ListObjects.Remove(SelectedObject);
     SelectedObject = null;
 }
        public ActionResult <ListObjectsResponse> Post(ListObjects request)
        {
            ListObjectsResponse ret = new ListObjectsResponse();
            GXSelectArgs        arg = GXSelectArgs.Select <GXObject>(null);

            arg.Columns.Add <GXAttribute>();
            arg.Joins.AddInnerJoin <GXObject, GXAttribute>(a => a.Id, b => b.ObjectId);
            if (request.Objects != null)
            {
                List <int> indexes = new List <int>();
                foreach (GXObject it in request.Objects)
                {
                    if (it.Id != 0)
                    {
                        arg.Where.And <GXObject>(q => q.Id == it.Id);
                    }
                    else if (it.ObjectType != 0 && !string.IsNullOrEmpty(it.LogicalName))
                    {
                        if (it.Attributes != null)
                        {
                            foreach (GXAttribute a in it.Attributes)
                            {
                                if (a.Index != 0)
                                {
                                    indexes.Add(a.Index);
                                }
                            }
                        }
                        arg.Where.Or <GXObject>(q => q.Removed == DateTime.MinValue && q.ObjectType == it.ObjectType && q.LogicalName.Equals(it.LogicalName));
                    }
                }
                arg.Where.And <GXAttribute>(q => q.Removed == DateTime.MinValue);
                GXSelectArgs devices = GXSelectArgs.Select <GXObject>(q => q.DeviceId);
                if (request.DeviceId != 0)
                {
                    devices.Where.And <GXObject>(q => q.DeviceId == request.DeviceId);
                }
                arg.Where.And <GXObject>(q => GXSql.In(q.DeviceId, devices));
                ret.Items = host.Connection.Select <GXObject>(arg).ToArray();
                //Delete Removed attributes.
                foreach (GXObject o in ret.Items)
                {
                    List <GXAttribute> list = new List <GXAttribute>();
                    for (int pos = 0; pos < o.Attributes.Count; ++pos)
                    {
                        if (o.Attributes[pos].Removed != DateTime.MinValue || (indexes.Count != 0 && !indexes.Contains(o.Attributes[pos].Index)))
                        {
                            o.Attributes.RemoveAt(pos);
                            --pos;
                        }
                    }
                }
            }
            else if (request.DeviceId != 0)
            {
                arg.Where.And <GXObject>(q => q.DeviceId == request.DeviceId);
                arg.Where.And <GXAttribute>(q => q.Removed == DateTime.MinValue);
                if ((request.Targets & TargetType.Attribute) != 0)
                {
                    if (request.Index == 0 && request.Count == 0 && request.Start == DateTime.MinValue && request.End == DateTime.MinValue)
                    {
                        arg.Columns.Add <GXValue>();
                        arg.Joins.AddLeftJoin <GXAttribute, GXValue>(a => a.Id, v => v.AttributeId);
                    }
                }
                ret.Items = host.Connection.Select <GXObject>(arg).ToArray();
            }
            foreach (GXObject obj in ret.Items)
            {
                if (obj.ObjectType == (int)ObjectType.ProfileGeneric)
                {
                    foreach (GXAttribute a in obj.Attributes)
                    {
                        if (a.Index == 2)
                        {
                            arg = GXSelectArgs.SelectAll <GXValue>();
                            arg.Where.And <GXValue>(q => q.AttributeId == a.Id);
                            if (request.Index != 0)
                            {
                                arg.Index = (UInt32)(request.Index - 1);
                            }
                            arg.Count = (UInt32)request.Count;
                            if (request.Start != DateTime.MinValue)
                            {
                                arg.Where.And <GXValue>(q => q.Read >= request.Start);
                            }
                            if (request.End != DateTime.MinValue)
                            {
                                arg.Where.And <GXValue>(q => q.Read <= request.End);
                            }
                            arg.OrderBy.Add <GXValue>(o => o.Read);
                            List <GXValue> values = host.Connection.Select <GXValue>(arg);
                            StringBuilder  sb     = new StringBuilder();
                            sb.Append("<Array>");
                            foreach (GXValue v in values)
                            {
                                sb.Append(v.Value);
                            }
                            sb.Append("</Array>");
                            a.Value = sb.ToString();
                        }
                    }
                }
            }
            return(ret);
        }