コード例 #1
0
 public void GetItemsOfCalcuation(out InputData inputData, out GatewaySchedule gs, out WaterLevel waterLevel, out int waterLevelPercent)
 {
     inputData         = this.inputData;
     gs                = this.gs;
     waterLevel        = this.waterLevel;
     waterLevelPercent = this.waterLevelPercent;
 }
コード例 #2
0
 public OutputData(IDataAccess dataAccess, InputData inputData, GatewaySchedule gs) : this(dataAccess, inputData)
 {
     this.gs = gs ?? throw new System.ArgumentNullException(nameof(gs));
 }
コード例 #3
0
        public void RecalculateSaltBalancePart(string yearOfCalculation)
        {
            if (DataAccess == null)
            {
                throw new ArgumentNullException("DataAccess is null.");
            }

            // get input data => S1, S2 and other
            s1 = DataAccess.GetColumnData <double>($"SELECT S1 FROM OutputData WHERE YearName = {yearOfCalculation} LIMIT 12").ToArray();
            //s2 = DataAccess.GetColumnData<double>($"SELECT S2 FROM OutputData WHERE YearName = {yearOfCalculation} LIMIT 12").ToArray();

            for (int i = 0; i < s1.Length - 1; i++)
            {
                s2[i] = s1[i + 1];
            }
            s2[s1.Length - 1] = DataAccess.GetCellData <double>($"SELECT S2 FROM OutputData WHERE YearName = {yearOfCalculation} AND MonthID = 12");

            vp  = DataAccess.GetColumnData <double>($"SELECT Vp FROM OutputData WHERE YearName = {yearOfCalculation} LIMIT 12").ToArray();
            vr  = DataAccess.GetColumnData <double>($"SELECT Vr FROM OutputData WHERE YearName = {yearOfCalculation} LIMIT 12").ToArray();
            vb  = DataAccess.GetColumnData <double>($"SELECT Vb FROM OutputData WHERE YearName = {yearOfCalculation} LIMIT 12").ToArray();
            vg  = DataAccess.GetColumnData <double>($"SELECT Vg FROM OutputData WHERE YearName = {yearOfCalculation} LIMIT 12").ToArray();
            vdr = DataAccess.GetColumnData <double>($"SELECT Vdr FROM OutputData WHERE YearName = {yearOfCalculation} LIMIT 12").ToArray();

            gs = new GatewaySchedule(DataAccess, yearOfCalculation);

            inputData = new InputData()
            {
                Vz = DataAccess.GetColumnData <double>($"SELECT Vz FROM InputData WHERE YearName = {yearOfCalculation} LIMIT 12").ToArray()
            };

            // calculate
            CalculateSaltBalancePart(true);
            RoundOutputData();

            // save changes
            string sql = "";

            for (int i = 0; i < 14; i++)
            {
                if (i < 12)
                {
                    sql += "UPDATE OutputData SET " +
                           $"S2 = {s2[i]}, " +
                           $"Sp = {sp[i]}, Sr = {sr[i]}, Sb = {sb[i]}, Sg = {sg[i]}, Sdr = {sdr[i]}, SD_plus = {sdPlus[i]}, Soz_plus = {sozPlus[i]}, " +
                           $"C1 = {c1[i]}, C2 = {c2[i]}, Cp = {cp[i]}, Cr = {cr[i]}, Cb = {cb[i]}, Cg = {cg[i]}, Cdr = {cdr[i]}, " +
                           $"CD_plus = {cdPlus[i]}, Coz_plus = {cozPlus[i]}, EpCi_plus = {epciPlus[i]}, Sf = {sf[i]}, Sz = {sz[i]}, " +
                           $"SD_minus = {sdMinus[i]}, Soz_minus = {sozMinus[i]}, Cf = {cf[i]}, Cz = {cz[i]}, CD_minus = {cdMinus[i]}, " +
                           $"Coz_minus = {cozMinus[i]}, EpCi_minus = {epciMinus[i]} WHERE MonthID = {i + 1} AND YearName = {yearOfCalculation};\n";
                }
                else if (i == 12)
                {
                    sql += "UPDATE OutputData SET " +
                           $"Cp = {sumsOfSBP[0]}, Cr = {sumsOfSBP[1]}, Cb = {sumsOfSBP[2]}, Cg = {sumsOfSBP[3]}, Cdr = {sumsOfSBP[4]}, CD_plus = {sumsOfSBP[5]}, " +
                           $"Coz_plus = {sumsOfSBP[6]}, EpCi_plus = {sumsOfSBP[7]}, Cf = {sumsOfSBC[0]}, Cz = {sumsOfSBC[1]}, CD_minus = {sumsOfSBC[2]}, " +
                           $"Coz_minus = {sumsOfSBC[3]}, EpCi_minus = {sumsOfSBC[4]} WHERE MonthID = {i + 1} AND YearName = {yearOfCalculation};\n";
                }
                else
                {
                    sql += "UPDATE OutputData SET " +
                           $"Cp = {percentsOfSBP[0]}, Cr = {percentsOfSBP[1]}, Cb = {percentsOfSBP[2]}, Cg = {percentsOfSBP[3]}, Cdr = {percentsOfSBP[4]}, CD_plus = {percentsOfSBP[5]}, " +
                           $"Coz_plus = {percentsOfSBP[6]}, EpCi_plus = {percentsOfSBP[7]}, Cf = {percentsOfSBC[0]}, Cz = {percentsOfSBC[1]}, CD_minus = {percentsOfSBC[2]}, " +
                           $"Coz_minus = {percentsOfSBC[3]}, EpCi_minus = {percentsOfSBC[4]} WHERE MonthID = {i + 1} AND YearName = {yearOfCalculation};";
                }
            }

            sql = sql.Replace(",", ".");
            sql = sql.Replace(". ", ", ");

            DataAccess.Execute(sql);
        }