Esempio n. 1
0
        /// <summary>
        /// Gets the count from database/template and update into DBMetadata Table
        /// </summary>
        public void GetNUpdateCounts()
        {
            string    AreaCount       = string.Empty;
            string    IndicatorCount  = string.Empty;
            string    IUSCount        = string.Empty;
            string    TimeperiodCount = string.Empty;
            string    SourceCount     = string.Empty;
            string    DataCount       = string.Empty;
            string    SearchString    = string.Empty;
            DataTable SourceTable;

            // Get NId from DBMetadata Table

            // Get area count
            AreaCount = this.DBConnection.ExecuteScalarSqlQuery(DIQueries.GetTableRecordsCount(this.DBQueries.TablesName.Area, string.Empty)).ToString();

            // Get Indicator count
            IndicatorCount = this.DBConnection.ExecuteScalarSqlQuery(DIQueries.GetTableRecordsCount(this.DBQueries.TablesName.Indicator, string.Empty)).ToString();
            // Get IUS count
            IUSCount = this.DBConnection.ExecuteScalarSqlQuery(DIQueries.GetTableRecordsCount(this.DBQueries.TablesName.IndicatorUnitSubgroup, string.Empty)).ToString();

            // Get timeperiod count
            TimeperiodCount = this.DBConnection.ExecuteScalarSqlQuery(DIQueries.GetTableRecordsCount(this.DBQueries.TablesName.TimePeriod, string.Empty)).ToString();

            // Get source count
            SearchString = IndicatorClassifications.ICParent_NId + ">0";
            SourceTable  = this.DBConnection.ExecuteDataTable(this.DBQueries.Source.GetSource(FilterFieldType.Search, SearchString, FieldSelection.NId, false));
            if (SourceTable.Rows.Count > 0)
            {
                SourceCount = Convert.ToString(SourceTable.Select().Length);
            }
            else
            {
                SourceCount = "0";
            }


            // Get data count
            DataCount = this.DBConnection.ExecuteScalarSqlQuery(DIQueries.GetTableRecordsCount(this.DBQueries.TablesName.Data, string.Empty)).ToString();

            this.UpdateCounts(-1, AreaCount, IndicatorCount, IUSCount, TimeperiodCount, SourceCount, DataCount);
        }
Esempio n. 2
0
        /// <summary>
        /// Updates count information
        /// </summary>
        /// <param name="NID"></param>
        /// <param name="areaCount"></param>
        /// <param name="indicatorCount"></param>
        /// <param name="IUSCount"></param>
        /// <param name="timeperiodCount"></param>
        /// <param name="sourceCount"></param>
        /// <param name="dataCount"></param>
        public void UpdateCounts(int NID,
                                 string areaCount, string indicatorCount, string IUSCount, string timeperiodCount, string sourceCount, string dataCount)
        {
            string   PublishedOn = System.DateTime.Now.ToString("yyyy-MM-dd");
            string   SqlQuery    = string.Empty;
            DITables TablesName;
            string   DataPrefix     = this.DBConnection.DIDataSetDefault();
            bool     UseUpdateQuery = true;

            try
            {
                // check record exists in DB_Metadata table or not
                if (Convert.ToInt32(this.DBConnection.ExecuteScalarSqlQuery(DIQueries.GetTableRecordsCount(this.DBQueries.TablesName.DBMetadata, string.Empty))) == 0)
                {
                    UseUpdateQuery = false;
                }

                foreach (DataRow Row in this.DBConnection.DILanguages(DataPrefix).Rows)
                {
                    TablesName = new DITables(DataPrefix, "_" + Row[Language.LanguageCode].ToString());

                    if (UseUpdateQuery)
                    {
                        // update query
                        SqlQuery = DevInfo.Lib.DI_LibDAL.Queries.DBMetadata.Update.UpdateCounts(TablesName.DBMetadata, NID,
                                                                                                areaCount, indicatorCount, IUSCount, timeperiodCount, sourceCount, dataCount);
                    }
                    else
                    {
                        //insert query
                        SqlQuery = DevInfo.Lib.DI_LibDAL.Queries.DBMetadata.Insert.InsertRecord(TablesName.DBMetadata, string.Empty, string.Empty, PublishedOn, string.Empty, string.Empty, string.Empty,
                                                                                                areaCount, indicatorCount, IUSCount, timeperiodCount, sourceCount, dataCount);
                    }
                    this.DBConnection.ExecuteNonQuery(SqlQuery);
                }
            }
            catch (Exception ex)
            {
                ExceptionFacade.ThrowException(ex);
            }
        }