private static void AddItems(Random random, ICollection <KbItem> items, KbItem parent)
        {
            var name =
                parent == null
                ? ("Folder " + (items.Count + 1))
                : parent.Name + "." + (items.Count + 1);
            var sb = new StringBuilder();

            sb.AppendLine("```csharp");
            sb.AppendLine("public class " + name.Replace(" ", string.Empty).Replace(".", "_"));
            sb.AppendLine("{");
            sb.AppendLine(@"    Console.WriteLine(""This is a test!"");");
            sb.AppendLine("}");
            sb.AppendLine("```");

            var item = new KbItem
            {
                DomainId = Guid.NewGuid(),
                Name     = name,
                Markdown = "##" + name + Environment.NewLine + Environment.NewLine + sb
            };

            items.Add(item);

            // Nasty....if we're 4 levels deep....
            if (name.Count(x => x == '.') <= 3)
            {
                for (var i = 0; i < random.Next(3, 10); i++)
                {
                    AddItems(random, item.ChildItems, item);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Create a new <see cref="KnowledgeBaseItem"/> from the given <see cref="KbItem"/>.
        /// </summary>
        /// <param name="kbItem">The kb item.</param>
        /// <returns></returns>
        public static KnowledgeBaseItem FromKbItem(KbItem kbItem)
        {
            var result = new KnowledgeBaseItem(kbItem.DomainId, kbItem.Name, kbItem.Markdown);

            foreach (var childItem in kbItem.ChildItems)
            {
                result._childItems.Add(FromKbItem(childItem));
            }

            return(result);
        }
Ejemplo n.º 3
0
        // **********************************************************************

        public string GetQueueText()
        {
            tlistText.Length = 0;

            if (tlist.Count > 0)
            {
                lock (tlist)
                {
                    tlistText.Append("Очередь операций:");

                    foreach (Transaction t in tlist)
                    {
                        tlistText.AppendLine();
                        tlistText.Append(KbItem.OpText(t.Source));

                        if (t.Price > 0)
                        {
                            tlistText.Append(" @");
                            tlistText.Append(Price.GetRaw(t.Price));
                        }

                        string qtyText = KbItem.QtyText(t.Source);
                        if (qtyText != null)
                        {
                            tlistText.Append(" ");
                            tlistText.Append(qtyText);
                        }

                        switch (t.State)
                        {
                        case Transaction.States.Execute:
                            tlistText.Append(" ...");
                            break;

                        case Transaction.States.Cancel:
                            tlistText.Append(" - отмена");
                            break;

                        case Transaction.States.Disposed:
                            tlistText.Append(" (отменено)");
                            break;
                        }
                    }
                }
            }
            else
            {
                tlistText.Append("Очередь операций пуста");
            }

            return(tlistText.ToString());
        }