System.Net.NetworkCredential LoadCurrentAccount()
        {
            var acc = AccountManager.Instance.CurrentAccount;

            System.Net.NetworkCredential account = null;
            if (!acc.IsAnonymous)
            {
                account = new System.Net.NetworkCredential()
                {
                    UserName = acc.Name, Password = acc.Password
                }
            }
            ;

            return(account);
        }

        void StartUpgrade(BatchItem bitem, string binPath)
        {
            NvtSessionFactory sessionFactory = new NvtSessionFactory(LoadCurrentAccount());

            IdentitySubscriptions.Add(sessionFactory.CreateSession(bitem.Device.Uris)
                                      .ObserveOnCurrentDispatcher()
                                      .Subscribe(isession => {
                OdmSession odmsession = new OdmSession(isession);
                var async             = odmsession.UpgradeFirmware(binPath);

                var taskFact       = BackgroundTask.CreateForAsync(async.ObserveOnCurrentDispatcher(), bitem.Device);
                var backgroundTask = taskFact(
                    result => CompleteWith(() => {
                }),
                    error => CompleteWith(() => {
                    context.Error(error);
                })
                    );
                BackgroundTaskManager.tasks.Add(backgroundTask);
            }, err => {
                dbg.Error(err);
            }));
        }
Ejemplo n.º 2
0
        void StartRestore(BatchItem bitem, string binPath)
        {
            NvtSessionFactory sessionFactory = new NvtSessionFactory(LoadCurrentAccount());

            IdentitySubscriptions.Add(sessionFactory.CreateSession(bitem.Device.Uris)
                                      .ObserveOnCurrentDispatcher()
                                      .Subscribe(isession => {
                OdmSession odmsession = new OdmSession(isession);
                var async             = odmsession.RestoreSystem(binPath);

                var taskFact       = BackgroundTask.CreateForAsync(async.ObserveOnCurrentDispatcher(), bitem.Device);
                var backgroundTask = taskFact(
                    result => CompleteWith(() => {
                }),
                    error => CompleteWith(() => {
                    activityContext.Error(error);
                })
                    );
                BackgroundTaskManager.tasks.Add(backgroundTask);
            }, err => {
                dbg.Error(err);
            }));
        }