示例#1
0
 private string ToString(JsonStat stat)
 {
     return(stat.Text?.Replace("{0}", stat.Param0?.ToString(System.Globalization.CultureInfo.InvariantCulture))
            .Replace("{1}", stat.Param1?.ToString(System.Globalization.CultureInfo.InvariantCulture))
            .Replace("{2}", stat.Param2?.ToString(System.Globalization.CultureInfo.InvariantCulture))
            .Replace("{3}", stat.Param3)
            .Replace("{4}", stat.Param4?.ToString(System.Globalization.CultureInfo.InvariantCulture))
            .Replace("{5}", stat.Param5)
            .Replace("{6}", stat.Param6));
 }
示例#2
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);
        }
示例#3
0
        public override bool Equals(object obj)
        {
            JsonStat o = obj as JsonStat;

            return(this.ToString().Equals(obj?.ToString()));
        }
示例#4
0
 public int CompareTo(JsonStat obj)
 {
     return(ToString().CompareTo(obj.ToString()));
 }