Esempio n. 1
0
        //private UIColumnValueRangeResetDTO ToUIColumnValueRangeResetDTO(UIColumnValueRangeReset item)
        //{
        //    UIColumnValueRangeResetDTO msgtem = new UIColumnValueRangeResetDTO();
        //    msgtem.ColumnValueRangeID = item.ColumnValueRangeID;
        //    msgtem.ID = item.ID;
        //    return msgtem;
        //}

        public UIColumnValueDTO ToColumnValueDTO(DataAccess.UIColumnValue item)
        {
            UIColumnValueDTO result = new UIColumnValueDTO();

            result.ColumnID     = item.ColumnID;
            result.ExactValue   = item.ExactValue;
            result.EvenIsNotNew = item.EvenIsNotNew;
            result.EvenHasValue = item.EvenHasValue;
            //     result.EntityRelationshipTailID = item.EntityRelationshipTailID ?? 0;
            //BizEntityRelationshipTail bizEntityRelationshipTail = new BizEntityRelationshipTail();
            //if (result.EntityRelationshipTailID != 0)
            //    result.EntityRelationshipTail = bizEntityRelationshipTail.ToEntityRelationshipTailDTO(item.EntityRelationshipTail);
            result.ID = item.ID;
            //foreach (var validValue in item.ColumnValue_ValidValues)
            //{
            //    result.ValidValues.Add(new ColumnValueValidValuesDTO() { Value = validValue.ValidValue });
            //}
            return(result);
        }
Esempio n. 2
0
        //private void RelatedDataColumnValueChanged(object sender, RelatedDataColumnValueChangedArg e, FormulaDTO formula, DP_DataRepository dataItem, int columnID)
        //{

        //}


        public void CalculateProperty(EntityInstanceProperty dataProperty, ColumnCustomFormulaDTO columnCustomFormula, DP_DataRepository dataItem, bool asDefault)
        {
            var key = "formulaCalculated" + "_" + dataProperty.ColumnID;

            EditArea.RemoveDataItemMessage(dataItem, key);

            if (columnCustomFormula.OnlyOnNewData)
            {
                if (!dataItem.IsNewItem)
                {
                    AddDataMessageItem(dataItem, key, ControlItemPriority.Normal, "فرمول" + " " + columnCustomFormula.Formula.Name + " " + "بروی داده موجود اعمال نمی شود");
                    return;
                }
            }
            if (columnCustomFormula.OnlyOnEmptyValue)
            {
                if (dataProperty.Value != null && !string.IsNullOrEmpty(dataProperty.Value.ToString()))
                {
                    AddDataMessageItem(dataItem, key, ControlItemPriority.Normal, "فرمول" + " " + columnCustomFormula.Formula.Name + " " + "بروی خصوصیت دارای مقدار اعمال نمی شود");
                    return;
                }
            }


            var result = AgentUICoreMediator.GetAgentUICoreMediator.formulaManager.CalculateFormula(columnCustomFormula.Formula.ID, dataItem, AgentUICoreMediator.GetAgentUICoreMediator.GetRequester());

            dataProperty.FormulaID              = columnCustomFormula.Formula.ID;
            dataProperty.FormulaException       = null;
            dataProperty.FormulaUsageParemeters = result.FormulaUsageParemeters;


            if (result.Exception == null)
            {
                //dataProperty.Value = result.Result;

                //    AddDataMessageItem(dataItem, key, ControlItemPriority.Normal, "محاسبه شده توسط فرمول" + " " + columnCustomFormula.Formula.Title);
            }
            else
            {
                dataProperty.FormulaException = result.Exception.Message;
                //  dataProperty.Value = "";

                //اینجا خطا روی ستون یا رابطه بدهد
                AddDataMessageItem(dataItem, key, ControlItemPriority.Normal, "خطا در محاسبه فرمول" + " " + columnCustomFormula.Formula.Title + ":" + " " + dataProperty.FormulaException);
            }

            if (asDefault)
            {
                dataProperty.Value = result.Result;
            }
            else
            {
                var uiColumnValue = new UIColumnValueDTO();
                uiColumnValue.ColumnID = columnCustomFormula.ID;
                //ابجکت نشه؟ExactValue
                uiColumnValue.ExactValue   = result.Result.ToString();
                uiColumnValue.EvenHasValue = !columnCustomFormula.OnlyOnEmptyValue;
                uiColumnValue.EvenIsNotNew = !columnCustomFormula.OnlyOnNewData;
                List <UIColumnValueDTO> uIColumnValues = new List <UIColumnValueDTO>()
                {
                    uiColumnValue
                };
                EditArea.SetColumnValueFromState(dataItem, uIColumnValues, null, columnCustomFormula.Formula);
            }
        }