Exemple #1
0
        private static void ActivatePartnerApi()
        {
            Configuration.Configuration configuration = ConfigurationManager.ReadConfiguration();

            EmisPartnerInterface emisInterface = new EmisPartnerInterface();

            InitialiseWithIdResult initializeResult = emisInterface.InitializeWithId(configuration.EmisWebIPAddress, configuration.EmisWebCdb, configuration.PartnerApiKey);

            emisInterface.Logon(initializeResult.LoginId, configuration.PartnerApiUserName, configuration.PartnerApiPassword);

            Log.WriteToConsoleAndLog(string.Empty);
            Log.WriteToConsoleAndLog("Partner API activation succeeded");
        }
Exemple #2
0
        internal override void DoWork()
        {
            try
            {
                Log.Write("Starting synchronization");

                _state = StateManager.Instance;

                if (_emisInterface == null)
                {
                    _emisInterface = new EmisPartnerInterface();
                }

                if (_stopping)
                {
                    return;
                }

                InitialiseApi();

                if (_state.Mode == State.Mode.BULK)
                {
                    if (!_state.BulkInitialised)
                    {
                        _state.StartBulk();

                        int[] patientIds = GetBulkPatientList();

                        if (_stopping)
                        {
                            return;
                        }

                        _state.AddBulkPatients(patientIds);
                    }

                    ProcessQueue();

                    _state.CompleteBulk();
                }
                else if (_state.Mode == State.Mode.TRANSACTIONAL)
                {
                    DateTime synchronisationStart = DateTime.UtcNow;

                    int[] changedPatients = GetChangedPatients(_state.LastSynchronisation.Value);

                    if (_stopping)
                    {
                        return;
                    }

                    _state.AddChangedPatients(changedPatients, synchronisationStart);

                    ProcessQueue();
                }
                else
                {
                    throw new NotSupportedException("Unrecognised mode");
                }

                Log.Write("Synchronization completed");
            }
            catch (Exception e)
            {
                Log.Write("Synchronization stopped, error synchronising.", e);
            }
        }