예제 #1
0
        /// <summary>
        /// Creates a frequency object and persists it to the database via bulk upload
        /// </summary>
        /// <param name="frequency"></param>
        /// <param name="matrixId"></param>
        /// <returns></returns>
        private int CreateFrequency(FrequencyRecordDTO_Create frequency, int matrixId)
        {
            Matrix_ADO matrixAdo = new Data.Matrix_ADO(Ado);

            frequency.FrequencyId = matrixAdo.CreateFrequencyRecord(frequency, matrixId);

            DataTable dtPeriods = new DataTable();

            dtPeriods.Columns.Add("PRD_CODE");
            dtPeriods.Columns.Add("PRD_VALUE");
            dtPeriods.Columns.Add("PRD_FRQ_ID");

            foreach (var p in frequency.Period)
            {
                DataRow dr = dtPeriods.NewRow();
                dr["PRD_CODE"]   = p.Code;
                dr["PRD_VALUE"]  = p.Value;
                dr["PRD_FRQ_ID"] = frequency.FrequencyId;
                dtPeriods.Rows.Add(dr);
            }

            matrixAdo.CreatePeriodRecordBulk(dtPeriods);

            //read the period id's for the uploaded periods
            List <dynamic> periodData = matrixAdo.ReadPeriodsByMatrixId(matrixId).ToList();

            foreach (var p in frequency.Period)
            {
                p.FrequencyPeriodId = periodData.Where(x => x.PrdCode == p.Code).FirstOrDefault().PrdId;
            }

            return(frequency.FrequencyId);
        }
예제 #2
0
        /// <summary>
        /// Creates classifications
        /// </summary>
        /// <param name="classifications"></param>
        /// <param name="matrixId"></param>
        private void CreateClassifications(IList <ClassificationRecordDTO_Create> classifications, int matrixId)
        {
            Matrix_ADO matrixAdo = new Data.Matrix_ADO(Ado);

            DataTable variablesTable = new DataTable();

            variablesTable.Columns.Add("VRB_CODE");
            variablesTable.Columns.Add("VRB_VALUE");
            variablesTable.Columns.Add("VRB_CLS_ID");

            foreach (var classification in classifications)
            {
                classification.ClassificationId = matrixAdo.CreateClassificationRecord(classification, matrixId);
                foreach (var v in classification.Variable)
                {
                    variablesTable.Rows.Add(new Object[] { v.Code, v.Value, classification.ClassificationId });
                }
            }
            matrixAdo.CreateVariableRecordBulk(variablesTable);

            //we need to get the variable ID's for the new variables, so we need to read them for each classificatio
            foreach (var classification in classifications)
            {
                classification.Variable = matrixAdo.ReadClassificationVariables(classification.ClassificationId);
            }
        }
예제 #3
0
        /// <summary>
        /// Creates an ID for statistic
        /// </summary>
        /// <param name="statistics"></param>
        /// <param name="matrixId"></param>
        private void CreateStatisticalProducts(IList <StatisticalRecordDTO_Create> statistics, int matrixId)
        {
            Matrix_ADO matrixAdo = new Data.Matrix_ADO(Ado);

            foreach (var stat in statistics)
            {
                stat.StatisticalProductId = matrixAdo.CreateStatisticalRecord(stat, matrixId);
            }
        }
예제 #4
0
        /// <summary>
        /// Creates the metadata for a specific language (px files may contain metadata in more than one language)
        /// </summary>
        /// <param name="releaseId"></param>
        /// <param name="theMatrix"></param>
        /// <param name="languageSpec"></param>
        /// <param name="username"></param>
        /// <param name="DTO"></param>
        private void CreateMatrixForLanguage(int releaseId, Matrix theMatrix, Matrix.Specification languageSpec, string username, dynamic DTO)
        {
            Matrix_ADO matrixAdo       = new Data.Matrix_ADO(Ado);
            var        matrixRecordDTO = GetMatrixDto(theMatrix, languageSpec, DTO);

            languageSpec.MatrixId = matrixAdo.CreateMatrixRecord(matrixRecordDTO, releaseId, username);

            languageSpec.Frequency.FrequencyId = CreateFrequency(languageSpec.Frequency, languageSpec.MatrixId);

            // if I have contvariable I use the content of contvariable to access the values with that value to obtain the names of stat products
            // and I use codes with same name to get the correspondent codes!
            // otherwise

            // if there is only one statistical product we use contents for the title and we set the code at zero 0

            CreateStatisticalProducts(languageSpec.Statistic, languageSpec.MatrixId);

            CreateClassifications(languageSpec.Classification, languageSpec.MatrixId);
        }
예제 #5
0
        /// <summary>
        /// Deletes a release based on release code
        /// </summary>
        /// <param name="rlsCode"></param>
        /// <param name="username"></param>
        internal void DeleteReleaseEntities(int rlsCode, string username)
        {
            Matrix_ADO matrixAdo = new Data.Matrix_ADO(new API.ADO());

            matrixAdo.Delete(rlsCode, username);
        }