public string SearchModel(string SearchInput)
        {
            string Result = string.Empty;

            KuttyPayanMongodbClass KPdbObj = new KuttyPayanMongodbClass();
            var SearchResult = KPdbObj.KPEmployeeSearchMethod(SearchInput);
            KPEmployeeSchemaEvaluatorClass SchemaEvaluator = new KPEmployeeSchemaEvaluatorClass();
            SchemaEntityClass SchemaResult = SchemaEvaluator.EmployeeSchemaEvaluatorMethod(SearchResult, SearchInput);

            KPEmployeeSchemaImplementerClass objEmployeeImplementor = new KPEmployeeSchemaImplementerClass();
            List <EmployeeSample>            EmployeeList           = new List <EmployeeSample>();

            if (SchemaResult != null)
            {
                Result = objEmployeeImplementor.EmployeeSchemaImplementerMethod(SchemaResult);
                //EmployeeList = objEmployeeImplementor.EmployeeSchemaImplementerMethod(SchemaResult);
            }
            else
            {
                Result = "Schema Not Found";
            }
            return(Result);

            // return SearchResult;
            //return EmployeeList;
        }
Example #2
0
        public CRUDSchema KPFindCRUDSchemaMethod(EmployeeSchema InputSchema, SchemaEntityClass SchemaEntity)
        {
            MongoCollection <CRUDSchema> collection = database.GetCollection <CRUDSchema>("KPCRUDSchema");
            var query = Query <CRUDSchema> .EQ(e => e.MappedSchema, InputSchema.Name);

            List <CRUDSchema> CRUDSchemaList = collection.Find(query).ToList();
            CRUDSchema        objCRUDSchema  = new CRUDSchema();

            List <string[]> CRUDSChemaColumns = new List <string[]>();

            List <string> EmployeeSchemaColumns = new List <string>();
            List <WordSchemaReferenceValueClass> objEntityList = new List <WordSchemaReferenceValueClass>();

            objEntityList = SchemaEntity.WordSchemaReferenceValueCollection;
            StringBuilder QueryBuilder = new StringBuilder();

            Dictionary <string, string> MatchCRUDSchema = new Dictionary <string, string>();

            for (int i = 0; i < CRUDSchemaList.Count; i++)
            {
                for (int ColumnPos = 0; ColumnPos < CRUDSchemaList[i].column.Count; ColumnPos++)
                {
                    string CRUDColumn     = string.Empty;
                    string EmployeeColumn = string.Empty;
                    var    column         = CRUDSchemaList[i].column.ElementAt(ColumnPos);
                    if (column.Count() > 1)
                    {
                        if (column[1] == objEntityList[ColumnPos].SchemaValue)
                        {
                            CRUDColumn = objEntityList[ColumnPos].SchemaValue;
                            //EmployeeColumn=
                            //QueryBuilder.Append(column[i]);
                        }
                    }
                    else
                    {
                        if (column[0] == objEntityList[ColumnPos].SchemaReference)
                        {
                            EmployeeColumn = objEntityList[ColumnPos].SchemaValue;
                            QueryBuilder.Append(objEntityList[ColumnPos].SchemaReference);
                        }
                    }
                    MatchCRUDSchema.Add(EmployeeColumn, CRUDColumn);
                }

                CRUDSChemaColumns.Add(CRUDSchemaList[i].column[0]);
                EmployeeSchemaColumns.Add(objEntityList[i].SchemaReference);
            }


            //if(CRUDSchemaList.Count>1)
            //{
            objCRUDSchema = CRUDSchemaList.Where(a => a.column[0][1] == "select").FirstOrDefault();
            return(objCRUDSchema);
            //}
            //else
            //{
            //    return CRUDSchemaList.First();
            //}
        }
Example #3
0
        public EmployeeSchema KPFindEmployeeSchemaMethod(SchemaEntityClass EmployeeSchema)
        {
            MongoCollection <EmployeeSchema> collection = database.GetCollection <EmployeeSchema>("KPEmployeeSchema");
            var query = Query <EmployeeSchema> .EQ(e => e.Name, EmployeeSchema.SchemaName);

            EmployeeSchema objEmployeeSchema = collection.Find(query).FirstOrDefault();

            return(objEmployeeSchema);
        }
Example #4
0
        public string EmployeeSchemaImplementerMethod(SchemaEntityClass SchemaName)
        {
            string Result = string.Empty;
            List <WordSchemaReferenceValueClass> objWordSchemalist = SchemaName.WordSchemaReferenceValueCollection;
            int    WordCount = SchemaName.WordCount;
            string SchemaMap = SchemaName.SchemaName;

            string[] SchemaReferenceArray = SchemaName.WordSchemaReferenceValueCollection.Select(a => a.SchemaReference).ToArray();
            string[] SchemaValueArray     = SchemaName.WordSchemaReferenceValueCollection.Select(a => a.SchemaValue).ToArray();
            //var EmployeeSchema = KPDBObj.KPFindEmployeeSchemaMethod(SchemaName);
            List <SchemaMap> SchemaList = KPDBObj.KPEmployeeSchemaImplementerMethod();
            int FoundSchemaIndex        = -1;

            for (int i = 0; i < SchemaList.Count; i++)
            {
                if (SchemaList[i].MappedSchema == SchemaMap)
                {
                    int count = 0;
                    for (int j = 0; j < SchemaReferenceArray.Count(); j++)
                    {
                        if (SchemaReferenceArray[j] == SchemaList[i].column[j])
                        {
                            count++;
                        }
                        else if (SchemaValueArray[j] == SchemaList[i].column[j])
                        {
                            count++;
                        }
                    }
                    if (SchemaReferenceArray.Count() == count)
                    {
                        FoundSchemaIndex = i;
                    }
                }
            }
            if (FoundSchemaIndex >= 0)
            {
                if (SchemaList[FoundSchemaIndex].group == "sql")
                {
                    Result = KPSql.SqlSchemaParsermethod(SchemaList[FoundSchemaIndex], SchemaReferenceArray, SchemaValueArray, SchemaMap);
                }
                string[] operation = SchemaList[FoundSchemaIndex].operation;
                return(Result);
            }
            else
            {
                Result = "schema doesnt match for the current query";
                return(Result);
            }
            //SchemaMap objSchemaMap = SchemaList.Where(a => a.MappedSchema == SchemaMap && a.columns == WordArray).All();
            //var EmployeeList = KPDBObj.KPEmployeeSchemaImplementerMethod("Employee");
            //CRUDSchema objCRUDSchema = FindCRUDSchema(EmployeeSchema, SchemaName);
        }
Example #5
0
 public CRUDSchema FindCRUDSchema(EmployeeSchema SchemaName, SchemaEntityClass SchemaEntity)
 {
     return(KPDBObj.KPFindCRUDSchemaMethod(SchemaName, SchemaEntity));
 }