void UploadData()
 {
     if (BackupModel == null)
     {
         return;
     }
     if (BackupModel.IsBackingUpToCloud.Value)
     {
         BlowTrialDataService.SetAppData(
             BackupModel.CloudDirectories,
             BackupModel.BackupIntervalMinutes.Value,
             true,
             BackupModel.PatientsPreviouslyRandomised
             );
         if (SitesModel != null)
         {
             BlowTrialDataService.DefineNewStudyCentres(SitesModel.StudySitesData);
         }
     }
     else
     {
         BlowTrialDataService.SetBackupDetails(
             BackupModel.CloudDirectories,
             BackupModel.BackupIntervalMinutes.Value,
             false,
             BackupModel.PatientsPreviouslyRandomised
             );
     }
     WasCancelled = false;
 }
        void HandleAuthorisationClose()
        {
            var identity = GetCurrentPrincipal().Identity;

            if (identity.Name == "Admin")
            {
                ShowCreateNewUser();
            }
            else
            {
                IsAuthorised = identity.IsAuthenticated;
                if (IsAuthorised)
                {
                    using (var m = new MembershipContext())
                    {
                        _backupService = new BackupService(_repository, m);
                        //IsEnvelopeRandomising = BlowTrialDataService.IsEnvelopeRandomising(m);
                        var backDetails = BlowTrialDataService.GetBackupDetails(m);
                        if (backDetails.BackupData.IsBackingUpToCloud)
                        {
                            _transferLog             = new TransferLog(backDetails.CloudDirectories.First() + '\\' + LogFileName);
                            _backupService.OnBackup += OnBackupInterval;
                        }
                    }
                }
                else
                {
                    OnRequestClose();
                }
            }
        }
Example #3
0
 public void Save(object param)
 {
     BlowTrialDataService.SetBackupDetails(
         CloudModel.CloudDirectoryItems.Select(c => c.DirectoryPath),
         CloudModel.BackupIntervalMinutes.Value);
     OnSave?.Invoke(this, new EventArgs()); CloseCmd.Execute(null);
 }
Example #4
0
        private void ClearAllFields()
        {
            _patient = new PatientDemographicsModel {
                WasEnvelopeRandomised = BlowTrialDataService.IsEnvelopeRandomising()
            };
            StudyCentre         = StudyCentreOptions.First().Key;
            _multipleSibling    = null;
            _hasSiblingEnrolled = false;

            _wtForAgeCentile = null;
            NotifyPropertyChanged("Name", "HospitalIdentifier", "AdmissionWeight", "GestAgeDays", "GestAgeWeeks", "IsMale", "DateOfBirth", "TimeOfBirth", "DateOfEnrollment", "TimeOfEnrollment", "LikelyDie24Hr", "BadMalform", "BadInfectnImmune", "WasGivenBcgPrior", "RefusedConsent", "MothersName", "WtForAgeCentile", "PhoneNumber", "IsYoungerThanMinEnrolTime", "EnvelopeNumber", "OkToRandomise", "IsConsentRequired", "HasSiblingEnrolled", "MultipleSiblingId", "HasNoPhone", "AdmissionDiagnosis", "StudyCentre", "BackgroundBrush", "TextBrush", "HospitalIdentifierMask", "PhoneMask", "IsInborn");
            RecordAltered = false;
            _isEnrollmentDateTimeAssigned = false;
        }
Example #5
0
        static string GetLogOutputPath()
        {
            BackupDataSet bak = BlowTrialDataService.GetBackupDetails();

            if (bak != null)
            {
                string dir = bak.CloudDirectories.FirstOrDefault();
                if (dir != null)
                {
                    // if environment.machinename not working due to duplicate names, could try
                    //var searcher = new System.Management.ManagementObjectSearcher("select * from " + Key);
                    // key = Win32_DiskDrive or Win32_Processor
                    return(Path.Combine(dir, StringExtensions.GetSafeFilename($"log_{Environment.MachineName}_{Environment.UserName}_{MAC()}.txt")));
                }
            }
            return(null);
        }
Example #6
0
        public BackupService(IRepository repo, IAppData backupData)
        {
            _repo = repo;
            var backupDetails = BlowTrialDataService.GetBackupDetails(backupData);

            _repo.CloudDirectories = backupDetails.CloudDirectories;
            //use DispatcherTimer rather than dispatcher as CE does not handle multiple connections inevitable with multi threading
            _timer = new DispatcherTimer(DispatcherPriority.Normal)
            {
                Interval = new TimeSpan(0, backupDetails.BackupData.BackupIntervalMinutes, 0)
            };
            if (backupDetails.BackupData.IsBackingUpToCloud)
            {
                _handler    = new EventHandler(Backup);
                _isToBackup = true;
            }
            else
            {
                _handler = new EventHandler(Restore);
                Restore(this, new EventArgs());
            }
            _timer.Tick += _handler;
            _timer.Start();
        }
 void Save()
 {
     BlowTrialDataService.SetRandomisingMessages(InterventionInstructions, ControlInstructions, DischargeExplanation);
     CloseCmd.Execute(null);
 }
Example #8
0
        protected override void OnStartup(StartupEventArgs e)
        {
            _log = LogManager.GetLogger(typeof(App));
#if !DEBUG
            if (CurrentClickOnceVersion != null)
            {
                ThreadContext.Properties["deploymentVersion"] = CurrentClickOnceVersion;
            }
            this.DispatcherUnhandledException += Application_DispatcherUnhandledException;
            log4net.Config.XmlConfigurator.Configure();
#endif
            base.OnStartup(e);

            // AppDomain.CurrentDomain.SetData("DataDirectory", baseDir);

            //Application initialisation

            AutoMapperConfiguration.Configure();

            /*
             * catch (Exception ex)
             * {
             *  _log.Error("App_AutomapperConfigurationException", ex);
             *  MessageBox.Show("An error has occured with automapper. An error has been logged, but this file will have to be attached and emailed to the application developer");
             *  throw;
             * }
             */

            //Security
            CustomPrincipal customPrincipal = new CustomPrincipal();
            AppDomain.CurrentDomain.SetThreadPrincipal(customPrincipal);

            ShutdownMode = System.Windows.ShutdownMode.OnExplicitShutdown;
            //test if wizard needs to run
#if !DEBUG
            try
            {
#endif
            CodeBasedMigration.ApplyPendingMigrations <BlowTrial.Migrations.TrialData.TrialDataConfiguration>(TrialDataContext.GetConnectionString(), ContextCeConfiguration.ProviderInvariantName, true);

            CodeBasedMigration.ApplyPendingMigrations <BlowTrial.Migrations.Membership.MembershipConfiguration>(MembershipContext.GetConnectionString(), ContextCeConfiguration.ProviderInvariantName, true);
#if !DEBUG
        }

        catch (Exception ex)
        {
            string usrErrMsg = null;
            if (ex.Message.StartsWith("Access to the database file is not allowed"))
            {
                string administratorInstructions = string.Format("User:{0}\nRequies modify permissions be allowed for folder:\n{1}\nAnd all files within", System.Security.Principal.WindowsIdentity.GetCurrent().Name, DataDirectory);
                usrErrMsg = "Cannot access database: \nPlease contact the systems administrator with the following message:\n" + administratorInstructions;
            }
            else
            {
                usrErrMsg = "An error has occured trying to access the database: \n" + ex.Message;
            }
            if (usrErrMsg != null)
            {
                _log.Error("App_FirstDatabaseAccessException", ex);
                MessageBox.Show(usrErrMsg);
                throw;
            }
        }
#endif

            var backDetails    = BlowTrialDataService.GetBackupDetails();
            bool displayWizard = (backDetails.BackupData == null);
            if (!displayWizard && backDetails.BackupData.IsBackingUpToCloud)
            {
                using (var t = new TrialDataContext())
                {
                    displayWizard = !t.StudyCentres.Any();
                }
            }
            if (displayWizard && !DisplayAppSettingsWizard())
            {
                Shutdown(259);
                return;
            }

            // Create the ViewModel to which
            // the main window binds.
            var mainWindowVm  = new MainWindowViewModel();
            MainWindow window = new MainWindow(mainWindowVm);

            // When the ViewModel asks to be closed,
            // close the window.
            EventHandler handler = null;
            handler = delegate
            {
                window.Close();
                if (!window.IsLoaded) //in case user cancelled
                {
                    mainWindowVm.RequestClose -= handler;
                }
            };
            mainWindowVm.RequestClose += handler;
            _log.InfoFormat("Application started {0}", DateTime.Now);
            window.Show();
        }