Esempio n. 1
0
        public static void StartDBProcess()
        {
            List <TblDatabaseManagement> lstDB = DatabaseManagementsDS.GetDBToWork(StatusDB.Received);
            Metaquery rootMQ = Metaquery.GetRootMQ();

            foreach (TblDatabaseManagement db in lstDB)
            {
                //create first level
                Console.WriteLine("start  : {0}:{1}:{2}:{3}", DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second, DateTime.Now.Millisecond);
                Console.WriteLine(rootMQ.ToString());
                TblMetaquery tblMetaquery = new TblMetaquery()
                {
                    Arity        = rootMQ.Arity,
                    FkDatabaseId = db.Id,
                    FkStatusId   = (int)StatusDB.Received,
                    Metaquery    = rootMQ.ToString()
                };
                MetaqueryDS.Create(tblMetaquery);
                DatabaseManagementsDS.UpdateStatus(db, StatusDB.InProcess);
            }
            //if at least 1 metaquery created - we can start send it to solver
            if (lstDB.Count > 0 && IsAutoRunJobs)
            {
                ThreadPool.QueueUserWorkItem(delegate
                {
                    StartSendMQToSolver();
                });
            }
        }
Esempio n. 2
0
        public static void StartExpandMQProcess()
        {
            List <TblMetaquery> lstMQ = MetaqueryDS.GetMQForExpand();

            while (lstMQ.Count > 0)
            {
                foreach (TblMetaquery tblMetaquery in lstMQ)
                {
                    TblDatabaseManagement curDB             = tblMetaquery.TblDatabaseManagement;
                    Metaquery             metaqueryToExpand = new Metaquery(tblMetaquery.Metaquery);

                    //create first level
                    //int MaxVariablesInRelation = ProcessMQDetails.MaxVariablesInRelation;
                    int        maxVariables = curDB.MaxVariablesInRelation;
                    ExpandType expandType   = ExpandType.All;
                    if (tblMetaquery.FkResult == (int)ResultMQ.SupportFailure)
                    {
                        expandType = ExpandType.NewRelationOnly;
                    }
                    if (tblMetaquery.FkResult == (int)ResultMQ.ConfidenceFailure)
                    {
                        expandType = ExpandType.InBodyOnly;
                    }

                    List <Metaquery> list = metaqueryToExpand.Expand(maxVariables, expandType);
                    foreach (Metaquery mq in list)
                    {
                        TblMetaquery newTblMetaquery = new TblMetaquery()
                        {
                            Arity        = mq.Arity,
                            FkDatabaseId = curDB.Id,
                            FkStatusId   = (int)StatusDB.Received,
                            Metaquery    = mq.ToString()
                        };
                        MetaqueryDS.Create(newTblMetaquery);
                    }

                    if (curDB.ForExperiment || tblMetaquery.FkResult != (int)ResultMQ.HasAnswers)
                    {
                        MetaqueryDS.UpdateStatus(tblMetaquery, StatusMQ.ExpandedAndDone);
                    }
                    else
                    {
                        MetaqueryDS.UpdateStatus(tblMetaquery, StatusMQ.Expanded);
                    }
                }
                lstMQ = MetaqueryDS.GetMQForExpand();
            }

            if (IsAutoRunJobs)
            {
                StartIncreaseDBArity();
            }
        }