Пример #1
0
        public async Task AfterRunJobAsync(IDialogContext context, IAwaitable <bool> argument)
        {
            var confirm = await argument;

            if (confirm)
            {
                string JobName     = context.UserData.Get <string>(CONST_JOB_NAME);
                string JobFilepath = CONST_JOB_DIRECTORY + JobName;

                FileInfo JobFileInfo = new FileInfo(JobFilepath);
                if (JobFileInfo.Exists)
                {
                    try
                    {
                        SystemOps.ExecuteCommand(JobFileInfo);

                        await context.PostAsync("And there it goes...off and running!");
                    }
                    catch (Exception ex)
                    {
                        await context.PostAsync(ex.ToString());
                    }
                }
                else
                {
                    await context.PostAsync($"Job ({JobName}) does not exist.");
                }
            }
            else
            {
                await context.PostAsync("Did not run the job.");
            }

            context.Wait(MessageReceivedAsync);
        }
Пример #2
0
        private void MainClientForm_Load(object sender, EventArgs e)
        {
            TraceOps.LoadLog();
            Services.PrepareGetService();
            SystemOps.SetAutoStart();

            _configServer          = new ConfigServer();
            _configServer.Changed += ConfigServerOnChanged;

            _keyboard = new KeyboardControl();
            _keyboard.RegisterGlobalHotKey(Constants.NOMOD, Keys.Left, this);
            _keyboard.RegisterGlobalHotKey(Constants.NOMOD, Keys.Right, this);
            _keyboard.KeyPressed += HandleHotkey;


            DllLoader.InitializeClientPlugIns(_plugins);
        }
Пример #3
0
        public virtual async Task MessageReceivedAsync(IDialogContext context, IAwaitable <IMessageActivity> argument)
        {
            var message = await argument;

            if (message.Text.ToLower().StartsWith("run "))
            {
                bool QuestionAnswered = false;

                if (message.Text.Contains(" "))
                {
                    string[] ProvidedCommand = message.Text.Split(new char[1] {
                        ' '
                    });

                    if (ProvidedCommand.Length == 2)
                    {
                        string sJobName = ProvidedCommand[1];

                        QuestionAnswered = true;

                        context.UserData.SetValue(CONST_JOB_NAME, sJobName);

                        PromptDialog.Confirm(
                            context,
                            AfterRunJobAsync,
                            $"Are you sure you want to run the job {sJobName}?",
                            "Didn't get that!",
                            promptStyle: PromptStyle.None);
                    }
                }

                if (!QuestionAnswered)
                {
                    await context.PostAsync($"I did not understand the request : {message.Text}");

                    context.Wait(MessageReceivedAsync);
                }
            }
            else if (message.Text.ToLower().StartsWith("check "))
            {
                bool QuestionAnswered = false;

                if (message.Text.Contains(" "))
                {
                    string[] ProvidedCommand = message.Text.Split(new char[1] {
                        ' '
                    });

                    if (ProvidedCommand.Length == 2)
                    {
                        string sJobName = ProvidedCommand[1];

                        QuestionAnswered = true;

                        bool bIsJobRunning = SystemOps.IsJobRunning(CONST_JOB_DIRECTORY, sJobName);

                        if (bIsJobRunning)
                        {
                            await context.PostAsync("Yes, it is currently running.");
                        }
                        else
                        {
                            await context.PostAsync("No, it's not currently running.");
                        }
                    }
                }

                if (!QuestionAnswered)
                {
                    await context.PostAsync($"I did not understand the request : {message.Text}");

                    context.Wait(MessageReceivedAsync);
                }
            }
            else
            {
                await context.PostAsync($"I did not understand the request : {message.Text}");

                context.Wait(MessageReceivedAsync);
            }
        }