Пример #1
0
        private WuRemoteCallResult Call(IWuEndpoint endpoint, object param)
        {
            if (endpoint == null)
            {
                throw new ArgumentNullException(nameof(endpoint));
            }

            Log.Info($"Execute remote call {GetType().Name} on endpoint {endpoint.FQDN}, param: {param?.ToString()}");
            WuRemoteCallResult result = null;

            try
            {
                if (endpoint.IsDisposed)
                {
                    return(new WuRemoteCallResult(endpoint, this, false, null, "Host connection is disposed, please reconnect to this host."));
                }
                result = CallInternal(endpoint, param);
            }
            catch (Exception e)
            {
                Log.Error($"Execute remote call {GetType().Name} on endpoint {endpoint.FQDN} failed.", e);
                return(new WuRemoteCallResult(endpoint, this, false, e, e.Message));
            }
            if (result == null)
            {
                return(new WuRemoteCallResult(endpoint, this, true, null, null));
            }
            return(result);
        }
Пример #2
0
        protected override WuRemoteCallResult CallInternal(IWuEndpoint endpoint, object param)
        {
            if (ReconnectIfDisconnected(endpoint))
            {
                switch (endpoint.State.StateId)
                {
                case WuStateId.Searching:
                    endpoint.Service.AbortSearchUpdates();
                    break;

                case WuStateId.Downloading:
                    endpoint.Service.AbortDownloadUpdates();
                    break;

                case WuStateId.Installing:
                    endpoint.Service.AbortInstallUpdates();
                    break;

                default:
                    return(new WuRemoteCallResult(endpoint, this, false, null, "The remote service is not searching, downloading or installing updates, can not abort the current state."));
                }
                return(WuRemoteCallResult.SuccessResult(endpoint, this));
            }
            return(WuRemoteCallResult.EndpointNotAvailableResult(endpoint, this));
        }
        protected override WuRemoteCallResult CallInternal(IWuEndpoint endpoint, object param)
        {
            SelectionParameter parameter;

            if (param is SelectionParameter)
            {
                parameter = (SelectionParameter)param;
            }
            else
            {
                throw new ArgumentException($"A {nameof(SelectionParameter)} parameter is required.", nameof(param));
            }
            if (ReconnectIfDisconnected(endpoint))
            {
                if (parameter.Value && endpoint.Service.SelectUpdate(parameter.Update.ID)) // try to select update
                {
                    return(WuRemoteCallResult.SuccessResult(endpoint, this, $"Update {parameter.Update.Title} selected."));
                }
                if (!parameter.Value && endpoint.Service.UnselectUpdate(parameter.Update.ID)) // try to unselect update
                {
                    return(WuRemoteCallResult.SuccessResult(endpoint, this, $"Update {parameter.Update.Title} unselected."));
                }
                return(new WuRemoteCallResult(endpoint, this, false, null, $"Update {parameter.Update.Title} could not be {(parameter.Value?"selected":"unselected")}."));
            }
            return(WuRemoteCallResult.EndpointNotAvailableResult(endpoint, this));
        }
 protected override WuRemoteCallResult CallInternal(IWuEndpoint endpoint, object param)
 {
     if (ReconnectIfDisconnected(endpoint))
     {
         endpoint.Service.BeginInstallUpdates();
         return(WuRemoteCallResult.SuccessResult(endpoint, this));
     }
     return(WuRemoteCallResult.EndpointNotAvailableResult(endpoint, this));
 }
Пример #5
0
 protected override WuRemoteCallResult CallInternal(IWuEndpoint endpoint, object param)
 {
     if (ReconnectIfDisconnected(endpoint))
     {
         endpoint.Service.ResetService();
         endpoint.RefreshState();
         return(WuRemoteCallResult.SuccessResult(endpoint, this));
     }
     return(WuRemoteCallResult.EndpointNotAvailableResult(endpoint, this));
 }
        protected override WuRemoteCallResult CallInternal(IWuEndpoint endpoint, object param)
        {
            bool value = (param is bool) ? (bool)param : true;

            if (ReconnectIfDisconnected(endpoint))
            {
                endpoint.Service.SetAutoSelectUpdates(value);
                endpoint.RefreshSettings();
                return(WuRemoteCallResult.SuccessResult(endpoint, this));
            }
            return(WuRemoteCallResult.EndpointNotAvailableResult(endpoint, this));
        }
        protected override WuRemoteCallResult CallInternal(IWuEndpoint endpoint, object param)
        {
            UpdateDescription update = param as UpdateDescription;

            if (update == null)
            {
                throw new ArgumentException($"A {nameof(UpdateDescription)} parameter which includes an update id is required.", nameof(param));
            }
            if (ReconnectIfDisconnected(endpoint))
            {
                if (endpoint.Service.AcceptEula(update.ID))
                {
                    return(WuRemoteCallResult.SuccessResult(endpoint, this, $"The EULA of update {update.Title} was accepted."));
                }
                return(new WuRemoteCallResult(endpoint, this, false, null, $"The EULA of update {update.Title} could not be accepted."));
            }
            return(WuRemoteCallResult.EndpointNotAvailableResult(endpoint, this));
        }
Пример #8
0
        private void OnTaskFinished(Task <WuRemoteCallResult> task)
        {
            Result          = task.Result;
            _lastTaskStatus = task.Status;

            if (task.Exception != null && task.Result == null)
            {
                Result = new WuRemoteCallResult(_endpoint, _call, false, task.Exception, task.Exception.Message);
            }

            _call     = null;
            _endpoint = null;

            lock (_taskLock)
            {
                _task = null;
            }

            OnPropertyChanged(nameof(Result));
        }
Пример #9
0
 protected override WuRemoteCallResult CallInternal(IWuEndpoint endpoint, object param)
 {
     endpoint.Reconnect();
     endpoint.RefreshState();
     return(WuRemoteCallResult.SuccessResult(endpoint, this));
 }