Beispiel #1
0
        public override bool Execute(ICodeBase codeBase)
        {
            sysBpmsEntityDef sysBpmsEntityDef = codeBase.GetUnitOfWork.Repository <IEntityDefRepository>().GetInfo(this.EntityDefID);

            switch (this.MethodType)
            {
            case e_MethodType.Create:
                VariableModel entityModel = new VariableModel(sysBpmsEntityDef.Name, new DataModel());
                sysBpmsEntityDef.AllProperties.ForEach(c =>
                {
                    entityModel[c.Name] = this.GetParameterCode(codeBase, this.Rows.FirstOrDefault(d => d.ParameterName == c.Name), c);
                });
                codeBase.EntityHelper.Save(entityModel);
                break;

            case e_MethodType.Update:
                entityModel = new VariableModel(sysBpmsEntityDef.Name, new DataModel());
                sysBpmsEntityDef.Properties.ForEach(c =>
                {
                    entityModel[c.Name] = this.GetParameterCode(codeBase, this.Rows.FirstOrDefault(d => d.ParameterName == c.Name), c);
                });
                codeBase.EntityHelper.Save(entityModel);
                break;

            case e_MethodType.Delete:
                codeBase.EntityHelper.DeleteById(sysBpmsEntityDef.Name, this.GetParameterCode(codeBase, this.Rows.FirstOrDefault(d => d.ParameterName == "ID"), sysBpmsEntityDef.AllProperties.FirstOrDefault(d => d.Name == "ID")).ToGuidObj());
                break;
            }
            sysBpmsEntityDef = null;
            return(true);
        }
        /// <summary>
        /// this method would return variable convert type like string,int,boo,... according to variable name
        /// </summary>
        public static e_ConvertType GetVariableConvertType(string variableName, Guid?processId, Guid?applicationPageId, IUnitOfWork unitOfWork)
        {
            e_ConvertType   e_Convert       = e_ConvertType.Integer;
            sysBpmsVariable sysBpmsVariable = unitOfWork.Repository <IVariableRepository>().GetInfo(processId, applicationPageId, variableName.Split('.')[0], null);;

            if (sysBpmsVariable != null)
            {
                switch ((sysBpmsVariable.e_VarTypeLU)sysBpmsVariable.VarTypeLU)
                {
                case sysBpmsVariable.e_VarTypeLU.String:
                    e_Convert = e_ConvertType.String;
                    break;

                case sysBpmsVariable.e_VarTypeLU.Uniqueidentifier:
                    e_Convert = e_ConvertType.Uniqueidentifier;
                    break;

                case sysBpmsVariable.e_VarTypeLU.Integer:
                    e_Convert = e_ConvertType.Integer;
                    break;

                case sysBpmsVariable.e_VarTypeLU.Decimal:
                    e_Convert = e_ConvertType.Decimal;
                    break;

                case sysBpmsVariable.e_VarTypeLU.List:

                    break;

                case sysBpmsVariable.e_VarTypeLU.Object:
                    switch ((sysBpmsVariable.e_RelationTypeLU)sysBpmsVariable.RelationTypeLU)
                    {
                    case sysBpmsVariable.e_RelationTypeLU.Entity:
                        sysBpmsEntityDef sysEntity = unitOfWork.Repository <IEntityDefRepository>().GetInfo(sysBpmsVariable.EntityDefID.Value);
                        if (sysEntity != null && variableName.Split('.').Count() == 2)
                        {
                            EntityPropertyModel propertyModel = sysEntity.AllProperties.FirstOrDefault(c => c.Name == variableName.Split('.')[1]);
                            if (propertyModel != null)
                            {
                                switch (propertyModel.DbType)
                                {
                                case EntityPropertyModel.e_dbType.String: e_Convert = e_ConvertType.String; break;

                                case EntityPropertyModel.e_dbType.Integer: e_Convert = e_ConvertType.Integer; break;

                                case EntityPropertyModel.e_dbType.Decimal: e_Convert = e_ConvertType.Decimal; break;

                                case EntityPropertyModel.e_dbType.Long: e_Convert = e_ConvertType.Long; break;

                                case EntityPropertyModel.e_dbType.DateTime: e_Convert = e_ConvertType.DateTime; break;

                                case EntityPropertyModel.e_dbType.Uniqueidentifier: e_Convert = e_ConvertType.Uniqueidentifier; break;

                                case EntityPropertyModel.e_dbType.boolean: e_Convert = e_ConvertType.Boolean; break;
                                }
                            }
                        }
                        break;
                    }
                    break;

                case sysBpmsVariable.e_VarTypeLU.DateTime:
                    e_Convert = e_ConvertType.DateTime;
                    break;

                case sysBpmsVariable.e_VarTypeLU.Boolean:
                    e_Convert = e_ConvertType.Boolean;
                    break;
                }
            }
            return(e_Convert);
        }