コード例 #1
0
        private int MouseHookCallback(
            int nCode, IntPtr wParam, IntPtr lParam)
        {
            MouseMessages mouseInfo = (MouseMessages)wParam;

            if (nCode >= 0 &&
                ((mouseInfo == MouseMessages.WM_LBUTTONDOWN) || (mouseInfo == MouseMessages.WM_RBUTTONDOWN)))
            {
                _lastActivity = DateTime.Now;

                Debug.WriteLine("MouseHookCallback: " + _currState.ToString() + "\t" + DateTime.Now.ToString() + "\t" + nCode.ToString() + "\t" + wParam + "\t" + lParam);
                //Debug.WriteLine("\t" + hookStruct.flags.ToString() + "\t" + hookStruct.mouseData.ToString() + "\t" + hookStruct.time.ToString());
            }
            return(CallNextHookEx(_mouseHookID, nCode, wParam, lParam));
        }
コード例 #2
0
        /// <summary>
        /// Executes this instance.
        /// </summary>
        /// <exception cref="WorkerHaltedException"></exception>
        public void Execute()
        {
            // Process the activity, which will use the defined plugin, and once processed
            // then tell the Activity Dispatcher to release the next activity.
            Thread.CurrentThread.SetName(this.ActivityType);

            // Save the activity and transaction ID for global access
            GlobalDataStore.CurrentActivity       = this.Id;
            GlobalDataStore.CurrentTransaction    = SequentialGuid.NewGuid();
            _executionContext.ActivityExecutionId = GlobalDataStore.CurrentTransaction;

            // Prep logging for the activity
            var dataLogger = new ActivityExecutionLogger
                             (
                GlobalDataStore.ResourceInstanceId,
                GlobalDataStore.Credential.UserName,
                GlobalDataStore.CurrentTransaction,
                this.Id,
                GlobalDataStore.Manifest.SessionId,
                this.Name,
                this.ActivityType
                             );

            dataLogger.Status = ActivityState.Started.ToString();

            // Set the initial status
            UpdateActivityStatus(ActivityState.Started);
            ExecutionServices.DataLogger.AsInternal().SubmitAsync(dataLogger);

            // Refresh asset availability
            RefreshAssetAvailability();

            // Attempt to process the activity, and catch any exceptions that are returned
            // If there is no failure, then update the event status to Completed
            TraceFactory.Logger.Debug($"Starting ProcessActivity for activity execution ID {_executionContext.ActivityExecutionId.ToString()}.");

            PluginExecutionResult result;

            try
            {
                result = ProcessActivity();
            }
            catch (WorkerHaltedException ex)
            {
                _lastExecutionState = ActivityState.Failed;
                UpdateActivityStatus(_lastExecutionState, ex.Message);

                TraceFactory.Logger.Debug($"Ending ProcessActivity for FAILED activity execution ID {_executionContext.ActivityExecutionId.ToString()}.");

                dataLogger.UpdateValues(_lastExecutionState.ToString(), ex.Message);
                ExecutionServices.DataLogger.AsInternal().UpdateAsync(dataLogger);
                throw;
            }

            switch (result.Result)
            {
            case PluginResult.Passed:
                _lastExecutionState = ActivityState.Completed;
                break;

            case PluginResult.Failed:
                _lastExecutionState = ActivityState.Failed;
                break;

            case PluginResult.Skipped:
                _lastExecutionState = ActivityState.Skipped;
                break;

            case PluginResult.Error:
                _lastExecutionState = ActivityState.Error;
                break;
            }
            UpdateActivityStatus(_lastExecutionState, result.Message);

            TraceFactory.Logger.Debug($"Ending ProcessActivity for activity execution ID {_executionContext.ActivityExecutionId.ToString()}.");

            dataLogger.UpdateResultValues(result);
            ExecutionServices.DataLogger.AsInternal().UpdateAsync(dataLogger);
        }