public object GetEntityProperty(Guid?EntityID = null, Guid?VariableID = null)
 {
     using (EntityDefService entityDefService = new EntityDefService())
     {
         if (EntityID.HasValue)
         {
             return(entityDefService.GetInfo(EntityID.Value).AllProperties);
         }
         else
         {
             using (VariableService variableService = new VariableService())
                 return(entityDefService.GetInfo(variableService.GetInfo(VariableID.Value)?.EntityDefID ?? Guid.Empty)?.AllProperties ?? new List <EntityPropertyModel>());
         }
     }
 }
 public List <EntityPropertyModel> GetEntityProperties(Guid ID)
 {
     using (EntityDefService entityDefService = new EntityDefService())
     {
         sysBpmsEntityDef sysBpmsEntityDef1 = entityDefService.GetInfo(ID);
         return(sysBpmsEntityDef1.AllProperties);
     }
 }
 public object GetAddEdit(Guid?ID = null)
 {
     using (EntityDefService entityDefService = new EntityDefService())
     {
         EntityDefDTO            entityDef = new EntityDefDTO(ID.HasValue ? entityDefService.GetInfo(ID.Value) : null);
         List <sysBpmsEntityDef> AllPublishedEntityDefs = entityDefService.GetList(string.Empty, true);
         return(Json(new
         {
             Model = entityDef,
             DbTypes = EnumObjHelper.GetEnumList <EntityPropertyModel.e_dbType>().Where(c => c.Key != (int)EntityPropertyModel.e_dbType.Entity).Select(c => new QueryModel(c.Key.ToString(), c.Value)).
                       Union(AllPublishedEntityDefs.Select(c => new QueryModel((int)EntityPropertyModel.e_dbType.Entity + ":" + c.ID.ToString(), c.Name))).ToList(),
             RelationProperties = entityDef.AllProperties
         }));
     }
 }
        public object ExecuteQuery(ExecuteQueryDTO model)
        {
            using (EntityDefService entityDefService = new EntityDefService())
            {
                using (DataBaseQueryService dataBaseQueryService = new DataBaseQueryService())
                {
                    try
                    {
                        sysBpmsEntityDef entityDef = entityDefService.GetInfo(model.EntityId);
                        model.Query = string.IsNullOrWhiteSpace(model.Query) ? $" select top(200) * from {entityDef.FormattedTableName} " : model.Query;
                        DataTable data = dataBaseQueryService.GetBySqlQuery(model.Query, true, null);

                        return(Json(new { Data = data, Columns = data.Columns, EntityId = model.EntityId, Query = model.Query }));
                    }
                    catch (Exception ex)
                    {
                        return(new PostMethodMessage(ex.ToStringObj(), DisplayMessageType.error));
                    }
                }
            }
        }
예제 #5
0
        public SelectVariableDTO(sysBpmsVariable variable)
        {
            this.ID = variable.ID;
            this.ProcessID = variable.ProcessID;
            this.ApplicationPageID = variable.ApplicationPageID;
            this.Name = variable.Name;
            this.VarTypeLU = variable.VarTypeLU;
            this.EntityDefID = variable.EntityDefID;
            this.FieldName = variable.FieldName;
            this.Query = variable.Query;
            this.FilterTypeLU = variable.FilterTypeLU;
            this.Collection = variable.Collection;
            this.DBConnectionID = variable.DBConnectionID;
            this.DefaultValue = variable.DefaultValue;
            this.WhereClause = variable.WhereClause;
            this.OrderByClause = variable.OrderByClause;
            this.listVariableDependencyDTO = variable.DependentVariableDependencies?.Select(c => new VariableDependencyDTO(c)).ToList();

            if (this.EntityDefID.HasValue && this.VarTypeLU == (int)sysBpmsVariable.e_VarTypeLU.Object)
                using (EntityDefService entityDefService = new EntityDefService())
                    this.ListEntityPropertyModel = entityDefService.GetInfo(this.EntityDefID.Value).AllProperties.Where(c => c.IsActive).ToList();
        }
        public object GetAddEdit(Guid?ID = null, string VariableName = "", Guid?ProcessId = null, Guid?ApplicationPageId = null)
        {
            using (VariableService variableService = new VariableService())
            {
                VariableDTO variable = null;

                if (ID.ToGuidObj() != Guid.Empty)
                {
                    variable = new VariableDTO(variableService.GetInfo(ID.Value));
                }
                else
                if (!string.IsNullOrWhiteSpace(VariableName))
                {
                    variable = new VariableDTO(variableService.GetInfo(ProcessId, ApplicationPageId, VariableName));
                }
                if (variable == null)
                {
                    variable = new VariableDTO(new sysBpmsVariable()
                    {
                        ProcessID = ProcessId, ApplicationPageID = ApplicationPageId
                    });
                }

                using (EntityDefService entityDefService = new EntityDefService())
                {
                    List <EntityPropertyModel> Properties = new List <EntityPropertyModel>();
                    var Entities = entityDefService.GetList(string.Empty, true);
                    if (variable != null && variable.EntityDefID.HasValue)
                    {
                        Properties = entityDefService.GetInfo(variable.EntityDefID.Value).AllProperties;
                    }
                    else
                    {
                        Properties = new List <EntityPropertyModel>();
                    }

                    variable.ListVariableDependencyDTO?.ForEach((item) =>
                    {
                        if (item.ToVariableID.HasValue)
                        {
                            sysBpmsVariable getVar = variableService.GetInfo(item.ToVariableID.Value);
                            if (getVar.EntityDefID.HasValue)
                            {
                                item.GetToVariableProperties = entityDefService.GetInfo(getVar.EntityDefID.Value).AllProperties;
                            }
                        }
                        else
                        {
                            item.GetToVariableProperties = new List <EntityPropertyModel>();
                        }
                    });

                    using (DBConnectionService dbConnectionService = new DBConnectionService())
                        return new
                               {
                                   Model                 = variable,
                                   ListConnection        = dbConnectionService.GetList("").Select(c => new DBConnectionDTO(c)).ToList(),
                                   ListTypes             = EnumObjHelper.GetEnumList <sysBpmsVariable.e_VarTypeLU>().Select(c => new QueryModel(c.Key.ToString(), c.Value)),
                                   ListRelations         = EnumObjHelper.GetEnumList <sysBpmsVariable.e_RelationTypeLU>().Where(c => variable.ProcessID.HasValue || c.Key != (int)sysBpmsVariable.e_RelationTypeLU.Local).Select(c => new QueryModel(c.Key.ToString(), c.Value)),
                                   ListEntities          = Entities.Select(c => new { c.ID, Name = c.Name + $"({c.DisplayName})" }).ToList(),
                                   ListFilters           = EnumObjHelper.GetEnumList <sysBpmsVariable.e_FilterTypeLU>().Select(c => new QueryModel(c.Key.ToString(), c.Value)),
                                   ListProperties        = Properties,
                                   DependencyToVariables = variableService.GetList(base.ProcessId, base.ApplicationPageId, null, "", null, true).Where(c => c.ID != variable.ID).Select(c => new VariableDTO(c)).ToList()
                               };
                }
            }
        }
        public object PostAddEdit(PostAddEditEntityDefDTO postAddEdit)
        {
            using (EntityDefService entityDefService = new EntityDefService())
            {
                sysBpmsEntityDef entityDef = postAddEdit.EntityDefDTO.ID != Guid.Empty ? entityDefService.GetInfo(postAddEdit.EntityDefDTO.ID) : new sysBpmsEntityDef();

                if (postAddEdit.listProperties != null)
                {
                    foreach (var Item in postAddEdit.listProperties)
                    {
                        if (string.IsNullOrWhiteSpace(Item.ID))
                        {
                            Item.ID = Guid.NewGuid().ToString();
                        }
                        Item.IsActive = true;
                        postAddEdit.EntityDefDTO.Properties.Add(Item);
                    }
                }

                ResultOperation resultOperation = entityDef.Update(postAddEdit.EntityDefDTO.DisplayName, postAddEdit.EntityDefDTO.Name, postAddEdit.EntityDefDTO.DesignXML, true, postAddEdit.EntityDefDTO.Properties);
                if (resultOperation.IsSuccess)
                {
                    if (entityDef.ID != Guid.Empty)
                    {
                        resultOperation = entityDefService.Update(entityDef);
                    }
                    else
                    {
                        resultOperation = entityDefService.Add(entityDef);
                    }

                    if (resultOperation.IsSuccess)
                    {
                        return(new PostMethodMessage(SharedLang.Get("Success.Text"), DisplayMessageType.success, new { entityDef.ID, Name = (entityDef.Name + $"({entityDef.DisplayName})") }));
                    }
                    else
                    {
                        return(new PostMethodMessage(resultOperation.GetErrors(), DisplayMessageType.error));
                    }
                }
                else
                {
                    return(new PostMethodMessage(resultOperation.GetErrors(), DisplayMessageType.error));
                }
            }
        }