Share script component class between two packages in the same SSIS project

741 Views Asked by At

Edit

I created a class library project in Visual Studio 2015, added the code I needed in that class library, then built the project. Visual Studio created a .DLL file named Biometria.dll (name of the project .DLL):

enter image description here

Opened the SSIS project, added existing item, selected Biometria.dll in bin/debug directory from the Biometria project. Visual Studio 2015 imported the .DLL file to the SSIS project:

enter image description here

The class is ready to be used anywhere in the project now, just need to reference its name space:

using Biometria;

double qx = Tabuas.RP2000F[age];

Original

I created an SSIS (SQL Server Integration Services) solution in Visual Studio 2015 using SSDT (SQL Server Data Tools).

I have finished the project, but I had to create a file with the same exact C# class for two different packages (red rectangle):

enter image description here

The class contains probabilities from mortality tables and they are equal for those two benefit plans (.DTSX packages).

I would like to have only one file, where I can make changes once, and then share with those two packages in the same project/solution. How do I do that, knowing that the class in currently hosted in a script component?

Tabuas.cs ("Tabuas" means "Tables" in Portuguese):

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SC_aed76656845d41c99051e4a4bff9c40f
{
    public static class Tabuas
    {
        // RP2000 Feminino
        public static double RP2000F(int idade)
        {
            // Probabilidades em ordem crescente das idades de 0 até 120 anos
            // RP2000F Desagravada 20%
            double[] qx = { 0.000000, 0.000457, 0.000298, 0.000222, 0.000166, 0.000150, 0.000141, 0.000132, 0.000118, 0.000112, 0.000113, 0.000114, 0.000118, 0.000124, 0.000130, 0.000136, 0.000142, 0.000147, 0.000150, 0.000152, 0.000153, 0.000154, 0.000155, 0.000158, 0.000161, 0.000166, 0.000171, 0.000178, 0.000188, 0.000198, 0.000211, 0.000246, 0.000280, 0.000315, 0.000348, 0.000380, 0.000411, 0.000443, 0.000478, 0.000518, 0.000565, 0.000619, 0.000682, 0.000750, 0.000823, 0.000899, 0.000978, 0.001061, 0.001147, 0.001240, 0.001341, 0.001482, 0.001614, 0.001766, 0.001939, 0.002174, 0.002472, 0.002782, 0.003138, 0.003553, 0.004044, 0.004651, 0.005326, 0.006118, 0.006895, 0.007765, 0.008763, 0.009730, 0.010756, 0.011888, 0.013394, 0.014863, 0.016532, 0.018376, 0.020366, 0.022485, 0.024773, 0.027284, 0.030076, 0.033205, 0.036703, 0.040624, 0.045035, 0.050005, 0.055614, 0.061957, 0.069101, 0.077070, 0.085842, 0.095323, 0.105346, 0.115683, 0.126094, 0.136346, 0.146239, 0.155607, 0.164303, 0.172192, 0.179158, 0.185110, 0.189974, 0.195867, 0.203598, 0.212835, 0.223244, 0.234493, 0.246249, 0.258180, 0.269953, 0.281235, 0.291694, 0.300997, 0.308812, 0.314806, 0.318646, 0.320000, 0.320000, 0.320000, 0.320000, 0.320000, 1.000000 };

            if (idade < qx.Length)
            {
                return qx[idade];
            }
            else
            {
                return 1;
            }
        }

        // RP2000 Masculino
        public static double RP2000M(int idade)
        {
            // Aqui estão as probabilidades das idades 0 até 120 em ordem  crescente
            // RP2000M desagravada em 20%
            double[] qx = {0.000000, 0.000510, 0.000344, 0.000286, 0.000222, 0.000204, 0.000195, 0.000187, 0.000173, 0.000167, 0.000170, 0.000175, 0.000182, 0.000192, 0.000203, 0.000215, 0.000227, 0.000241, 0.000253, 0.000265, 0.000276, 0.000286, 0.000293, 0.000298, 0.000301, 0.000301, 0.000302, 0.000306, 0.000314, 0.000330, 0.000355, 0.000399, 0.000450, 0.000505, 0.000562, 0.000618, 0.000673, 0.000723, 0.000771, 0.000817, 0.000863, 0.000914, 0.000972, 0.001039, 0.001118, 0.001206, 0.001293, 0.001387, 0.001488, 0.001596, 0.001710, 0.001959, 0.002134, 0.002333, 0.002557, 0.002899, 0.003360, 0.003754, 0.004218, 0.004756, 0.005398, 0.006141, 0.007006, 0.008010, 0.009024, 0.010190, 0.011527, 0.012860, 0.014297, 0.015842, 0.017765, 0.019656, 0.021825, 0.024310, 0.027120, 0.030267, 0.033735, 0.037525, 0.041698, 0.046342, 0.051494, 0.057633, 0.064389, 0.071774, 0.079823, 0.088606, 0.098238, 0.108834, 0.120472, 0.133136, 0.146726, 0.159815, 0.173284, 0.186930, 0.200554, 0.213993, 0.227124, 0.239882, 0.252237, 0.264166, 0.275645, 0.286902, 0.297348, 0.306432, 0.313602, 0.318309, 0.320000, 0.320000, 0.320000, 0.320000, 0.320000, 0.320000, 0.320000, 0.320000, 0.320000, 0.320000, 0.320000, 0.320000, 0.320000, 0.320000, 1.000000};

            if(idade < qx.Length)
            {
                return qx[idade];
            }
            else
            {
                return 1;
            }
        }

        // CSO 58
        public static double CSO58(int idade)
        {
            // Probabilidades de morte de inválidos de 0 a 120 anos em ordem crescente
            // CSO 58
            double[] qxi = { 0.007080, 0.001760, 0.001520, 0.001460, 0.001400, 0.001350, 0.001300, 0.001260, 0.001230, 0.001210, 0.001210, 0.001230, 0.001260, 0.001320, 0.001390, 0.001460, 0.001540, 0.001620, 0.001690, 0.001740, 0.001790, 0.001830, 0.001860, 0.001890, 0.001910, 0.001930, 0.001960, 0.001990, 0.002030, 0.002080, 0.002130, 0.002190, 0.002250, 0.002320, 0.002400, 0.002510, 0.002640, 0.002800, 0.003010, 0.003250, 0.003530, 0.003840, 0.004170, 0.004530, 0.004920, 0.005350, 0.005830, 0.006360, 0.006950, 0.007600, 0.008320, 0.009110, 0.009960, 0.010890, 0.011900, 0.013000, 0.014210, 0.015540, 0.017000, 0.018590, 0.020340, 0.022240, 0.024310, 0.026570, 0.029040, 0.031750, 0.034740, 0.038040, 0.041680, 0.045610, 0.049790, 0.054150, 0.058650, 0.063260, 0.068120, 0.073370, 0.079180, 0.085700, 0.093060, 0.101190, 0.109980, 0.119350, 0.129170, 0.139380, 0.150010, 0.161140, 0.172820, 0.185130, 0.198250, 0.212460, 0.228140, 0.245770, 0.265930, 0.289300, 0.316660, 0.351240, 0.400560, 0.488420, 0.668150, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000};

            if(idade < qxi.Length)
            {
                return qxi[idade];
            }
            else
            {
                return 1;
            }
        }

        // Light Fraca
        public static double LIGHTFRACA(int idade)
        {
            // Probabilidades de entrada em invalidez de 0 a 120 anos em ordem crescente
            // Light Fraca
            double[] ix = {0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000010, 0.000020, 0.000020, 0.000020, 0.000020, 0.000030, 0.000030, 0.000040, 0.000040, 0.000050, 0.000060, 0.000070, 0.000080, 0.000090, 0.000110, 0.000130, 0.000150, 0.000170, 0.000200, 0.000230, 0.000270, 0.000310, 0.000360, 0.000420, 0.000490, 0.000570, 0.000670, 0.000780, 0.000900, 0.001050, 0.001220, 0.001420, 0.001650, 0.001920, 0.002230, 0.002600, 0.003020, 0.003510, 0.004090, 0.004750, 0.005530, 0.006430, 0.007480, 0.008700, 0.010120, 0.011770, 0.013690, 0.015920, 0.018520, 0.021540, 0.025050, 0.030000, 0.034390, 0.039910, 0.046210, 0.053390, 0.053390, 0.053390, 0.053390, 0.053390, 0.053390, 0.053390, 0.053390, 0.053390, 0.053390, 0.053390, 0.053390, 0.053390, 0.053390, 0.053390, 0.053390, 0.053390, 0.053390, 0.053390, 0.053390, 0.053390, 0.053390, 0.053390, 0.053390, 0.053390, 0.053390, 0.053390, 0.053390, 0.053390, 0.053390, 0.053390, 0.053390, 0.053390, 0.053390, 0.053390, 0.053390, 0.053390, 0.053390, 0.053390, 0.053390, 0.053390, 0.053390, 0.053390, 0.053390, 0.053390, 0.053390, 0.053390, 0.053390, 0.053390, 0.053390, 0.053390};

            if (idade < ix.Length)
            {
                return ix[idade];
            }
            else
            {
                return 1;
            }
        }

        // IBGE 2018
        public static double IBGE2018(int idade)
        {
            double[] ex = { 76.305156, 76.258923, 75.322710, 74.362955, 73.393040, 72.417312, 71.437824, 70.455761, 69.471928, 68.486960, 67.501443, 66.516011, 65.531435, 64.548736, 63.569339, 62.595288, 61.638475, 60.691495, 59.752874, 58.820373, 57.892162, 56.968025, 56.047755, 55.129597, 54.211493, 53.292005, 52.370491, 51.447202, 50.522759, 49.598182, 48.674247, 47.751180, 46.828899, 45.907523, 44.987131, 44.067886, 43.150125, 42.234251, 41.320605, 40.409543, 39.501455, 38.596660, 37.695596, 36.798895, 35.907257, 35.021252, 34.141264, 33.267511, 32.400182, 31.539395, 30.685291, 29.838132, 28.998162, 28.165483, 27.340162, 26.522307, 25.712273, 24.910322, 24.116417, 23.330445, 22.552488, 21.782836, 21.022062, 20.270896, 19.530204, 18.800761, 18.082780, 17.376682, 16.683646, 16.005086, 15.342062, 14.694709, 14.063042, 13.447780, 12.849786, 12.269695, 11.707430, 11.162922, 10.636812, 10.130008, 9.643295, 9.643295, 9.643295, 9.643295, 9.643295, 9.643295, 9.643295, 9.643295, 9.643295, 9.643295, 9.643295, 9.643295, 9.643295, 9.643295, 9.643295, 9.643295, 9.643295, 9.643295, 9.643295, 9.643295, 9.643295, 9.643295, 9.643295, 9.643295, 9.643295, 9.643295, 9.643295, 9.643295, 9.643295, 9.643295, 9.643295, 9.643295, 9.643295, 9.643295, 9.643295, 9.643295, 9.643295, 9.643295, 9.643295, 9.643295, 9.643295 };

            if(idade < ex.Length)
            {
                return ex[idade];
            }
            else
            {
                return 0;
            }
        }

        // Tábua de entrada em aposentadoria FUNCEF 2016 Masculino
        public static double EAPO2016M (int idade)
        {
            // Probabilidades de entrada em aposentadoria
            // Experiência FUNCEF Reg/Replan 2016 Masculino
            double[] eapomx = { 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.075000, 0.120000, 0.137500, 0.152500, 0.132500, 0.122500, 0.072500, 0.055000, 0.030000, 0.025000, 0.025000, 0.027500, 0.010000, 0.007500, 0.007500, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000 };

            if (idade < eapomx.Length)
            {
                return eapomx[idade];
            }
            else
            {
                return 0;
            }
        }

        // Tábua de entrada em aposentadoria FUNCEF 2016 Feminino
        public static double EAPO2016F (int idade)
        {
            // Probabilidades de entrada em aposentadoria das idades 0 a 120 anos em ordem crescente
            // Experiência FUNCEF Reg/Replan Não Saldado 2016 Feminino
            double[] eapomx = { 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.037678, 0.071283, 0.115071, 0.144603, 0.134420, 0.106925, 0.107943, 0.078411, 0.060081, 0.039715, 0.042770, 0.016293, 0.011202, 0.016293, 0.007128, 0.005092, 0.002037, 0.003055, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000 };

            if(idade < eapomx.Length)
            {
                return eapomx[idade];
            }
            else
            {
                return 0;
            }
        }

        // Diferença de Idade Masculino
        public static double DIFIDADEM (int idade)
        {
            double[] difidadem = { -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, -2.000000, -2.000000, -2.000000, -2.000000, -2.000000, -2.000000, -2.000000, -2.000000, -2.000000, -2.000000, -4.000000, -4.000000, -4.000000, -4.000000, -4.000000, -4.000000, -4.000000, -4.000000, -4.000000, -4.000000, -5.000000, -5.000000, -5.000000, -5.000000, -5.000000, -5.000000, -5.000000, -5.000000, -5.000000, -5.000000, -5.000000, -5.000000, -5.000000, -5.000000, -5.000000, -5.000000, -5.000000, -5.000000, -5.000000, -5.000000, -6.000000, -6.000000, -6.000000, -6.000000, -6.000000, -6.000000, -6.000000, -6.000000, -6.000000, -6.000000, -6.000000, -6.000000, -6.000000, -6.000000, -6.000000, -6.000000, -6.000000, -6.000000, -6.000000, -6.000000, -6.000000, -6.000000, -6.000000, -6.000000, -6.000000, -6.000000, -6.000000, -6.000000, -6.000000, -6.000000, -6.000000, -6.000000, -6.000000, -6.000000, -6.000000, -6.000000, -6.000000, -6.000000, -6.000000, -6.000000, -6.000000, -6.000000, -6.000000, -6.000000, -6.000000, -6.000000, -6.000000, -6.000000, -6.000000, -6.000000, -6.000000 };

            if (idade < difidadem.Length - 18)
            {
                return difidadem[idade - 18];
            }
            else
            {
                return 0;
            }
        }

        // Diferença de idade Feminino
        public static double DIFIDADEF(int idade)
        {
            double[] difidadef = { 4.000000, 4.000000, 4.000000, 4.000000, 4.000000, 4.000000, 4.000000, 4.000000, 4.000000, 4.000000, 4.000000, 4.000000, 3.000000, 3.000000, 3.000000, 3.000000, 3.000000, 3.000000, 3.000000, 3.000000, 3.000000, 3.000000, 3.000000, 3.000000, 3.000000, 3.000000, 3.000000, 3.000000, 3.000000, 3.000000, 3.000000, 3.000000, 3.000000, 3.000000, 3.000000, 3.000000, 3.000000, 3.000000, 3.000000, 3.000000, 3.000000, 3.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000, 2.000000 };

            if (idade < difidadef.Length - 18)
            {
                return difidadef[idade - 18];
            }
            else
            {
                return 0;
            }
        }

        // Percentual casados masculino
        public static double PERCCASADOSM(int idade)
        {
            double[] perccasadosm = { 0.000000, 0.000000, 0.000000, 0.060000, 0.120000, 0.170000, 0.220000, 0.270000, 0.320000, 0.360000, 0.400000, 0.440000, 0.480000, 0.520000, 0.550000, 0.580000, 0.610000, 0.640000, 0.660000, 0.680000, 0.710000, 0.720000, 0.740000, 0.760000, 0.770000, 0.790000, 0.800000, 0.810000, 0.820000, 0.830000, 0.840000, 0.840000, 0.850000, 0.850000, 0.850000, 0.860000, 0.860000, 0.860000, 0.860000, 0.860000, 0.860000, 0.850000, 0.850000, 0.850000, 0.850000, 0.840000, 0.840000, 0.840000, 0.830000, 0.830000, 0.820000, 0.820000, 0.810000, 0.810000, 0.810000, 0.810000, 0.810000, 0.810000, 0.810000, 0.810000, 0.810000, 0.810000, 0.810000, 0.810000, 0.810000, 0.810000, 0.810000, 0.810000, 0.810000, 0.810000, 0.810000, 0.810000, 0.810000, 0.810000, 0.810000, 0.810000, 0.810000, 0.810000, 0.810000, 0.810000, 0.810000, 0.810000, 0.810000, 0.810000, 0.810000, 0.810000, 0.810000, 0.810000, 0.810000, 0.810000, 0.810000, 0.810000, 0.810000, 0.810000, 0.810000, 0.810000, 0.810000, 0.810000, 0.810000, 0.810000, 0.810000, 0.810000, 0.810000 };

            if(idade < perccasadosm.Length - 18)
            {
                return perccasadosm[idade - 18];
            }
            else
            {
                return 0;
            }

        }

        // Percentual casados feminino
        public static double PERCCASADOSF(int idade)
        {
            double[] perccasadosf = { 0.000000, 0.000000, 0.020000, 0.080000, 0.140000, 0.190000, 0.240000, 0.280000, 0.330000, 0.370000, 0.400000, 0.440000, 0.470000, 0.500000, 0.530000, 0.550000, 0.570000, 0.590000, 0.610000, 0.630000, 0.640000, 0.650000, 0.660000, 0.670000, 0.680000, 0.680000, 0.680000, 0.690000, 0.690000, 0.680000, 0.680000, 0.680000, 0.670000, 0.660000, 0.660000, 0.650000, 0.640000, 0.630000, 0.620000, 0.600000, 0.590000, 0.580000, 0.560000, 0.550000, 0.530000, 0.520000, 0.500000, 0.490000, 0.470000, 0.460000, 0.440000, 0.420000, 0.410000, 0.410000, 0.410000, 0.410000, 0.410000, 0.410000, 0.410000, 0.410000, 0.410000, 0.410000, 0.410000, 0.410000, 0.410000, 0.410000, 0.410000, 0.410000, 0.410000, 0.410000, 0.410000, 0.410000, 0.410000, 0.410000, 0.410000, 0.410000, 0.410000, 0.410000, 0.410000, 0.410000, 0.410000, 0.410000, 0.410000, 0.410000, 0.410000, 0.410000, 0.410000, 0.410000, 0.410000, 0.410000, 0.410000, 0.410000, 0.410000, 0.410000, 0.410000, 0.410000, 0.410000, 0.410000, 0.410000, 0.410000, 0.410000, 0.410000, 0.410000 };

            if (idade < perccasadosf.Length - 18)
            {
                return perccasadosf[idade - 18];
            }
            else
            {
                return 0;
            }
        }
    }
}

NOTICE: some tables contain the difference of age between the participant of a benefit plan and their spouses, not a probability. Every table has the value of the premise based on the age of the participant, considering that the person can live up to 120 years. Some tables start at the age of zero and others start at the age of 18.

1

There are 1 best solutions below

0
AudioBubble On

The "Edit" section of the question has the solution that is helping me right now. It was the best solution I could come up with by now.

Thank you guys!