Exemple #1
0
        /// <summary>
        /// Run a cleanup function to hard delete unwanted
        /// </summary>
        private static void runDeletes()
        {
            ADO defaultADO = new ADO("defaultConnection");
            ADO adoBatch   = new ADO("msdbConnection");

            try

            {
                Matrix_ADO defaultMatrixAdo = new Matrix_ADO(defaultADO);

                string processName = "DataMatrixDeleteEntities_" + defaultMatrixAdo.getDbName();

                if (!defaultMatrixAdo.IsProcessRunning(processName))
                {
                    Matrix_ADO mAdo = new Matrix_ADO(adoBatch);


                    mAdo.DeleteEntities(processName);
                    adoBatch.CloseConnection();
                    adoBatch.Dispose();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                defaultADO.CloseConnection();
                defaultADO.Dispose();
                adoBatch.CloseConnection();
                adoBatch.Dispose();
            }
        }
Exemple #2
0
        /// <summary>
        /// Execute
        /// </summary>
        /// <returns></returns>
        protected override bool Execute()
        {
            if (DTO.Format.FrmDirection != FormatDirection.DOWNLOAD.ToString())
            {
                return(false);
            }

            ////See if this request has cached data
            MemCachedD_Value cache = MemCacheD.Get_BSO <dynamic>("PxStat.Data", "Cube_API", "ReadPreMetadata", DTO);

            if (cache.hasData)
            {
                Response.data = cache.data;
                return(true);
            }

            var item   = new Matrix_ADO(Ado).Read(DTO.release, DTO.language, SamAccountName);
            var result = Release_ADO.GetReleaseDTO(item);

            if (result == null)
            {
                Response.data = null;
                return(true);
            }

            DTO.language = item.LngIsoCode;
            return(Cube_BSO_ReadMetadata.ExecuteReadMetadata(Ado, DTO, result, Response, false));
        }
Exemple #3
0
        /// <summary>
        /// Execute
        /// </summary>
        /// <returns></returns>
        protected override bool Execute()
        {
            var adoMatrix = new Matrix_ADO(Ado);
            var list      = adoMatrix.ReadHistory(SamAccountName, DTO);

            Response.data = list;

            return(true);
        }
Exemple #4
0
        /// <summary>
        /// Execute
        /// </summary>
        /// <returns></returns>
        protected override bool Execute()
        {
            var adoMatrix = new Matrix_ADO(Ado);
            var list      = adoMatrix.Read(DTO.RlsCode, DTO.LngIsoCode, SamAccountName);

            Response.data = list;

            return(true);
        }
Exemple #5
0
        protected override bool Execute()
        {
            var adoMatrix = new Matrix_ADO(Ado);

            var list = adoMatrix.ReadByProduct(DTO.PrcCode, DTO.LngIsoCode);

            if (list.hasData)
            {
                Response.data = list.data;
            }

            return(true);
        }
Exemple #6
0
        /// <summary>
        /// Delete method
        /// </summary>
        /// <param name="Ado"></param>
        /// <param name="rlsCode"></param>
        /// <param name="userName"></param>
        /// <returns></returns>
        internal int Delete(ADO Ado, int rlsCode, string userName, bool mandatoryKeywordsOnly)
        {
            Matrix_ADO adoMatrix = new Matrix_ADO(Ado);

            int deleted = adoMatrix.Delete(rlsCode, userName);

            Keyword_Release_ADO adoKeywordRelease = new Keyword_Release_ADO();

            deleted = adoKeywordRelease.Delete(Ado, rlsCode, null, mandatoryKeywordsOnly);

            Release_ADO adoRelease = new Release_ADO(Ado);


            deleted = adoRelease.Delete(rlsCode, userName);

            return(deleted);
        }
Exemple #7
0
        /// <summary>
        /// Execute
        /// </summary>
        /// <returns></returns>
        protected override bool Execute()
        {
            if (DTO.Format.FrmDirection != FormatDirection.DOWNLOAD.ToString())
            {
                return(false);
            }

            var item   = new Matrix_ADO(Ado).Read(DTO.release, DTO.language, SamAccountName);
            var result = Release_ADO.GetReleaseDTO(item);

            if (result == null)
            {
                Response.data = null;
                return(true);
            }

            DTO.language = item.LngIsoCode;
            return(Cube_BSO_ReadMetadata.ExecuteReadMetadata(Ado, DTO, result, Response));
        }
Exemple #8
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        protected override bool Execute()
        {
            var item   = new Matrix_ADO(Ado).Read(DTO.jStatQueryExtension.extension.RlsCode, DTO.jStatQueryExtension.extension.Language.Code, SamAccountName);
            var result = Release_ADO.GetReleaseDTO(item);

            if (result == null)
            {
                Response.data = null;
                return(true);
            }

            DTO.jStatQueryExtension.extension.Matrix = result.MtrCode;
            //if the role details haven't been supplied then look it up from the metadata in the database
            if (DTO.Role == null)
            {
                DTO.Role = new Cube_BSO().UpdateRoleFromMetadata(Ado, DTO);
            }

            //The returned data may not be in the same language as the preferred language, so we must change the DTO.language property
            // DTO.language = item.LngIsoCode;
            return(Cube_BSO_ReadDataset.ExecuteReadDataset(Ado, DTO, result, Response, DTO.jStatQueryExtension.extension.Language.Code, DTO.jStatQueryExtension.extension.Language.Culture));
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="request"></param>
 internal Matrix_BSO_Create(JSONRPC_API request) : base(request, new PxUploadValidator())
 {
     matrixAdo  = new Matrix_ADO(Ado);
     releaseAdo = new Release_ADO(Ado);
 }
Exemple #10
0
        /// <summary>
        /// Get a list of datapoints with their associated dimension metadata
        /// </summary>
        /// <param name="Ado"></param>
        /// <param name="lngIsoCode"></param>
        /// <param name="RlsCodeLeft"></param>
        /// <param name="RlsCodeRight"></param>
        /// <param name="spec"></param>
        /// <returns></returns>
        private List <DataItem_DTO> GetCellMetadata(ADO Ado, string lngIsoCode, int RlsCodeLeft, int RlsCodeRight, Specification spec)
        {
            Matrix_ADO mAdo = new Matrix_ADO(Ado);


            List <DimensionValue_DTO> dimensions = new List <DimensionValue_DTO>();


            DimensionValue_DTO sVal = new DimensionValue_DTO();

            sVal.dimType = DimensionType.STATISTIC;
            foreach (StatisticalRecordDTO_Create stat in spec.Statistic)
            {
                DimensionDetail_DTO detail = new DimensionDetail_DTO();
                detail.key            = stat.Code;
                detail.value          = stat.Value;
                detail.dimensionValue = sVal;
                sVal.details.Add(detail);
            }
            dimensions.Add(sVal);


            DimensionValue_DTO pVal = new DimensionValue_DTO();

            pVal.dimType = DimensionType.PERIOD;
            foreach (PeriodRecordDTO_Create per in spec.Frequency.Period)
            {
                DimensionDetail_DTO detail = new DimensionDetail_DTO();
                detail.key            = per.Code;
                detail.value          = per.Value;
                detail.dimensionValue = pVal;
                pVal.details.Add(detail);
            }
            dimensions.Add(pVal);

            foreach (ClassificationRecordDTO_Create cls in spec.Classification)
            {
                DimensionValue_DTO cVal = new DimensionValue_DTO();
                cVal.dimType = DimensionType.CLASSIFICATION;
                cVal.code    = cls.Code;
                cVal.value   = cls.Value;
                foreach (var vrb in cls.Variable)
                {
                    DimensionDetail_DTO detail = new DimensionDetail_DTO();
                    detail.key            = vrb.Code;
                    detail.value          = vrb.Value;
                    detail.dimensionValue = cVal;
                    cVal.details.Add(detail);
                }
                dimensions.Add(cVal);
            }

            var graph = CartesianProduct(dimensions[0].details.ToArray());

            for (int i = 1; i < dimensions.Count; i++)
            {
                graph = CartesianProduct(graph.ToArray(), dimensions[i].details.ToArray());
            }
            List <DataItem_DTO> itemList = new List <DataItem_DTO>();

            //int counter = 0;
            foreach (var item in graph)
            {
                DataItem_DTO dto = new DataItem_DTO();
                populateDataItem(ref dto, item);
                itemList.Add(dto);
            }


            return(itemList);
        }
Exemple #11
0
        /// <summary>
        /// Compare Releases and find data points that have changed
        /// </summary>
        /// <param name="Ado"></param>
        /// <param name="dtoRight"></param>
        /// <param name="dtoLeft"></param>
        /// <returns></returns>
        internal Matrix CompareAmendment(ADO Ado, Compare_DTO_Read dtoRight, Compare_DTO_Read dtoLeft)
        {
            bool totalChange = false;


            Release_DTO lDto = new Release_DTO();
            Release_DTO rDto = new Release_DTO();

            lDto.RlsCode = dtoLeft.RlsCode;
            rDto.RlsCode = dtoRight.RlsCode;

            Matrix leftMatrix  = new Matrix(Ado, lDto, dtoLeft.LngIsoCode);
            Matrix rightMatrix = new Matrix(Ado, rDto, dtoRight.LngIsoCode);


            Specification spec = new Data.Matrix.Specification();

            spec.Statistic        = leftMatrix.MainSpec.Statistic.Intersect(rightMatrix.MainSpec.Statistic).ToList <StatisticalRecordDTO_Create>();
            spec.Frequency        = new FrequencyRecordDTO_Create();
            spec.Frequency.Code   = rightMatrix.MainSpec.Frequency.Code;
            spec.Frequency.Value  = rightMatrix.MainSpec.Frequency.Value;
            spec.Frequency.Period = new List <PeriodRecordDTO_Create>();
            spec.Frequency.Period = leftMatrix.MainSpec.Frequency.Period.Intersect(rightMatrix.MainSpec.Frequency.Period).ToList <PeriodRecordDTO_Create>();



            //We now get the added variables. Note that this only applies where the classifications themselves have not been added
            //Classifications will contain (1) Brand new classifications, (2) classifications that have had variables added to them
            List <ClassificationRecordDTO_Create> intersectCls = leftMatrix.MainSpec.Classification.Intersect(rightMatrix.MainSpec.Classification).ToList <ClassificationRecordDTO_Create>();

            //if there are different classifications in each matrix (something added or deleted) then return all false for amendments
            if (intersectCls != null)
            {
                if (intersectCls.Count != leftMatrix.MainSpec.Classification.Count || intersectCls.Count != rightMatrix.MainSpec.Classification.Count)
                {
                    totalChange = true;
                }
            }
            else
            {
                totalChange = true;
            }

            spec.Classification = new List <ClassificationRecordDTO_Create>();

            foreach (ClassificationRecordDTO_Create cls in intersectCls)
            {
                ClassificationRecordDTO_Create  otherCls = rightMatrix.MainSpec.Classification.Where(x => x.Equals(cls)).FirstOrDefault();//lefttoright
                List <VariableRecordDTO_Create> newVars  = cls.Variable.Intersect(otherCls.Variable).ToList <VariableRecordDTO_Create>();

                if (newVars.Count > 0)
                {
                    cls.Variable = newVars;
                    spec.Classification.Add(cls);
                }
                if (newVars.Count == 0)
                {
                    totalChange = true;
                }
            }

            //If there are no periods or statistics in common then everything has changed and this is flagged
            if (spec.Frequency.Period.Count == 0 || spec.Statistic.Count == 0)
            {
                totalChange = true;
            }

            leftMatrix.MainSpec = spec;

            //If there are no periods in common then nothing could have been amended - prepare for a graceful exit
            if (spec.Frequency.Period.Count > 0)
            {
                rightMatrix.MainSpec = spec;
            }

            //Get the matrix based on a database read of the DTO RlsCode
            Matrix_ADO mAdo = new Matrix_ADO(Ado);


            //Get the data for leftMatrix
            //Get the data for rightMatrix
            //Compare and flag where they're not equal
            //return the matrix

            leftMatrix.TimeFilterWasApplied  = true;
            rightMatrix.TimeFilterWasApplied = true;
            leftMatrix.StatFilterWasApplied  = true;
            rightMatrix.StatFilterWasApplied = true;
            foreach (var cls in leftMatrix.MainSpec.Classification)
            {
                cls.ClassificationFilterWasApplied = true;
            }

            if (!totalChange)
            {
                leftMatrix = new Cube_ADO(Ado).ReadCubeData(leftMatrix);
            }

            rightMatrix = new Cube_ADO(Ado).ReadCubeData(rightMatrix);



            int counter = 0;

            foreach (var cell in rightMatrix.Cells)
            {
                //If there are no periods in common then nothing could have been amended.
                //Similarly, if there was a difference in the number of classifications
                if (totalChange)
                {
                    cell.WasAmendment = false;
                }
                else
                {
                    if (cell.TdtValue.Equals(DBNull.Value))
                    {
                        cell.TdtValue = Configuration_BSO.GetCustomConfig("px.confidential-value");
                    }
                    if (leftMatrix.Cells.ElementAt(counter).TdtValue.Equals(DBNull.Value))
                    {
                        leftMatrix.Cells.ElementAt(counter).TdtValue = Configuration_BSO.GetCustomConfig("px.confidential-value");
                    }

                    if (cell.TdtValue != leftMatrix.Cells.ElementAt(counter).TdtValue)
                    {
                        cell.WasAmendment = true;
                    }
                    else
                    {
                        cell.WasAmendment = false;
                    }
                }

                counter++;
            }



            return(rightMatrix);
        }
Exemple #12
0
        /// <summary>
        /// Compare Releases and find data points that have either been added or deleted
        /// </summary>
        /// <param name="Ado"></param>
        /// <param name="dtoRight"></param>
        /// <param name="dtoLeft"></param>
        /// <returns></returns>
        internal Matrix CompareAddDelete(ADO Ado, Compare_DTO_Read dtoRight, Compare_DTO_Read dtoLeft)
        {
            Release_DTO lDto = new Release_DTO();
            Release_DTO rDto = new Release_DTO();

            lDto.RlsCode = dtoLeft.RlsCode;
            rDto.RlsCode = dtoRight.RlsCode;


            Matrix leftMatrix  = new Matrix(Ado, lDto, dtoLeft.LngIsoCode);
            Matrix rightMatrix = new Matrix(Ado, rDto, dtoRight.LngIsoCode);


            Specification spec = new Specification();


            spec.Classification = leftMatrix.MainSpec.Classification.Except(rightMatrix.MainSpec.Classification).ToList <ClassificationRecordDTO_Create>();

            bool test = leftMatrix.MainSpec.Statistic.Equals(rightMatrix.MainSpec.Statistic);

            spec.Statistic = leftMatrix.MainSpec.Statistic.Except(rightMatrix.MainSpec.Statistic).ToList <StatisticalRecordDTO_Create>();


            spec.Frequency        = new FrequencyRecordDTO_Create();
            spec.Frequency.Period = new List <PeriodRecordDTO_Create>();
            spec.Frequency.Period = leftMatrix.MainSpec.Frequency.Period.Except(rightMatrix.MainSpec.Frequency.Period).ToList <PeriodRecordDTO_Create>();



            //Classifications will contain (1) Brand new classifications, (2) classifications that have had variables added to them
            List <ClassificationRecordDTO_Create> intersectCls = leftMatrix.MainSpec.Classification.Intersect(rightMatrix.MainSpec.Classification).ToList <ClassificationRecordDTO_Create>();

            foreach (ClassificationRecordDTO_Create cls in intersectCls)
            {
                ClassificationRecordDTO_Create  otherCls = rightMatrix.MainSpec.Classification.Where(x => x.Equals(cls)).FirstOrDefault();
                List <VariableRecordDTO_Create> newVars  = cls.Variable.Except(otherCls.Variable).ToList <VariableRecordDTO_Create>();

                ClassificationRecordDTO_Create newCls = new ClassificationRecordDTO_Create();
                newCls.Code     = cls.Code;
                newCls.Value    = cls.Value;
                newCls.Variable = new List <VariableRecordDTO_Create>();

                if (newVars.Count > 0)
                {
                    newCls.Variable = newVars;
                    spec.Classification.Add(newCls);
                }
            }
            leftMatrix.TimeFilterWasApplied = true;

            leftMatrix.StatFilterWasApplied = true;
            foreach (var cls in leftMatrix.MainSpec.Classification)
            {
                cls.ClassificationFilterWasApplied = true;
            }


            //Get the matrix based on a database read of the DTO RlsCode
            Matrix_ADO mAdo = new Matrix_ADO(Ado);


            //Get the metadata for the left matrix as a list of DataItem_DTO
            List <DataItem_DTO> resDataLeft = GetCellMetadata(Ado, dtoLeft.LngIsoCode, dtoLeft.RlsCode, dtoRight.RlsCode, leftMatrix.MainSpec);

            //Get the data for the added-to or deleted-from matrix
            leftMatrix = new Cube_ADO(Ado).ReadCubeData(leftMatrix);

            //Get the WasAmendment flag set on the list of items. This is calculated by referring to the extra dimensions in spec
            resDataLeft = GetFlaggedItemsAddDelete(resDataLeft, spec, leftMatrix);


            //This is the final result of Add/Delete
            leftMatrix = GetFlaggedMatrix(leftMatrix, resDataLeft);

            return(leftMatrix);
        }