/// <summary>
        /// Initializes a new instance of the <see cref="MobileDevicesEditor"/> class.
        /// </summary>
        /// <param name="synchronizationService">The synchronization service to be used
        /// for manipulating devices at the tracking service.</param>
        /// <param name="resourceProvider">The instance of resource provider for obtaining
        /// messages.</param>
        /// <param name="workingStatusController">The instance of the controller to be used
        /// for managing application status.</param>
        /// <param name="exceptionHandler">The exception handler for tracking service
        /// related errors.</param>
        /// <exception cref="ArgumentNullException"><paramref name="synchronizationService"/>,
        /// <paramref name="resourceProvider"/>, <paramref name="workingStatusController"/>,
        /// <paramref name="exceptionHandler"/> or <paramref name="project"/> is a null
        /// reference.</exception>
        public MobileDevicesEditor(
            ISynchronizationService synchronizationService,
            IWorkingStatusController workingStatusController,
            IExceptionHandler exceptionHandler,
            IProject project)
        {
            if (synchronizationService == null)
            {
                throw new ArgumentNullException("synchronizationService");
            }

            if (workingStatusController == null)
            {
                throw new ArgumentNullException("workingStatusController");
            }

            if (exceptionHandler == null)
            {
                throw new ArgumentNullException("exceptionHandler");
            }

            if (project == null)
            {
                throw new ArgumentNullException("project");
            }

            _synchronizationService = synchronizationService;
            _workingStatusController = workingStatusController;
            _exceptionHandler = exceptionHandler;
            _project = project;
        }
        public SynchronizationPageViewModel(ISynchronizationService synchronizationService, IChannelService channelService)
        {
            _synchronizationService = synchronizationService;
            _channelService         = channelService;

            _synchronizationService.ProgressChanged += _synchronizationService_ProgressChanged;
        }
Пример #3
0
        /// <summary>
        /// Ctor.
        /// </summary>
        public LoginControlViewModel(IDialogService dialogService, ITokenService tokenService,
                                     ISynchronizationService synchronizationService, IUserCredentials userCredentials, ILogger logger)
        {
            System.Threading.ThreadPool.QueueUserWorkItem((x) =>
            {
                try
                {
                    DevicesList = NFCWMQService.GetConnectedDevices();
                }
                catch (Exception)
                {
                }
            });
            _dialogService          = dialogService;
            _tokenService           = tokenService;
            _synchronizationService = synchronizationService;
            _userCredentials        = userCredentials;
            _logger = logger;

            Title = "NFCRing - Fence";

            AddCommand                     = new RelayCommand(Add, () => AllowAdd);
            RemoveCommand                  = new RelayCommand <RingItemViewModel>(Remove);
            SelectImageCommand             = new RelayCommand <string>(SelectImage);
            SaveNameCommand                = new RelayCommand <object>(SaveName, x => !string.IsNullOrEmpty(Items.FirstOrDefault(y => Equals(x, y.Token))?.Name));
            CancelEditNameCommand          = new RelayCallbackCommand <object>(CancelEditName);
            RefreshConnectedDevicesCommand = new RelayCallbackCommand <object>(RefreshConnectedDevices);
            AboutCommand                   = new RelayCommand(AboutCommandMethod);
            PropertyChanged               += OnPropertyChanged;
        }
Пример #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MobileDevicesEditor"/> class.
        /// </summary>
        /// <param name="synchronizationService">The synchronization service to be used
        /// for manipulating devices at the tracking service.</param>
        /// <param name="resourceProvider">The instance of resource provider for obtaining
        /// messages.</param>
        /// <param name="workingStatusController">The instance of the controller to be used
        /// for managing application status.</param>
        /// <param name="exceptionHandler">The exception handler for tracking service
        /// related errors.</param>
        /// <exception cref="ArgumentNullException"><paramref name="synchronizationService"/>,
        /// <paramref name="resourceProvider"/>, <paramref name="workingStatusController"/>,
        /// <paramref name="exceptionHandler"/> or <paramref name="project"/> is a null
        /// reference.</exception>
        public MobileDevicesEditor(
            ISynchronizationService synchronizationService,
            IWorkingStatusController workingStatusController,
            IExceptionHandler exceptionHandler,
            IProject project)
        {
            if (synchronizationService == null)
            {
                throw new ArgumentNullException("synchronizationService");
            }

            if (workingStatusController == null)
            {
                throw new ArgumentNullException("workingStatusController");
            }

            if (exceptionHandler == null)
            {
                throw new ArgumentNullException("exceptionHandler");
            }

            if (project == null)
            {
                throw new ArgumentNullException("project");
            }

            _synchronizationService  = synchronizationService;
            _workingStatusController = workingStatusController;
            _exceptionHandler        = exceptionHandler;
            _project = project;
        }
        public TaskCollectionsViewModel(
            INavigationService navigationService,
            IRtmServiceClient rtmServiceClient,
            ITaskStoreLocator taskStoreLocator,
            IListStoreLocator listStoreLocator,
            ILocationStoreLocator locationStoreLocator,
            ISynchronizationService synchronizationService)
            : base(navigationService)
        {
            this._rtmServiceClient = rtmServiceClient;
            this._taskStoreLocator = taskStoreLocator;
            this._listStoreLocator = listStoreLocator;
            this._locationStoreLocator = locationStoreLocator;
            this._synchronizationService = synchronizationService;

            this.submitErrorInteractionRequest = new InteractionRequest<Notification>();
            this.submitNotificationInteractionRequest = new InteractionRequest<Notification>();

            this.StartSyncCommand = new DelegateCommand(
                () => { this.StartSync(); },
                () => !this.IsSyncing && !this.SettingAreNotConfigured);

            this.ViewTaskCollectionCommand = new DelegateCommand(
                () => { this.NavigationService.Navigate(new Uri("/Views/TaskCollectionView.xaml", UriKind.Relative)); },
                () => !this.IsSyncing);

            this.AppSettingsCommand = new DelegateCommand(
                () => { this.NavigationService.Navigate(new Uri("/Views/AppSettingsView.xaml", UriKind.Relative)); },
                () => !this.IsSyncing);

            this.IsBeingActivated();
        }
Пример #6
0
 public RunInstanceCreator(
     IRepositoryFactory repositoryFactory,
     IAuditEventRepository auditEventRepository,
     IAutoBookInputHandler autoBookInputHandler,
     IAutoBookOutputHandler autoBookOutputHandler,
     RunCompletionNotifier runCompletionNotifier,
     ScenarioSnapshotGenerator scenarioSnapshotGenerator,
     ISynchronizationService synchronizationService,
     IPipelineAuditEventRepository pipelineAuditEventRepository,
     IBRSIndicatorManager brsIndicatorManager,
     ILandmarkRunService landmarkRunService,
     IAutoBooks autoBooks,
     IConfiguration configuration)
 {
     _repositoryFactory            = repositoryFactory;
     _auditEventRepository         = auditEventRepository;
     _autoBookInputHandler         = autoBookInputHandler;
     _autoBookOutputHandler        = autoBookOutputHandler;
     _runCompletionNotifier        = runCompletionNotifier;
     _scenarioSnapshotGenerator    = scenarioSnapshotGenerator;
     _synchronizationService       = synchronizationService;
     _pipelineAuditEventRepository = pipelineAuditEventRepository;
     _brsIndicatorManager          = brsIndicatorManager;
     _landmarkRunService           = landmarkRunService;
     _autoBooks     = autoBooks;
     _configuration = configuration;
 }
Пример #7
0
 public static bool TryCapture(
     this ISynchronizationService synchronizationService,
     int synchronizationServiceId,
     Guid ownerId,
     out SynchronizationToken token)
 {
     return(synchronizationService.TryCapture(synchronizationServiceId, ownerId.ToString("D").ToLowerInvariant(), out token));
 }
Пример #8
0
        public WindowsServiceBus(ILog logger, ISynchronizationService syncService, IServiceBusConnectionStringProvider connectionStringProvider)
        {
            _logger      = logger;
            _syncService = syncService;
            _connectionStringProvider = connectionStringProvider;

            SubscriberClients = new Dictionary <Type, SubscriptionClient>();
        }
        public SynchronizationViewModel(IFileSystemTextManipulator manipulator, UserDto user, Action synchronizationFinished)
        {
            _service = manipulator.GenerateSynchronizationService(
                user, new SynchronizationCallbacks(synchronizationFinished, SynchronizationProgrssChanged)); ;
            _dlg = new SynchronizationDialog(this);
            _dlg.Hide();

            InitSynchronizationTimer();
        }
Пример #10
0
 public InspireDatasetService(RegisterDbContext dbContext)
 {
     _dbContext              = dbContext;
     _registerService        = new RegisterService(_dbContext);
     _registerItemService    = new RegisterItemService(_dbContext);
     _datasetDeliveryService = new DatasetDeliveryService(_dbContext);
     _metadataService        = new MetadataService(_dbContext);
     _synchronizationService = new SynchronizationService(_dbContext);
 }
Пример #11
0
 public SynchronizationModule(ISynchronizationService synchronizationService)
 {
     _synchronizationService = synchronizationService;
     Post["/synchronize"] = p =>
     {
         var syncRequest = this.Bind<SynchronizationRequest>();
         return Synchronize(syncRequest);
     };
 }
Пример #12
0
 public BuildOperationsService(IProjectService projectService,
                               ISynchronizationService synchronizationService,
                               BuilderContext context,
                               ProcessorProducer producer)
 {
     _projectService         = projectService;
     _synchronizationService = synchronizationService;
     _context  = context;
     _producer = producer;
 }
Пример #13
0
 public InviteModel(UserManager <ApplicationUser> userManager,
                    SignInManager <ApplicationUser> signInManager,
                    ISynchronizationService synchronizationService,
                    ILogger <InviteModel> logger)
 {
     _userManager            = userManager;
     _signInManager          = signInManager;
     _synchronizationService = synchronizationService;
     _logger = logger;
 }
Пример #14
0
 public ApiRootController(RegisterDbContext dbContext, ISearchService searchService, IRegisterService registerService, IRegisterItemService registerItemService, IInspireDatasetService inspireDatasetService, IInspireMonitoringService inspireMonitoringService, IAccessControlService accessControlService, ISynchronizationService synchronizationService, IStatusReportService statusReportService)
 {
     _registerItemService      = registerItemService;
     _inspireDatasetService    = inspireDatasetService;
     _searchService            = searchService;
     _registerService          = registerService;
     _inspireMonitoringService = inspireMonitoringService;
     _accessControlService     = accessControlService;
     _synchronizationService   = synchronizationService;
     _statusReportService      = statusReportService;
     db = dbContext;
 }
Пример #15
0
 public EventPublisherWorker(
     ISynchronizationService synchService,
     IEventRepository eventRepository,
     IServiceBus serviceBus,
     ILog logger)
 {
     _syncService     = synchService;
     _eventRepository = eventRepository;
     _serviceBus      = serviceBus;
     _logger          = logger;
     _eventTypes      = new Dictionary <string, Type>();
 }
Пример #16
0
        public static BudgetModel OpenExistingOnNewDevice(Guid deviceId, ISynchronizationService syncService, IBudgetStore budgetStore)
        {
            //var budgetId = events.Single(e => e.EntityType == "Budget" && e is EntityCreatedEvent).EntityID;
            BudgetModel model = new BudgetModel(deviceId, budgetStore, false);

            model.SetSynchronizationService(syncService);
            model.Sync();

            //model.Budget = (Budget)model.BudgetGenerator.GetAll().Single();
            //model.Budget.AttachToModel(model);
            return(model);
        }
Пример #17
0
 public HomeController(IDataOldService dataOldService,
                       ISynchronizationService synchronizationService,
                       IMapper mapper,
                       IDataService dataService,
                       IAlgorithmService algorithmService,
                       IChartService chartService)
 {
     _dataOldService         = dataOldService;
     _synchronizationService = synchronizationService;
     _mapper           = mapper;
     _dataService      = dataService;
     _algorithmService = algorithmService;
     _chartService     = chartService;
 }
Пример #18
0
 public ParticipationService(
     IInstantWinService instantWinService,
     IPrizeManager prizeManager,
     IParticipantManager participantManager,
     IParticipationManager participationManager,
     ICountryManager countryManager,
     ISynchronizationService crmService)
 {
     _instantWinService    = instantWinService;
     _participationManager = participationManager;
     _prizeManager         = prizeManager;
     _participantManager   = participantManager;
     _crmService           = crmService;
     _countryManager       = countryManager;
 }
Пример #19
0
        public MainViewModel(ISynchronizationService synchronizationService, LoginViewModel loginViewModel)
        {
            synchronizationService.Synchronize();
            ViewModelLocator = new ViewModelLocator();
            Logout           = new RelayCommand(ExecuteLogout);
            ToggleDarkMode   = new RelayCommand(ExecuteToggleDarkMode);

            CurrentUser       = null;
            DarkModeIsEnabled = false;

            LoginViewModel   = loginViewModel;
            CurrentViewModel = LoginViewModel;

            MessengerInstance.Register <UserLoginSuccess>(this, ExecuteLogin);
        }
Пример #20
0
        public TaskViewModel(Task taskItem, DelegateCommand viewTaskCommand,
            INavigationService navigationService, ISynchronizationService synchronizationService)
            : base(navigationService)
        {
            this.TaskItem = taskItem;

            this._synchronizationService = synchronizationService;

            this.MarkCompleteCommand = new DelegateCommand(MarkCompleteCommandDelegate);
            this.MarkPostponeCommand = new DelegateCommand(MarkPostponeCommandDelegate);
            this.ViewTaskCommand = viewTaskCommand;
            this.EditTaskCommand = new DelegateCommand(EditTaskCommandDelegate); ;

            this.IsBeingActivated();
        }
Пример #21
0
 public RemoteTaskService(IHardwareVaultService hardwareVaultService,
                          IHardwareVaultTaskService hardwareVaultTaskService,
                          IAccountService accountService,
                          IDataProtectionService dataProtectionService,
                          ILdapService ldapService,
                          IAppSettingsService appSettingsService,
                          ISynchronizationService synchronizationService)
 {
     _hardwareVaultService     = hardwareVaultService;
     _hardwareVaultTaskService = hardwareVaultTaskService;
     _accountService           = accountService;
     _dataProtectionService    = dataProtectionService;
     _ldapService            = ldapService;
     _appSettingsService     = appSettingsService;
     _synchronizationService = synchronizationService;
 }
Пример #22
0
        public App()
        {
            ISynchronizationService synchronizationService = DependencyService.Get <ISynchronizationService>();
            IDatabaseConnection     databaseConnection     = DependencyService.Get <IDatabaseConnection>();

            string path = DependencyService.Get <IFileHelper>().GetLocalFilePath("generic-example.db3");

            databaseConnection.Connection = new SQLiteConnection(path);
            databaseConnection.Version    = GlobalConstants.Version;

            synchronizationService.CreateTables();

            InitializeComponent();

            MainPage = new GenericPage();
        }
 public RegistersController(ITranslationService translationService,
                            RegisterDbContext dbContext, IRegisterItemService registerItemService, ISearchService searchService, IVersioningService versioningService,
                            IRegisterService registerService, IAccessControlService accessControlService, IInspireDatasetService inspireDatasetService, IGeodatalovDatasetService geodatalovService, IInspireMonitoringService inspireMonitoringService, ISynchronizationService synchronizationService, IStatusReportService statusReportService)
 {
     _db = dbContext;
     _registerItemService      = registerItemService;
     _searchService            = searchService;
     _versioningService        = versioningService;
     _registerService          = registerService;
     _accessControlService     = accessControlService;
     _translationService       = translationService;
     _inspireDatasetService    = inspireDatasetService;
     _geodatalovDatasetService = geodatalovService;
     _inspireMonitoringService = inspireMonitoringService;
     _synchronizationService   = synchronizationService;
     _statusReportService      = statusReportService;
 }
 public GroupTransactionExecutionService(
     IMessageInfoRepository eventInfoRepository,
     IGroupTransactionInfoRepository groupTransactionRepository,
     IIndex <IPayloadStorageProviderService> payloadStorageProviderResolver,
     IIndex <IHandlerDispatcher> handlerDispatcherResolver,
     IBigMessageService bigMessageService,
     IMessageInfoRepository messageInfoRepository,
     ISynchronizationService synchronizationService,
     ILoggerService logger)
 {
     _payloadStorageProviderResolver = payloadStorageProviderResolver;
     _eventInfoRepository            = eventInfoRepository;
     _groupTransactionRepository     = groupTransactionRepository;
     _handlerDispatcherResolver      = handlerDispatcherResolver;
     _bigMessageService      = bigMessageService;
     _synchronizationService = synchronizationService;
     _messageInfoRepository  = messageInfoRepository;
     _logger = logger;
 }
Пример #25
0
        /// <summary>
        /// Ctor.
        /// </summary>
        public LoginControlViewModel(IDialogService dialogService, ITokenService tokenService,
                                     ISynchronizationService synchronizationService, IUserCredentials userCredentials, ILogger logger)
        {
            _dialogService          = dialogService;
            _tokenService           = tokenService;
            _synchronizationService = synchronizationService;
            _userCredentials        = userCredentials;
            _logger = logger;

            Title = "NFCRing - Fence";

            AddCommand            = new RelayCommand(Add, () => AllowAdd);
            RemoveCommand         = new RelayCommand <RingItemViewModel>(Remove);
            SelectImageCommand    = new RelayCommand <string>(SelectImage);
            SaveNameCommand       = new RelayCommand <object>(SaveName, x => !string.IsNullOrEmpty(Items.FirstOrDefault(y => Equals(x, y.Token))?.Name));
            CancelEditNameCommand = new RelayCallbackCommand <object>(CancelEditName);

            PropertyChanged += OnPropertyChanged;
        }
Пример #26
0
        public TaskGroupViewModel(
            string groupName, int order, List<Task> tasks, DelegateCommand taskGroupCommand,
            INavigationService navigationService, ISynchronizationService synchronizationService)
            : base(navigationService)
        {
            this.Name = groupName;
            this.Order = order;
            this.Tasks = tasks;

            this.TaskGroupCommand = taskGroupCommand;

            this._synchronizationService = synchronizationService;

            this.ViewTaskCommand = new DelegateCommand(
                () => { this.NavigationService.Navigate(new Uri("/Views/TaskDetailsView.xaml", UriKind.Relative)); });

            Load();
            this.IsBeingActivated();
        }
Пример #27
0
 public AppHub(IRemoteDeviceConnectionsService remoteDeviceConnectionsService,
               IRemoteWorkstationConnectionsService remoteWorkstationConnectionsService,
               IWorkstationAuditService workstationAuditService,
               IWorkstationService workstationService,
               IHardwareVaultService hardwareVaultService,
               IEmployeeService employeeService,
               ILicenseService licenseService,
               IAppSettingsService appSettingsService,
               ISynchronizationService synchronizationService,
               ILogger <AppHub> logger)
 {
     _remoteDeviceConnectionsService      = remoteDeviceConnectionsService;
     _remoteWorkstationConnectionsService = remoteWorkstationConnectionsService;
     _workstationAuditService             = workstationAuditService;
     _workstationService     = workstationService;
     _hardwareVaultService   = hardwareVaultService;
     _employeeService        = employeeService;
     _licenseService         = licenseService;
     _appSettingsService     = appSettingsService;
     _synchronizationService = synchronizationService;
     _logger = logger;
 }
Пример #28
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Tracker"/> class.
        /// </summary>
        /// <param name="settings">Settings to be used by the tracker.</param>
        /// <param name="trackingService">The tracking service client to be used to communicate
        /// with the tracking server.</param>
        /// <param name="synchronizationService">The synchronization service to be used for
        /// synchronizing data in the project and at the tracking service.</param>
        /// <param name="solver">The VRP solver to be used by the tracker.</param>
        /// <param name="geocoder">The geocoder to be used by the tracker.</param>
        /// <param name="messageReporter">The message reporter to be used for reporting
        /// tracking errors.</param>
        /// <exception cref="ArgumentNullException"><paramref name="settings"/>,
        /// <paramref name="trackingService"/>, <paramref name="synchronizationService"/>,
        /// <paramref name="solver"/>, <paramref name="geocoder"/> or
        /// <paramref name="messageReporter"/> is a null reference.</exception>
        internal Tracker(
            TrackingSettings settings,
            ITrackingService trackingService,
            ISynchronizationService synchronizationService,
            IVrpSolver solver,
            IGeocoder geocoder,
            IMessageReporter messageReporter)
        {
            CodeContract.RequiresNotNull("settings", settings);
            CodeContract.RequiresNotNull("trackingService", trackingService);
            CodeContract.RequiresNotNull("synchronizationService", synchronizationService);
            CodeContract.RequiresNotNull("solver", solver);
            CodeContract.RequiresNotNull("geocoder", geocoder);
            CodeContract.RequiresNotNull("messageReporter", messageReporter);

            _settings               = settings;
            _trackingService        = trackingService;
            _synchronizationService = synchronizationService;

            _solver = solver;

            _geocoder        = geocoder;
            _messageReporter = messageReporter;
        }
 /// <summary>
 /// DI constructor for job
 /// </summary>
 public RemoteSynchronizationJob(ISynchronizationService synchronizationService, IJobStateManagerService stateManager)
 {
     this.m_synchronizationService = synchronizationService;
     this.m_stateManager           = stateManager;
 }
Пример #30
0
 public SynchronizeSaldeoCompaniesJob(ISynchronizationService synchronizationService, ILogger <SynchronizeSaldeoCompaniesJob> logger)
 {
     _synchronizationService = synchronizationService;
     _logger = logger;
 }
 public SyncController()
 {
     _service = new SynchronizationService(new ModelStateWrapper(ModelState));
     _context = new CurrentContext();
 }
 public SynchronizationController(ISynchronizationService service)
 {
     _service = service;
 }
        public ISynchronizationService GenerateSynchronizationService(UserDto user, SynchronizationCallbacks callbacks)
        {
            if (_synchronizationService != null) _synchronizationService.Dispose();

            _synchronizationService = new SynchronizationService(_fileSystem, user, callbacks);
            return _synchronizationService;
        }
Пример #34
0
 public static void Release(this ISynchronizationService synchronizationService, Guid ownerId)
 {
     synchronizationService.Release(ownerId.ToString("D").ToLowerInvariant());
 }
 public SynchronizationStarter()
 {
     _authenticationService  = ServiceLocator.ServiceProvider.GetService <IAuthenticationService>();
     _synchronizationService = ServiceLocator.ServiceProvider.GetService <ISynchronizationService>();
 }
Пример #36
0
 public void SetSynchronizationService(ISynchronizationService syncService)
 {
     _syncService = syncService;
 }
Пример #37
0
 public ValuesController(ISynchronizationService synchronizationService)
 {
     _synchronizationService = synchronizationService;
 }
Пример #38
0
        /// <summary>
        /// Start the daemon service
        /// </summary>
        /// <returns></returns>
        public bool Start()
        {
            this.Starting?.Invoke(this, EventArgs.Empty);

            this.m_tracer.TraceInfo("Starting care plan manager / warehousing service...");

            // Application context has started
            ApplicationContext.Current.Started += (ao, ae) =>
                                                  ApplicationContext.Current.GetService <IThreadPoolService>().QueueUserWorkItem(xo =>
            {
                try
                {
                    ApplicationContext.Current.SetProgress(Strings.locale_start_careplan, 0);

                    // Warehouse service
                    this.m_warehouseService = ApplicationContext.Current.GetService <IAdHocDatawarehouseService>();
                    foreach (var cp in ApplicationContext.Current.GetService <ICarePlanService>().Protocols)
                    {
                        ApplicationContext.Current.SetProgress(String.Format(Strings.locale_starting, cp.Name), 0);
                        this.m_tracer.TraceInfo("Loaded {0}...", cp.Name);
                    }

                    // Deploy schema?
                    this.m_dataMart = this.m_warehouseService.GetDatamart("oizcp");
                    if (this.m_dataMart == null)
                    {
                        this.m_tracer.TraceInfo("Datamart for care plan service doesn't exist, will have to create it...");
                        this.m_dataMart = this.m_warehouseService.CreateDatamart("oizcp", DatamartSchema.Load(typeof(CarePlanManagerService).GetTypeInfo().Assembly.GetManifestResourceStream("OpenIZ.Mobile.Core.Data.Warehouse.CarePlan.CarePlanWarehouseSchema.xml")));
                        this.m_tracer.TraceVerbose("Datamart {0} created", this.m_dataMart.Id);
                    }
                    //else // prune datamart
                    //{
                    //    this.m_warehouseService.Delete(this.m_dataMart.Id, new
                    //    {
                    //        max_date = String.Format("<=", DateTime.Now.AddDays(-365))
                    //    });
                    //}

                    // Stage 2. Ensure consistency with existing patient dataset
                    var patientPersistence = ApplicationContext.Current.GetService <IDataPersistenceService <Patient> >();
                    var remoteSyncService  = ApplicationContext.Current.GetService <ISynchronizationService>();
                    var queueService       = ApplicationContext.Current.GetService <QueueManagerService>();
                    var lastRefresh        = DateTime.Parse(ApplicationContext.Current.Configuration.GetAppSetting("openiz.mobile.core.protocol.plan.lastRun") ?? "0001-01-01");

                    // Should we ?
                    var patientSync = SynchronizationLog.Current.GetAll().FirstOrDefault(o => o.ResourceType == "Person");

                    this.RefreshCarePlan(false);
                    remoteSyncService.PullCompleted += (o, e) => { if (!remoteSyncService.IsSynchronizing)
                                                                   {
                                                                       this.m_resetEvent.Set();
                                                                   }
                    };
                    // Subscribe to events
                    this.SubscribeEvents();

                    // We're not connected to the in
                    queueService.QueueExhausted += (o, e) =>
                    {
                        int inboundQueueCount = SynchronizationQueue.Inbound.Count();
                        if (e.Queue == "inbound" && !remoteSyncService.IsSynchronizing &&
                            inboundQueueCount == 0)
                        {
                            Guid queryId = Guid.NewGuid();
                            int tr       = 1, ofs = 0;
                            queryId      = Guid.NewGuid();
                            tr           = 1;
                            ofs          = 0;
                            //this.m_actCarePlanPromise.Clear();
                            var syncFilter = patientSync?.LastSync ?? new DateTime(1900, 01, 01);
                            while (ofs < tr)
                            {
                                if (tr > 1)
                                {
                                    ApplicationContext.Current.SetProgress(Strings.locale_calculateImportedCareplan, ofs / (float)tr);
                                }

                                var prodPatients = patientPersistence.QueryExplicitLoad(p => p.ObsoletionTime == null && p.StatusConcept.Mnemonic != "OBSOLETE" && p.CreationTime >= syncFilter, ofs, 15, out tr, queryId, new String[] { "Patient.Relationships" });
                                this.QueueWorkItem(prodPatients);
                                ofs += 15;
                            }

                            this.m_isSubscribed = false;
                            this.SubscribeEvents();
                        }
                        else if (e.Queue == "inbound")
                        {
                            this.m_tracer.TraceWarning("Cannot execute CP yet because inbound={0} & isSync={1}", inboundQueueCount, queueService.IsBusy);
                        }
                    };
                }
                catch (Exception e)
                {
                    this.m_tracer.TraceError("Could not bind clinical protocols: {0}", e);
                }
            });

            this.m_running = true;

            // Polling for the doing of work
            ApplicationContext.Current.GetService <IThreadPoolService>().QueueNonPooledWorkItem((o) =>
            {
                try
                {
                    ISynchronizationService syncService = ApplicationContext.Current.GetService <ISynchronizationService>();

                    while (this.m_running)
                    {
                        this.m_resetEvent.WaitOne();
                        // de-queue
                        int promiseCount = this.m_actCarePlanPromise.Count;
                        while (!syncService.IsSynchronizing &&
                               SynchronizationQueue.Inbound.Count() == 0 &&
                               this.m_actCarePlanPromise.Count > 0)
                        {
                            if (this.m_actCarePlanPromise.Count > promiseCount)
                            {
                                promiseCount = this.m_actCarePlanPromise.Count;
                            }

                            ApplicationContext.Current.SetProgress(String.Format(Strings.locale_calculatingCarePlan, this.m_actCarePlanPromise.Count), (promiseCount - this.m_actCarePlanPromise.Count) / (float)promiseCount);
                            IdentifiedData qitm = null;
                            qitm = this.m_actCarePlanPromise.First();
                            if (qitm is Patient)
                            {
                                Patient[] patients = null;
                                // Get all patients
                                lock (this.m_lock)
                                {
                                    patients = this.m_actCarePlanPromise.OfType <Patient>().Take(5).ToArray();
                                    this.m_actCarePlanPromise.RemoveAll(d => patients.Contains(d));
                                }
                                this.UpdateCarePlan(patients);

                                // We can also remove all acts that are for a patient
                                //lock (this.m_lock)
                                //    this.m_actCarePlanPromise.RemoveAll(i => i is Act && (i as Act).Participations.Any(p => p.PlayerEntityKey == qitm.Key));
                            }
                            else if (qitm is Act)
                            {
                                // Get all patients
                                var act = this.m_actCarePlanPromise.OfType <Act>().First();
                                this.UpdateCarePlan(act);

                                //// Remove all acts which are same protocol and same patient
                                lock (this.m_lock)
                                {
                                    this.m_actCarePlanPromise.Remove(act);
                                    this.m_actCarePlanPromise.RemoveAll(i => i is Act && (i as Act).Protocols.Any(p => (qitm as Act).Protocols.Any(q => q.ProtocolKey == p.ProtocolKey)) && (i as Act).Participations.Any(p => p.PlayerEntityKey == (qitm as Act).Participations.FirstOrDefault(c => c.ParticipationRoleKey == ActParticipationKey.RecordTarget || c.ParticipationRole?.Mnemonic == "RecordTarget").PlayerEntityKey));
                                }
                            }

                            // Drop everything else in the queue
                            lock (this.m_lock)
                                this.m_actCarePlanPromise.RemoveAll(i => i.Key == qitm.Key);
                        }

                        if (promiseCount > 0 && this.m_actCarePlanPromise.Count == 0)
                        {
                            ApplicationContext.Current.SetProgress(String.Format(Strings.locale_calculatingCarePlan, 0), 1.0f);
                            ApplicationContext.Current.Configuration.SetAppSetting("openiz.mobile.core.protocol.plan.lastRun", DateTime.Now);
                            ApplicationContext.Current.SaveConfiguration();
                        }

                        this.m_resetEvent.Reset();
                    }
                }
                catch (Exception e)
                {
                    this.m_tracer.TraceError("Error polling warehouse service: {0}", e);
                }
            }, null);

            this.Started?.Invoke(this, EventArgs.Empty);
            return(true);
        }
Пример #39
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Tracker"/> class.
        /// </summary>
        /// <param name="settings">Settings to be used by the tracker.</param>
        /// <param name="trackingService">The tracking service client to be used to communicate
        /// with the tracking server.</param>
        /// <param name="synchronizationService">The synchronization service to be used for
        /// synchronizing data in the project and at the tracking service.</param>
        /// <param name="solver">The VRP solver to be used by the tracker.</param>
        /// <param name="geocoder">The geocoder to be used by the tracker.</param>
        /// <param name="messageReporter">The message reporter to be used for reporting
        /// tracking errors.</param>
        /// <exception cref="ArgumentNullException"><paramref name="settings"/>,
        /// <paramref name="trackingService"/>, <paramref name="synchronizationService"/>,
        /// <paramref name="solver"/>, <paramref name="geocoder"/> or
        /// <paramref name="messageReporter"/> is a null reference.</exception>
        internal Tracker(
            TrackingSettings settings,
            ITrackingService trackingService,
            ISynchronizationService synchronizationService,
            IVrpSolver solver,
            IGeocoder geocoder,
            IMessageReporter messageReporter)
        {
            CodeContract.RequiresNotNull("settings", settings);
            CodeContract.RequiresNotNull("trackingService", trackingService);
            CodeContract.RequiresNotNull("synchronizationService", synchronizationService);
            CodeContract.RequiresNotNull("solver", solver);
            CodeContract.RequiresNotNull("geocoder", geocoder);
            CodeContract.RequiresNotNull("messageReporter", messageReporter);

            _settings = settings;
            _trackingService = trackingService;
            _synchronizationService = synchronizationService;

            _solver = solver;

            _geocoder = geocoder;
            _messageReporter = messageReporter;
        }
        private void Dispose(bool disposing)
        {
            // If you need thread safety, use a lock around these
            // operations, as well as in your methods that use the resource.

            if (!disposing) return;

            // free managed resources

            if (_synchronizationService != null)
            {
                _synchronizationService.Dispose();
                _synchronizationService = null;
            }

            if (_fileSystem != null)
            {
                _fileSystem.Dispose();
                _fileSystem = null;
            }
        }