コード例 #1
0
 public EventHandlerContext(byte[] initContext, int initSizeOfContext) // this will be changed with an interface for contexts
 {
     command          = EventHandlerFunctions.InvalidCommand;
     coreCommand      = CoreKnownFunctions.InvalidCommand;
     subModuleCommand = SubModuleFunctions.InvalidCommand;
     contextHandler   = new IContext(initContext, initSizeOfContext);
 }
コード例 #2
0
ファイル: SymptomLearning.cs プロジェクト: rs98xi/Framework
        public override bool InvokeCommand(SubModuleFunctions command, IContext contextHandler)
        {
            Console.WriteLine("InvokeCommand execution for SymptomLearning subModule");

            SymptomLearningContext subModuleContextHandler = contextHandler as SymptomLearningContext;

            switch (command)
            {
            case SubModuleFunctions.MachineLearningAdapt:
                // improve machine learning
                return(true);

            case SubModuleFunctions.MachineLearningAsk:
                // query machine learning
                return(true);

            case SubModuleFunctions.MachineLearningGetResults:
                // query results
                return(true);

            case SubModuleFunctions.MachineLearningStoreResults:
                // store results for improvements
                return(true);

            default:
                return(false);
            }
        }
コード例 #3
0
 public EventHandlerContext()
 {
     command          = EventHandlerFunctions.InvalidCommand;
     coreCommand      = CoreKnownFunctions.InvalidCommand;
     subModuleCommand = SubModuleFunctions.InvalidCommand;
     contextHandler   = null;
 }
コード例 #4
0
ファイル: ImageProcessing.cs プロジェクト: rs98xi/Framework
        public override bool InvokeCommand(SubModuleFunctions command, IContext contextHandler)
        {
            Console.WriteLine("InvokeCommand execution for Image subModule");

            ImageContext subModuleContextHandler = contextHandler as ImageContext;

            switch (command)
            {
            case SubModuleFunctions.ImageAdapt:
                // improve machine learning
                return(true);

            case SubModuleFunctions.ImageAddPhoto:
                // add data to machine learning
                return(true);

            case SubModuleFunctions.ImageComparePhoto:
                // query machine learning
                return(true);

            case SubModuleFunctions.ImageStoreResults:
                // store results for machine learning
                return(true);

            default:
                return(false);
            }
        }
コード例 #5
0
        public override bool InvokeCommand(SubModuleFunctions command, IContext contextHandler)
        {
            Console.WriteLine("InvokeCommand execution for EpidemyAlert subModule");

            EpidemyContext subModuleContextHandler = contextHandler as EpidemyContext;

            switch (command)
            {
            case SubModuleFunctions.EpidemyAlert:
                // alert user for epidemy
                return(true);

            case SubModuleFunctions.EpidemyAskData:
                // check data for epidemy
                return(true);

            case SubModuleFunctions.EpidemyCheckForAlert:
                // alert watcher
                return(true);

            case SubModuleFunctions.EpidemyStoreData:
                // save data about the epidemy
                return(true);

            default:
                return(false);
            }
        }
コード例 #6
0
        public override bool InvokeCommand(SubModuleFunctions command, IContext contextHandler)
        {
            Console.WriteLine("InvokeCommand execution for Form SubModule");
            Question       question;
            SymptomContext symptomContext = contextHandler as SymptomContext;

            switch (command)
            {
            case SubModuleFunctions.GetQuestion:
                question = quizHandler.GetQuestion(symptomContext.id);
                symptomContext.response = question.ToJson(symptomContext.id);
                return(true);

            case SubModuleFunctions.SendResponse:
                Answer answer = InitAnswer(symptomContext);
                quizHandler.ProcessAnswer(symptomContext.id, answer);
                question = quizHandler.GetQuestion(symptomContext.id);
                if (question == null && quizHandler.GetQuizById(symptomContext.id).IsQuizFinished())
                {
                    symptomContext.response = quizHandler.GetQuizById(symptomContext.id).GetSymptomsHolder().GetJsonVerdict();
                    quizHandler.RemoveById(symptomContext.id);
                    return(true);
                }
                symptomContext.response = question.ToJson(symptomContext.id);
                return(true);

            default:
                return(false);
            }
        }
コード例 #7
0
        public override bool InvokeCommand(SubModuleFunctions command, IContext contextHandler)
        {
            Console.WriteLine("InvokeCommand execution for Form SubModule");

            FormContext subModuleContextHandler = contextHandler as FormContext;

            switch (command)
            {
            case SubModuleFunctions.CreateForm:
                // create form function
                return(true);

            case SubModuleFunctions.AskForFormResults:
                // return formular result in a context
                return(true);

            case SubModuleFunctions.SaveFormResults:
                // save form to DB
                return(true);

            case SubModuleFunctions.StartForm:
                // form start
                return(true);

            default:
                return(false);
            }
        }
コード例 #8
0
ファイル: DataBaseHandler.cs プロジェクト: rs98xi/Framework
        public override bool InvokeCommand(SubModuleFunctions command, IContext contextHandler)
        {
            Console.WriteLine("InvokeCommand execution for Database subModule");

            DataBaseContext subModuleContextHandler = contextHandler as DataBaseContext;

            string answer;

            switch (command)
            {
            case SubModuleFunctions.DataBaseAlterData:
                // modify data

                answer = "Ai apelat db-ul cu comanda AlterData, dar inca nu e definit un raspuns";
                contextHandler.answer       = Encoding.ASCII.GetBytes(answer);
                contextHandler.sizeOfAnswer = answer.Length;

                return(true);

            case SubModuleFunctions.DataBaseDestroyData:
                // remove data

                answer = "Ai apelat db-ul cu comanda DestroyData, dar inca nu e definit un raspuns";
                contextHandler.answer       = Encoding.ASCII.GetBytes(answer);
                contextHandler.sizeOfAnswer = answer.Length;

                return(true);

            case SubModuleFunctions.DataBaseQueryData:
                // search data


                return(true);

            case SubModuleFunctions.DataBaseSaveData:
                // save data

                answer = "Ai apelat db-ul cu comanda SaveData, dar inca nu e definit un raspuns";
                contextHandler.answer       = Encoding.ASCII.GetBytes(answer);
                contextHandler.sizeOfAnswer = answer.Length;

                return(true);

            default:
                return(false);
            }
        }
コード例 #9
0
ファイル: Sandbox.cs プロジェクト: tabaraemanuel/ProiectIP_B4
        public override bool InvokeCommand(SubModuleFunctions command, IContext contextHandler)
        {
            switch (command)
            {
            case SubModuleFunctions.CheckSigsForUser:
                ResetEngine();
                ExecuteAllSigs();
                return(true);

            case SubModuleFunctions.ReloadSigs:
                LoadSignatures("../../../signatures");
                return(true);

            default:
                return(false);
            }
        }
コード例 #10
0
        public override bool InvokeCommand(SubModuleFunctions command, IContext contextHandler)
        {
            Console.WriteLine("InvokeCommand execution for EpidemyAlert subModule");

            EpidemyContext subModuleContextHandler = contextHandler as EpidemyContext;

            DBModule     instance    = Utils.Singleton <DBModule> .Instance;
            UserHandler  userHandler = instance.GetUserHandler();
            List <Point> points;

            switch (command)
            {
            case SubModuleFunctions.EpidemyCheckForAreas:

                points = userHandler.GetPoints();
                subModuleContextHandler.json = CreateConvexHauls(points);
                return(true);

            case SubModuleFunctions.EpidemyCheckForSpecificAlert:

                points = userHandler.GetPointsForDisease(subModuleContextHandler.specificSearch);
                subModuleContextHandler.json = CreateConvexHauls(points);
                return(true);

            case SubModuleFunctions.EpidemyCheckForAlert:

                points = userHandler.GetPointsForDisease(subModuleContextHandler.specificSearch);
                Point user = new Point();
                subModuleContextHandler.json = CheckIfPointsCauseAlert(points, user);
                return(true);

            default:

                return(false);
            }
        }
コード例 #11
0
ファイル: EpidemyAlert.cs プロジェクト: rs98xi/Framework
        public override bool InvokeCommand(SubModuleFunctions command, IContext contextHandler)
        {
            Console.WriteLine("InvokeCommand execution for EpidemyAlert subModule");

            EpidemyContext subModuleContextHandler = contextHandler as EpidemyContext;


            switch (command)
            {
            case SubModuleFunctions.EpidemyCheckForSpecificAlert:

                DataBaseContext contextSpecific = new DataBaseContext();
                contextSpecific.databaseId         = DataBaseDefines.DatabaseDiseases;              // the database id;
                contextSpecific.databaseFunctionId = DataBaseDefines.DiseasesSpecificQueryDisease;  // function ID

                Dictionary <string, string> dictionarySpecific = new Dictionary <string, string>(); // the params
                dictionarySpecific.Add("x", subModuleContextHandler.x.ToString());
                dictionarySpecific.Add("y", subModuleContextHandler.y.ToString());
                dictionarySpecific.Add("disease", subModuleContextHandler.specificSearch);
                contextSpecific.ParametersDictionary = dictionarySpecific;

                EventHandlerContext commandContextSpecific = new EventHandlerContext();
                commandContextSpecific.command          = EventHandlerFunctions.DataBaseModule;
                commandContextSpecific.subModuleCommand = SubModuleFunctions.DataBaseQueryData;
                commandContextSpecific.coreCommand      = CoreKnownFunctions.InvalidCommand;
                commandContextSpecific.contextHandler   = contextSpecific;

                bool resultSpecific = fatherHandler.InvokeCommand(commandContextSpecific);

                if (!resultSpecific)
                {
                    return(false);
                }

                foreach (KeyValuePair <string, string> entry in contextSpecific.AnswerDictionary)
                {
                    // Validate each response

                    subModuleContextHandler.AnswerDictionary[entry.Key] = entry.Value;     // perechi boala - zona
                }

                if (subModuleContextHandler.AnswerDictionary.Count == 0)
                {
                    return(false);
                }

                return(true);

            case SubModuleFunctions.EpidemyCheckForAlert:

                DataBaseContext context = new DataBaseContext();
                context.databaseId         = DataBaseDefines.DatabaseDiseases;              // the database id;
                context.databaseFunctionId = DataBaseDefines.DiseasesFullQuery;             // function ID

                Dictionary <string, string> dictionary = new Dictionary <string, string>(); // the params
                dictionary.Add("x", subModuleContextHandler.x.ToString());
                dictionary.Add("y", subModuleContextHandler.y.ToString());
                context.ParametersDictionary = dictionary;

                EventHandlerContext commandContext = new EventHandlerContext();
                commandContext.command          = EventHandlerFunctions.DataBaseModule;
                commandContext.subModuleCommand = SubModuleFunctions.DataBaseQueryData;
                commandContext.coreCommand      = CoreKnownFunctions.InvalidCommand;
                commandContext.contextHandler   = context;

                bool result = fatherHandler.InvokeCommand(commandContext);

                if (!result)
                {
                    return(false);
                }

                foreach (KeyValuePair <string, string> entry in context.AnswerDictionary)
                {
                    // Validate each response

                    subModuleContextHandler.AnswerDictionary[entry.Key] = entry.Value;     // perechi boala - zona
                }

                if (subModuleContextHandler.AnswerDictionary.Count == 0)
                {
                    return(false);
                }

                return(true);

            default:
                return(false);
            }
        }
コード例 #12
0
 public abstract bool InvokeCommand(SubModuleFunctions command, IContext contextHandler);