public void InitializeComboBoxes()
        {
            _departmentService  = new DepartmentService();
            _credentialsService = new CredentialsService();
            _doctorService      = new DoctorService();

            _deptsList  = _departmentService.FindAll();
            _statusList = new List <string>()
            {
                "active", "inactive"
            };
            ComboBoxItem cbm;

            if (_deptsList != null)
            {
                foreach (Department d in _deptsList)
                {
                    cbm         = new ComboBoxItem();
                    cbm.Content = d.Name;
                    cbm.Tag     = d.Id;
                    departmentComboBox.Items.Add(cbm);
                }
            }
            foreach (KeyValuePair <int, string> status in DoctorStatus.DoctorStatuses)
            {
                cbm         = new ComboBoxItem();
                cbm.Content = status.Value;
                cbm.Tag     = status.Key;
                statusComoBox.Items.Add(cbm);
            }
        }
Пример #2
0
        /// <summary>Registers the type mappings with the Unity container.</summary>
        /// <param name="container">The unity container to configure.</param>
        /// <remarks>There is no need to register concrete types such as controllers or API controllers (unless you want to
        /// change the defaults), as Unity allows resolving a concrete type even if it was not previously registered.</remarks>
        public static void RegisterTypes(IUnityContainer container)
        {
            Log.Information("Registering IoC dependencies with container");

            var settingStore      = new SettingStore();
            var credentialService = new CredentialsService(settingStore.ForKey(SettingKeys.Credentials));

            var credentials = credentialService.Get();

            var connectionSettingsService = new ConnectionSettingsService(settingStore.ForKey(SettingKeys.ConnectionSettings));

            container.RegisterInstance(connectionSettingsService);

            var connectionSettings = connectionSettingsService.Get();

            var tfsBuildDefinitionRepository = new TfsBuildDefinitionRepository(credentials, settingStore.ForKey(SettingKeys.BuildDefinitions), settingStore.ForKey(SettingKeys.Builds), connectionSettings);
            var tfsMonitoringService         = new TfsMonitoringService(tfsBuildDefinitionRepository, TimeSpan.FromMinutes(1), TimeSpan.FromSeconds(30));

            tfsMonitoringService.Start();
            var observableCollections = new Dictionary <string, IObservableRepository>
            {
                { "buildDefinitions", tfsMonitoringService.BuildDefinitions },
                { "builds", tfsMonitoringService.Builds },
                { "settings", tfsMonitoringService.Settings }
            };

            var observableRepositoryHubSubscriptionFactory = new ObservableRepositoryHubSubscriptionFactory(observableCollections);

            container.RegisterInstance(observableRepositoryHubSubscriptionFactory);
            container.RegisterInstance(credentialService);
        }
Пример #3
0
        protected override void OnAppearing()
        {
            base.OnAppearing();

            MessagingCenter.Subscribe <Object, string>(this, "InstagramMedia", async(arg1, arg2) =>
            {
                try
                {
                    if (!string.IsNullOrEmpty(arg2))
                    {
                        var result = await App.TodoManager.GetInstagramMedia(arg2);

                        if (result.Equals("Success"))
                        {
                            CredentialsService.SaveCredentials(instagramMedia: App.InstagramMedia);
                            Application.Current.MainPage = new RootPage(App.SelectedView);
                        }
                        else
                        {
                            await DisplayAlert("Alert", result, "Ok");
                        }
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex.ToString());
                    await DisplayAlert("Alert", "something went wrong", "Ok");
                }
            });
        }
Пример #4
0
        public async Task WhenNoSuggestedUserNameProvidedAndSilentIsTrue_ThenSuggestionIsDerivedFromSigninNameWithoutPrompting()
        {
            var serviceRegistry = new ServiceRegistry();

            var auth = new Mock <IAuthorization>();

            auth.SetupGet(a => a.Email).Returns("*****@*****.**");
            serviceRegistry.AddMock <IAuthorizationAdapter>()
            .SetupGet(a => a.Authorization).Returns(auth.Object);

            serviceRegistry.AddSingleton <IJobService, SynchronousJobService>();
            serviceRegistry.AddMock <IComputeEngineAdapter>()
            .Setup(a => a.ResetWindowsUserAsync(
                       It.IsAny <InstanceLocator>(),
                       It.Is <string>(user => user == "bobsemail"),
                       It.IsAny <CancellationToken>()))
            .ReturnsAsync(new NetworkCredential("bobsemail", "password"));

            var credDialog = serviceRegistry.AddMock <IGenerateCredentialsDialog>();
            var settings   = InstanceConnectionSettings.CreateNew(SampleInstance);

            var credentialsService = new CredentialsService(serviceRegistry);
            await credentialsService.GenerateCredentialsAsync(
                null,
                SampleInstance,
                settings,
                true);

            Assert.AreEqual("bobsemail", settings.RdpUsername.Value);
            Assert.AreEqual("password", settings.RdpPassword.ClearTextValue);
            credDialog.Verify(d => d.PromptForUsername(
                                  It.IsAny <IWin32Window>(),
                                  It.IsAny <string>()), Times.Never);
        }
Пример #5
0
        async void CreateLPRecord(LPRecord lp)
        {
            Models.LPDBRecord exists = await App.Database.GetLPByID(lp.id);

            if (exists == null)
            {
                CredentialsService credentials = new CredentialsService();
                Models.LPDBRecord  lprecord    = new Models.LPDBRecord();
                lprecord.LPID          = lp.id;
                lprecord.LPTitle       = lp.title;
                lprecord.LPDescription = lp.description;
                lprecord.LPMap         = "";
                await App.Database.SaveLPAsync(lprecord);
            }
            //else
            //{
            //    if (String.IsNullOrEmpty(exists.LPMap))
            //    {
            //        CredentialsService credentials = new CredentialsService();
            //        TCMobile.Map map = await Courses.GetLearningPath(credentials.HomeDomain, credentials.UserID, lp.id);
            //        if (map != null)
            //        {
            //            string tempMap = JsonConvert.SerializeObject(map);

            //            exists.LPMap = tempMap;
            //            //  await App.Database.SaveLPAsync(exists);
            //        }
            //    }

            //}

            Cards card = new Cards();

            card.buildLPCard(lp.id, lp.title, lp.description, LP, DetailsClicked);
        }
        private void RegisterEvent()
        {
            MessagingCenter.Subscribe <ViewModels.SignupViewModel>(this, "SignUpCalenderPage", async(sender) =>
            {
                await this.Navigation.PushAsync(new SignUpCalenderPage(signupViewModel));
            });

            MessagingCenter.Subscribe <ViewModels.SignupViewModel>(this, "SignUpSuccess", (sender) =>
            {
                var member = App.SelectedView == "Trainee" ? App.LoginResponse : App.TrainerData;
                CredentialsService.SaveCredentials(signupViewModel.EmailAddress, signupViewModel.Password, App.LoginResponse, App.FacebookUser, userType: App.SelectedView);

                if (App.TrainerStripeUrl != "" && App.SelectedView == "Trainer")
                {
                    Application.Current.MainPage = new StripeSelectionPage();
                }
                else
                {
                    Application.Current.MainPage = new RootPage(signupViewModel.SelectedView);
                }
            });

            MessagingCenter.Subscribe <ViewModels.SignupViewModel, String>(this, "SignUpFailure", async(sender, message) =>
            {
                await DisplayAlert("Alert", message, "Ok");
            });
        }
        /// <summary>
        /// opens a connection to the database and initializes necessary services
        /// </summary>
        private void OpenConnection()
        {
            try
            {
                DBConnection.CreateConnection("localhost", "xe", "hr", "hr");
            }
            catch (Exception)
            {
                try
                {
                    DBConnection.CreateConnection("localhost", "ORCL", "hr", "roxana");
                }
                catch (Exception e)
                {
                    throw e;
                }
            }

            credentialsService   = new CredentialsService();
            administratorService = new AdministratorService();
            patientService       = new PatientService();
            doctorService        = new DoctorService();
            departmentService    = new DepartmentService();
            appointmentService   = new AppointmentService();
            resultService        = new ResultsService();
            scheduleService      = new ScheduleService();
        }
        public void InitializeComboBoxes()
        {
            _departmentService = new DepartmentService();
            _credentialsService = new CredentialsService();
            _doctorService = new DoctorService();

            _deptsList = _departmentService.FindAll();
            _statusList = new List<string>() { "active", "inactive" };
            ComboBoxItem cbm;
            if (_deptsList != null)
            {
                foreach (Department d in _deptsList)
                {
                    cbm = new ComboBoxItem();
                    cbm.Content = d.Name;
                    cbm.Tag = d.Id;
                    departmentComboBox.Items.Add(cbm);
                }
            }
            foreach (KeyValuePair<int, string> status in DoctorStatus.DoctorStatuses)
            {
                cbm = new ComboBoxItem();
                cbm.Content = status.Value;
                cbm.Tag = status.Key;
                statusComoBox.Items.Add(cbm);
            }
        }
Пример #9
0
        async void LoadCourses()
        {
            openPopup();
            Cat.Children.Clear();
            // show the spinner and turn it on
            // CatalogueProgress.IsVisible = true;
            // CatalogueProgress.IsRunning = true;
            // Load the catalogue
            CredentialsService credentials = new CredentialsService();
            var current = Connectivity.NetworkAccess;

            if (current == NetworkAccess.Internet)
            {
                App.CourseCatalogue = await Courses.GetCatalogue(credentials.HomeDomain, credentials.UserID);

                buildCatalogue(App.CourseCatalogue.courses.OrderBy(o => o.title).ToList());
            }
            else
            {
                buildCatalogueOffline();
            }
            //Hide the spinner
            closePopup();
            //CatalogueProgress.IsVisible = false;
            // CatalogueProgress.IsRunning = false;

            // Bind the courses to the ListView
        }
Пример #10
0
 public void Reset()
 {
     DropTables();
     CreateTables();
     CredentialsService.DeleteCredentials();
     NotificationService.Send(NotificationEvent.Reset);
 }
Пример #11
0
        async void Handle_Tapped_1(object sender, System.EventArgs e)
        {
            await this.Navigation.PushAsync(new InstagramLoginPage(false));

            MessagingCenter.Subscribe <Object, string>(this, "InstagramMedia", async(arg1, arg2) =>
            {
                try
                {
                    if (!string.IsNullOrEmpty(arg2))
                    {
                        traineeProfileViewModel.IsServiceInProgress = true;
                        var result = await App.TodoManager.GetInstagramMedia(arg2);

                        if (result.Equals("Success"))
                        {
                            CredentialsService.SaveCredentials(instagramMedia: App.InstagramMedia);
                            Application.Current.MainPage = new RootPage(App.SelectedView);
                        }
                        else
                        {
                            await DisplayAlert("Alert", result, "Ok");
                        }
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex.ToString());
                    await DisplayAlert("Alert", "something went wrong", "Ok");
                }
                traineeProfileViewModel.IsServiceInProgress = false;
            });
        }
Пример #12
0
        public static async Task Main(string[] args)
        {
            var builder = WebAssemblyHostBuilder.CreateDefault(args);

            builder.RootComponents.Add <App>("app");

            var engineService = await EngineService.Instantiate();

            var credentialsService = new CredentialsService();
            var actors             = await engineService.Instance.Storage.GetActors();

            credentialsService.SetCurrentActor(actors.First());

            builder.Services.AddTransient(sp => new HttpClient {
                BaseAddress = new Uri(builder.HostEnvironment.BaseAddress)
            });
            builder.Services.AddSingleton(sp => engineService.Instance);
            builder.Services.AddSingleton(sp => engineService);
            builder.Services.AddSingleton(sp => credentialsService);
            builder.Services.AddSingleton(sp => new BackupService());
            builder.Services.AddSingleton(sp => new RoutingService());
            builder.Services.AddSingleton(typeof(IStorageAPI), engineService.Instance.Storage);

            builder.Services.AddScoped(typeof(DialogService));
            builder.Services.AddScoped(typeof(TransactionsService));
            builder.Services.AddScoped(typeof(PropertyProviderService));
            builder.Services.AddScoped(typeof(PropertyContainerService));
            builder.Services.AddScoped(typeof(EntityService));
            builder.Services.AddScoped(typeof(ConditionsService));
            builder.Services.AddBlazoredModal();

            await builder.Build().RunAsync();
        }
Пример #13
0
        public void WhenNoSuggestedUserNameProvided_ThenSuggestionIsDerivedFromSigninName()
        {
            var serviceRegistry = new ServiceRegistry();

            var auth = new Mock <IAuthorization>();

            auth.SetupGet(a => a.Email).Returns("*****@*****.**");

            serviceRegistry.AddMock <IAuthorizationAdapter>()
            .SetupGet(a => a.Authorization).Returns(auth.Object);

            var credDialog = serviceRegistry.AddMock <IGenerateCredentialsDialog>();

            credDialog
            .Setup(d => d.PromptForUsername(
                       It.IsAny <IWin32Window>(),
                       It.IsAny <string>()))
            .Returns <string>(null);    // Cancel dialog


            var settings = InstanceConnectionSettings.CreateNew(SampleInstance);

            var credentialsService = new CredentialsService(serviceRegistry);

            AssertEx.ThrowsAggregateException <TaskCanceledException>(
                () => credentialsService.GenerateCredentialsAsync(
                    null,
                    SampleInstance,
                    settings,
                    false).Wait());

            credDialog.Verify(d => d.PromptForUsername(
                                  It.IsAny <IWin32Window>(),
                                  It.Is <string>(u => u == "bobsemail")), Times.Once);
        }
Пример #14
0
        async void loadCourses(string lpid)
        {
            openPopup();
            LP.Children.Clear();
            CredentialsService credentials = new CredentialsService();
            var current = Connectivity.NetworkAccess;

            if (current == NetworkAccess.Internet)
            {
                lp = await Courses.GetLearningPath(credentials.HomeDomain, credentials.UserID, lpid);

                if (lp != null)
                {
                    bool x = await buildLPDetails(lp.StudentActivityMap, lpid);
                }
            }
            else
            {
                Courses           l  = new Courses();
                Models.LPDBRecord lp = await l.GetActivityMap(lpid);

                if (lp != null && lp.LPMap != null && lp.LPMap != "")
                {
                    JsonSerializerSettings ser = new JsonSerializerSettings();
                    ser.DefaultValueHandling = DefaultValueHandling.Populate;
                    StudentActivityMap lpMap = JsonConvert.DeserializeObject <StudentActivityMap>(lp.LPMap, ser);
                    bool x = await buildLPDetails(lpMap, lpid);
                }
            }

            closePopup();
        }
Пример #15
0
        public void WhenSuggestedUserNameProvided_ThenSuggestionIsUsed()
        {
            var serviceRegistry = new ServiceRegistry();
            var credDialog      = serviceRegistry.AddMock <IGenerateCredentialsDialog>();

            credDialog
            .Setup(d => d.PromptForUsername(
                       It.IsAny <IWin32Window>(),
                       It.IsAny <string>()))
            .Returns <string>(null);    // Cancel dialog

            var settings = InstanceConnectionSettings.CreateNew(SampleInstance);

            settings.RdpUsername.Value = "alice";

            var credentialsService = new CredentialsService(serviceRegistry);

            AssertEx.ThrowsAggregateException <TaskCanceledException>(
                () => credentialsService.GenerateCredentialsAsync(
                    null,
                    SampleInstance,
                    settings,
                    false).Wait());

            credDialog.Verify(d => d.PromptForUsername(
                                  It.IsAny <IWin32Window>(),
                                  It.Is <string>(u => u == "alice")), Times.Once);
        }
 /// <summary>
 /// find current user that is logged in the application and get his email in order to fill the edit
 /// form with his old email
 /// </summary>
 private void PopulateEmailInput()
 {
     _credentialsService = new CredentialsService();
     _credentials        = _credentialsService.FindById(SessionData.UserSessionData.CurrentUserId);
     if (_credentials != null)
     {
         textBoxUserEmail.Text = _credentials.Email;
     }
 }
Пример #17
0
        public void Smoke()
        {
            // arrange
            var repository = new Mock <ICredentialsRepository>();
            var service    = new CredentialsService(repository.Object);

            // act/assert
            Assert.That(service, Is.Not.Null);
        }
Пример #18
0
        public static async Task RefreshEbooksAsync()
        {
            await _ebooksAsyncLock.WaitAsync();

            try
            {
                var credentials = CredentialsService.GetProviderCredentials();

                foreach (var credential in credentials)
                {
                    var provider = EbookProviderService.GetProvider(credential);

                    Ebook[] ebooks;

                    try
                    {
                        ebooks = await provider.GetEbooksAsync();
                    }
                    catch
                    {
                        await provider.AuthenticateAsync(credential);

                        ebooks = await provider.GetEbooksAsync();
                    }

                    await EbookStorage.SaveEbooksAsync(ebooks);

                    await UIThread.RunAsync(() =>
                    {
                        // TODO: Support for multiple providers of the same books
                        // remove
                        {
                            var oldEbooks = Ebooks.Where(eb => !ebooks.Select(ebb => ebb.Isbn).Contains(eb.Isbn)).ToArray();
                            foreach (var oldEbook in oldEbooks)
                            {
                                Ebooks.Remove(oldEbook);
                            }
                        }

                        // Add
                        foreach (var ebook in ebooks)
                        {
                            var existing = Ebooks.FirstOrDefault(eb => eb.Isbn == ebook.Isbn);

                            if (existing == null)
                            {
                                Ebooks.Add(ebook);
                            }
                        }
                    });
                }
            }
            finally
            {
                _ebooksAsyncLock.Release();
            }
        }
Пример #19
0
        public void NavigateAsync(int id)
        {
            Page newPage;

            if (!Pages.ContainsKey(id))
            {
                switch (id)
                {
                case (int)MenuType.TraineeProfile:
                    Pages.Add(id, new HanselmanNavigationPage(new Views.TraineeProfilePage(this)));
                    break;

                case (int)MenuType.TrainerProfile:
                    Pages.Add(id, new HanselmanNavigationPage(new Views.TrainerProfilePage()));
                    break;

                case (int)MenuType.CoachList:
                    Pages.Add(id, new HanselmanNavigationPage(new Views.CoachListPage()));
                    break;

                case (int)MenuType.Contact:
                    Pages.Add(id, new HanselmanNavigationPage(new Views.ScheduleList()));
                    break;


                case (int)MenuType.Logout:
                    App.LoginResponse  = new Models.LoginResponse.Member();
                    App.TrainerData    = new Models.LoginResponse.Member();
                    App.FacebookUser   = null;
                    App.InstagramUser  = null;
                    App.InstagramMedia = null;
                    //App.FacebookProfile = new Models.FacebookProfile();
                    App.SelectedView = null;
                    App.access_code  = null;
                    CredentialsService.DeleteCredentials();

                    Application.Current.MainPage = new NavigationPage(new Views.SelectionPage());

                    //await this.Navigation.PushAsync(new NavigationPage(new LoginPage(selectedView)));
                    return;
                }
            }

            newPage = Pages[id];
            if (newPage == null)
            {
                return;
            }



            Detail           = newPage;
            this.IsPresented = false;
        }
Пример #20
0
        /// <summary>Handle prompting for this data source. This method is written using the
        /// yield return construct to be able to handle asynchronous prompting. After the first yeild
        /// return one can assume that the prompting has been successfully performed.
        /// </summary>
        /// <returns>The prompt models.</returns>
        private IEnumerable <object> Prompt(CredentialsService credentialsService)
        {
            LmiDataSourcePromptModel promptModel = createPromptModel();

            // Return the prompt model to the prompting framework.
            yield return(promptModel);

            String[] credentials = { promptModel.Host, promptModel.UserName, promptModel.UserPass };
            credentialsService.SetCredentials <String[]>("LMI::DEFAULT", credentials);
            // When we get to this point we know that the prompting has been performed, so we assign
            // the properties to the model.
            updateFromPromptReturn(promptModel);
        }
Пример #21
0
        static void Main()
        {
            var x = new CredentialsService();
            var serviceClientCredentials = x.GetCredentials().Result;
            var client             = new KeyVaultClient(serviceClientCredentials);
            var key                = client.CreateKeyAsync("https://kv-???????.vault.azure.net/", "testkey1", JsonWebKeyType.Rsa).Result;
            var csr                = GetCSR(key.Key);
            var keyOperationResult = client.SignAsync("testkey1", "RS256", csr.GetDataToSign()).Result;

            csr.SignRequest(keyOperationResult.Result);

            Console.Out.WriteLine("done");
            Console.In.ReadLine();
        }
Пример #22
0
        public void NotifyUserOnRegistration_Integration_EmailSent()
        {
            using (var fixture = new FixtureInit("http://localhost"))
            {
                // assert
                var credentialsRepository = new CredentialsRepository(fixture.Setup.Context);
                var credentialService     = new CredentialsService(credentialsRepository);
                var emailService          = new EmailService(credentialService);
                var notificationService   = new NotificationService(emailService);

                // act / assert
                notificationService.NotifyUserOnRegistration("*****@*****.**", "password");
            }
        }
Пример #23
0
        private void AddServices(IServiceCollection services)
        {
            var cityRepository = new CitySqlRepository(GetContextFactory());
            var cityService    = new CityService(cityRepository);

            services.Add(new ServiceDescriptor(typeof(CityService), cityService));

            var countryRepository = new CountrySqlRepository(GetContextFactory());
            var countryService    = new CountryService(countryRepository);

            services.Add(new ServiceDescriptor(typeof(CountryService), countryService));

            var doctorRepositry = new DoctorSqlRepository(GetContextFactory());
            var doctorService   = new DoctorService(doctorRepositry);

            services.Add(new ServiceDescriptor(typeof(DoctorService), doctorService));

            var patientRepository        = new PatientSqlRepository(GetContextFactory());
            var patientAccountRepository = new PatientAccountSqlRepository(GetContextFactory());
            var registrationNotifier     = new RegistrationNotifier(
                "http://" +
                Environment.GetEnvironmentVariable("PSW_API_GATEWAY_HOST") +
                ":" +
                Environment.GetEnvironmentVariable("PSW_API_GATEWAY_PORT") +
                "/api/patient/activate/");

            var patientAccountService      = new PatientAccountService(patientAccountRepository);
            var patientRegistrationService = new PatientRegistrationService(patientAccountService, registrationNotifier);

            var patientService = new PatientService(patientRepository, patientAccountRepository);

            var specialtyRepository = new SpecialtySqlRepository(GetContextFactory());
            var specialtyService    = new SpecialtyService(specialtyRepository);

            // Auth
            var userAccountRepository = new UserAccountSqlRepository(GetContextFactory());
            var credentialService     = new CredentialsService(userAccountRepository, GetJwtSecretFromEnvironment());

            // Advertisement
            var advertisementRepository = new AdvertisementSqlRepository(GetContextFactory());
            var advertisementService    = new AdvertisementService(advertisementRepository);

            services.Add(new ServiceDescriptor(typeof(CredentialsService), credentialService));
            services.Add(new ServiceDescriptor(typeof(IPatientAccountService), patientAccountService));
            services.Add(new ServiceDescriptor(typeof(IPatientRegistrationService), patientRegistrationService));
            services.Add(new ServiceDescriptor(typeof(PatientService), patientService));
            services.Add(new ServiceDescriptor(typeof(SpecialtyService), specialtyService));
            services.Add(new ServiceDescriptor(typeof(AdvertisementService), advertisementService));
        }
 /// <summary>
 ///  Get user (identified by SessionData.UserSessionData.CurrentUserId) data from database using CredentialsService and PatientService 
 ///and display data on the page
 /// </summary>
 private void DisplayPatientInfo()
 {
     _credentialsService = new CredentialsService();
     Credentials credentials = _credentialsService.FindById(SessionData.UserSessionData.CurrentUserId);
     _patientService = new PatientService();
     Patient patient = _patientService.FindById(SessionData.UserSessionData.CurrentUserId);
     if (patient != null && credentials != null)
     {
         SetImages();
         labelPatientName.Content = patient.FirstName + " " + patient.LastName;
         labelPatientEmail.Content = credentials.Email;
         labelPatientPhone.Content = patient.PhoneNumber;
         labelPatientAddress.Content = patient.Address;
     }
 }
Пример #25
0
        protected override async void OnStartup(StartupEventArgs e)
        {
            // Create app services
            IApplicationSettings appSettings        = new ApplicationSettings();
            ILogService          logService         = new DebugLogService();
            ICredentialsService  credentialsService = new CredentialsService();

            IZoomService zoomService = new ZoomService(logService);

            // Create and show MainWindow
            var mainWindow    = new MainWindow();
            var mainViewModel = new MainViewModel(zoomService, credentialsService);

            mainWindow.DataContext = mainViewModel;
            mainWindow.ShowDialog();
        }
Пример #26
0
        public AccountController(
            IIdentityServerInteractionService interaction,
            IClientStore clientStore,
            IAuthenticationSchemeProvider schemeProvider,
            IEventService events,
            CredentialsService credentialsService,
            UserQueries userQueries)
        {
            _interaction    = interaction;
            _clientStore    = clientStore;
            _schemeProvider = schemeProvider;
            _events         = events;

            this.credentialsService = credentialsService;
            this.userQueries        = userQueries;
        }
        /// <summary>
        ///  Get user (identified by SessionData.UserSessionData.CurrentUserId) data from database using CredentialsService and PatientService
        ///and display data on the page
        /// </summary>
        private void DisplayPatientInfo()
        {
            _credentialsService = new CredentialsService();
            Credentials credentials = _credentialsService.FindById(SessionData.UserSessionData.CurrentUserId);

            _patientService = new PatientService();
            Patient patient = _patientService.FindById(SessionData.UserSessionData.CurrentUserId);

            if (patient != null && credentials != null)
            {
                SetImages();
                labelPatientName.Content    = patient.FirstName + " " + patient.LastName;
                labelPatientEmail.Content   = credentials.Email;
                labelPatientPhone.Content   = patient.PhoneNumber;
                labelPatientAddress.Content = patient.Address;
            }
        }
        /// <summary>
        ///Handler for helpButton click event,
        ///open help according to current user type
        /// </summary>
        private void helpButton_Click(object sender, RoutedEventArgs e)
        {
            int id = SessionData.UserSessionData.CurrentUserId;

            _credentialsService = new CredentialsService();
            Credentials c = _credentialsService.FindById(id);

            if (c != null)
            {
                switch (c.Type)
                {
                case Utils.UserTypes.ADMIN: System.Diagnostics.Process.Start(System.IO.Path.GetDirectoryName(System.IO.Path.GetDirectoryName(System.IO.Directory.GetCurrentDirectory())) + "\\Resources\\helps\\AdminHelp.chm"); break;

                case Utils.UserTypes.PATIENT: System.Diagnostics.Process.Start(System.IO.Path.GetDirectoryName(System.IO.Path.GetDirectoryName(System.IO.Directory.GetCurrentDirectory())) + "\\Resources\\helps\\PatientHelp.chm"); break;

                case Utils.UserTypes.DOCTOR: System.Diagnostics.Process.Start(System.IO.Path.GetDirectoryName(System.IO.Path.GetDirectoryName(System.IO.Directory.GetCurrentDirectory())) + "\\Resources\\helps\\DoctorHelp.chm"); break;
                }
            }
        }
Пример #29
0
        async void HandleAction(Models.FacebookUser arg1, string arg2)
        {
            try
            {
                App.FacebookUser = arg1;
                App.access_code  = arg1.Token;

                var loginRequestModel = new Models.LoginRequestModel("App", arg1.Email, App.SelectedView, "fb@trainme");
                var message           = await App.TodoManager.Login(loginRequestModel);

                if (message == "Success")
                {
                    ViewModels.SignupViewModel signupViewModel = new ViewModels.SignupViewModel();
                    signupViewModel.EmailAddress = App.FacebookUser.Email;
                    signupViewModel.Password     = "******";
                    //signupViewModel.Name = arg1.FirstName + " " + arg1.LastName;
                    signupViewModel.UserIcon     = arg1.Picture;
                    signupViewModel.SelectedView = App.SelectedView;

                    var data = App.LoginResponse;

                    if (data.Profile == null || data.Profile == "")
                    {
                        await this.Navigation.PushAsync(new Views.UserInformationPage(signupViewModel));
                    }
                    else
                    {
                        var member = App.LoginResponse;
                        CredentialsService.SaveCredentials(App.FacebookUser.Email, "fb@trainme", member, App.FacebookUser, userType: App.SelectedView);
                        Application.Current.MainPage = new RootPage(App.SelectedView);
                    }
                }
                else
                {
                    await DisplayAlert("Alert", message, "Ok");
                }
            }
            catch (Exception ex)
            {
                await DisplayAlert("Alert", ex.Message, "Ok");
            }
        }
Пример #30
0
        public void GetCredentials_Returns_Null_If_Credentials_Not_Set()
        {
            // arrange
            var repository = new Mock <ICredentialsRepository>();
            var service    = new CredentialsService(repository.Object);

            var creds = new List <Credential> {
                new Credential {
                    Account = "support", Email = "*****@*****.**", Password = "******"
                }
            };

            repository.Setup(r => r.Credentials).Returns(creds.AsQueryable());

            // act
            var result = service.GetCredentialsForAccount("support-aaa");

            // assert
            Assert.That(result, Is.Null);
        }
Пример #31
0
        public static async Task DownloadEbookAsync(Ebook ebook)
        {
            var credential = CredentialsService.GetProviderCredential(ebook.Provider);

            var provider = EbookProviderService.GetProvider(credential);

            try
            {
                try
                {
                    await provider.DownloadEbookAsync(ebook);
                }
                catch
                {
                    await provider.AuthenticateAsync(credential);

                    await provider.DownloadEbookAsync(ebook);
                }
            }
            catch (EbookException e)
            {
                ContentDialog downloadErrorDialog = new ContentDialog()
                {
                    Title                = "Kunde inte ladda ner e-bok",
                    Content              = $"E-boken {ebook.Title} (publicerad av {ebook.Publisher}) kunde inte laddas ner. Skapa gärna ett nytt Issue på GitHub om felet inträffar flera gånger.",
                    CloseButtonText      = "Stäng",
                    PrimaryButtonText    = "Öppna GitHub",
                    PrimaryButtonCommand = new RelayCommand(async() =>
                    {
                        var uriBing = new Uri(@"https://github.com/mikaeldui/MinaLaromedel/issues");

                        await Windows.System.Launcher.LaunchUriAsync(uriBing);
                    })
                };

                SentrySdk.CaptureException(e);

                await UIThread.RunAsync(async() => await downloadErrorDialog.ShowAsync());
            }
        }
Пример #32
0
        async void loadLearningPaths()
        {
            openPopup();
            LP.Children.Clear();
            // show the spinner and turn it on
            LPProgress.IsVisible = true;
            LPProgress.IsRunning = true;
            CredentialsService credentials = new CredentialsService();
            var current = Connectivity.NetworkAccess;

            if (current == NetworkAccess.Internet)
            {
                lp = await Courses.GetLearningPaths(credentials.HomeDomain, credentials.UserID);

                var temp = lp.LearningPaths.OrderBy(o => o.title).ToList();
                buildLPS(temp);
            }
            else
            {
                buildLPSOffline();
            }
        }
Пример #33
0
        static void Main(string[] args)
        {
            Console.WriteLine("Trackyt.net - upgrade for v.1.0.1.\nNotify all users about password remove.\n");

            try
            {
                // repositories
                var usersRepository = new UsersRepository();
                var credentialsRepository = new CredentialsRepository();

                // services
                var credentialService = new CredentialsService(credentialsRepository);
                var emailService = new EmailService(credentialService);

                SendEmailNotificationsToUsers(usersRepository, emailService);
            }
            catch (Exception e)
            {
                Console.WriteLine("User notification failed!");
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
            }
        }
 public CreateAdminForm()
 {
     InitializeComponent();
     _credentialsService = new CredentialsService();
     _administratorService = new AdministratorService();
 }
 /// <summary>
 /// handler for buttonSignin click Event, 
 /// gets user input and check if is valid,
 /// if input is valid use CrentialsService and PatientService to insert a new patient, 
 /// otherwise set the errorLabel content and make it visible
 /// </summary>
 private void buttonSignin_Click(object sender, RoutedEventArgs e)
 {
     //create new user, if success redirect to login view
     _credentialsService = new CredentialsService();
     _patientService = new PatientService();
     _defaultDate = DateTime.Now;
     String patientFirstName = textBoxUserFirstName.Text;
     String patientLastName = textBoxUserLastName.Text;
     String patientAddress = textBoxUserAddress.Text;
     String patientPhone = textBoxUserPhone.Text;
     String patientGeneticDisorder = textBoxUserGeneticDisorder.Text;
     String patientInsuranceNumber = textBoxUserInsuranceNr.Text;
     String patientEmail = textBoxUserEmail.Text;
     String patientPassword = (!(passwordBoxUserPassword.Password != null && String.IsNullOrEmpty(passwordBoxUserPassword.Password))) ? Encrypter.GetMD5(passwordBoxUserPassword.Password) : "";
     DateTime patientBirthdate;
     if (datePickerUserBirthdate.SelectedDate != null)
     {
         patientBirthdate = datePickerUserBirthdate.SelectedDate.Value;
     }
     else
     {
         patientBirthdate = _defaultDate;
     }
     int patientId = 0;
     if (ValidateUserInput(patientFirstName, patientLastName, patientAddress, patientPhone, patientEmail, patientPassword
         , patientBirthdate))
     {
         try
         {
             patientId = _credentialsService.Save(new Credentials(patientEmail, patientPassword, Utils.UserTypes.PATIENT));
         }
         catch (Exception ee)
         {
             MessageBox.Show("Something went wrong ! \n" + ee.Data.ToString());
         }
         if (patientId != 0)
         {
             try
             {
                 _patientService.Save(new Patient(patientId, patientLastName, patientFirstName, patientInsuranceNumber, patientAddress, patientBirthdate, patientGeneticDisorder, patientPhone));
                 MessageBox.Show("Account created!");
                 RaiseChangePageContentEvent(new LoginContent());
             }
             catch (Exception ee)
             {
                 MessageBox.Show("Something went wrong ! \n" + ee.Data.ToString());
                 try
                 {
                     _credentialsService.Delete(patientId);
                 }
                 catch (Exception eee)
                 {
                     MessageBox.Show("Something went wrong trying to fix errors ! \n" + eee.Data.ToString());
                 }
             }
         }
     }
     else
     {
         labelError.Visibility = Visibility.Visible;
         labelError.Content = _errorMessage;
     }
 }
 /// <summary>
 /// find current user that is logged in the application and get his email in order to fill the edit
 /// form with his old email
 /// </summary>
 private void PopulateEmailInput()
 {
     _credentialsService = new CredentialsService();
     _credentials = _credentialsService.FindById(SessionData.UserSessionData.CurrentUserId);
     if (_credentials != null)
     {
         textBoxUserEmail.Text = _credentials.Email;
     }
 }
Пример #37
0
        /// <summary>
        /// opens a connection to the database and initializes necessary services
        /// </summary>
        private void OpenConnection()
        {
            try
            {
                DBConnection.CreateConnection("localhost", "xe", "hr", "hr");
            }
            catch (Exception)
            {
                try
                {
                    DBConnection.CreateConnection("localhost", "ORCL", "hr", "roxana");
                }
                catch (Exception e)
                {
                    throw e;
                }
            }

            credentialsService = new CredentialsService();
            administratorService = new AdministratorService();
            patientService = new PatientService();
            doctorService = new DoctorService();
            departmentService = new DepartmentService();
            appointmentService = new AppointmentService();
            resultService = new ResultsService();
            scheduleService = new ScheduleService();
        }