예제 #1
0
        /// <summary>
        /// run validation
        /// </summary>
        /// <returns></returns>
        internal bool Validate()
        {
            PxValidator ppValidator = new PxValidator();
            PxDocument  PxDoc       = ppValidator.ParsePxFile(DTO.MtrInput);


            if (!ppValidator.ParseValidatorResult.IsValid)
            {
                Response.error = Error.GetValidationFailure(ppValidator.ParseValidatorResult.Errors);
                return(false);
            }

            MatrixData = new Matrix(PxDoc, DTO.FrqCodeTimeval ?? "", DTO.FrqValueTimeval ?? "");
            if (MatrixData.MainSpec.requiresResponse)
            {
                this.RequiresResponse = true;
                return(false);
            }
            MatrixValidator matrixValidator = new MatrixValidator();

            if (!matrixValidator.Validate(MatrixData, false))
            {
                Response.error = Error.GetValidationFailure(matrixValidator.MatrixValidatorResult.Errors);
                return(false);
            }

            return(true);
        }
예제 #2
0
        /// <summary>
        /// Execute
        /// </summary>
        /// <returns></returns>
        protected override bool Execute()
        {
            dynamic result = new ExpandoObject();



            //This is required for validation in the Matrix code, but is not used for px build
            Request.parameters.GrpCode = Utility.GetCustomConfig("APP_DEFAULT_GROUP");
            Request.parameters.source  = Utility.GetCustomConfig("APP_DEFAULT_SOURCE");

            //We get the PxDocument from the validator
            PxValidator pxValidator = new PxValidator();
            PxDocument  PxDoc       = pxValidator.ParsePxFile(DTO.MtrInput);

            if (!pxValidator.ParseValidatorResult.IsValid)
            {
                Response.error = Error.GetValidationFailure(pxValidator.ParseValidatorResult.Errors);
                return(false);
            }



            //Get this matrix from the px file , but we also need to pass in the Timeval stuff
            //The "" bit is temporary until we make the parameters optional (Currently this interferes with existing overloads)
            Matrix matrixPxFile = new Matrix(PxDoc, DTO.FrqCodeTimeval ?? "", DTO.FrqValueTimeval ?? "");


            matrixPxFile.ValidateMyMaps(true);
            if (matrixPxFile.MainSpec.ValidationErrors != null)
            {
                Response.error = Error.GetValidationFailure(matrixPxFile.MainSpec.ValidationErrors);
                return(false);
            }


            List <dynamic> cells = new List <dynamic>();

            matrixPxFile.Cells = cells;

            List <JRaw> jsonData = new List <JRaw>();

            var jsonStat = matrixPxFile.GetJsonStatObject(false, false);

            jsonData.Add(new JRaw(Serialize.ToJson(jsonStat)));

            if (matrixPxFile.OtherLanguageSpec != null)
            {
                foreach (Matrix.Specification s in matrixPxFile.OtherLanguageSpec)
                {
                    matrixPxFile.MainSpec = s;
                    jsonStat = matrixPxFile.GetJsonStatObject(false, false);
                    jsonData.Add(new JRaw(Serialize.ToJson(jsonStat)));
                }
            }

            Response.data = jsonData;

            return(true);
        }
예제 #3
0
        /// <summary>
        /// Execute
        /// </summary>
        /// <returns></returns>
        protected override bool Execute()
        {
            dynamic result = new ExpandoObject();

            Stopwatch sw = new Stopwatch();

            sw.Start();

            //This is required for validation in the Matrix code, but is not used for px build
            Request.parameters.GrpCode = Utility.GetCustomConfig("APP_DEFAULT_GROUP");
            Request.parameters.source  = Utility.GetCustomConfig("APP_DEFAULT_SOURCE");

            //We get the PxDocument from the validator
            PxValidator pxValidator = new PxValidator();
            PxDocument  PxDoc       = pxValidator.ParsePxFile(DTO.MtrInput);

            if (!pxValidator.ParseValidatorResult.IsValid)
            {
                Response.error = Error.GetValidationFailure(pxValidator.ParseValidatorResult.Errors);
                return(false);
            }
            Log.Instance.Debug("*Diagnostic* px valid: " + sw.ElapsedMilliseconds);

            Matrix matrixPxFile = new Matrix(PxDoc, DTO.FrqCodeTimeval ?? "", DTO.FrqValueTimeval ?? "");



            Log.Instance.Debug("*Diagnostic* Matrix created: " + sw.ElapsedMilliseconds);

            //Sorting, in case the px file is not in SPC order
            Build_BSO pBso = new Build_BSO();
            //List<DataItem_DTO> existingItems = pBso.GetExistingDataItems(matrixPxFile, matrixPxFile.MainSpec, true, false);

            Specification theSpec = matrixPxFile.GetSpecFromLanguage(DTO.LngIsoCode);

            // pBso.SetMetadataSortIds(ref theSpec);

            List <DataItem_DTO> existingItems = pBso.GetMatrixDataItems(matrixPxFile, DTO.LngIsoCode, theSpec);

            // pBso.SetDataSortIds(ref existingItems, theSpec);

            //Log.Instance.Debug("*Diagnostic* GetExistingDataItems: " + sw.ElapsedMilliseconds);



            Log.Instance.Debug("*Diagnostic* Read Cells - count = " + matrixPxFile.Cells.Count + "  elapsed: " + sw.ElapsedMilliseconds);

            result.csv = matrixPxFile.GetCsvObject(existingItems, DTO.LngIsoCode, true);

            Log.Instance.Debug("*Diagnostic* GetCsvObject-   elapsed: " + sw.ElapsedMilliseconds);
            result.MtrCode = matrixPxFile.Code;
            Response.data  = result;

            Log.Instance.Debug("GetCsvObject: " + sw.ElapsedMilliseconds);

            return(true);
        }
예제 #4
0
        /// <summary>
        /// Execute
        /// </summary>
        /// <returns></returns>
        protected override bool Execute()
        {
            //do the physical structure validation

            //This is required for validation in the Matrix code, but is not used for px build
            Request.parameters.GrpCode = Utility.GetCustomConfig("APP_DEFAULT_GROUP");
            Request.parameters.CprCode = Utility.GetCustomConfig("APP_DEFAULT_SOURCE");
            //validate the px file

            //We get the PxDocument from the validator
            PxValidator pxValidator = new PxValidator();
            PxDocument  PxDoc       = pxValidator.ParsePxFile(DTO.MtrInput);

            if (!pxValidator.ParseValidatorResult.IsValid)
            {
                Response.error = Error.GetValidationFailure(pxValidator.ParseValidatorResult.Errors);
                return(false);
            }


            Matrix theMatrixData;

            //Get this matrix from the px file
            theMatrixData = new Matrix(PxDoc, DTO.FrqCodeTimeval ?? "", DTO.FrqValueTimeval ?? "");

            Build_BSO bBso = new Build_BSO();

            //We need to add the new periods to the matrix
            //And either add cells of default data or else the values from DTO.data

            var requestPeriods = DTO.Periods;//.OrderBy(x => x.Code).ToList();


            DTO.Periods = DTO.Periods.Except(theMatrixData.MainSpec.Frequency.Period).ToList();

            theMatrixData = bBso.UpdateMatrixFromBuild(theMatrixData, DTO, Ado);

            theMatrixData.MainSpec.MainValues = sortMainValuesSpc(theMatrixData.MainSpec);

            theMatrixData.MainSpec.Values = theMatrixData.MainSpec.MainValues;

            //bBso.Query needs to be in the same order as the periods in the matrix - why?
            theMatrixData = bBso.Query(theMatrixData, GetQueryMatrix(requestPeriods, theMatrixData));

            theMatrixData.ValidateMyMaps(true);

            var dataList = bBso.GetMatrixDataItems(theMatrixData, DTO.LngIsoCode, theMatrixData.MainSpec, false);

            dynamic result = new ExpandoObject();

            result.csv     = theMatrixData.GetCsvObject(dataList, DTO.LngIsoCode, true, null, DTO.Labels);
            result.MtrCode = theMatrixData.Code;
            Response.data  = result;


            return(true);
        }
예제 #5
0
        /// <summary>
        /// Execute
        /// </summary>
        /// <returns></returns>
        protected override bool Execute()
        {
            //do the physical structure validation

            //This is required for validation in the Matrix code, but is not used for px build
            Request.parameters.GrpCode = Utility.GetCustomConfig("APP_DEFAULT_GROUP");
            Request.parameters.CprCode = Utility.GetCustomConfig("APP_DEFAULT_SOURCE");
            //validate the px file

            //We get the PxDocument from the validator
            PxValidator pxValidator = new PxValidator();
            PxDocument  PxDoc       = pxValidator.ParsePxFile(DTO.MtrInput);

            if (!pxValidator.ParseValidatorResult.IsValid)
            {
                Response.error = Error.GetValidationFailure(pxValidator.ParseValidatorResult.Errors);
                return(false);
            }

            //Get this matrix from the px file
            Matrix theMatrixData = new Matrix(PxDoc, DTO.FrqCodeTimeval ?? "", DTO.FrqValueTimeval ?? "");

            Build_BSO bBso = new Build_BSO();


            //Get this matrix from the px file
            //theMatrixData = bBso.UpdateMatrixFromDto(theMatrixData, DTO, Ado, false, true);

            List <DataItem_DTO> itemList = bBso.GetDataForNewPeriods(theMatrixData, DTO, Ado);

            //We need to check the matrix in case it incurred any validation problems at the time of creation
            //If there are, then we need to return the details of these errors to the caller and terminate this process
            //if (theMatrixData.ValidationResult != null)
            //{
            //    if (!theMatrixData.ValidationResult.IsValid)
            //    {
            //        Response.error = Error.GetValidationFailure(theMatrixData.ValidationResult.Errors);
            //        return false;
            //    }
            //}

            dynamic result = new ExpandoObject();

            result.csv     = theMatrixData.GetCsvObject(itemList, DTO.LngIsoCode, true);
            result.MtrCode = theMatrixData.Code;
            Response.data  = result;


            return(true);
        }
예제 #6
0
        /// <summary>
        /// Execute
        /// </summary>
        /// <returns></returns>
        protected override bool Execute()
        {
            dynamic result = new ExpandoObject();


            //This is required for validation in the Matrix code, but is not used for px build
            Request.parameters.GrpCode = Utility.GetCustomConfig("APP_DEFAULT_GROUP");

            //This is required for validation in the Matrix code, but is not used for px build
            Request.parameters.GrpCode = Utility.GetCustomConfig("APP_DEFAULT_GROUP");
            Request.parameters.source  = Utility.GetCustomConfig("APP_DEFAULT_SOURCE");

            //We get the PxDocument from the validator
            PxValidator pxValidator = new PxValidator();
            PxDocument  PxDoc       = pxValidator.ParsePxFile(DTO.MtrInput);

            if (!pxValidator.ParseValidatorResult.IsValid)
            {
                Response.error = Error.GetValidationFailure(pxValidator.ParseValidatorResult.Errors);
                return(false);
            }



            //Get this matrix from the px file , but we also need to pass in the Timeval stuff
            //The "" bit is temporary until we make the parameters optional (Currently this interferes with existing overloads)
            Matrix theMatrixData = new Matrix(PxDoc, DTO.FrqCodeTimeval ?? "", DTO.FrqValueTimeval ?? "");

            var signature = Utility.GetMD5(Utility.GetCustomConfig("APP_SALSA") + Utility.JsonSerialize_IgnoreLoopingReference(DTO.GetSignatureDTO()));

            if (signature != DTO.Signature)
            {
                Response.error = Label.Get("error.validation");
                return(false);
            }



            Build_BSO pBso = new Build_BSO();

            result.FrqValue = "";
            result.template = pBso.GetCsvTemplate(theMatrixData, DTO.LngIsoCode, DTO.FrqCodeTimeval);
            result.MtrCode  = theMatrixData.Code;
            Response.data   = result;



            return(true);
        }
        /// <summary>
        /// Execute
        /// </summary>
        /// <returns></returns>
        protected override bool Execute()
        {
            //do the physical structure validation

            //This is required for validation in the Matrix code, but is not used for px build
            Request.parameters.GrpCode = Utility.GetCustomConfig("APP_DEFAULT_GROUP");
            Request.parameters.CprCode = Utility.GetCustomConfig("APP_DEFAULT_SOURCE");
            //validate the px file

            //We get the PxDocument from the validator
            PxValidator pxValidator = new PxValidator();
            PxDocument  PxDoc       = pxValidator.ParsePxFile(DTO.MtrInput);

            if (!pxValidator.ParseValidatorResult.IsValid)
            {
                Response.error = Error.GetValidationFailure(pxValidator.ParseValidatorResult.Errors);
                return(false);
            }

            //There might be a cache:
            Matrix theMatrixData;

            theMatrixData = new Matrix(PxDoc, DTO.FrqCodeTimeval ?? "", DTO.FrqValueTimeval ?? "");

            Build_BSO bBso = new Build_BSO();

            List <DataItem_DTO> dataList;

            dataList = bBso.GetDataForAllPeriods(theMatrixData, DTO, Ado);


            dynamic result = new ExpandoObject();

            result.csv     = theMatrixData.GetCsvObject(dataList, DTO.LngIsoCode, true);
            result.MtrCode = theMatrixData.Code;
            Response.data  = result;


            return(true);
        }
예제 #8
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        protected override bool Execute()
        {
            Stopwatch sw = new Stopwatch();

            sw.Start();

            Build_BSO bBso = new Build_BSO();

            if (!bBso.HasBuildPermission(Ado, SamAccountName, "update"))
            {
                Response.error = Label.Get("error.privilege");
                return(false);
            }

            //do the physical structure validation

            //This is required for validation in the Matrix code, but is not used for px build
            Request.parameters.GrpCode = Utility.GetCustomConfig("APP_DEFAULT_GROUP");
            Request.parameters.CprCode = Utility.GetCustomConfig("APP_DEFAULT_SOURCE");
            //validate the px file

            //We get the PxDocument from the validator
            PxValidator pxValidator = new PxValidator();
            PxDocument  PxDoc       = pxValidator.ParsePxFile(DTO.MtrInput);

            if (!pxValidator.ParseValidatorResult.IsValid)
            {
                Response.error = Error.GetValidationFailure(pxValidator.ParseValidatorResult.Errors);
                return(false);
            }

            //Get this matrix from the px file
            Matrix theMatrixData = new Matrix(PxDoc, DTO.FrqCodeTimeval ?? "", DTO.FrqValueTimeval ?? "");



            Log.Instance.Debug("Object updated - " + theMatrixData.Cells.Count + " rows in " + sw.ElapsedMilliseconds + " milliseconds");

            theMatrixData = bBso.UpdateMatrixFromBuild(theMatrixData, DTO, Ado);



            Log.Instance.Debug("Object updated - " + theMatrixData.Cells.Count + " rows in " + sw.ElapsedMilliseconds + " milliseconds");

            //We need to check the matrix in case it incurred any validation problems at the time of creation
            //If there are, then we need to return the details of these errors to the caller and terminate this process
            if (theMatrixData.ValidationResult != null)
            {
                if (!theMatrixData.ValidationResult.IsValid)
                {
                    Log.Instance.Debug(Error.GetValidationFailure(theMatrixData.ValidationResult.Errors));
                    Response.error = Label.Get("error.validation");
                    return(false);
                }
            }

            //SortId is for internal use only, so we remove it from the output
            foreach (var i in DTO.PxData.DataItems)
            {
                i.Remove("SortId");
            }

            if (DTO.Format.FrmType == DatasetFormat.Px)
            {
                dynamic        result = new ExpandoObject();
                List <dynamic> file   = new List <dynamic>();
                file.Add(theMatrixData.GetPxObject(true).ToString());
                result.file = file;


                result.report = DTO.PxData.DataItems;


                Response.data = result;
                Log.Instance.Debug("Update complete in " + sw.ElapsedMilliseconds + " milliseconds");
                return(true);
            }

            else if (DTO.Format.FrmType == DatasetFormat.JsonStat)
            {
                //Return the metadata and data, using one json-stat object for each specification
                List <JRaw>   jsons     = new List <JRaw>();
                List <string> languages = new List <string>();
                if (theMatrixData.Languages != null)
                {
                    foreach (var lang in theMatrixData.Languages)
                    {
                        languages.Add(lang.ToPxValue());
                    }
                }
                else
                {
                    languages.Add(theMatrixData.MainSpec.Language);
                }

                foreach (var lang in languages)
                {
                    JsonStat json = theMatrixData.GetJsonStatObject(false, true, lang);
                    jsons.Add(new JRaw(Serialize.ToJson(json)));
                }
                dynamic result = new ExpandoObject();
                result.file = jsons;

                result.report = DTO.PxData.DataItems;
                Response.data = result;
                Log.Instance.Debug("Update complete in " + sw.ElapsedMilliseconds + " milliseconds");
                return(true);
            }

            return(false);
        }