Click or drag to resize

IInfrascaleSdkRunRefreshRecoveryInfoJob Method

Starts RefreshRecoveryInfo job that refreshes local db of metadata by syncing it with backup server.

Namespace:  SOS.SDK.Contracts
Assembly:  SOS.SDK (in SOS.SDK.dll) Version: 7.6.1.5742
Syntax
C#
RefreshRecoveryInfoJobSessionContract RunRefreshRecoveryInfoJob(
	RunRefreshRecoveryInfoJobRequest request
)

Parameters

request
Type: SOS.SDK.Contracts.DataContracts.RequestsRunRefreshRecoveryInfoJobRequest
Container with request parameters.

Return Value

Type: RefreshRecoveryInfoJobSessionContract
Operation execution results.
Exceptions
ExceptionCondition
NotSignedIn
MethodCallFailed
Remarks
Please note: this operation can be performed for a long time in case of a large number of backed up data. Operation performs page-by-page. If you cancelled operation - next time refreshing started from last known page. If you start the recovery without the refreshing procedure, or after the refreshing is canceled, the results of the recovery may be unpredictable incorrect. Some files may be skipped, some files may have a non-actual version, etc. Please wait for the refreshing to finish.
Examples

Refreshing recovery info using RefreshRecoveryInfoJobRunner helper.

Run RefreshRecovery info with helper
using System;
using System.IO;
using System.Linq;
using System.Text;
using SOS.SDK.Contracts.DataContracts;
using SOS.SDK.Contracts.DataContracts.Enums;
using SOS.SDK.Contracts.DataContracts.Jobs;
using SOS.SDK.Contracts.DataContracts.Jobs.Recovery;
using SOS.SDK.Contracts.DataContracts.Requests;
using SOS.SDK.Contracts.DataContracts.Responses;
using SOS.SDK.Tools.Runners;

namespace SOS.SDK.Test.Examples.Recovery
{
    public class RecoveryExamples
    {
        private readonly string _testAccount = @"sdk.test@sosonlinebackup.com";
        private readonly string _testAccountPassword = @"qweqwe";
        private IInfrascaleClient _client;

        private readonly string _recoveryDestination = @"C:\Obrm.Sdk.TestRecovery\";

        private readonly TimeSpan _refreshRecoveryInfoTimeout = TimeSpan.FromMinutes(10);
        private readonly TimeSpan _recoveryTimeout = TimeSpan.FromMinutes(10);
        private IdentityContract _identity;

        public void SignIn()
        {
            if (_client == null)
            {
                _client = new InfrascaleClient();
                _client.Connect();
                _identity = null;
            }

            if (_identity == null)
            {
                var signInResponse = _client.SignIn(new SignInRequest
                {
                    Credentials = new CredentialsContract { Login = _testAccount, Password = _testAccountPassword }
                });

                _identity = signInResponse.Identity;

                _client.SubscribeCallback(new SubscribeCallbackRequest { Identity = _identity });
            }
        }

        private void RefreshRecoveryInfoWithRunner()
        {
            var runner = new RefreshRecoveryInfoJobRunner(_client);
            runner.Run(_identity, _refreshRecoveryInfoTimeout);
        }
    }
}

Refreshing recovery info using raw contracts and listening of callbacks.

Run RefreshRecovery info with raw contracts
using System;
using System.IO;
using System.Linq;
using System.Text;
using SOS.SDK.Contracts.DataContracts;
using SOS.SDK.Contracts.DataContracts.Enums;
using SOS.SDK.Contracts.DataContracts.Jobs;
using SOS.SDK.Contracts.DataContracts.Jobs.Recovery;
using SOS.SDK.Contracts.DataContracts.Requests;
using SOS.SDK.Contracts.DataContracts.Responses;
using SOS.SDK.Tools.Runners;

namespace SOS.SDK.Test.Examples.Recovery
{
    public class RecoveryExamples
    {
        private readonly string _testAccount = @"sdk.test@sosonlinebackup.com";
        private readonly string _testAccountPassword = @"qweqwe";
        private IInfrascaleClient _client;

        private readonly string _recoveryDestination = @"C:\Obrm.Sdk.TestRecovery\";

        private readonly TimeSpan _refreshRecoveryInfoTimeout = TimeSpan.FromMinutes(10);
        private readonly TimeSpan _recoveryTimeout = TimeSpan.FromMinutes(10);
        private IdentityContract _identity;

        public void SignIn()
        {
            if (_client == null)
            {
                _client = new InfrascaleClient();
                _client.Connect();
                _identity = null;
            }

            if (_identity == null)
            {
                var signInResponse = _client.SignIn(new SignInRequest
                {
                    Credentials = new CredentialsContract { Login = _testAccount, Password = _testAccountPassword }
                });

                _identity = signInResponse.Identity;

                _client.SubscribeCallback(new SubscribeCallbackRequest { Identity = _identity });
            }
        }

        private void RefreshRecoveryInfoWithListener()
        {
            using (var listener = _client.ListenRefreshRecoveryInfoJob(OnRefreshStarted, OnRefreshProgress, OnRefreshEvents, OnRefreshCompleted))
            {
                var session =
                    _client.RunRefreshRecoveryInfoJob(new RunRefreshRecoveryInfoJobRequest {Identity = _identity});
                listener.FilterJobId = session.JobId;
                listener.WaitForCompletion();
            }
        }

        private void OnRefreshStarted(RefreshRecoveryInfoJobSessionContract started)
        {
            Console.WriteLine("RefreshRecoveryInfo Job {0} is Started", started.JobId);
        }

        private void OnRefreshProgress(RefreshRecoveryInfoJobSessionContract progress)
        {
            Console.WriteLine("JobID: {0}", progress.JobId);
            Console.WriteLine("\tJob state: {0}", progress.State);
            Console.WriteLine("\tCompleted, %: {0}", progress.ProgressPercentage);
        }

        private void OnRefreshEvents(JobEventsContract events)
        {
            Console.WriteLine("JobID: {0}", events.JobId);
            Console.WriteLine("\tEvents:");

            foreach (var jobEventContract in events.Events)
            {
                Console.WriteLine("\t{0}: [{1}] {2}", jobEventContract.EventTime, jobEventContract.MessageType, jobEventContract.Message);
            }
        }

        private void OnRefreshCompleted(RefreshRecoveryInfoJobSessionContract completed)
        {
            Console.WriteLine("JobID: {0}", completed.JobId);
            Console.WriteLine("JobState: {0}", completed.State);
            if (completed.State == SessionStateContract.Failed)
            {
                Console.WriteLine("Error: {0}", completed.ErrorMessage);
            }
        }
    }
}
See Also