Esempio n. 1
0
 public IHttpActionResult FillCatalog()
 {
     try
     {
         ViewModel.Search SearchLegalUser = new ViewModel.Search();
         SearchLegalUser.Order      = " order by tblCatalog.IDRet, tblCatalog.[Sort] Asc";
         SearchLegalUser.JsonResult = " FOR JSON path";
         JArray JsonCatalog = BisCatalog.GetJsonCatalogData(SearchLegalUser);
         foreach (JObject JItem in JsonCatalog)
         {
             JItem.Add(new JProperty("SizeOfPDF", SizeOfFile(JItem["PDFUrl"].ToString())));
         }
         return(Ok(JsonCatalog));
     }
     catch
     {
         return(NotFound());
     }
 }
Esempio n. 2
0
 private void ProcessInbox(DRequestCompletedEventArgs e, string QId)
 {
     try
     {
         JsonObject JDef  = JsonStatus.Parse(e.ResponseString);
         JsonArray  JData = JDef.GetNamedArray("data");
         foreach (JsonValue JItem in JData)
         {
             InboxMessage BoxMessage = new InboxMessage(JItem.GetObject());
             Member.Activities.AddUI(new Activity(BoxMessage.Name, BoxMessage.OpenComment)
             {
                 TimeStamp = BoxMessage.TimeStamp
             });
         }
     }
     catch (Exception)
     {
     }
 }
Esempio n. 3
0
 public void ShowQueryEqualByParameter(
     IEnumerable <JKeyValuePair> query,
     string[] args, string parameter, bool key = true,
     JItemType itemType = JItemType.SingleValue)
 {
     if (args.Contains(parameter))
     {
         if (args.Length > (Array.IndexOf(args, parameter) + 1))
         {
             Console.WriteLine($"Queries with value Equal to {args[Array.IndexOf(args, parameter) + 1]}");
             var student      = new JString("Student");
             var certainQuery = query.Where(x =>
                                            (key ? x.Key : x.Value)
                                            .Equals(JItem.Factory(itemType, args[Array.IndexOf(args, parameter) + 1]))
                                            ).Select(x => x.FindContainerOrReturnParent(student));
             ShowQuery(certainQuery);
         }
     }
 }
Esempio n. 4
0
 public JProperty(JItem parent, string name, object value)
     : base(parent, name, JItemType.Property)
 {
     _value = value;
 }
Esempio n. 5
0
 public JArray(JItem parent, string name)
     : base(parent, name, JItemType.Object)
 {
 }
Esempio n. 6
0
        /// <summary>
        /// Converts JSON text from 'getstats' command to human-friendly HTML.
        /// </summary>
        public static string GetStatsHtml(string json, string serviceName = null, string version = null)
        {
            dynamic data = JsonConvert.DeserializeObject(json);

            if (serviceName == null)
            {
                serviceName = data.service.name;
            }
            if (version == null)
            {
                version = data.service.version;
            }

            JObject root          = null;
            JItem   currentParent = null;

            using (StringReader stringReader = new StringReader(json))
            {
                using (JsonTextReader reader = new JsonTextReader(stringReader))
                {
                    bool      done      = false;
                    JsonToken token     = JsonToken.Undefined;
                    object    value     = null;
                    JsonToken prevToken = JsonToken.Undefined;
                    object    prevValue = null;

                    do
                    {
                        done = !reader.Read();
                        if (!done)
                        {
                            prevToken = token;
                            prevValue = value;
                            token     = reader.TokenType;
                            value     = reader.Value;

                            if (token == JsonToken.StartObject)
                            {
                                if (currentParent == null)
                                {
                                    root          = new JObject(null, serviceName + " v" + version);
                                    currentParent = root;
                                }
                                else
                                {
                                    string  name = prevToken == JsonToken.PropertyName ? prevValue.ToString() : "";
                                    JObject obj  = new JObject(currentParent, name);
                                    currentParent.Items.Add(obj);
                                    currentParent = obj;
                                }
                            }

                            else if (token == JsonToken.EndObject)
                            {
                                currentParent = currentParent.Parent;
                            }

                            else if (token == JsonToken.StartArray)
                            {
                                string name = prevToken == JsonToken.PropertyName ? prevValue.ToString() : "";
                                JArray arr  = new JArray(currentParent, name);
                                currentParent.Items.Add(arr);
                                currentParent = arr;
                            }

                            else if (token == JsonToken.EndArray)
                            {
                                currentParent = currentParent.Parent;
                            }

                            else if ((token == JsonToken.Boolean) || (token == JsonToken.Date) || (token == JsonToken.Float) || (token == JsonToken.Integer) || (token == JsonToken.String) || (token == JsonToken.Raw))
                            {
                                if (prevToken == JsonToken.PropertyName)
                                {
                                    string    name = prevToken == JsonToken.PropertyName ? prevValue.ToString() : "";
                                    JProperty prop = new JProperty(currentParent, name, value);
                                    currentParent.Items.Add(prop);
                                }
                                else if (prevToken == JsonToken.StartArray)
                                {
                                    JObject val = new JObject(currentParent, value.ToString());
                                    currentParent.Items.Add(val);
                                }
                            }
                        }
                    }while (!done);
                }
            }

            string body = root.Render(null);

            return(HTML.Replace("##TITLE##", "").Replace("##BODY##", body));
        }
Esempio n. 7
0
 public Tree(JItem root)
 {
     JRoot = root;
     InitializeComponent();
     treeView1.Nodes.Add(new JItemNode(JRoot));
 }
Esempio n. 8
0
 public void Activate(JItem jitem)
 {
     this.jitem = jitem;
     ConstructDataString();
     jtooltip.SetActive(true);
 }