Beispiel #1
0
        private void InstallIpuApplication(CMApplication cmApp)
        {
            if (_ipuRunning)
            {
                return;
            }

            _ipuRunning = true;

            Task.Run(() =>
            {
                _runningIpuApp = CcmUtils.GetSpecificApp(new ScheduledObject {
                    ObjectId = cmApp.Id, Revision = cmApp.Revision
                });

                if (_runningIpuApp == null)
                {
                    Globals.Log.Error($"Failed to get specific application, Id '{cmApp.Id}' Revision: '{cmApp.Revision}'");
                    _ipuRunning = false;
                    RegistryMethods.RemoveIpuIsRunning();
                    return;
                }

                var contentInfo = SqlCe.GetContentStatus(_runningIpuApp.DeploymentTypeId, _runningIpuApp.DeploymentTypeRevision);

                if (contentInfo != null)
                {
                    if (contentInfo.IsDownloaded && contentInfo.InstallTime < DateTime.Now.AddMinutes(-30))
                    {
                        Globals.Log.Information($"Detected request for upgrade, IpuApplication at '{contentInfo.Location}' - attempting upgrade.");
                        RegistryMethods.SetIpuIsRunning();
                        CcmUtils.InstallApplication(_runningIpuApp);
                    }
                    else
                    {
                        Globals.Log.Information($"Detected request for upgrade, IpuApplication at '{contentInfo.Location}' - content not yet downloaded or already installed, skipping.");
                        _ipuRunning = false;
                        RegistryMethods.RemoveIpuIsRunning();
                    }
                }
                else
                {
                    Globals.Log.Information($"Detected request for upgrade, IpuApplication DT Id '{_runningIpuApp.DeploymentTypeId}' Revision '{_runningIpuApp.DeploymentTypeRevision}' - content status returned Null, skipping.");
                    _ipuRunning = false;
                    RegistryMethods.RemoveIpuIsRunning();
                }
            });
        }