private void SetFromulas()
        {
            lokFormula.DisplayMember       = "Name";
            lokFormula.SelectedValueMember = "ID";
            BizFormula bizFormula = new BizFormula();

            lokFormula.ItemsSource = bizFormula.GetFormulas(EntityID, true);
        }
Beispiel #2
0
        //private void cmbColumns_SelectionChanged(object sender, SelectionChangedEventArgs e)
        //{
        //    if (cmbColumns.SelectedItem != null)
        //        SetActinList(DatabaseObjectCategory.Column);
        //}

        //private void cmbCommands_SelectionChanged(object sender, SelectionChangedEventArgs e)
        //{
        //    if (cmbCommands.SelectedItem != null)
        //        SetActinList(DatabaseObjectCategory.Command);
        //}

        //private int GetEntityID()
        //{
        //    int entityID = 0;
        //    if (Object != null)
        //    {
        //        if (Object.ObjectCategory == DatabaseObjectCategory.Entity)
        //        {
        //            entityID = Convert.ToInt32(Object.ObjectIdentity);
        //        }
        //        else if (Object.ObjectCategory == DatabaseObjectCategory.Column)
        //        {

        //            var parent = bizDatabaseToObject.GetParentObject(DatabaseObjectCategory.Column, Convert.ToInt32(Object.ObjectIdentity));
        //            if (parent.ObjectCategory == DatabaseObjectCategory.Entity)
        //            {
        //                entityID = Convert.ToInt32(parent.ObjectIdentity);
        //            }
        //        }
        //    }
        //    return entityID;
        //}

        private void SetFromulas(int entityID)
        {
            cmbFormula.DisplayMemberPath = "Name";
            cmbFormula.SelectedValuePath = "ID";
            BizFormula bizFormula = new BizFormula();

            cmbFormula.ItemsSource = bizFormula.GetFormulas(entityID);
        }
        private void AddParameterNodes(ItemCollection items, int entityID)
        {
            items.Clear();
            var listFormulas = bizFormula.GetFormulas(entityID);

            foreach (var formula in listFormulas)
            {
                AddParameterNode(items, formula);
            }
        }
 private void SetParameters()
 {
     colParameters.DisplayMemberPath       = "Name";
     colParameters.SelectedValueMemberPath = "ID";
     FormulaParameters = bizFormula.GetFormulas(EntityID, true);
     FormulaParameters.Add(new FormulaDTO()
     {
         ID = 0, Name = " "
     });
     colParameters.ItemsSource = FormulaParameters;
 }
        //private int GetEntityID()
        //{
        //    int entityID = 0;
        //    if (Object != null)
        //    {
        //        if (Object.ObjectCategory == DatabaseObjectCategory.Entity)
        //        {
        //            entityID = Convert.ToInt32(Object.ObjectIdentity);
        //        }
        //        else if (Object.ObjectCategory == DatabaseObjectCategory.Column)
        //        {

        //            var parent = bizDatabaseToObject.GetParentObject(DatabaseObjectCategory.Column, Convert.ToInt32(Object.ObjectIdentity));
        //            if (parent.ObjectCategory == DatabaseObjectCategory.Entity)
        //            {
        //                entityID = Convert.ToInt32(parent.ObjectIdentity);
        //            }
        //        }
        //    }
        //    return entityID;
        //}

        private void SetFromulas()
        {
            if (cmbEntities.SelectedItem != null)
            {
                var entity = cmbEntities.SelectedItem as TableDrivedEntityDTO;
                cmbFormula.DisplayMemberPath = "Name";
                cmbFormula.SelectedValuePath = "ID";
                BizFormula bizFormula = new BizFormula();
                cmbFormula.ItemsSource = bizFormula.GetFormulas(entity.ID);
            }
        }
 private void GetFormulas()
 {
     if (EntityID == 0)
     {
         var listFomula = bizFormula.GetAllFormulas(MyProjectManager.GetMyProjectManager.GetRequester(), "");
         dtgFormulas.ItemsSource = listFomula;
     }
     else
     {
         var listFomula = bizFormula.GetFormulas(EntityID, false);
         dtgFormulas.ItemsSource = listFomula;
     }
 }
        private void SetFormulas()
        {
            BizFormula bizFormula = new BizFormula();

            var listAllFormula = bizFormula.GetFormulas(Process.EntityID, false);
            List <FormulaDTO> listValidFormula = new List <FormulaDTO>();

            foreach (var formula in listAllFormula)
            {
                if (formula.ResultDotNetType == typeof(bool) ||
                    formula.ResultDotNetType == typeof(Boolean))
                {
                    listValidFormula.Add(formula);
                }
            }
            colFormula.ItemsSource             = listValidFormula;
            colFormula.DisplayMemberPath       = "Name";
            colFormula.SelectedValueMemberPath = "ID";
        }
        private void GetFormulas()
        {
            var listFomula = bizFormula.GetFormulas(EntityID);

            dtgFormulas.ItemsSource = listFomula;
        }
        public static Dictionary <string, MyPropertyInfo> GetProperties(TableDrivedEntityDTO entity, MyPropertyInfo parentPropetyInfo, bool definition, bool withHelpers)
        {
            Dictionary <string, MyPropertyInfo> m_properties = new Dictionary <string, MyPropertyInfo>();

            //روابط
            foreach (var relationship in entity.Relationships.OrderBy(x => x.Name))
            {
                var name = "";
                if (relationship.TypeEnum == Enum_RelationshipType.OneToMany)
                {
                    name = "OTMREL" + relationship.Entity2;// + +relationship.ID;// + "_" + relationship.ID;
                }
                else if (relationship.TypeEnum == Enum_RelationshipType.ManyToOne)
                {
                    name = "MTOREL" + relationship.Entity2;// +  + relationship.ID;// + "_" + relationship.ID;
                }
                else
                {
                    name = "OTOREL" + relationship.Entity2;// +  + relationship.ID;// + "_" + relationship.ID;
                }
                MyPropertyInfo propertyInfo = GeneratePropertyInfo(entity, PropertyType.Relationship, parentPropetyInfo, relationship.ID, name, relationship);

                //else
                //    propertyInfo.RelationshipTail = relationship.ID.ToString();
                if (m_properties.Any(x => x.Key == propertyInfo.Name))
                {
                    SetUniqueName(propertyInfo, m_properties);
                }
                propertyInfo.PropertyRelationship = relationship;
                propertyInfo.Tooltip = relationship.TypeStr + Environment.NewLine + relationship.Name;
                if (relationship.TypeEnum == Enum_RelationshipType.OneToMany)
                {
                    propertyInfo.Type = GetNewFormulaObjectList(propertyInfo).GetType();
                }
                else
                {
                    propertyInfo.Type = GetNewFormulaObject(propertyInfo).GetType();
                }
                m_properties.Add(propertyInfo.Name, propertyInfo);
            }

            foreach (var column in entity.Columns)
            {
                var            name         = "cl_" + column.Name;
                MyPropertyInfo propertyInfo = GeneratePropertyInfo(entity, PropertyType.Column, parentPropetyInfo, column.ID, name, column);

                //if (column.DateColumnType != null && column.DateColumnType.IsPersianDate)
                //{
                //    propertyInfo.Type = GetCustomTypePropertyType(propertyInfo, ValueCustomType.IsPersianDate);
                //}
                //else
                propertyInfo.Type = column.DotNetType;

                if (definition)
                {
                    //if (column.DateColumnType != null && column.DateColumnType.IsPersianDate)
                    //{
                    //    propertyInfo.Value = GetCustomTypePropertyDefaultValue(propertyInfo, ValueCustomType.IsPersianDate);
                    //}
                    //else
                    //{
                    propertyInfo.Value = GetPropertyDefaultValue(propertyInfo);
                    //}
                    propertyInfo.ValueSearched = true;
                }
                else
                {
                    propertyInfo.Value = null;
                }


                m_properties.Add(propertyInfo.Name, propertyInfo);
            }

            //مدل رو تا فولدر فرمول رفتم یا استیت رابطه داره و استیت هم با فرمول چیکار کنم
            var formulaStates = bizEntityState.GetEntityStates(entity.ID, false);

            foreach (var state in formulaStates)
            {
                var            name         = "st_" + state.Title;
                MyPropertyInfo propertyInfo = GeneratePropertyInfo(entity, PropertyType.State, parentPropetyInfo, state.ID, name, state);
                propertyInfo.Type = typeof(bool);
                propertyInfo.Name = "st_" + state.Title;
                if (definition)
                {
                    propertyInfo.Value         = GetPropertyDefaultValue(propertyInfo);
                    propertyInfo.ValueSearched = true;
                }
                else
                {
                    propertyInfo.Value = null;
                }
                m_properties.Add(propertyInfo.Name, propertyInfo);
            }


            var formulaParameters = bizFormula.GetFormulas(entity.ID);

            foreach (var formulaParameter in formulaParameters)
            {
                var            name         = "p_" + formulaParameter.Name;
                MyPropertyInfo propertyInfo = GeneratePropertyInfo(entity, PropertyType.FormulaParameter, parentPropetyInfo, formulaParameter.ID, name, formulaParameter);
                propertyInfo.ParameterFormulaID = formulaParameter.ID;
                //if (formulaParameter.ValueCustomType != ValueCustomType.None)
                //{
                //    propertyInfo.Type = GetCustomTypePropertyType(propertyInfo, formulaParameter.ValueCustomType);
                //}
                //else
                propertyInfo.Type = formulaParameter.ResultDotNetType;
                if (definition)
                {
                    //if (formulaParameter.ValueCustomType != ValueCustomType.None)
                    //{
                    //    propertyInfo.Value = GetCustomTypePropertyDefaultValue(propertyInfo, formulaParameter.ValueCustomType);
                    //}
                    //else
                    //{
                    propertyInfo.Value = GetPropertyDefaultValue(propertyInfo);
                    //}
                    propertyInfo.ValueSearched = true;
                }
                else
                {
                    propertyInfo.Value = null;
                }

                m_properties.Add(propertyInfo.Name, propertyInfo);
            }

            //////var databaseFunctions = bizDatabaseFunction.GetDatabaseFunctionsByEntityID(entity.ID);
            //////foreach (var dbfunction in databaseFunctions)
            //////{
            //////    var name = "";
            //////    if (dbfunction.Type == Enum_DatabaseFunctionType.Function)
            //////        name = "fn_" + dbfunction.FunctionName;
            //////    else if (dbfunction.Type == Enum_DatabaseFunctionType.StoredProcedure)
            //////        name = "sp_" + dbfunction.FunctionName;
            //////    MyPropertyInfo propertyInfo = GeneratePropertyInfo(entity, PropertyType.DBFormula, parentPropetyInfo, dbfunction.ID, name, dbfunction, formulaObject);
            //////    //if (dbfunction.ValueCustomType != ValueCustomType.None)
            //////    //{
            //////    //    propertyInfo.Type = GetCustomTypePropertyType(propertyInfo, dbfunction.ValueCustomType);
            //////    //}
            //////    //else
            //////    propertyInfo.Type = dbfunction.DotNetType;
            //////    if (definition)
            //////    {
            //////        //if (dbfunction.ValueCustomType != ValueCustomType.None)
            //////        //{
            //////        //    propertyInfo.Value = GetCustomTypePropertyDefaultValue(propertyInfo, dbfunction.ValueCustomType);
            //////        //}
            //////        //else
            //////        //{
            //////        propertyInfo.Value = GetPropertyDefaultValue(propertyInfo);
            //////        //}

            //////        propertyInfo.ValueSearched = true;

            //////    }
            //////    else
            //////    {
            //////        propertyInfo.Value = null;
            //////    }
            //////    m_properties.Add(propertyInfo.Name, propertyInfo);
            //////}


            var codeFunctions = bizCodeFunction.GetCodeFunctionsByEntityID(entity.ID);

            foreach (var codeFunction in codeFunctions)
            {
                var            name         = "cd_" + codeFunction.FunctionName;
                MyPropertyInfo propertyInfo = GeneratePropertyInfo(entity, PropertyType.Code, parentPropetyInfo, codeFunction.ID, name, codeFunction);
                //if (codeFunction.ValueCustomType != ValueCustomType.None)
                //{
                //    propertyInfo.Type = GetCustomTypePropertyType(propertyInfo, codeFunction.ValueCustomType);
                //}
                //else
                propertyInfo.Type = codeFunction.RetrunDotNetType;
                if (definition)
                {
                    //if (codeFunction.ValueCustomType != ValueCustomType.None)
                    //{
                    //    propertyInfo.Value = GetCustomTypePropertyDefaultValue(propertyInfo, codeFunction.ValueCustomType);
                    //}
                    //else
                    //{
                    propertyInfo.Value = GetPropertyDefaultValue(propertyInfo);
                    //}
                    propertyInfo.ValueSearched = true;
                }
                else
                {
                    propertyInfo.Value = null;
                }

                //فانکشنها در تعریف  فرمول همینجا مقدار میگیرند
                m_properties.Add(propertyInfo.Name, propertyInfo);
            }
            if (parentPropetyInfo == null)
            {
                //MyPropertyInfo numericHelperPropertyInfo = GeneratePropertyInfo(entity, PropertyType.Helper, parentPropetyInfo, 0, "NumericHelper", null);
                //numericHelperPropertyInfo.Type = typeof(NumericHelper);
                //numericHelperPropertyInfo.Value = new NumericHelper();
                //numericHelperPropertyInfo.ValueSearched = true;
                //m_properties.Add(numericHelperPropertyInfo.Name, numericHelperPropertyInfo);

                ////StringHelper
                //MyPropertyInfo stringHelperPropertyInfo = GeneratePropertyInfo(entity, PropertyType.Helper, parentPropetyInfo, 0, "StringHelper", null);
                //stringHelperPropertyInfo.Type = typeof(StringHelper);
                //stringHelperPropertyInfo.Value = new StringHelper();
                //stringHelperPropertyInfo.ValueSearched = true;
                //m_properties.Add(stringHelperPropertyInfo.Name, stringHelperPropertyInfo);

                //MyPropertyInfo persinaDateHelperPropertyInfo = GeneratePropertyInfo(entity, PropertyType.Helper, parentPropetyInfo, 0, "PersianDateHelper", null);
                //persinaDateHelperPropertyInfo.Type = typeof(PersianDateHelper);
                //persinaDateHelperPropertyInfo.Value = new PersianDateHelper();
                //persinaDateHelperPropertyInfo.ValueSearched = true;
                //m_properties.Add(persinaDateHelperPropertyInfo.Name, persinaDateHelperPropertyInfo);

                //MyPropertyInfo miladiDateHelperPropertyInfo = GeneratePropertyInfo(entity, PropertyType.Helper, parentPropetyInfo, 0, "MiladiDateHelper", null);
                //miladiDateHelperPropertyInfo.Type = typeof(MiladiDateHelper);
                //miladiDateHelperPropertyInfo.Value = new MiladiDateHelper();
                //miladiDateHelperPropertyInfo.ValueSearched = true;
                //m_properties.Add(miladiDateHelperPropertyInfo.Name, miladiDateHelperPropertyInfo);


                //MyPropertyInfo dbFunctionHelperHelperPropertyInfo = GeneratePropertyInfo(entity, PropertyType.Helper, parentPropetyInfo, 0, "DBFunctionHelper", null);
                //dbFunctionHelperHelperPropertyInfo.Type = typeof(DBFunctionHelper);
                //dbFunctionHelperHelperPropertyInfo.Value = new DBFunctionHelper(entity.DatabaseID);
                //dbFunctionHelperHelperPropertyInfo.ValueSearched = true;
                //m_properties.Add(dbFunctionHelperHelperPropertyInfo.Name, dbFunctionHelperHelperPropertyInfo);
            }
            return(m_properties);
        }