示例#1
0
        protected override void DoConfigure(IConfigSectionNode node)
        {
            base.DoConfigure(node);
            var ndata = node.NonEmpty(nameof(node))[CONFIG_DATA_SECTION]
                        .NonEmpty($"section `{CONFIG_DATA_SECTION}`");

            m_Data = FactoryUtils.MakeAndConfigureDirectedComponent <IForestDataSource>(this, ndata, typeof(ForestDataSource));
        }
示例#2
0
        public static async Task <TDoc> treeExecuteAsync <TDoc>(this IForestDataSource forestData,
                                                                TreePtr tree,
                                                                Query <TDoc> qry) where TDoc : Doc
        {
            var doc = await forestData.GetCrudData(tree).ExecuteAsync(qry).ConfigureAwait(false);

            if (doc == null)
            {
                return(null);
            }
            var result = doc.CastTo <TDoc>($"Query returned value of type `{doc.GetType().DisplayNameWithExpandedGenericArgs()}`");

            return(result);
        }
示例#3
0
        /// <summary>
        /// Gets ICrudDataStore context for Corporate Area
        /// </summary>
        public static ICrudDataStore GetCrudData(this IForestDataSource forestData, TreePtr tree)
        {
            var tds = forestData.NonNull(nameof(forestData)).TryGetTreeDataStore(tree.IdForest, tree.IdTree);

            if (tds == null)
            {
                var tnmsg = "Forest tree `{0}` is not found".Args(tree);
                throw new ValidationException(tnmsg)
                      {
                          HttpStatusCode = 404, HttpStatusDescription = tnmsg
                      };
            }

            return((tds as ICrudDataStore).NonNull(DATA_STORE_CLAUSE));
        }
示例#4
0
 public MySqlConfForestTreeDataStore(IForestDataSource director) : base(director)
 {
 }
示例#5
0
 /// <summary>
 /// Extension which executes a query in tree data context and does not fetch any result
 /// </summary>
 public static ConfiguredTaskAwaitable <TDoc> TreeExecuteAsync <TDoc>(this IForestDataSource forestData,
                                                                      TreePtr tree,
                                                                      Query <TDoc> qry) where TDoc : Doc
 => forestData.treeExecuteAsync(tree, qry).ConfigureAwait(false);
示例#6
0
 /// <summary>
 /// Extension which loads a document returned by query executed in tree data context
 /// </summary>
 public static ConfiguredTaskAwaitable <TDoc> TreeLoadDocAsync <TDoc>(this IForestDataSource forestData,
                                                                      TreePtr tree,
                                                                      Query <TDoc> qry) where TDoc : Doc
 => forestData.GetCrudData(tree).LoadDocAsync(qry).ConfigureAwait(false);