// GET: /BpmsTableManager/
 public object GetList([System.Web.Http.FromUri] EntityIndexSearchDTO indexSearchVM)
 {
     using (EntityDefService entityDefService = new EntityDefService())
     {
         indexSearchVM.Update(entityDefService.GetList(indexSearchVM.Name, null, indexSearchVM.GetPagingProperties).Select(c => new EntityDefDTO(c)).ToList());
         return(indexSearchVM);
     }
 }
 public List <EntityPropertyModel> GetEntityProperties(Guid ID)
 {
     using (EntityDefService entityDefService = new EntityDefService())
     {
         sysBpmsEntityDef sysBpmsEntityDef1 = entityDefService.GetInfo(ID);
         return(sysBpmsEntityDef1.AllProperties);
     }
 }
        public object GetActive(Guid ID)
        {
            ResultOperation result = new EntityDefService().Active(ID);

            if (result.IsSuccess)
            {
                return(new PostMethodMessage(SharedLang.Get("Success.Text"), DisplayMessageType.success));
            }
            else
            {
                return(new PostMethodMessage(result.GetErrors(), DisplayMessageType.success));
            }
        }
 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 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 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));
                }
            }
        }
 public object Delete(Guid ID)
 {
     if (ID != Guid.Empty)
     {
         ResultOperation result = new EntityDefService().Delete(ID);
         if (result.IsSuccess)
         {
             return(new PostMethodMessage(SharedLang.Get("Success.Text"), DisplayMessageType.success));
         }
         else
         {
             return(new PostMethodMessage(result.GetErrors(), DisplayMessageType.error));
         }
     }
     else
     {
         return(new PostMethodMessage(SharedLang.Get("NotFound.Text"), DisplayMessageType.error));
     }
 }
        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));
                    }
                }
            }
        }
Beispiel #9
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 PostLoadEntityForm(PostLoadEntityFormDTO model)
        {
            Guid?         dynamicFormId = model.DynamicFormId.ToGuidObjNull();
            DCEntityModel designCode    = null;

            if (!string.IsNullOrWhiteSpace(model.XmlB64Model))
            {
                designCode             = DesignCodeUtility.GetObjectOfDesignCode <DCEntityModel>(model.XmlB64Model.ToStringObj().FromBase64());
                designCode.IsOutputYes = model.IsOutputYes;
            }
            else
            {
                designCode = new DCEntityModel(Guid.NewGuid().ToString(), string.Empty, model.ShapeId.ToStringObj(),
                                               model.ParentShapeId.ToStringObj(), model.IsOutputYes.ToBoolObjNull(),
                                               new List <DCEntityParametersModel>(), model.IsFirst.ToBoolObj(), model.DefaultMethodType);
            }

            using (EntityDefService entityDefService = new EntityDefService())
            {
                var listENtities = entityDefService.GetList(null, true);
                if (designCode.EntityDefID != Guid.Empty)
                {
                    designCode.Rows.ForEach((item) =>
                    {
                        item.IsRequired = listENtities.FirstOrDefault(c => c.ID == designCode.EntityDefID).AllProperties.FirstOrDefault(d => d.Name == item.ParameterName).Required;
                    });
                }
                using (DynamicFormService dynamicFormService = new DynamicFormService())
                    return new
                           {
                               ListEntities    = listENtities.Select(c => new EntityDefDTO(c)).ToList(),
                               DynamicFormId   = dynamicFormId,
                               ProcessControls = dynamicFormId != Guid.Empty && dynamicFormId.HasValue ?
                                                 dynamicFormService.GetControls(dynamicFormService.GetInfo(dynamicFormId.Value)).Select(c => new QueryModel(c.Key, c.Value)).ToList() : new List <QueryModel>(),
                               Model = designCode
                           };
            }
        }
        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()
                               };
                }
            }
        }