Example #1
0
        public async Task <CQuerieResult> GetqueriesResult(string database, string projectuid, string layer, string lcid, string target, string start_objid)
        {
            var content = await communicationManager.GetqueriesResult(m_Url, database, projectuid, target, lcid, layer, start_objid, m_Session.Id, serverName);

            if (content == null)
            {
                return(null);
            }
            JObject json = JObject.Parse(content);

            if (json == null)
            {
                return(null);
            }

            CQuerieResult q = new CQuerieResult()
            {
                UID = json.SelectToken("UID").Value <string>(),
            };
            List <int>     invisiblecolumns = new List <int>();
            int            index            = 0;
            List <CColumn> columns          = new List <CColumn>();

            foreach (var jcol in (JArray)json.SelectToken("Columns"))
            {
                CColumn c = new CColumn()
                {
                    Alignment          = jcol.SelectToken("Alignment").Value <int>(),
                    DisplayDescription = jcol.SelectToken("DisplayDescription").Value <string>(),
                    Id          = jcol.SelectToken("Id").Value <int>(),
                    IsDate      = jcol.SelectToken("IsDate").Value <bool>(),
                    Numeric     = jcol.SelectToken("Numeric").Value <bool>(),
                    Visible     = jcol.SelectToken("Visible").Value <bool>(),
                    Width       = jcol.SelectToken("Width").Value <int>(),
                    WithPicture = jcol.SelectToken("WithPicture").Value <bool>(),
                    WrapText    = jcol.SelectToken("WrapText").Value <bool>(),
                };

                if (c.Width > 0)
                {
                    columns.Add(c);
                }
                else
                {
                    invisiblecolumns.Add(index);
                }
                index++;
            }
            q.Columns = columns.ToArray();
            List <CRow> rows = new List <CRow>();

            foreach (var jrow in (JArray)json.SelectToken("Rows"))
            {
                CRow c = new CRow()
                {
                    UID = jrow.SelectToken("UID").Value <string>(),
                };
                List <CCell> cells = new List <CCell>();
                index = 0;

                foreach (var jcell in (JArray)jrow.SelectToken("Items"))
                {
                    CCell cell = new CCell()
                    {
                        IsClientPicture = jcell.SelectToken("IsClientPicture").Value <bool>(),
                        NumericValue    = jcell.SelectToken("NumericValue").Value <double>(),
                        Picture         = jcell.SelectToken("Picture").Value <string>(),
                        Text            = jcell.SelectToken("Text").Value <string>(),
                        UID             = jcell.SelectToken("UID").Value <string>(),
                    };
                    if (!invisiblecolumns.Contains(index))
                    {
                        cells.Add(cell);
                    }
                    index++;
                }
                c.Items = cells.ToArray();
                rows.Add(c);
            }
            q.Rows = rows.ToArray();

            return(q);
        }