Exemple #1
0
        /// <summary>
        /// Returns the entire tree.
        /// </summary>
        public async Task <TreeVM> GetTreeAsync(string key)
        {
            var keyLower = key?.ToLowerInvariant();

            var page = await _db.Pages
                       .AsNoTracking()
                       .Include(x => x.TreeLayout)
                       .GetAsync(x => x.Aliases.Any(y => y.Key == keyLower) && x.IsDeleted == false, "Страница не найдена");

            var result = new TreeVM {
                RootId = page.Id
            };
            var json = page?.TreeLayout?.LayoutJson;

            if (!string.IsNullOrEmpty(json))
            {
                result.Content = JObject.Parse(json);
                foreach (var child in result.Content["children"])
                {
                    var info = child["info"];
                    if (info == null)
                    {
                        continue;
                    }

                    info["Photo"] = _url.Content(info["Photo"].Value <string>());
                    info["Url"]   = _url.Action("Description", "Page",
                                                new { area = "Front", key = info["Url"].Value <string>() });
                }
            }

            return(result);
        }
Exemple #2
0
        private void TreeView(object sender, RoutedEventArgs e)
        {
            var vm  = new TreeVM();
            var win = new TreeWin
            {
                DataContext = vm,
            };

            win.Show();
        }
        public static void SetTreeTDV(TreeVM tree, TreeDefaultValueDO tdv)
        {
            tree.TreeDefaultValue = tdv;
            if (tdv != null)
            {
                tree.Species = tdv.Species;

                tree.LiveDead           = tdv.LiveDead;
                tree.Grade              = tdv.TreeGrade;
                tree.FormClass          = tdv.FormClass;
                tree.RecoverablePrimary = tdv.Recoverable;
                //tree.HiddenPrimary = tdv.HiddenPrimary; //#367
            }
            else
            {
                //tree.Species = string.Empty;
                //tree.LiveDead = string.Empty;
                //tree.Grade = string.Empty;
                //tree.FormClass = 0;
                //tree.RecoverablePrimary = 0;
                //tree.HiddenPrimary = 0;
            }
        }
        public static object GetTreeTDVList(this DAL database, TreeVM tree)
        {
            if (tree == null)
            {
                return(EMPTY_SPECIES_LIST);
            }
            if (tree.Stratum == null)
            {
                if (database.GetRowCount("CuttingUnitStratum", "WHERE CuttingUnit_CN = @p1", tree.CuttingUnit_CN) == 1)
                {
                    tree.Stratum = database.From <StratumVM>()
                                   .Join("CuttingUnitStratum", "USING (Stratum_CN)").Where("CuttingUnit_CN = @p1")
                                   .Read(tree.CuttingUnit_CN).FirstOrDefault();
                }
                else
                {
                    return(EMPTY_SPECIES_LIST);
                }
            }

            if (tree.SampleGroup == null)
            {
                if (database.GetRowCount("SampleGroup", "WHERE Stratum_CN = @p1", tree.Stratum_CN) == 1)
                {
                    tree.SampleGroup = database.From <SampleGroupDO>()
                                       .Where("Stratum_CN = @p1").Read(tree.Stratum_CN).FirstOrDefault();
                }
                if (tree.SampleGroup == null)
                {
                    return(EMPTY_SPECIES_LIST);
                }
            }

            return(database.From <TreeDefaultValueDO>()
                   .Join("SampleGroupTreeDefaultValue", "USING (TreeDefaultValue_CN)")
                   .Where("SampleGroup_CN = @p1").Read(tree.SampleGroup_CN).ToArray());
        }
 public object GetTreeTDVList(TreeVM tree)
 {
     throw new NotImplementedException();
 }