internal async Task<Result> ExecuteDeviceTypeCommandAsync(DeviceTypeCommand command, string argument, string argument2, CancellationToken cancellationToken)
        {
            using (var context = new ZvsContext(EntityContextConnection))
            {
                int dId = int.TryParse(argument2, out dId) ? dId : 0;

                var device = await context.Devices
                    .Include(o => o.Type)
                    .Include(o => o.Type.Adapter)
                    .FirstOrDefaultAsync(o => o.Id == dId, cancellationToken);

                if (device == null)
                    return Result.ReportErrorFormat("Cannot find device with id of {0}", dId);

                var commandAction =
                    $"{command.Name}{(string.IsNullOrEmpty(argument) ? "" : " " + argument)} {device.Name}";

                var aGuid = device.Type.Adapter.AdapterGuid;
                var adapter = AdapterManager.FindZvsAdapter(aGuid);
                if (adapter == null)
                {
                    return Result.ReportErrorFormat("{0} failed, device adapter is not loaded!",
                        commandAction);
                }

                if (!adapter.IsEnabled)
                    return Result.ReportErrorFormat("{0} failed because the {1} adapter is {2}",
                        commandAction,
                        device.Type.Adapter.Name,
                        adapter.IsEnabled ? "not ready" : "disabled");

                await adapter.ProcessDeviceTypeCommandAsync(device.Type, device, command, argument);
                return Result.ReportSuccessFormat("{0} complete", commandAction);
            }
        }