Esempio n. 1
0
        public override List <ArchTechArchive> InvokeReadArchive()
        {
            using (var cnctns = new SqlConnection(Settings.DbConnectionString))
                using (var cmd = new SqlCommand("usp2_ArchTech_Select", cnctns))
                {
                    cmd.CommandType    = CommandType.StoredProcedure;
                    cmd.CommandTimeout = 600;
                    cmd.Parameters.AddWithValue("@DTStart", RequestParams.DtStart);
                    cmd.Parameters.AddWithValue("@DTEnd", RequestParams.DtEnd);
                    cmd.Parameters.AddWithValue("@UseLossesCoefficient", RequestParams.UseLossesCoefficient);
                    cmd.Parameters.AddWithValue("@UseCoeffTransformation", RequestParams.UseCoeffTransformation);

                    if (RequestParams.TechProfilePeriod.HasValue)
                    {
                        cmd.Parameters.AddWithValue("@techProfilePeriod", RequestParams.TechProfilePeriod);
                    }

                    var userDefinedTypeTable = SQLTableTypeAdapter <IntPair> .ArchiveValuesToDataTable(TiIds);

                    //Таблица с ТИ
                    cmd.Parameters.AddWithValue("@TIArray", userDefinedTypeTable);
                    cnctns.Open();
                    //Читаем данные
                    using (var dr = cmd.ExecuteReader())
                    {
                        Dictionary <int, Dictionary <byte, List <TPeriodCoeff> > >       coeffTransformationDict = null;
                        Dictionary <int, Dictionary <byte, List <TLossesCoefficient> > > lossesCoefficientsDict  = null;

                        #region Таблица с коэфф. потерь для ТИ

                        if (RequestParams.UseLossesCoefficient)
                        {
                            lossesCoefficientsDict = ReadLossesCoefficientsDict(dr);
                            dr.NextResult();
                        }

                        #endregion

                        #region Чтение коэфф. трансформации

                        if (RequestParams.UseCoeffTransformation)
                        {
                            coeffTransformationDict = ReadCoeffTransformation(dr);
                            dr.NextResult();
                        }

                        #endregion

                        return(ReadArchives(dr, coeffTransformationDict, lossesCoefficientsDict));
                    }
                }
        }
Esempio n. 2
0
        private void SaveResiudes(IEnumerable <DBResiduesTable> tiForResaveResiudes, int halfHoursShiftFromUtc, bool isReadCalculatedValues)
        {
            try
            {
                //Параметры процедуры
                var otherParams = new List <Tuple <string, object> >
                {
                    new Tuple <string, object>("@HalfHoursShiftFromUTC", halfHoursShiftFromUtc),
                    new Tuple <string, object>("@IsReadCalculatedValues", isReadCalculatedValues),
                };

                var sqlAdapter = new SQLTableTypeAdapter <DBResiduesTable>(tiForResaveResiudes);
                sqlAdapter.WriteTableToSQL("usp2_WriteExpDocResidues", "@ResiduesTable", otherParams);
            }
            catch
            {
            }
        }