public object Deserialize(WorkStep step) { if (step.Type != OperationConstants.SUM) { //TODO throw exception return(null); } var desc = new SumDescription(); desc.VariableCode = step.Params["variableCode"]; desc.NewValueName = step.Params["newValueName"]; desc.NewValueCode = step.Params["newValueCode"]; desc.KeepValues = bool.Parse(step.Params["keepValues"]); desc.ConstantValue = double.Parse(step.Params["constantValue"]); desc.CalculateWithConstant = bool.Parse(step.Params["calcWithContant"]); desc.Operation = (SumOperationType)Enum.Parse(typeof(SumOperationType), step.Params["operation"], true); desc.GroupedVariableIndex = int.Parse(step.Params["groupedVariableIndex"]); desc.DoEliminationForSumAll = bool.Parse(step.Params["doEiminationForSumAll"]); int count = int.Parse(step.Params["values._count"]); for (int i = 0; i < count; i++) { desc.ValueCodes.Add(step.Params["values." + i]); } return(desc); }
/// <summary> /// Make calculation on PXModel instance /// </summary> /// <param name="px"></param> /// <param name="sumDescription">Instance of SumDescription describing the calculation</param> /// <returns></returns> public static PXModel Calculate(this PXModel px, SumDescription sumDescription) { return (sum.Execute(px, sumDescription)); }