Пример #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);
        }
        public FinancialTransactionsExport Export(
            int page      = 1,
            int pageSize  = 1000,
            string sortBy = null,
            System.Web.UI.WebControls.SortDirection sortDirection = System.Web.UI.WebControls.SortDirection.Ascending,
            int?dataViewId         = null,
            DateTime?modifiedSince = null,
            DateTime?startDateTime = null,
            DateTime?endDateTime   = null,
            string attributeKeys   = null,
            AttributeReturnType attributeReturnType = AttributeReturnType.Raw
            )
        {
            // limit to 'API Max Items Per Page' global attribute
            int maxPageSize    = GlobalAttributesCache.Get().GetValue("core_ExportAPIsMaxItemsPerPage").AsIntegerOrNull() ?? 1000;
            var actualPageSize = Math.Min(pageSize, maxPageSize);

            FinancialTransactionExportOptions exportOptions = new FinancialTransactionExportOptions
            {
                SortBy              = sortBy,
                SortDirection       = sortDirection,
                DataViewId          = dataViewId,
                ModifiedSince       = modifiedSince,
                AttributeList       = AttributesExport.GetAttributesFromAttributeKeys <FinancialTransaction>(attributeKeys),
                AttributeReturnType = attributeReturnType,
                StartDateTime       = startDateTime,
                EndDateTime         = endDateTime
            };

            var rockContext = new RockContext();
            var financialTransactionService = new FinancialTransactionService(rockContext);

            return(financialTransactionService.GetFinancialTransactionExport(page, actualPageSize, exportOptions));
        }
Пример #3
0
 /// <summary>
 /// Copies the base properties from a source AttributesExport object
 /// </summary>
 /// <param name="source">The source.</param>
 public void CopyPropertiesFrom(AttributesExport source)
 {
     this.AttributeValues = source.AttributeValues;
 }
Пример #4
0
        public ActionResult GetCSV(string guid)
        {
            string resp = "";

            DrawingState ds = DrawingManager.Get(guid);

            if (ds != null)
            {
                List <AttributesExport> toExcel = new List <AttributesExport>();

                if (DrawingManager.Engine == DrawingEngine.CADNET)
                {
                    CADImage cadImage = ds.Drawing.GetInstance() as CADImage;
                    foreach (CADEntity ent in cadImage.Converter.Entities)
                    {
                        if ((ent is CADInsert) && ((ent as CADInsert).Attribs.Count == 3))
                        {
                            AttributesExport atrExp = new AttributesExport();
                            atrExp.Tags = new Dictionary <string, string>();
                            foreach (CADAttrib attr in (ent as CADInsert).Attribs)
                            {
                                atrExp.Tags.Add(attr.Tag, attr.Value);
                            }
                            atrExp.BlockName = (ent as CADInsert).Block.Name;
                            toExcel.Add(atrExp);
                        }
                    }
                }
                else
                {
                    string xml = ds.Drawing.ProcessXML("<?xml version=\"1.0\" encoding=\"UTF-8\"?><cadsofttools version=\"2\"><get mode=\"5\" /></cadsofttools>");

                    XmlDocument doc = new XmlDocument();
                    doc.LoadXml(xml);
                    XmlNodeList nodes = doc.SelectNodes("//cstInsert");

                    foreach (XmlNode node in nodes)
                    {
                        if (node.ChildNodes.Count == 3)
                        {
                            AttributesExport attrExp = new AttributesExport();
                            attrExp.Tags = new Dictionary <string, string>();
                            XmlAttribute attr = node.Attributes["BlockName"];
                            if (attr != null)
                            {
                                attrExp.BlockName = attr.Value;
                            }
                            foreach (XmlNode cNode in node.ChildNodes)
                            {
                                XmlAttribute atrTag   = cNode.Attributes["Tag"];
                                XmlAttribute atrValue = cNode.Attributes["Value"];
                                if ((atrTag != null) && (atrValue != null))
                                {
                                    attrExp.Tags.Add(atrTag.Value, atrValue.Value);
                                }
                            }
                            toExcel.Add(attrExp);
                        }
                    }
                }

                foreach (AttributesExport attr in toExcel)
                {
                    resp += attr.BlockName + "; ";
                    foreach (var tag in attr.Tags)
                    {
                        resp += tag.Key + "; " + tag.Value + "; ";
                    }
                    resp += "\r\n";
                }
            }
            Response.AddHeader("Content-Disposition", "attachment;filename=attribs.csv");
            return(Content(resp, "text/csv"));
        }