コード例 #1
0
        private ResultOperation SaveInto()
        {
            VariableService variableService = new VariableService(base.UnitOfWork);
            ResultOperation resultOperation = new ResultOperation();
            //Resort this.SetDataList because of variable dependencies.
            var listSetDataList = this.SetDataList.ToList();

            for (int i = 0; i < listSetDataList.Count; i++)
            {
                var             item     = listSetDataList[i];
                sysBpmsVariable variable = variableService.GetInfo(base.EngineSharedModel?.CurrentProcessID, base.EngineSharedModel?.CurrentApplicationPageID, item.Key, new string[] { $"{nameof(sysBpmsVariable.DependentVariableDependencies)}.{nameof(sysBpmsVariableDependency.ToVariable)}" });
                foreach (sysBpmsVariableDependency vDependency in variable.DependentVariableDependencies)
                {
                    var parentVariable = listSetDataList.Select((c, index) => new { item = c, index }).FirstOrDefault(c => c.item.Key != item.Key && c.item.Key == vDependency.ToVariable.Name && i < c.index);
                    //if variable has a dependency which has higher index ,this code block replace both of them.
                    if (parentVariable != null)
                    {
                        listSetDataList[i] = parentVariable.item;
                        listSetDataList[parentVariable.index] = item;
                        i--;
                    }
                }
            }
            this.SetDataList = listSetDataList.ToDictionary(c => c.Key, c => c.Value);

            //save variables.
            foreach (var item in this.SetDataList)
            {
                if (resultOperation.IsSuccess)
                {
                    sysBpmsVariable variable = variableService.GetInfo(base.EngineSharedModel?.CurrentProcessID, base.EngineSharedModel?.CurrentApplicationPageID, item.Key, new string[] { nameof(sysBpmsVariable.DependentVariableDependencies) });
                    if (variable != null)
                    {
                        switch ((sysBpmsVariable.e_RelationTypeLU)variable.RelationTypeLU)
                        {
                        case sysBpmsVariable.e_RelationTypeLU.Local:
                            resultOperation = new SystemicVariableTypeEngine(base.EngineSharedModel, variable, base.EngineSharedModel?.CurrentProcessID, this.ThreadID, this.AdditionalParams, this.UnitOfWork).SaveValues(item.Value);
                            break;

                        case sysBpmsVariable.e_RelationTypeLU.Entity:
                            resultOperation = new EntityVariableTypeEngine(base.EngineSharedModel, variable, base.EngineSharedModel?.CurrentProcessID, this.ThreadID, this.AdditionalParams, this.UnitOfWork).SaveValues(item.Value, this.SetDataList);
                            item.Value.SetValue("ID", resultOperation.CurrentObject);
                            break;

                        case sysBpmsVariable.e_RelationTypeLU.SqlQuery:
                            resultOperation = new SqlQueryVariableTypeEngine(base.EngineSharedModel, variable, base.EngineSharedModel?.CurrentProcessID, this.ThreadID, this.AdditionalParams, this.UnitOfWork).SaveValues(item.Value);
                            break;
                        }
                    }
                }
            }
            return(resultOperation);
        }
コード例 #2
0
        private VariableModel GetEntitiesByName(string VarName, List <QueryModel> additionalParams = null, PagingProperties currentPaging = null, string containerQuery = null, string[] includes = null)
        {
            if (additionalParams != null)
            {
                this.AdditionalParams = additionalParams;
            }

            if (!this.GetDataList.Any(c => c.Name == VarName))
            {
                sysBpmsVariable  _Variable  = new VariableService(base.UnitOfWork).GetInfo(base.EngineSharedModel?.CurrentProcessID, base.EngineSharedModel?.CurrentApplicationPageID, VarName, new string[] { nameof(sysBpmsVariable.DependentVariableDependencies) });
                List <DataModel> _DataModel = new List <DataModel>();
                if (_Variable != null)
                {
                    switch ((sysBpmsVariable.e_RelationTypeLU)_Variable.RelationTypeLU)
                    {
                    case sysBpmsVariable.e_RelationTypeLU.SqlQuery:
                        //this set each DataModel's key corresponding to returned columns by query and then set value into it.
                        _DataModel = new SqlQueryVariableTypeEngine(base.EngineSharedModel, _Variable, base.EngineSharedModel?.CurrentProcessID, this.ThreadID, this.AdditionalParams, base.UnitOfWork).GetResult(currentPaging, containerQuery);
                        break;

                    case sysBpmsVariable.e_RelationTypeLU.Local:
                        //this set each DataModel's key corresponding to variable name and then set value into it.
                        _DataModel = new SystemicVariableTypeEngine(base.EngineSharedModel, _Variable, base.EngineSharedModel?.CurrentProcessID, this.ThreadID, this.AdditionalParams, base.UnitOfWork).GetResult();
                        break;

                    case sysBpmsVariable.e_RelationTypeLU.Entity:
                        //this set each DataModel's key corresponding to returned columns by query and then set value into it.
                        //this method return one DataModel if the _Variable FilterTypeLU is Filtered otherwise it will return list of DataModel.
                        _DataModel = new EntityVariableTypeEngine(base.EngineSharedModel, _Variable, base.EngineSharedModel?.CurrentProcessID, this.ThreadID, this.AdditionalParams, base.UnitOfWork).GetResult(currentPaging, containerQuery, includes);
                        break;
                    }
                    this.GetDataList.Add(new VariableModel(VarName, _DataModel));
                }
            }
            return(this.GetDataList.FirstOrDefault(c => c.Name == VarName));
        }