Ejemplo n.º 1
0
        /// <summary>
        /// Waste Transfer Area Comparison.  Chart data is formated into JSON then encoded into Base64
        /// </summary>
        private static string MakeJSONData(EPRTRT.DataContracts.WasteTransferAreaCollection myWasteTransfer)
        {
            string output = JsonConvert.SerializeObject(myWasteTransfer);

            byte[] encData_byte = new byte[output.Length];
            encData_byte = System.Text.Encoding.UTF8.GetBytes(output);
            string encodedData = Convert.ToBase64String(encData_byte);

            return(encodedData);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Waste Transfer Area Comparison
        /// </summary>
        private static EPRTRT.DataContracts.WasteTransferAreaCollection PopulateChartDataContract(List <QueryLayer.WasteTransfers.AreaComparison> waste)
        {
            EPRTRT.DataContracts.WasteTransferAreaCollection myWTAC = new EPRTRT.DataContracts.WasteTransferAreaCollection();

            foreach (var item in waste)
            {
                EPRTRT.DataContracts.WasteTransferAreaComparison myWTA = new EPRTRT.DataContracts.WasteTransferAreaComparison();
                myWTA.Area       = item.Area;
                myWTA.Facilities = item.Facilities.ToString();
                myWTA.TotalCount = convertToString(item.TotalCount);

                myWTA.Disposal    = convertToString(item.Disposal);
                myWTA.Recovery    = convertToString(item.Recovery);
                myWTA.Total       = convertToString(item.Total);
                myWTA.Unspecified = convertToString(item.Unspecified);

                //Double counting
                myWTA.DisposalAnnexI    = convertToString(item.DisposalAnnexI);
                myWTA.RecoveryAnnexI    = convertToString(item.RecoveryAnnexI);
                myWTA.UnspecifiedAnnexI = convertToString(item.UnspecifiedAnnexI);
                myWTA.TotalAnnexI       = convertToString(item.TotalAnnexI);

                //Get Percentages - normal and Double count. Normal is reduced with double counting parts sincebars will be stacked.
                double?reducedDisposal = removeDoubleCounting(item.Disposal, item.DisposalAnnexI);
                double?reducedRecovery = removeDoubleCounting(item.Recovery, item.RecoveryAnnexI);
                double?reducedUnspec   = removeDoubleCounting(item.Unspecified, item.UnspecifiedAnnexI);
                double?reducedTotal    = removeDoubleCounting(item.Total, item.TotalAnnexI);

                myWTA.DisposalPercentage       = convertToString(GetPercent(reducedDisposal, item.TotalCount));
                myWTA.DisposalAnnexIPercentage = convertToString(GetPercent(item.DisposalAnnexI, item.TotalCount));
                //Recovery
                myWTA.RecoveryPercentage       = convertToString(GetPercent(reducedRecovery, item.TotalCount));
                myWTA.RecoveryAnnexIPercentage = convertToString(GetPercent(item.RecoveryAnnexI, item.TotalCount));
                //Total
                myWTA.TotalPercentage       = convertToString(GetPercent(reducedTotal, item.TotalCount));
                myWTA.TotalAnnexIPercentage = convertToString(GetPercent(item.TotalAnnexI, item.TotalCount));
                //Unspecified
                myWTA.UnspecifiedPercentage       = convertToString(GetPercent(reducedUnspec, item.TotalCount));
                myWTA.UnspecifiedAnnexIPercentage = convertToString(GetPercent(item.UnspecifiedAnnexI, item.TotalCount));

                myWTAC.Add(myWTA);
            }
            return(myWTAC);
        }