Пример #1
0
        /// <summary>
        /// Gets an export of FinancialTransaction Records
        /// </summary>
        /// <param name="page">The page being requested (where first page is 1).</param>
        /// <param name="pageSize">The number of records to provide per page. NOTE: This is limited to the 'API Max Items Per Page' global attribute.</param>
        /// <param name="exportOptions">The export options.</param>
        /// <returns></returns>
        public FinancialTransactionsExport GetFinancialTransactionExport(int page, int pageSize, FinancialTransactionExportOptions exportOptions)
        {
            IQueryable <FinancialTransaction> financialTransactionQry;
            SortProperty sortProperty = exportOptions.SortProperty;

            RockContext rockContext = this.Context as RockContext;

            if (exportOptions.DataViewId.HasValue)
            {
                financialTransactionQry = ModelExport.QueryFromDataView <FinancialTransaction>(rockContext, exportOptions.DataViewId.Value);
            }
            else
            {
                financialTransactionQry = this.Queryable();
            }

            if (sortProperty != null)
            {
                financialTransactionQry = financialTransactionQry.Sort(sortProperty);
            }

            if (exportOptions.ModifiedSince.HasValue)
            {
                financialTransactionQry = financialTransactionQry.Where(a => a.ModifiedDateTime.HasValue && a.ModifiedDateTime >= exportOptions.ModifiedSince.Value);
            }

            if (exportOptions.StartDateTime.HasValue)
            {
                financialTransactionQry = financialTransactionQry.Where(a => a.TransactionDateTime.HasValue && a.TransactionDateTime >= exportOptions.StartDateTime.Value);
            }

            if (exportOptions.EndDateTime.HasValue)
            {
                financialTransactionQry = financialTransactionQry.Where(a => a.TransactionDateTime.HasValue && a.TransactionDateTime < exportOptions.EndDateTime.Value);
            }

            var skip = (page - 1) * pageSize;

            FinancialTransactionsExport financialTransactionsExport = new FinancialTransactionsExport();

            financialTransactionsExport.Page       = page;
            financialTransactionsExport.PageSize   = pageSize;
            financialTransactionsExport.TotalCount = financialTransactionQry.Count();

            var pagedFinancialTransactionQry = financialTransactionQry
                                               .Include(a => a.AuthorizedPersonAlias)
                                               .Include(a => a.TransactionDetails)
                                               .Include(a => a.FinancialPaymentDetail)
                                               .Include(a => a.TransactionDetails.Select(d => d.Account))
                                               .AsNoTracking()
                                               .Skip(skip)
                                               .Take(pageSize);

            var financialTransactionList = pagedFinancialTransactionQry.ToList();

            financialTransactionsExport.FinancialTransactions = financialTransactionList.Select(f => new FinancialTransactionExport(f)).ToList();

            AttributesExport.LoadAttributeValues(exportOptions, rockContext, financialTransactionsExport.FinancialTransactions, pagedFinancialTransactionQry);
            return(financialTransactionsExport);
        }
Пример #2
0
        static void WriteExport(ModelExport sExport)
        {
            var repo = new Models.ExportHashRepository("ModelExports");

            var metadata = new Models.ExportMetadata();

            metadata.Name = "test model";

            var set = new Models.ExportSetMetadata();

            metadata.Sets.Add(set);

            set.Name = "test set";

            foreach (var mesh in sExport.Meshes)
            {
                var model = new Models.ExportModelMetadata();
                model.Alpha    = repo.Write(mesh.Alpha);
                model.Diffuse  = repo.Write(mesh.Diffuse);
                model.Emissive = repo.Write(mesh.Emissive);
                model.Normal   = repo.Write(mesh.Normal);
                model.Obj      = repo.Write(".obj", mesh.Bytes);
                model.Specular = repo.Write(mesh.Specular);
                set.Models.Add(model);
            }

            var json = JsonConvert.SerializeObject(metadata, Formatting.Indented);

            File.WriteAllText("ModelExports\\metadata.json", json);
        }