예제 #1
0
        public MaterialMatrix Clone()
        {
            MaterialMatrix m2 = new MaterialMatrix();

            m2.Data = (int[, ]) this.Data.Clone();
            return(m2);
        }
예제 #2
0
        public static MaterialMatrix GetMaterials(string[] produktkey)
        {
            // only RKP II
            if (!produktkey[0].StartsWith("D"))
            {
                return(null);
            }
            MaterialMatrix resultMat = new MaterialMatrix();

            string[] tmp_prodkey    = (string[])produktkey.Clone();
            bool     next_pump_avai = false;

            do
            {
                string old_pos19 = tmp_prodkey[19];

                if (old_pos19 != "" && old_pos19 != "DS1")
                {
                    tmp_prodkey[19] = "DS1";
                    next_pump_avai  = true;
                }
                else
                {
                    next_pump_avai = false;
                }

                MaterialMatrix soloMat = GetMaterialsSolo(tmp_prodkey);
                if (soloMat == null || soloMat.CountNonNegativeEntrys() != 3)
                {
                    return(null);
                }
                resultMat = resultMat + soloMat;

                tmp_prodkey[19] = old_pos19;

                if (next_pump_avai)
                {
                    // remove repeating part to simulate solo pump
                    // articlenum might be false then but its only for detect of RKP II

                    for (int cnt = 0; (19 + cnt) < tmp_prodkey.Length; cnt++)
                    {
                        tmp_prodkey[11 + cnt] = tmp_prodkey[19 + cnt];
                    }

                    // all following stages of RKP's have XX cover
                    tmp_prodkey[10] = "XX";
                }
            } while (next_pump_avai);
            return(resultMat);
        }
예제 #3
0
        public static MaterialMatrix operator -(MaterialMatrix m1, MaterialMatrix m2)
        {
            MaterialMatrix m3 = new MaterialMatrix();

            for (int x = 0; x < SIZE_X; x++)
            {
                for (int y = 0; y < SIZE_Y; y++)
                {
                    if (m3.Data[x, y] != INACTIVE_ENTRY)
                    {
                        m3.Data[x, y] = m1.Data[x, y] - m2.Data[x, y];
                    }
                }
            }
            return(m3);
        }
예제 #4
0
        public static bool IsAvailable(string[] productkey, MaterialMatrix avaiMat)
        {
            if (avaiMat == null)
            {
                throw new Exception("Availibility Matrix is null (" + avaiMat + ")");
            }
            // only RKP II
            MaterialMatrix matMat = GetMaterials(productkey);

            if (matMat == null)
            {
                return(false);
            }
            MaterialMatrix m3 = avaiMat - matMat;

            return(m3.IsNotNegativ());
        }
예제 #5
0
        public static MaterialMatrix ReadFromFile(string path)
        {
            MaterialMatrix mat = new MaterialMatrix();

            using (TextFieldParser parser = new TextFieldParser(path))
            {
                parser.TextFieldType = FieldType.Delimited;
                parser.SetDelimiters(";");
                if (!parser.EndOfData)
                {
                    parser.ReadFields();                    // name/ version of serialize
                }
                if (!parser.EndOfData)
                {
                    parser.ReadFields();                    // label of x
                }
                for (int y = 0; y < SIZE_Y && !parser.EndOfData; y++)
                {
                    //Processing row
                    string[] fields = parser.ReadFields();
                    for (int x = 0; x < SIZE_X && x < fields.Length; x++)
                    {
                        int val = 0;
                        if (fields[x + 1] == "NaN")
                        {
                            mat.Data[x, y] = INACTIVE_ENTRY;
                        }
                        else if (string.IsNullOrWhiteSpace(fields[x + 1]))
                        {
                            mat.Data[x, y] = 0;
                        }
                        else if (int.TryParse(fields[x + 1], out val))
                        {
                            mat.Data[x, y] = val;
                        }
                        else
                        {
                            throw new Exception("Illegal character at serialization");
                        }
                    }
                }
            }
            return(mat);
        }
 public MaterialMatrix GetAvailibilityMatrix()
 {
     if (close_after_request)
     {
         conn = new MySqlConnection(connStr);
         conn.Open();
     }
     try
     {
         MaterialMatrix mat = new MaterialMatrix();
         for (int px = 0; px < MaterialMatrix.SIZE_X; px++)
         {
             for (int py = 0; py < MaterialMatrix.SIZE_Y; py++)
             {
                 string          type = MaterialMatrix.LabelMatX[px].Replace(' ', '_') + "_" + MaterialMatrix.LabelMatY[py].Replace(' ', '_');
                 string          sql  = "SELECT count FROM lager WHERE type='" + type + "'";
                 var             cmd  = new MySqlCommand(sql, conn);
                 MySqlDataReader rdr  = cmd.ExecuteReader();
                 try
                 {
                     if (rdr.Read())
                     {
                         if (!mat.IsInactive(px, py))
                         {
                             mat[px, py] = (int)rdr[0];
                         }
                     }
                 }
                 finally
                 {
                     rdr.Close();
                 }
             }
         }
         return(mat);
     }
     finally
     {
         if (close_after_request)
         {
             conn.Close();
         }
     }
 }
        public void SetAvailibilityMatrix(MaterialMatrix mat)
        {
            if (close_after_request)
            {
                conn = new MySqlConnection(connStr);
                conn.Open();
            }
            try
            {
                MySqlCommand cmd = new MySqlCommand("DELETE FROM lager", conn);
                cmd.ExecuteNonQuery();

                for (int px = 0; px < MaterialMatrix.SIZE_X; px++)
                {
                    for (int py = 0; py < MaterialMatrix.SIZE_Y; py++)
                    {
                        if (!mat.IsInactive(px, py))
                        {
                            int    count = mat[px, py];
                            string type  = MaterialMatrix.LabelMatX[px].Replace(' ', '_') + "_" + MaterialMatrix.LabelMatY[py].Replace(' ', '_');
                            int    hash  = type.GetHashCode();
                            string sql   = "INSERT INTO lager (dbkey,type,count) VALUES (" + hash + ",'" + type + "'," + count + ")";
                            cmd = new MySqlCommand(sql, conn);
                            cmd.ExecuteNonQuery();
                        }
                    }
                }
            }
            finally
            {
                if (close_after_request)
                {
                    conn.Close();
                }
            }
        }
예제 #8
0
        public static Statistics CalcStatistics(ExcelWrapper excelWrapper, MaterialMatrix materialMat)
        {
            Statistics ret = new Statistics();

#if !DEBUG
            try
#endif
            {
                if (materialMat == null || !materialMat.IsNotNegativ() || materialMat.CountNonNegativeEntrys() < 3)
                {
                    return(null);
                }
                MaterialMatrix tmpMaterialMatrix = materialMat.Clone();

                for (int colInd = 49; colInd < excelWrapper.GetRowCount(); colInd++)
                {
                    string[] obj          = excelWrapper.GetRow(colInd);
                    bool     isAvai       = false;
                    bool     isResolvable = false;
                    if (string.IsNullOrWhiteSpace(obj[0]))
                    {
                        throw new Exception();
                    }
#if !DEBUG
                    try
#endif
                    {
                        isAvai       = AvailabilityCheck.IsAvailable(obj, tmpMaterialMatrix);
                        isResolvable = AvailabilityCheck.CanResolve(obj);
                    }
#if !DEBUG
                    catch (Exception) { }
#endif
                    if (isAvai)
                    {
                        ret.countAllAvai++;
                        ret.allAvaiPumps.Add(obj);
                    }
                    ret.countAll++;
                    ret.allPumps.Add(obj);
                    if (obj[11] == "RKP" || obj[11] == "FRP")
                    {
                        ret.countRKP++;
                        ret.RKPPumps.Add(obj);
                        if (isAvai)
                        {
                            ret.countRKPAvai++;
                            ret.RKPAvaiPumps.Add(obj);
                        }
                    }
                    if (isResolvable)
                    {
                        ret.resolvable++;
                        ret.resolvablePumps.Add(obj);
                        if (isAvai)
                        {
                            ret.resolvableAvai++;
                            ret.resolvableAvaiPumps.Add(obj);
                        }
                    }
                    if (string.IsNullOrWhiteSpace(obj[0]))
                    {
                        throw new Exception();
                    }
                }
            }
#if !DEBUG
            catch (Exception) { return(ret); }
#endif
            return(ret);
        }
예제 #9
0
        public static MaterialMatrix GetMaterialsSolo(string[] produktkey)
        {
            // only RKP II
            if (!produktkey[0].StartsWith("D"))
            {
                return(null);
            }
            // no AZP's
            if (produktkey[11] != "RKP" && produktkey[11] != "FRP")
            {
                return(null);
            }
            // only solo
            if (!string.IsNullOrWhiteSpace(produktkey[19]) && produktkey[19] != "DS1")
            {
                return(null);
            }
            int pumpsize = int.Parse(produktkey[12]);

            // only size <= 140
            if (pumpsize > 140)
            {
                return(null);
            }

            MaterialMatrix materialMat = new MaterialMatrix();
            int            sizeIndex   = -1;

            switch (int.Parse(produktkey[12]))
            {
            case 19: sizeIndex = 0; break;

            case 32: sizeIndex = 1; break;

            case 45: sizeIndex = 2; break;

            case 63: sizeIndex = 3; break;

            case 80: sizeIndex = 4; break;

            case 100: sizeIndex = 5; break;

            case 140: sizeIndex = 6; break;

            default: throw new Exception("unknown pump size");
            }
            if (produktkey[11] == "RKP")
            {
                if (produktkey[8] == "R")
                {
                    if (string.IsNullOrWhiteSpace(produktkey[19]))
                    {
                        // double can be used as single anyway
                        materialMat[sizeIndex, 0]++;
                    }
                    else
                    {
                        materialMat[sizeIndex, 1]++;
                    }
                }
                else
                {
                    if (string.IsNullOrWhiteSpace(produktkey[19]))
                    {
                        // double can be used as single anyway
                        materialMat[sizeIndex, 5]++;
                    }
                    else
                    {
                        materialMat[sizeIndex, 6]++;
                    }
                }
            }
            if (produktkey[11] == "FRP")
            {
                if (produktkey[8] == "R")
                {
                    if (string.IsNullOrWhiteSpace(produktkey[19]))
                    {
                        // double can be used as single anyway
                        materialMat[sizeIndex, 2]++;
                    }
                    else
                    {
                        materialMat[sizeIndex, 3]++;
                    }
                }
            }
            if (string.IsNullOrWhiteSpace(produktkey[19])) // solo
            {
                if (produktkey[14] == "C")                 //HFC
                {
                    switch (produktkey[10])
                    {
                    case "A1": materialMat[sizeIndex, 20]++; break;

                    default: break;
                    }
                }
                else if (produktkey[14] == "M" || produktkey[14] == "D")     // Mineral-Oil
                {
                    switch (produktkey[10])
                    {
                    case "A1": materialMat[sizeIndex, 7]++; break;

                    case "C3": materialMat[sizeIndex, 10]++; break;

                    case "A7": materialMat[sizeIndex, 13]++; break;

                    case "XX": materialMat[sizeIndex, 16]++; break;

                    default: break;
                    }
                }
                else if (produktkey[14] == "A")     // Mineral-Oil
                {
                    switch (produktkey[10])
                    {
                    case "A7": materialMat[sizeIndex, 18]++; break;

                    default: break;
                    }
                }
            }
            else// no-solo (DS1)
            {
                if (produktkey[14] == "C")   //HFC
                {
                    switch (produktkey[10])
                    {
                    case "B1": materialMat[sizeIndex, 19]++; break;

                    default: break;
                    }
                }
                else if (produktkey[14] == "M" || produktkey[14] == "D")     // Mineral-Oil
                {
                    switch (produktkey[10])
                    {
                    case "A1": materialMat[sizeIndex, 8]++; break;

                    case "B1": materialMat[sizeIndex, 9]++; break;

                    case "C3": materialMat[sizeIndex, 11]++; break;

                    case "D3": materialMat[sizeIndex, 12]++; break;

                    case "A7": materialMat[sizeIndex, 14]++; break;

                    case "B7": materialMat[sizeIndex, 15]++; break;

                    case "XX": materialMat[sizeIndex, 17]++; break;

                    default: break;
                    }
                }
            }
            switch (produktkey[16])
            {
            case "F2": materialMat[sizeIndex, 21]++; break;

            case "F1": materialMat[sizeIndex, 22]++; break;

            case "H1": materialMat[sizeIndex, 23]++; break;

            case "H2": materialMat[sizeIndex, 25]++; break;

            case "J1": materialMat[sizeIndex, 26]++; break;

            case "R1": materialMat[sizeIndex, 27]++; break;

            case "U1": materialMat[sizeIndex, 28]++; break;

            case "G2": materialMat[sizeIndex, 29]++; break;

            case "C1": materialMat[sizeIndex, 30]++; break;

            case "E1": materialMat[sizeIndex, 31]++; break;

            case "E2": materialMat[sizeIndex, 32]++; break;

            case "D1": materialMat[sizeIndex, 33]++; break;

            case "D2": materialMat[sizeIndex, 34]++; break;

            case "B2": materialMat[sizeIndex, 37]++; break;

            case "S2": materialMat[sizeIndex, 38]++; break;

            case "S3": materialMat[sizeIndex, 39]++; break;

            case "S1": materialMat[sizeIndex, 40]++; break;
            }
            return(materialMat);
        }
예제 #10
0
        public static bool CanResolve(string[] productkey)
        {
            MaterialMatrix matMat = GetMaterials(productkey);

            return(matMat != null);
        }
예제 #11
0
 public void SetAvailibilityMatrix(MaterialMatrix mat)
 {
     throw new NotImplementedException();
 }