Пример #1
0
        public static void StartIncreaseDBArity()
        {
            //Update status of the db that this arity is the last
            List <TblDatabaseManagement> lstFinishDB = DatabaseManagementsDS.GetDBThatFinishedProcess();

            foreach (TblDatabaseManagement db in lstFinishDB)
            {
                DatabaseManagementsDS.UpdateStatus(db, StatusDB.Done);
                MQGeneratorMail.SendDBFinishedMail(db);
            }

            //Increase DB Arity in db that finished calculate the current arity
            List <TblDatabaseManagement> lstDB = DatabaseManagementsDS.GetDBToIncreaseArity();

            foreach (TblDatabaseManagement db in lstDB)
            {
                db.CurrentArity++;
                DatabaseManagementsDS.Update(db);
            }
            if (lstDB.Count > 0 && IsAutoRunJobs)
            {
                ThreadPool.QueueUserWorkItem(delegate
                {
                    StartSendMQToSolver();
                });
            }
        }
        private TblDatabaseManagement Create(TblDatabaseManagement tblDatabaseManagement)
        {
            DatabaseManagementsDS.Create(tblDatabaseManagement);

            MQGeneratorMail.SendDBInitializedMail(tblDatabaseManagement);

            return(tblDatabaseManagement);
        }
Пример #3
0
        public static void OnGetMessageFromSolver(string strMessage)
        {
            MQMessage message = null;

            if (strMessage.Contains("Result"))            //strMessage is MQResultMessage
            {
                message = JsonConvert.DeserializeObject <MQResultMessage>(strMessage);
            }
            else             //strMessage is MQAssignmentResultMessage
            {
                message = JsonConvert.DeserializeObject <MQAssignmentResultMessage>(strMessage);
            }

            int          metaqueryID  = message.ID;
            TblMetaquery tblMetaquery = MetaqueryDS.GetByID(metaqueryID);

            try
            {
                if (tblMetaquery == null)
                {
                    throw new UnknownMetaqueryException(string.Format("There is an unknown metaquery id sent from solver. message id: {0}. MQ Solver message :", metaqueryID, message.ToString()));
                }

                if (message is MQResultMessage)
                {
                    MQResultMessage resultMessage = message as MQResultMessage;
                    tblMetaquery.FkResult = (int)resultMessage.Result;
                    StatusMQ statusMQ = (tblMetaquery.IsExpanded || tblMetaquery.Arity == tblMetaquery.TblDatabaseManagement.MaxArity ? StatusMQ.Done : StatusMQ.WaitingToExpand);
                    MetaqueryDS.UpdateStatus(tblMetaquery, statusMQ);
                    bool execSendMail = bool.Parse(ConfigurationManager.AppSettings["ExecSendMail"]);
                    if (execSendMail)
                    {
                        MQGeneratorMail.SendResultMail(tblMetaquery);
                    }

                    if (MQGenerator.IsAutoRunJobs)
                    {
                        if (statusMQ == StatusMQ.WaitingToExpand)
                        {
                            MQGenerator.StartExpandMQProcess();
                        }
                        else if (statusMQ == StatusMQ.Done)
                        {
                            MQGenerator.StartIncreaseDBArity();
                        }
                    }
                }
                else if (message is MQAssignmentResultMessage)
                {
                    MQAssignmentResultMessage assignmentResultMessage = message as MQAssignmentResultMessage;
                    TblMetaqueriesResult      tblMetaqueriesResult    = new TblMetaqueriesResult()
                    {
                        FkMetaqueryId   = metaqueryID,
                        Assignment      = assignmentResultMessage.Assignment,
                        ConfidenceValue = assignmentResultMessage.ConfidenceValue,
                        SupportValue    = assignmentResultMessage.SupportValue
                    };
                    MetaqueryResultDS.Create(tblMetaqueriesResult);

                    bool execSendMail = bool.Parse(ConfigurationManager.AppSettings["ExecSendMail"]);
                    if (execSendMail)
                    {
                        MQGeneratorMail.SendAssignmentMail(tblMetaqueriesResult, tblMetaquery.Metaquery);
                    }
                    if (MQGenerator.IsAutoRunJobs && !tblMetaquery.IsExpanded)
                    {
                        MQGenerator.StartExpandMQProcess();
                    }
                }
                else
                {
                    throw new UnknownMetaqueryException("There is an unknown metaquery sent from solver. MQ Solver message :" + message.ToString());
                }
            }
            catch (Exception ex)
            {
                MQGeneratorMail.SendExceptionMail(ex);
            }
        }