예제 #1
0
        public async Task <ADashboard_Summary> GetDashboardDataAsync()
        {
            using var log = BeginFunction(nameof(DashboardAdminService), nameof(GetDashboardDataAsync));
            try
            {
                await Assert(SecurityPolicy.IsPrivileged).ConfigureAwait(false);

                var result = new ADashboard_Summary()
                {
                    MCommunication_Dashboard = await CommunicationMicroService.GetDashboardAsync(),
                    MDesign_Dashboard        = await DesignMicroService.GetDashboardAsync(),
                    MFulfillment_Dashboard   = await FulfillmentMicroService.GetDashboardAsync(),
                    MFunding_Dashboard       = await FundingMicroService.GetDashboardAsync(),
                    MLedger_Dashboard        = await LedgerMicroService.GetDashboardAsync(),
                    MOrder_Dashboard         = await OrderMicroService.GetDashboardAsync(),
                    MProject_Dashboard       = await ProjectMicroService.GetDashboardAsync(),
                    MSquare_Dashboard        = await SquareMicroService.GetDashboardAsync(),
                    MUser_Dashboard          = await UserMicroService.GetDashboardAsync()
                };

                //using (var ctx = QuiltContextFactory.Create())
                //{
                //    using var conn = QuiltContextFactory.CreateConnection();

                //    conn.Open();

                //    // Order
                //    //
                //    {
                //        var statusCounts = new List<Admin_Dashboard_StatusCountData>();
                //        foreach (var dbOrder in GetDashboardOrders(conn).ToList())
                //        {
                //            var statusCount = new Admin_Dashboard_StatusCountData()
                //            {
                //                StatusName = ctx.OrderStatusType(dbOrder.OrderStatusTypeCode).Name,
                //                Count = dbOrder.RecordCount.GetValueOrDefault()
                //            };
                //            statusCounts.Add(statusCount);
                //        }
                //        result.OrderStatusCounts = statusCounts;
                //    }

                //    // Order Return Request
                //    //
                //    {
                //        var statusCounts = new List<Admin_Dashboard_StatusCountData>();
                //        foreach (var dbOrderReturnRequest in GetDashboardOrderReturnRequests(conn).ToList())
                //        {
                //            var statusCount = new Admin_Dashboard_StatusCountData()
                //            {
                //                StatusName = ctx.ReturnRequestStatusType(dbOrderReturnRequest.OrderReturnRequestStatusTypeCode).Name,
                //                Count = dbOrderReturnRequest.RecordCount.GetValueOrDefault()
                //            };
                //            statusCounts.Add(statusCount);
                //        }
                //        result.OrderReturnRequestStatusCounts = statusCounts;
                //    }

                //    // Order Return
                //    //
                //    {
                //        var statusCounts = new List<Admin_Dashboard_StatusCountData>();
                //        foreach (var dbOrderReturn in GetDashboardOrderReturns(conn).ToList())
                //        {
                //            var statusCount = new Admin_Dashboard_StatusCountData()
                //            {
                //                StatusName = ctx.ReturnStatusType(dbOrderReturn.OrderReturnStatusTypeCode).Name,
                //                Count = dbOrderReturn.RecordCount.GetValueOrDefault()
                //            };
                //            statusCounts.Add(statusCount);
                //        }
                //        result.OrderReturnStatusCounts = statusCounts;
                //    }

                //    // Order Shipment Request
                //    //
                //    {
                //        var statusCounts = new List<Admin_Dashboard_StatusCountData>();
                //        foreach (var dbOrderShipmentRequest in GetDashboardOrderShipmentRequests(conn).ToList())
                //        {
                //            var statusCount = new Admin_Dashboard_StatusCountData()
                //            {
                //                StatusName = ctx.ShipmentRequestStatusType(dbOrderShipmentRequest.OrderShipmentRequestStatusTypeCode).Name,
                //                Count = dbOrderShipmentRequest.RecordCount.GetValueOrDefault()
                //            };
                //            statusCounts.Add(statusCount);
                //        }
                //        result.OrderShipmentRequestStatusCounts = statusCounts;
                //    }

                //    // Order Shipment
                //    //
                //    {
                //        var statusCounts = new List<Admin_Dashboard_StatusCountData>();
                //        foreach (var dbOrderShipment in GetDashboardOrderShipments(conn).ToList())
                //        {
                //            var statusCount = new Admin_Dashboard_StatusCountData()
                //            {
                //                StatusName = ctx.ShipmentStatusType(dbOrderShipment.OrderShipmentStatusTypeCode).Name,
                //                Count = dbOrderShipment.RecordCount.GetValueOrDefault()
                //            };
                //            statusCounts.Add(statusCount);
                //        }
                //        result.OrderShipmentStatusCounts = statusCounts;
                //    }
                //}

                log.Result(result);

                return(result);
            }
            catch (Exception ex)
            {
                log.Exception(ex);
                throw;
            }
        }