Ejemplo n.º 1
0
        /// <summary>
        /// Start the service
        /// </summary>
        public bool Start()
        {
            this.Starting?.Invoke(this, EventArgs.Empty);

            // Get configuration
            this.m_configuration      = ApplicationContext.Current.Configuration.GetSection <SynchronizationConfigurationSection>();
            this.m_threadPool         = ApplicationContext.Current.GetService <IThreadPoolService>();
            this.m_integrationService = ApplicationContext.Current.GetService <IClinicalIntegrationService>();
            this.m_networkInfoService = ApplicationContext.Current.GetService <INetworkInformationService>();

            this.m_networkInfoService.NetworkStatusChanged += (o, e) => this.Pull(SynchronizationPullTriggerType.OnNetworkChange);

            this.m_tracer.TraceInfo("Performing OnStart trigger pull...");
            this.Pull(SynchronizationPullTriggerType.OnStart);

            // Polling
            if (this.m_configuration.SynchronizationResources.Any(o => (o.Triggers & SynchronizationPullTriggerType.PeriodicPoll) != 0) &&
                this.m_configuration.PollInterval != default(TimeSpan))
            {
                Action <Object> pollFn = null;
                pollFn = _ =>
                {
                    this.Pull(SynchronizationPullTriggerType.PeriodicPoll);
                    ApplicationContext.Current.GetService <IThreadPoolService>().QueueUserWorkItem(this.m_configuration.PollInterval, pollFn, null);
                };
                ApplicationContext.Current.GetService <IThreadPoolService>().QueueUserWorkItem(this.m_configuration.PollInterval, pollFn, null);
            }
            this.Started?.Invoke(this, EventArgs.Empty);

            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MainViewModel"/> class.
        /// </summary>
        /// <param name="navigationService">
        /// The navigation service.
        /// </param>
        /// <param name="authenticationSessionService">
        /// The authentication session  service.
        /// </param>
        /// <param name="messageBox">
        /// The message box.
        /// </param>
        /// <param name="networkInformationService">
        /// The network connection.
        /// </param>
        /// <param name="logManager">
        /// The log manager.
        /// </param>
        /// 

        public MainViewModel(INavigationService navigationService,
            IAuthenticationSessionService authenticationSessionService,
            INetworkInformationService networkInformationService,
            IMessageBoxService messageBox, 
            ILogManager logManager)
        {
            _navigationService = navigationService;
            _authenticationSessionService = authenticationSessionService;
            _messageBox = messageBox;
            _networkInformationService = networkInformationService;
            _logManager = logManager;
            LoginCommand = new RelayCommand<string>(LoginAction);
        }
Ejemplo n.º 3
0
        public LogInViewModel(INavigationService navigationService, ISessionService sessionService,
                              IMessageBoxService messageBoxService, INetworkInformationService networkInformationService,
                              IApplicationDataService applicationSettings)
        {
            this.navigationService         = navigationService;
            this.sessionService            = sessionService;
            this.messageBoxService         = messageBoxService;
            this.networkInformationService = networkInformationService;
            this.applicationSettings       = applicationSettings;

            LogInCommand = new DelegateCommand <string>(LogInCommandExec);
#if WINDOWS_APP
            GoBackCommand = new DelegateCommand(GoBackCommandExec);
#endif
        }
        /// <summary> 
        /// Initializes a new instance of the <see cref="LoginViewModel"/> class. 
        /// </summary> 
        /// <param name="navigationService"> 
        /// The navigation service. 
        /// </param> 
        /// <param name="sessionService"> 
        /// The session service. 
        /// </param> 
        /// <param name="messageBox"> 
        /// The message box. 
        /// </param> 
        /// <param name="networkInformationService"> 
        /// The network connection. 
        /// </param> 
        /// <param name="logManager"> 
        /// The log manager. 
        /// </param> 
        public LoginViewModel(INavigationService navigationService,
            ISessionService sessionService,
            IMessageBoxService messageBox,
            INetworkInformationService networkInformationService,
            ILogManager logManager)
        {
            _navigationService = navigationService;
            _sessionService = sessionService;
            _messageBox = messageBox;
            _networkInformationService = networkInformationService;

            _logManager = logManager;
            LoginCommand = new RelayCommand<string>(LoginAction);
            SignUpCommad = new RelayCommand(SignUpAction);    
        }
 /// <summary>
 /// DI constructor
 /// </summary>
 public SystemPolicySynchronizationJob(INetworkInformationService networkInformationService,
                                       ITickleService tickleService,
                                       IAdministrationIntegrationService amiIntegrationService,
                                       IOfflinePolicyInformationService offlinePip,
                                       IOfflineRoleProviderService offlineRps,
                                       ISecurityRepositoryService securityRepository,
                                       IJobStateManagerService jobStateManager,
                                       IDataPersistenceService <SecurityChallenge> securityChallengeService = null)
 {
     this.m_networkInformationService = networkInformationService;
     this.m_offlinePip            = offlinePip;
     this.m_offlineRps            = offlineRps;
     this.m_securityRepository    = securityRepository;
     this.m_jobStateManager       = jobStateManager;
     this.m_securityChallenge     = securityChallengeService;
     this.m_amiIntegrationService = amiIntegrationService;
     this.m_tickleService         = tickleService;
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Updates the registered services in the application context when the network status changes.
        /// </summary>
        /// <param name="sender">The sender of the event.</param>
        /// <param name="e">The event arguments.</param>
        private void NetworkInformationService_NetworkStatusChanged(object sender, EventArgs e)
        {
            INetworkInformationService networkInformationService = (INetworkInformationService)sender;

            //         // Because we may have network connectivity
            //if (networkInformationService.IsNetworkAvailable)
            //{
            //	ApplicationContext.Current.Configuration.GetSection<ApplicationConfigurationSection>().ServiceTypes.RemoveAll(o => o == typeof(LocalPolicyInformationService).AssemblyQualifiedName);
            //	ApplicationContext.Current.Configuration.GetSection<ApplicationConfigurationSection>().ServiceTypes.Add(typeof(AmiPolicyInformationService).AssemblyQualifiedName);
            //	ApplicationContext.Current.Configuration.GetSection<ApplicationConfigurationSection>().ServiceTypes.Add(typeof(OAuthIdentityProvider).AssemblyQualifiedName);
            //	ApplicationContext.Current.Configuration.GetSection<ApplicationConfigurationSection>().ServiceTypes.Add(typeof(ImsiPersistenceService).AssemblyQualifiedName);
            //}
            //else
            //{
            //	ApplicationContext.Current.Configuration.GetSection<ApplicationConfigurationSection>().ServiceTypes.Add(typeof(LocalPersistenceService).AssemblyQualifiedName);
            //	ApplicationContext.Current.Configuration.GetSection<ApplicationConfigurationSection>().ServiceTypes.Add(typeof(LocalIdentityService).AssemblyQualifiedName);
            //}
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Start the service
        /// </summary>
        public bool Start()
        {
            this.Starting?.Invoke(this, EventArgs.Empty);

            // Get configuration
            this.m_configuration      = ApplicationContext.Current.Configuration.GetSection <SynchronizationConfigurationSection>();
            this.m_threadPool         = ApplicationContext.Current.GetService <IThreadPoolService>();
            this.m_integrationService = ApplicationContext.Current.GetService <IClinicalIntegrationService>();
            this.m_networkInfoService = ApplicationContext.Current.GetService <INetworkInformationService>();

            this.m_networkInfoService.NetworkStatusChanged += (o, e) => this.Pull(SynchronizationPullTriggerType.OnNetworkChange);

            // Notification for tickles when the pull is completed
            this.PullCompleted += (o, e) =>
            {
                if (e.Type == null) // general pull complete
                {
                    ApplicationContext.Current.SetProgress(Strings.locale_idle, 1.0f);
                    var tickleService = ApplicationContext.Current.GetService <ITickleService>();
                    if (e.IsInitial)
                    {
                        tickleService.SendTickle(
                            new Tickler.Tickle(Guid.Empty, Tickler.TickleType.Task | Tickler.TickleType.Toast, Strings.locale_sync_initial, DateTime.Now.Add(this.m_configuration.PollInterval))
                            );
                    }
                    else
                    {
                        tickleService.SendTickle(
                            new Tickler.Tickle(Guid.Empty, Tickler.TickleType.Task | Tickler.TickleType.Toast, Strings.locale_sync_complete, DateTime.Now.Add(this.m_configuration.PollInterval))
                            );
                    }
                }
            };

            ApplicationServiceContext.Current.Started += (xo, xe) =>
            {
                try
                {
                    this.m_tracer.TraceInfo("Performing OnStart trigger pull...");
                    this.Pull(SynchronizationPullTriggerType.OnStart);

                    // Polling
                    if (this.m_configuration.SynchronizationResources.Any(o => (o.Triggers & SynchronizationPullTriggerType.PeriodicPoll) != 0) &&
                        this.m_configuration.PollInterval != default(TimeSpan))
                    {
                        var jms  = ApplicationServiceContext.Current.GetService <IJobManagerService>();
                        var jsms = ApplicationServiceContext.Current.GetService <IJobStateManagerService>();
                        var job  = new RemoteSynchronizationJob(this, jsms);
                        jms.AddJob(job, JobStartType.DelayStart);
                        jms.SetJobSchedule(job, this.m_configuration.PollInterval);
                    }
                }
                catch (Exception)
                {
                    this.m_tracer.TraceError("Error starting remote sync service: {0}");
                }
            };

            this.Started?.Invoke(this, EventArgs.Empty);

            return(true);
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LogManager"/> class.
 /// </summary>
 /// <param name="networkInformationService">The network information service.</param>
 public LogManager(INetworkInformationService networkInformationService)
 {
     _networkInformationService = networkInformationService;
 }