コード例 #1
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);
 }
コード例 #2
0
 public CloudDirectoryViewModel(CloudDirectoryModel cloudDirModel)
 {
     CloudModel        = cloudDirModel;
     SaveCmd           = new RelayCommand(Save, param => IsValid());
     CancelCmd         = new RelayCommand(param => CloseCmd.Execute(param));
     IntervalTimeScale = 1;
     DisplayName       = Strings.CloudDirectoryViewModel_DisplayName;
     SetupDirectoryItems();
 }
コード例 #3
0
 public CreateCsvViewModel(IRepository repository, CreateCsvModel csvModel)
     : base(repository)
 {
     _model           = csvModel;
     SaveCmd          = new RelayCommand(Save, param => IsValid());
     SelectFileCmd    = new RelayCommand(SelectFile);
     CancelCmd        = new RelayCommand(param => CloseCmd.Execute(param), param => true);
     DisplayName      = Strings.CreateCsvVM_Title;
     SelectedFileType = FileTypes.First();
     DateFormat       = "u";
     IsDateInQuotes   = true;
     IsStringInQuotes = true;
     //SetDateInQuotes();
 }
コード例 #4
0
        public RandomisedMessagesViewModel(RandomisedMessagesModel model)
        {
            _messagesModel = model;
            DisplayName    = Strings.RandomisedMessagesViewModel_DisplayName;
            if (InterventionInstructions == null)
            {
                InterventionInstructions = Strings.RandomisedMessagesViewModel_DefaultIntervention;
            }
            if (ControlInstructions == null)
            {
                ControlInstructions = Strings.RandomisedMessagesViewModel_DefaultControl;
            }
            if (DischargeExplanation == null)
            {
                DischargeExplanation = Strings.RandomisedMessagesViewModel_DefaultDischarge_Hospital;
            }

            SaveCmd   = new RelayCommand(param => Save(), param => WasValidOnLastNotify);
            CancelCmd = new RelayCommand(param => CloseCmd.Execute(param));
        }
コード例 #5
0
        private void Login(object parameter)
        {
            PasswordBox passwordBox       = parameter as PasswordBox;
            var         clearTextPassword = passwordBox.SecurePassword;

            try
            {
                //Validate credentials through the authentication service
                IUser user = _authenticationService.AuthenticateUser(Username, clearTextPassword);

                //Get the current principal object
                CustomPrincipal customPrincipal = Thread.CurrentPrincipal as CustomPrincipal;
                if (customPrincipal == null)
                {
                    throw new ArgumentException("The application's default thread principal must be set to a CustomPrincipal object on startup.");
                }

                //Authenticate the user
                customPrincipal.Identity = new CustomIdentity(user.Id, user.Username, user.Roles.Select(r => r.Name).ToArray());

                //Update UI
                //RaisePropertyChanged("AuthenticatedUser");
                //RaisePropertyChanged("IsAuthenticated");
                Username             = string.Empty; //reset
                passwordBox.Password = string.Empty; //reset
                Status = string.Empty;
                Mediator.NotifyColleagues("AuthorisationRequest", true);
                log4net.LogManager.GetLogger("Authenticaton").InfoFormat("Logged in as {0}", user.Username);
                CloseCmd.Execute(null);
            }
            catch (UnauthorizedAccessException)
            {
                if (++LoginAttempts > MaxLoginAttempts)
                {
                    CloseCmd.Execute(null);
                }
                Status = "Login failed! Please provide valid credentials.";
                //Mediator.NotifyColleagues("AuthorisationRequest", false);
            }
        }
コード例 #6
0
        public void Save(object param)
        {
            if (!IsValid())
            {
                throw new InvalidOperationException("CreateCsvViewModel not valid - cannot call save");
            }
            string dofile = null;

            switch (TableType)
            {
            case TableOptions.Participant:
                var vaccines = _repository.Vaccines.ToList();
                try
                {
                    using (StreamWriter sw = new StreamWriter(_model.Filename))
                    {
                        PatientDataToCSV.ParticipantDataToCSV(_repository.Participants.Include("VaccinesAdministered").ToList(), vaccines, SelectedFileType.Delimiter, DateFormat, IsStringInQuotes, IsDateInQuotes, sw);
                    }
                }
                catch (System.IO.IOException e)
                {
                    System.Windows.MessageBox.Show(e.Message);
                    return;
                }
                if (SimultaneousStata)
                {
                    dofile = new ParticipantDataStataTemplate(
                        new ParticipantStataData(_model.FileNameWithExtension,
                                                 SelectedFileType.Delimiter,
                                                 _repository.LocalStudyCentres.Select(s => new KeyValuePair <int, string>(s.Id, s.Name)),
                                                 vaccines.Select(v => v.Name)
                                                 )).TransformText();
                }
                break;

            case TableOptions.ScreenedPatients:
                var screened           = Mapper.Map <ScreenedPatientCsvModel[]>(_repository.ScreenedPatients.ToArray());
                var csvEncodedScreened = ListConverters.ToCSV(screened, SelectedFileType.Delimiter, PatientDataToCSV.CSVOptions(DateFormat, IsStringInQuotes, IsDateInQuotes));
                try
                {
                    File.WriteAllText(_model.FileNameWithExtension, csvEncodedScreened);
                }
                catch (System.IO.IOException e)
                {
                    System.Windows.MessageBox.Show(e.Message);
                    return;
                }
                if (SimultaneousStata)
                {
                    dofile = new ScreenedPatientStataTemplate(new CentreStataData(
                                                                  _model.FileNameWithExtension,
                                                                  SelectedFileType.Delimiter,
                                                                  _repository.LocalStudyCentres.Select(s => new KeyValuePair <int, string>(s.Id, s.Name))
                                                                  )).TransformText();
                }
                break;

            case TableOptions.ProtocolViolations:
                var viol            = _repository.ProtocolViolations.ToArray();
                var csvEncodedViols = ListConverters.ToCSV(viol, SelectedFileType.Delimiter, PatientDataToCSV.CSVOptions(DateFormat, IsStringInQuotes, IsDateInQuotes));
                try
                {
                    File.WriteAllText(_model.FileNameWithExtension, csvEncodedViols);
                }
                catch (System.IO.IOException e)
                {
                    System.Windows.MessageBox.Show(e.Message);
                    return;
                }
                if (SimultaneousStata)
                {
                    dofile = new ScreenedPatientStataTemplate(new CentreStataData(
                                                                  _model.FileNameWithExtension,
                                                                  SelectedFileType.Delimiter,
                                                                  _repository.LocalStudyCentres.Select(s => new KeyValuePair <int, string>(s.Id, s.Name))
                                                                  )).TransformText();
                }
                break;

            default:
                throw new InvalidOperationException("save called no table selected");
            }
            if (dofile != null)
            {
                try
                {
                    File.WriteAllText(Path.ChangeExtension(_model.Filename, "do"), dofile);
                }
                catch (System.IO.IOException e)
                {
                    System.Windows.MessageBox.Show(e.Message);
                    return;
                }
            }
            CloseCmd.Execute(null);
        }
コード例 #7
0
 void Save()
 {
     BlowTrialDataService.SetRandomisingMessages(InterventionInstructions, ControlInstructions, DischargeExplanation);
     CloseCmd.Execute(null);
 }