// 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 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 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()
                               };
                }
            }
        }