public async Task EventHistory_ShouldSupress()
        {
            var beacon = new Beacon();
            beacon.Id1 = "7367672374000000ffff0000ffff0007";
            beacon.Id2 = 8008;
            beacon.Id3 = 5;
            beacon.Timestamp = DateTimeOffset.Now;
            var args = new BeaconEventArgs();
            args.Beacon = beacon;
            args.EventType = BeaconEventType.Exit;
            var resolvedActionEventArgs = new ResolvedActionsEventArgs() {BeaconPid = beacon.Pid, BeaconEventType = BeaconEventType.Enter};

            BeaconAction beaconaction1 = new BeaconAction() {Body = "body", Url = "http://www.com", Uuid = "1223"};
            BeaconAction beaconaction2 = new BeaconAction() {Body = "body", Url = "http://www.com", Uuid = "5678"};
            BeaconAction beaconaction3 = new BeaconAction() {Body = "body", Url = "http://www.com", Uuid = "9678"};
            ResolvedAction res1 = new ResolvedAction() {SuppressionTime = 100, SendOnlyOnce = true, BeaconAction = beaconaction1};
            ResolvedAction res2 = new ResolvedAction() {SuppressionTime = 100, SendOnlyOnce = true, BeaconAction = beaconaction2};
            ResolvedAction res3 = new ResolvedAction() {SuppressionTime = 1, SendOnlyOnce = true, BeaconAction = beaconaction3};

            EventHistory eventHistory = new EventHistory();

            await eventHistory.SaveBeaconEventAsync(args, null);
            await eventHistory.SaveExecutedResolvedActionAsync(resolvedActionEventArgs, beaconaction1);
            await eventHistory.SaveExecutedResolvedActionAsync(resolvedActionEventArgs, beaconaction3);

            eventHistory.ShouldSupressAsync(res1);
            eventHistory.ShouldSupressAsync(res3);

            await Task.Delay(2000);


            bool shouldSupress1 = eventHistory.ShouldSupressAsync(res1);
            bool shouldSupress2 = eventHistory.ShouldSupressAsync(res2);
            bool shouldSupress3 = eventHistory.ShouldSupressAsync(res3);

            Assert.IsTrue(shouldSupress1);
            Assert.IsFalse(shouldSupress2);
            Assert.IsFalse(shouldSupress3); //Supression time should be over
        }
예제 #2
0
 public DeviceManager(DeviceFactory deviceFactory, EventHistory eventHistory)
 {
     _device       = deviceFactory.GetDeviceAsync().Result;
     _eventHistory = eventHistory;
     ParticleCloud.SharedCloud.SubscribeToDeviceEventsWithPrefixAsync(OnParticleEvent, _device.Id).Wait();
 }
예제 #3
0
        public async Task <Unit> Handle(UpdateInterfaceStatusCommand request, CancellationToken cancellationToken)
        {
            bool isResendRequest = true;
            var  eventDto        = new EventDto(request.PaymentInterfaceError.CashId, request.PaymentInterfaceError.DocumentReference, (int)BusinessObjectType.PaymentOrder, request.Company);
            var  eventStatus     = await _interfaceEventLogService.FindEventAsync(eventDto);

            if (eventStatus != null)
            {
                var processInterfaceData = new ProcessInterfaceDataChangeLogsRequest
                {
                    CompanyId             = request.Company,
                    TransactionDocumentId = request.PaymentInterfaceError.TransactionDocumentId,
                    CashId                  = request.PaymentInterfaceError.CashId,
                    DocumentReference       = request.PaymentInterfaceError.DocumentReference,
                    BusinessApplicationType = (int)BusinessApplicationType.TRAX,
                };
                if (Enum.TryParse(request.PaymentInterfaceStatus, out InterfaceStatus status))
                {
                    if (status == InterfaceStatus.ReadyToTransmit)
                    {
                        // Made changes to process the document directly instead of queueing into Process.Queue
                        // Processing it instead of queueing since we received bug which states document status after resend is not updated immediately

                        var companyDate = await _systemDateTimeService.GetCompanyDate(processInterfaceData.CompanyId);

                        _unitOfWork.BeginTransaction();
                        try
                        {
                            await ProcessEventUpdate(eventStatus.EventId, InterfaceStatus.ReadyToTransmit, "Resend from Interface Monitoring Screen", processInterfaceData.ESBMessage, null, null, processInterfaceData.CompanyId);
                            await ProcessStatusUpdate(processInterfaceData, InterfaceStatus.ReadyToTransmit, "Resend from Interface Monitoring Screen");

                            _unitOfWork.Commit();
                        }
                        catch
                        {
                            _unitOfWork.Rollback();
                            throw;
                        }

                        _logger.LogInformation("Cash with DocumentId {Atlas_PaymentRequestCashDocumentId} having status {Atlas_PaymentRequestStatus} is sent to Treasury System at {Atlas_DateTime}", processInterfaceData.CashDocumentRef, InterfaceStatus.ReadyToTransmit, companyDate);

                        var paymentRequestMessage = await _paymentRequestRepository.GetTRAXMessageAsync(processInterfaceData.CashId, processInterfaceData.CompanyId);

                        var eventHistory = new EventHistory(eventStatus.EventId, "Message Generated", paymentRequestMessage, null, null);
                        _unitOfWork.BeginTransaction();
                        try
                        {
                            await _interfaceEventLogService.CreateEventHistoryAsync(eventHistory, processInterfaceData.CompanyId);

                            _unitOfWork.Commit();
                        }
                        catch
                        {
                            _unitOfWork.Rollback();
                            throw;
                        }

                        var legalEntityCode = await _paymentRequestRepository.GetLegalEntityCodeAsync(processInterfaceData.CompanyId, processInterfaceData.BusinessApplicationType);

                        // send the business object to Interface
                        await SendBusinessObjectToInterface(processInterfaceData, paymentRequestMessage, legalEntityCode, eventStatus.EventId);
                    }
                }

                _logger.LogInformation("Accounting Error with id {Atlas_DocumentReference} updated.", processInterfaceData.DocumentReference);
            }

            return(Unit.Value);
        }
예제 #4
0
 public void AssertEvents(Evt mask, ExpectedEvent[] expected, ArrayList actual)
 {
     AssertEvents(mask, expected, actual, "Event history did not match expected result.  Got:\n" + EventHistory.ToString(mask, actual) + "\n\nExpected:\n" + EventHistory.ToString(expected));
 }
 public void OnWristbandStepsCollected(StepsData stepsData)
 {
     EventHistory.Add(new WristbandHistoryEvent("OnWristbandStepsCollected > " + stepsData.totalStepsWalked().ToString(), false));
 }
        public void Insert(Guid calendarID)
        {
            using (var context = new EventContext(_credentials))
            {
                this.CalendarID = calendarID;

                var e = new Event();
                e.Contents = this.Contents;
                e.EndTime = this.EndTime;
                e.ID = this.EventID;
                e.IsAllDay = this.IsAllDay;
                e.IsReoccuring = this.IsReoccuring;
                e.Location = this.Location;
                e.StartTime = this.StartTime;
                e.Title = this.Title;
                e.Type = this.Type;
                e.CalendarID = this.CalendarID;
                e.AuthorID = _credentials.UserID;

                // Add and save here so we have the event id
                context.Events.Add(e);
                context.SaveChanges();

                // Grab the event ID after saved
                this.EventID = e.ID;

                // Add the reminders
                foreach (var item in Reminders)
                {
                    context.EventReminders.Add(item);
                }

                if (this.Type == EventType.None)
                {
                    this.Type = EventType.Private;
                }

                // Do the calendar sharing
                if (this.Type == EventType.Public || this.Type == EventType.EmployeesOnly)
                {
                    // Add the individuals who are already invited to the calendar
                    // only if the event is made public
                    var employeeInvitees = (from c in context.CalendarInvitees
                                            join u in context.Users on c.InviteeID equals u.ID
                                            where c.Type == InviteeType.Employee
                                            select new EventInvitee
                                            {
                                                EventID = this.EventID,
                                                InviteeID = u.ID,
                                                Type = InviteeType.Employee
                                            }).ToList();

                    Invitees.AddRange(employeeInvitees);

                    // add the customers
                    if (this.Type == EventType.Public)
                    {
                        var customerInvitees = (from c in context.CalendarInvitees
                                                join customers in context.Customers on c.InviteeID equals customers.ID
                                                where c.Type == InviteeType.Employee
                                                select new EventInvitee
                                                {
                                                    EventID = this.EventID,
                                                    InviteeID = customers.ID,
                                                    Type = InviteeType.Customer
                                                }).ToList();

                        Invitees.AddRange(customerInvitees);
                    }
                }

                // Add the invitees
                foreach (var item in Invitees)
                {
                    context.EventInvitees.Add(item);
                }

                // set the transaction dates
                this.DateCreated = DateTime.Now;
                this.DateEdied = this.DateCreated;

                // need to save the date created and date edited
                // need to do this here because we need the event id
                EventHistory history = new EventHistory();
                history.UserID = _credentials.UserID;
                history.TransactionDate = this.DateCreated;
                history.EventID = this.EventID;
                history.TransactionType = EventHistoryType.Create;
                context.EventHistory.Add(history);

                // save the history
                context.SaveChanges();

                // set the creator
                this.Creator = context.Users.Where(w => w.ID == e.AuthorID).First();
            }
        }
예제 #7
0
 private void OnNext(MonitorEvent ev)
 {
     EventHistory.Add(ev);
 }
예제 #8
0
 /// <summary>
 /// Add literal text that is not a property and not editable.
 /// </summary>
 /// <param name="_ss"/>
 public void AddString(ITsString _ss)
 {
     EventHistory.Add(new StringAdded {
         Content = _ss
     });
 }
예제 #9
0
    protected virtual bool CheckAgainst(float lastTime, EventHistory actualEvent)
    {
        if(CommonChecks(actualEvent)) return false;
        if(CheckTimes(lastTime, actualEvent)) return false;
        if(CheckState(actualEvent)) return false;
        if(CheckOther(actualEvent)) return false;

        return true;
    }
예제 #10
0
 public static string ToString(EventHistory[] eventHistory)
 {
     System.Text.StringBuilder sb = new System.Text.StringBuilder();
     foreach(EventHistory h in eventHistory) {
       sb.Append(h.ToString()).Append("\n");
     }
     return sb.ToString();
 }
        public async Task <Unit> Handle(ProcessInterfaceDataChangeLogsRequest request, CancellationToken cancellationToken)
        {
            int tAorJLTypeId = 0;
            // There should be no record in DB the first time.
            var docStatus = await _accountingInterfaceRepository.GetDocumentStatus((int)BusinessApplicationType.AX, request.CompanyId, null, request.TransactionDocumentId, request.DocumentId);

            var docReference = await _accountingInterfaceRepository.GetDocumentReferenceByAccountingId(request.DocumentId, (int)request.DocumentTypeId, request.CompanyId);

            if (docStatus == InterfaceStatus.None || docStatus == InterfaceStatus.TransmitError)
            {
                long eventId;
                if (request.DocumentTypeId == DocumentType.ManualTemporaryAdjustment)
                {
                    tAorJLTypeId = await _accountingInterfaceRepository.GetTATypeIdAsync(request.TransactionDocumentId, request.DocumentTypeId, request.CompanyId);
                }

                if (request.DocumentTypeId == DocumentType.RegularJournal)
                {
                    tAorJLTypeId = await _accountingInterfaceRepository.GetJLTypeIdAsync(request.TransactionDocumentId, request.DocumentTypeId, request.CompanyId);
                }

                EventSubType eventSubType = await GetEventSubType(request.DocumentTypeId, tAorJLTypeId);

                _unitOfWork.BeginTransaction();
                var eventdata = new Event((int)eventSubType, request.DocumentId, docReference, (int)InterfaceStatus.ReadyToTransmit, request.CompanyId, null);

                try
                {
                    eventId = await _interfaceEventLogService.CreateEventAsync(eventdata);

                    // Insert Record into InterfaceStatus
                    await ProcessStatusUpdate(request, InterfaceStatus.InterfaceReady, "Ready To be Interfaced");

                    _unitOfWork.Commit();
                }
                catch
                {
                    _unitOfWork.Rollback();
                    throw;
                }

                var companyDate = await _systemDateTimeService.GetCompanyDate(request.CompanyId);

                _logger.LogInformation("Accounting Document with DocumentId {Atlas_DocumentId} having status {Atlas_InterfaceStatus} is sent to Accounting System at {Atlas_DateTime}", request.DocumentId, docStatus.ToString(), companyDate);

                var accountingInterfaceXMLMessage = await _accountingInterfaceRepository.GetESBMessageAsync(request.DocumentId, request.CompanyId);

                var eventHistory = new EventHistory(eventId, "Message Generated", accountingInterfaceXMLMessage, null, null);
                _unitOfWork.BeginTransaction();
                try
                {
                    await _interfaceEventLogService.CreateEventHistoryAsync(eventHistory, request.CompanyId);

                    _unitOfWork.Commit();
                }
                catch
                {
                    _unitOfWork.Rollback();
                    throw;
                }

                await SendBusinessObjectToInterface(request, accountingInterfaceXMLMessage, tAorJLTypeId, eventId, false);
            }
            else
            {
                _logger.LogWarning("Invalid Document ({Atlas_DocumentReference}) status {Atlas_InterfaceStatus}.", request.DocumentReference, docStatus.ToString());
            }

            return(Unit.Value);
        }
        public async Task <ProcessESBResult> Handle(ProcessESBResponse esbRequest, CancellationToken cancellationToken)
        {
            CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture;
            TextInfo    textInfo    = cultureInfo.TextInfo;
            var         companyDate = await _systemDateTimeService.GetCompanyDate(esbRequest.CompanyId);

            long sourceId = await _interfaceEventLogService.GetAccountingIdandCashIdbyDocumentReference(esbRequest.CompanyId, esbRequest.DocumentReference, (int)BusinessApplicationType.AX, (int)esbRequest.BusinessObjectType);

            var eventDto    = new EventDto(sourceId, esbRequest.DocumentReference, (int)esbRequest.BusinessObjectType, esbRequest.CompanyId);
            var eventStatus = await _interfaceEventLogService.FindEventAsync(eventDto);

            if (eventStatus != null)
            {
                var eventHistoryData = new EventHistory(eventStatus.EventId, "Callback message received from ESB", esbRequest.ESBMessage, null, null);
                await _interfaceEventLogService.CreateEventHistoryAsync(eventHistoryData, esbRequest.CompanyId);

                _unitOfWork.BeginTransaction();
                try
                {
                    var responseToESB = await ValidateESBResponse(esbRequest);

                    if (responseToESB.IsSuccess)
                    {
                        var processInterfaceData = new ProcessInterfaceDataChangeLogsRequest();
                        processInterfaceData.DocumentReference       = esbRequest.DocumentReference;
                        processInterfaceData.CompanyId               = esbRequest.CompanyId;
                        processInterfaceData.BusinessApplicationType = BusinessApplicationType.AX;
                        processInterfaceData.ESBMessage              = esbRequest.ESBMessage;
                        processInterfaceData.AcknowledgementId       = esbRequest.AckBusinessDocId;
                        processInterfaceData.TransactionDate         = esbRequest.TransactionDate.GetValueOrDefault() == default(DateTime) ? null : esbRequest.TransactionDate;
                        processInterfaceData.TimeStamp               = esbRequest.TimeStamp;
                        processInterfaceData.JournalNumber           = esbRequest.JournalNumber;
                        InterfaceStatus status;
                        if (Enum.TryParse(textInfo.ToTitleCase(esbRequest.ResponseStatus.ToLowerInvariant()), out status))
                        {
                            switch (status)
                            {
                            case InterfaceStatus.Completed:
                                await ProcessEventUpdate(eventStatus.EventId, InterfaceStatus.Completed, "ESB callback Message integration", esbRequest.ESBMessage, ResultCode.Ok.ToString(), null, esbRequest.CompanyId);
                                await ProcessStatusUpdate(processInterfaceData, InterfaceStatus.Completed, esbRequest.ResponseMessage);

                                break;

                            case InterfaceStatus.Error:
                                await ProcessEventUpdate(eventStatus.EventId, InterfaceStatus.Error, "ESB callback Message integration", esbRequest.ESBMessage, ResultCode.Error.ToString(), esbRequest.ResponseMessage, esbRequest.CompanyId);
                                await ProcessStatusUpdate(processInterfaceData, InterfaceStatus.Error, esbRequest.ResponseMessage);

                                break;

                            case InterfaceStatus.Rejected:
                                await ProcessEventUpdate(eventStatus.EventId, InterfaceStatus.Rejected, "ESB callback Message integration", esbRequest.ESBMessage, ResultCode.Error.ToString(), esbRequest.ResponseMessage, esbRequest.CompanyId);
                                await ProcessStatusUpdate(processInterfaceData, InterfaceStatus.Rejected, esbRequest.ResponseMessage);

                                break;
                            }
                        }
                    }

                    _unitOfWork.Commit();
                    _logger.LogInformation("Document with DocumentId {Atlas_AccountingDocumentReference} received status {Atlas_AccountingStatus} from Accounting System at {Atlas_DateTime}", esbRequest.DocumentReference, esbRequest.ResponseStatus, companyDate);
                    return(responseToESB);
                }
                catch
                {
                    _unitOfWork.Rollback();
                    throw;
                }
            }
            else
            {
                processESBResult.Error     = "Invalid Document Reference";
                processESBResult.IsSuccess = false;
                return(processESBResult);
            }
        }
        private async Task ProcessAccountingInterfaceRequest(ProcessInterfaceDataChangeLogsRequest request, string accountingInterfaceXMLMessage, int tAorJLTypeId, long eventId, bool isResendRequest)
        {
            try
            {
                // Esb call inside its own try/catch
                request.UUID = await _esbService.CallESBClient(accountingInterfaceXMLMessage, request.DocumentTypeId, tAorJLTypeId);
            }
            catch (Exception e)
            {
                _logger.LogError(e, e.Message);

                _unitOfWork.BeginTransaction();
                try
                {
                    var updateEventStatus = new Event(eventId, (long)InterfaceStatus.TransmitError, e.Message);
                    var eventHistory      = new EventHistory(eventId, "Sending the message to ESB", null, ResultCode.Error.ToString(), e.Message);
                    await _interfaceEventLogService.UpdateEventStatusAsync(updateEventStatus, request.CompanyId);

                    await _interfaceEventLogService.CreateEventHistoryAsync(eventHistory, request.CompanyId);
                    await ProcessStatusUpdate(request, InterfaceStatus.TransmitError, e.Message);

                    _unitOfWork.Commit();
                }
                catch
                {
                    _unitOfWork.Rollback();
                    throw;
                }

                if (!isResendRequest)
                {
                    throw;
                }
            }

            _unitOfWork.BeginTransaction();
            try
            {
                if (request.UUID != null)
                {
                    var updateEventStatus = new Event(eventId, (long)InterfaceStatus.StandBy, request.UUID);
                    var eventHistory      = new EventHistory(eventId, "Sending the message to ESB", null, ResultCode.Ok.ToString(), request.UUID);
                    await _interfaceEventLogService.UpdateEventStatusAsync(updateEventStatus, request.CompanyId);

                    await _interfaceEventLogService.CreateEventHistoryAsync(eventHistory, request.CompanyId);
                    await ProcessStatusUpdate(request, InterfaceStatus.StandBy, accountingInterfaceXMLMessage);
                }
                else
                {
                    var updateEventStatus = new Event(eventId, (long)InterfaceStatus.TransmitError, accountingInterfaceXMLMessage);
                    var eventHistory      = new EventHistory(eventId, "Sending the message to ESB", null, ResultCode.Error.ToString(), accountingInterfaceXMLMessage);
                    await _interfaceEventLogService.UpdateEventStatusAsync(updateEventStatus, request.CompanyId);

                    await _interfaceEventLogService.CreateEventHistoryAsync(eventHistory, request.CompanyId);
                    await ProcessStatusUpdate(request, InterfaceStatus.TransmitError, accountingInterfaceXMLMessage);
                }

                _unitOfWork.Commit();
            }
            catch
            {
                _unitOfWork.Rollback();
                throw;
            }
        }
예제 #14
0
        /// <summary>
        /// Persons the event list asynchronous.
        /// </summary>
        /// <param name="personId">The person identifier.</param>
        /// <param name="searchParameters">The search parameters.</param>
        /// <returns>
        /// Instance of Event History
        /// </returns>
        public async Task<ListResult<EventHistory>> PersonEventListAsync(string personId, PersonEventSearchParameter searchParameters)
        {
            var eventHistoryCollection = new ListResult<EventHistory>();
            var eventHistory = new EventHistory();

            ////TODO : Implement Date time value to pass to mas service to retrieve drill events.
            DateTime dateTime;
            try
            {
                DateTime.TryParseExact(searchParameters.DateTime, CustomDateTimeFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime);
            }
            catch
            {
                dateTime = DateTime.UtcNow;
            }

            //// TODO : Will remove later after 2015-11-23 Release.
            if (dateTime.Equals(DateTime.MinValue))
            {
                dateTime = DateTime.UtcNow;
            }

            var drillEvents = RetrieveDrillEvents(dateTime, personId, searchParameters.PersonType.ToString(CultureInfo.CurrentCulture));
            var gangwayEvents = this.personEventClientRepository.RetrieveEventListAsync(new PersonHistorySearchParameters { ShipId = searchParameters.ShipId, PersonIds = searchParameters.PersonId, PersonTypeId = searchParameters.PersonTypeId, MaxResults = searchParameters.MaxResults, OrderBy = searchParameters.OrderBy, PageNumber = searchParameters.PageNumber, Parts = searchParameters.Parts });

            await Task.WhenAll(drillEvents, gangwayEvents);

            eventHistory.AssignGangwayEvents(PersonEventHistoryMapper.MapListAsync(gangwayEvents.Result.Items));
            eventHistory.AssignDrillEvents(drillEvents.Result);
            eventHistoryCollection.Items.Add(eventHistory);
            eventHistoryCollection.TotalResults = gangwayEvents.Result.TotalResults;
            return eventHistoryCollection;
        }
예제 #15
0
        public void Update()
        {
            WasLazyLoaded = false;
            // need to make sure the event is saved
            if (this.EventID == Guid.Empty)
            {
                throw new iONCalendarEventException(this, "Event ID Empty, cannot update");
            }

            using (var context = new EventContext(_credentials))
            {
                var e = context.Events.Find(this.EventID);

                // someone else could have removed the event
                if (e == null)
                {
                    throw new iONCalendarEventException(this, "Event not found, cannot update");
                }

                e.Contents = this.Contents;
                e.EndTime = this.EndTime;
                e.ID = this.EventID;
                e.IsAllDay = this.IsAllDay;
                e.IsReoccuring = this.IsReoccuring;
                e.Location = this.Location;
                e.StartTime = this.StartTime;
                e.Title = this.Title;

                // update the reminders, need to see if they changed
                foreach (var item in Reminders)
                {
                    if (item.MarkedForRemoval)
                    {
                        context.EventReminders.Remove(item);
                    }
                }

                // update the invitees, need to see if they changed
                foreach (var item in Invitees)
                {
                    if (item.MarkedForRemoval)
                    {
                        context.EventInvitees.Remove(item);
                    }
                }

                // do an atomic save here
                context.SaveChanges();

                // need to save the date created and date edited
                // need to do this here because we need the event id
                EventHistory history = new EventHistory();
                history.UserID = _credentials.UserID;
                history.TransactionDate = DateTime.Now;
                history.EventID = e.ID;
                history.TransactionType = EventHistoryType.Edit;
                context.EventHistory.Add(history);

                // save the history
                context.SaveChanges();
            }
        }
예제 #16
0
 public void Update(EventHistory eventHistory)
 {
     _context.Entry(eventHistory).State = EntityState.Modified;
 }
예제 #17
0
        public static void Test()
        {
            try
            {
                Console.WriteLine("Connecting to database...");
                using (var init = new InitDatabaseService())
                {
                    Console.WriteLine("Connection successful.\nResetting the database...");
                    init.Reset();
                    Console.WriteLine("Reset successful.\nLoading data...");

                    //create dummy pharmacy
                    Pharmacy pharm = new Pharmacy(1, "CSV Pharmacy", "19187661052", "1400 chrissartin street");
                    using (var service = new PharmacyService())
                    {
                        service.Create(pharm);
                    }
                    //create dummy patient
                    Patient patient  = new Patient(1, "Chris", "Sartin", new DateTime(2000, DateTime.Today.Month, DateTime.Today.Day), "77777", "19183994836", "*****@*****.**", pharm);
                    Patient patient1 = new Patient(2, "Matthew", "Miller", new DateTime(2000, DateTime.Today.Month, DateTime.Today.Day), "8675309", "19187661052", "*****@*****.**", pharm);

                    using (var service = new PatientService())
                    {
                        service.Create(patient);
                        service.Create(patient1);
                    }
                    //create dummy drug
                    Drug drug = new Drug(1, "Taco Medication");
                    using (var service = new DrugService())
                    {
                        service.Create(drug);
                    }
                    //create dummy prescription
                    Prescription prescription  = new Prescription(1, patient, drug, 7, 7);
                    Prescription prescription1 = new Prescription(2, patient1, drug, 6, 6);

                    using (var service = new PrescriptionService())
                    {
                        service.Create(prescription);
                        service.Create(prescription1);
                    }
                    EventRefill RefillEvent;

                    //create dummy event
                    using (var service = new EventService())
                    {
                        //create dummy eventRefill
                        Event Event  = new Event(patient, "this is a message", EventStatus.ToSend, EventType.REFILL);
                        Event Event1 = new Event(patient, "refill test event", EventStatus.Sent, EventType.REFILL);
                        Event Event2 = new Event(patient1, "this is a test", EventStatus.Fill, EventType.REFILL);
                        RefillEvent = new EventRefill(prescription, Event);
                        EventRefill RefillEvent1 = new EventRefill(prescription1, Event1);
                        EventRefill RefillEvent2 = new EventRefill(prescription1, Event2);
                        using (var service2 = new EventRefillService())
                        {
                            service.Create(Event);
                            service2.Create(RefillEvent);

                            service.Create(Event1);
                            service2.Create(RefillEvent1);

                            service.Create(Event2);
                            service2.Create(RefillEvent2);
                        }

                        //create dummy birthdayevent
                        Event BirthdayEvent = new Event(patient, "this is a message", EventStatus.ToSend, EventType.BIRTHDAY);
                        service.Create(BirthdayEvent);

                        //create dummy recallevent
                        Event = new Event(patient, "this is a message", EventStatus.ToSend, EventType.REFILL);
                        EventRecall RecallEvent = new EventRecall(Event);
                        using (var service2 = new EventRecallService())
                        {
                            service.Create(Event);
                            service2.Create(RecallEvent);
                        }

                        //create dummy eventhistory
                        EventHistory history = new EventHistory(Event, EventStatus.InActive, new DateTime(2000, 7, 14));
                        using (var service2 = new EventHistoryService())
                        {
                            service2.Create(history);
                        }
                    }

                    //create dummy pharmacist in the pharmacy
                    Pharmacist pharmacist  = new Pharmacist("James", "Taco", "*****@*****.**", "18884443333", new byte[] { 0 }, new byte[] { 0 });
                    Pharmacist pharmacist1 = new Pharmacist("Matthew", "Miller", "*****@*****.**", "19187661052", new byte[] { 0 }, new byte[] { 0 });
                    Pharmacist pharmacist2 = new Pharmacist("Luke", "Thorne", "*****@*****.**", "14056932048", new byte[] { 0 }, new byte[] { 0 });
                    Pharmacist pharmacist3 = new Pharmacist("Emily", "Pielemeier", "*****@*****.**", "13177536066", new byte[] { 0 }, new byte[] { 0 });
                    Pharmacist pharmacist4 = new Pharmacist("Tom", "Hartnett", "*****@*****.**", "14696671743", new byte[] { 0 }, new byte[] { 0 });

                    using (var service = new PharmacistService())
                    {
                        service.Create(pharmacist);
                        service.Create(pharmacist1);
                        service.Create(pharmacist2);
                        service.Create(pharmacist3);
                        service.Create(pharmacist4);
                    }


                    //create dummy fillhistory
                    FillHistory fill = new FillHistory(RefillEvent, pharmacist, new DateTime(2000, 7, 14));
                    using (var service = new FillHistoryService())
                    {
                        service.Create(fill);
                    }

                    //create dummy sysadmins (us)
                    SystemAdmin admin  = new SystemAdmin("testing", "the stuff", "*****@*****.**", "19184661052", new byte[] { 0 }, new byte[] { 0 });
                    SystemAdmin admin1 = new SystemAdmin("Tom", "Hartnett", "*****@*****.**", "14696671743", new byte[] { 0 }, new byte[] { 0 });
                    SystemAdmin admin2 = new SystemAdmin("Luke", "Thorne", "*****@*****.**", "14056932048", new byte[] { 0 }, new byte[] { 0 });
                    SystemAdmin admin3 = new SystemAdmin("Jon", "Hartnett", "*****@*****.**", "14696671064", new byte[] { 0 }, new byte[] { 0 });
                    SystemAdmin admin4 = new SystemAdmin("Emily", "Pielemeier", "*****@*****.**", "13177536066", new byte[] { 0 }, new byte[] { 0 });
                    using (var service = new SystemAdminService())
                    {
                        service.Create(admin);
                        service.Create(admin1);
                        service.Create(admin2);
                        service.Create(admin3);
                        service.Create(admin4);
                    }

                    //create dummy job
                    Job job = new Job(pharm, pharmacist, true, false);
                    using (var service = new JobService())
                    {
                        service.Create(job);
                        Job j1 = new Job(pharm, pharmacist1, true, true);
                        service.Create(j1);
                        Job j2 = new Job(pharm, pharmacist2, true, true);
                        service.Create(j2);
                        Job j3 = new Job(pharm, pharmacist3, true, true);
                        service.Create(j3);
                        Job j4 = new Job(pharm, pharmacist4, true, true);
                        service.Create(j4);
                    }

                    init.LoadFromFile(@"..\..\App_Data\Scrubbed_Data.xlsx - Sheet1.csv", pharm);
                    Console.WriteLine("Loading data successful.\nAll tests successful...");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                Console.ReadKey();
            }
        }
예제 #18
0
    protected virtual bool CheckOther(EventHistory actualEvent)
    {
        // TODO: Make this less sucky.  Come up with something that's clean and easy
        // for various event types...
        if((otherData != null) && (otherData != actualEvent.otherData)) return true;

        return false;
    }
        public async Task EventHistory_FlushHistory()
        {
            var beacon = new Beacon();
            beacon.Id1 = "7367672374000000ffff0000ffff0007";
            beacon.Id2 = 8008;
            beacon.Id3 = 5;
            beacon.Timestamp = DateTimeOffset.Now;
            var args = new BeaconEventArgs();
            args.Beacon = beacon;
            args.EventType = BeaconEventType.Exit;
            var resolvedActionEventArgs = new ResolvedActionsEventArgs() {BeaconPid = beacon.Pid, BeaconEventType = BeaconEventType.Enter};

            BeaconAction beaconaction1 = new BeaconAction() {Body = "body", Url = "http://www.com", Uuid = "1223"};
            BeaconAction beaconaction2 = new BeaconAction() {Body = "body", Url = "http://www.com", Uuid = "5678"};
            BeaconAction beaconaction3 = new BeaconAction() {Body = "body", Url = "http://www.com", Uuid = "9678"};
            ResolvedAction res1 = new ResolvedAction() {SuppressionTime = 100, SendOnlyOnce = true, BeaconAction = beaconaction1};
            ResolvedAction res2 = new ResolvedAction() {SuppressionTime = 100, SendOnlyOnce = true, BeaconAction = beaconaction2};
            ResolvedAction res3 = new ResolvedAction() {SuppressionTime = 1, SendOnlyOnce = true, BeaconAction = beaconaction3};

            EventHistory eventHistory = new EventHistory();

            await eventHistory.SaveBeaconEventAsync(args, null);
            await eventHistory.SaveExecutedResolvedActionAsync(resolvedActionEventArgs, beaconaction1);
            await eventHistory.SaveExecutedResolvedActionAsync(resolvedActionEventArgs, beaconaction3);

            await eventHistory.FlushHistoryAsync();
        }
예제 #20
0
    protected virtual bool CheckState(EventHistory actualEvent)
    {
        if((enabledState != actualEvent.enabledState) || (activeState != actualEvent.activeState)) return true;

        return false;
    }
 private void InterceptEvent(EventItem item)
 {
     lock (Hooks) {
         EventHistory.Enqueue(item);
     }
 }
예제 #22
0
    protected virtual bool CheckTimes(float lastTime, EventHistory actualEvent)
    {
        // Make sure we're on the exact frame we expect.
        if((frame > 0) && (frame != actualEvent.frame)) return true;
        // Make sure that at the specified time value is in the past (lets us test
        // that a certain amount of time has been waited).
        if((realtimeSinceStartup > 0) && (realtimeSinceStartup > actualEvent.realtimeSinceStartup)) return true;
        else if(realtimeSinceStartup < 0) {
          // Use negative values to specify relative times.
          float tmp = Mathf.Abs(realtimeSinceStartup) + lastTime;
          if(tmp > actualEvent.realtimeSinceStartup) return true;
        }

        return false;
    }
 public void OnWristbandUnknownProfile(string pheriperalID, string pheriperalName)
 {
     EventHistory.Add(new WristbandHistoryEvent("OnWristbandUnknownProfile > name: " + pheriperalName + ", id: " + pheriperalID, false));
 }
예제 #24
0
    protected virtual bool CommonChecks(EventHistory actualEvent)
    {
        if(actualEvent == null) return true;

        // Make sure we're looking at the right event type.
        if(name != actualEvent.name) return true;

        return false;
    }
 public void OnWristbandWriteComplete()
 {
     EventHistory.Add(new WristbandHistoryEvent("OnWristbandWriteComplete", false));
 }
예제 #26
0
    protected override bool CheckState(EventHistory actualEvent)
    {
        if(enabledState != actualEvent.enabledState) return true;

        return false;
    }
예제 #27
0
        public async Task <ProcessESBResult> Handle(ProcessESBResponse esbRequest, CancellationToken cancellationToken)
        {
            var         eventHistoryData = new EventHistory();
            var         eventData        = new Event();
            CultureInfo cultureInfo      = Thread.CurrentThread.CurrentCulture;
            TextInfo    textInfo         = cultureInfo.TextInfo;
            var         companyDate      = await _systemDateTimeService.GetCompanyDate(esbRequest.CompanyId);

            long sourceId = await _interfaceEventLogService.GetAccountingIdandCashIdbyDocumentReference(esbRequest.CompanyId, esbRequest.DocumentReference, (int)BusinessApplicationType.TRAX, (int)esbRequest.BusinessObjectType);

            var eventDto    = new EventDto(sourceId, esbRequest.DocumentReference, (int)esbRequest.BusinessObjectType, esbRequest.CompanyId);
            var eventStatus = await _interfaceEventLogService.FindEventAsync(eventDto);

            eventHistoryData = new EventHistory(eventStatus.EventId, "Callback message received from ESB", esbRequest.ESBMessage, null, null);
            await _interfaceEventLogService.CreateEventHistoryAsync(eventHistoryData, esbRequest.CompanyId);

            var paymentRequestStatus = await _paymentRequestRepository.GetPaymentRequestStatus((int)BusinessApplicationType.TRAX, esbRequest.CompanyId, esbRequest.DocumentReference);

            _unitOfWork.BeginTransaction();

            try
            {
                var responseToESB = await ValidateEsbResponse(esbRequest, paymentRequestStatus);

                if (responseToESB.IsSuccess)
                {
                    var processInterfaceData = new ProcessInterfaceDataChangeLogsRequest();
                    processInterfaceData.CashDocumentRef         = esbRequest.DocumentReference;
                    processInterfaceData.CompanyId               = esbRequest.CompanyId;
                    processInterfaceData.BusinessApplicationType = Convert.ToInt32(BusinessApplicationType.TRAX, CultureInfo.InvariantCulture);
                    processInterfaceData.ESBMessage              = esbRequest.ESBMessage;
                    processInterfaceData.AcknowledgementId       = esbRequest.AckBusinessDocId;
                    processInterfaceData.DocumentDate            = esbRequest.ValueDate;

                    InterfaceStatus status;
                    if (Enum.TryParse(textInfo.ToTitleCase(esbRequest.ResponseStatus.ToLower(CultureInfo.InvariantCulture)), out status))
                    {
                        switch (status)
                        {
                        case InterfaceStatus.Signed:
                            await ProcessEventUpdate(eventStatus.EventId, InterfaceStatus.Signed, "ESB callback Message integration", esbRequest.ESBMessage, ResultCode.Ok.ToString(), null, esbRequest.CompanyId);
                            await ProcessStatusUpdate(processInterfaceData, InterfaceStatus.Signed, esbRequest.ESBMessage);
                            await EnqueueMessage(paymentRequestStatus.TransactionDocumentId.ToString(CultureInfo.InvariantCulture), esbRequest.CompanyId);

                            break;

                        case InterfaceStatus.Error:
                            await ProcessEventUpdate(eventStatus.EventId, InterfaceStatus.Error, "ESB callback Message integration", esbRequest.ESBMessage, ResultCode.Error.ToString(), esbRequest.ResponseMessage, esbRequest.CompanyId);
                            await ProcessStatusUpdate(processInterfaceData, InterfaceStatus.Error, esbRequest.ResponseMessage);

                            break;

                        case InterfaceStatus.Included:
                            await ProcessEventUpdate(eventStatus.EventId, InterfaceStatus.Included, "ESB callback Message integration", esbRequest.ESBMessage, ResultCode.Ok.ToString(), null, esbRequest.CompanyId);
                            await ProcessStatusUpdate(processInterfaceData, InterfaceStatus.Interfaced, esbRequest.ResponseMessage);

                            break;

                        case InterfaceStatus.Rejected:
                            await ProcessEventUpdate(eventStatus.EventId, InterfaceStatus.Rejected, "ESB callback Message integration", esbRequest.ESBMessage, ResultCode.Error.ToString(), esbRequest.ResponseMessage, esbRequest.CompanyId);
                            await ProcessStatusUpdate(processInterfaceData, InterfaceStatus.Rejected, esbRequest.ResponseMessage);

                            break;
                        }
                    }
                }

                _unitOfWork.Commit();
                _logger.LogInformation("Cash with DocumentId {Atlas_PaymentRequestCashDocumentId} recieved status {Atlas_PaymentRequestStatus} from Treasury System at {Atlas_DateTime}", esbRequest.DocumentReference, esbRequest.ResponseStatus, companyDate);
                return(responseToESB);
            }
            catch
            {
                _unitOfWork.Rollback();
                throw;
            }
        }
예제 #28
0
 /// <summary>
 /// For creating event history.
 /// </summary>
 /// <param name="newEvent">Data for creating event history.</param>
 /// <param name="companyId">Company Identifier.</param>
 /// <returns>Creates event history.</returns>
 public async Task CreateEventHistoryAsync(EventHistory newEvent, string companyId)
 {
     await _eventRepository.CreateEventHistoryAsync(newEvent, companyId);
 }
예제 #29
0
        /// <summary>
        /// Retrieves the person event asynchronous.
        /// </summary>
        /// <param name="dateTime">The date time.</param>
        /// <param name="personId">The person identifier.</param>
        /// <param name="personType">The person type.</param>
        /// <returns>The person events.</returns>
        public async Task<EventHistory> RetrievePersonHistoryAsync(string dateTime, string personId, PersonType personType)
        {
            var workstation = DIContainer.Instance.Resolve<Workstation>();

            ListResult<EventHistory> eventData = new ListResult<EventHistory>();
            var eventHistory = new EventHistory();

            var personTypeId = personType.RetrievePersonTypeId();

            var command = this.Database.GetStoredProcCommand(RetrieveGangwayHistoryByPersonIdStoredProcedure)
                .AddParameter(PersonTypeId, DbType.Int16, personTypeId)
                .AddParameter(PersonIds, DbType.String, personId)
                .AddParameter(ShipIds, DbType.String, workstation.Ship.ShipId)
                .AddParameter(SortColumn1, DbType.String, AddedDate)
                .AddParameter(SortTypeColumn1, DbType.String, DESC)
                .AddParameter(PageNumber, DbType.Int32, OfflineConstants.DefaultPageNumber)
                .AddParameter(PageSize, DbType.Int32, OfflineConstants.DefaultPageSize);

            var list = await this.ExecuteReaderAsync(command, GangwayHistoryMapper.MapGangwayHistory);

            eventHistory.AssignGangwayEvents(PersonEventHistoryMapper.MapPersonHistory(list.Items));
            eventData.Items.Add(eventHistory);
            var data = eventData != null ? eventData.Items.FirstOrDefault() : new EventHistory();
            return await Task.FromResult(data);
        }
예제 #30
0
        public async Task EventHistory_ShouldSupress()
        {
            var beacon = new Beacon();

            beacon.Id1       = "7367672374000000ffff0000ffff0007";
            beacon.Id2       = 8008;
            beacon.Id3       = 5;
            beacon.Timestamp = DateTimeOffset.Now;
            var args = new BeaconEventArgs();

            args.Beacon    = beacon;
            args.EventType = BeaconEventType.Exit;
            var resolvedActionEventArgs = new ResolvedActionsEventArgs()
            {
                BeaconPid = beacon.Pid, BeaconEventType = BeaconEventType.Enter
            };

            BeaconAction beaconaction1 = new BeaconAction()
            {
                Body = "body", Url = "http://www.com", Uuid = "1223"
            };
            BeaconAction beaconaction2 = new BeaconAction()
            {
                Body = "body", Url = "http://www.com", Uuid = "5678"
            };
            BeaconAction beaconaction3 = new BeaconAction()
            {
                Body = "body", Url = "http://www.com", Uuid = "9678"
            };
            ResolvedAction res1 = new ResolvedAction()
            {
                SuppressionTime = 100, SendOnlyOnce = true, BeaconAction = beaconaction1
            };
            ResolvedAction res2 = new ResolvedAction()
            {
                SuppressionTime = 100, SendOnlyOnce = true, BeaconAction = beaconaction2
            };
            ResolvedAction res3 = new ResolvedAction()
            {
                SuppressionTime = 1, SendOnlyOnce = true, BeaconAction = beaconaction3
            };

            EventHistory eventHistory = new EventHistory();

            await eventHistory.SaveBeaconEventAsync(args, null);

            await eventHistory.SaveExecutedResolvedActionAsync(resolvedActionEventArgs, beaconaction1);

            await eventHistory.SaveExecutedResolvedActionAsync(resolvedActionEventArgs, beaconaction3);

            eventHistory.ShouldSupressAsync(res1);
            eventHistory.ShouldSupressAsync(res3);

            await Task.Delay(2000);


            bool shouldSupress1 = eventHistory.ShouldSupressAsync(res1);
            bool shouldSupress2 = eventHistory.ShouldSupressAsync(res2);
            bool shouldSupress3 = eventHistory.ShouldSupressAsync(res3);

            Assert.IsTrue(shouldSupress1);
            Assert.IsFalse(shouldSupress2);
            Assert.IsFalse(shouldSupress3); //Supression time should be over
        }
예제 #31
0
 public void Insert(EventHistory eventHistory)
 {
     _context.EventsHistoriesContext.Add(eventHistory);
 }
 public DeviceController(DeviceManager deviceManager, EventHistory eventHistory)
 {
     _deviceManager = deviceManager;
     _eventHistory  = eventHistory;
 }
예제 #33
0
        public void Delete(int eventHistoryId)
        {
            EventHistory eventHistory = _context.EventsHistoriesContext.Find(eventHistoryId);

            _context.EventsHistoriesContext.Remove(eventHistory);
        }
예제 #34
0
 private void UpdateReaderList(IEnumerable <string> readerNames)
 {
     Readers.ClearOnScheduler();
     EventHistory.ClearOnScheduler();
     Readers.AddRangeOnScheduler(readerNames);
 }
예제 #35
0
 private void AddEventHistory(EventHistory eventHistory) =>
 this.EventHistories.Add(eventHistory);
 public void OnBluetoothDeInitialized()
 {
     EventHistory.Add(new WristbandHistoryEvent("OnBluetoothDeInitialized", false));
 }
 public void OnError(WristbandProtocolError error, string info)
 {
     EventHistory.Add(new WristbandHistoryEvent("OnError > " + info, true));
 }
 public void OnWristbandDebugMessage(string msg)
 {
     EventHistory.Add(new WristbandHistoryEvent("OnWristbandDebugMessage > " + msg, false));
 }
예제 #39
0
 public static void ArchiveEvents()
 {
     EventHistory.Add(TodaysEvents);
     TodaysEvents = new List <Event>();
 }
 public void OnWristbandConnected(string pheriperalID, string pheriperalName, WristbandProfile profile)
 {
     EventHistory.Add(new WristbandHistoryEvent("OnWristbandConnected > name:" + pheriperalName + ", id:" + pheriperalID + ", profile: " + profile.description.ToString(), false));
 }
예제 #41
0
 private void OnError(Exception exception)
 {
     Debug.Print(exception.Message);
     Readers.Clear();
     EventHistory.Clear();
 }
 public void OnWristbandDisconnected()
 {
     EventHistory.Add(new WristbandHistoryEvent("OnWristbandDisconnected", false));
 }
예제 #43
0
 public async Task PostAsync(EventHistory _event)
 {
     _unitOfWork.GetRepoInstance <EventHistory>().Insert(_event);
     await _unitOfWork.saveAsync();
 }
예제 #44
0
        /// <summary>
        /// Creates a new Engine object.
        /// </summary>
        /// <param name="createdOnForeground">bool for indication if the engine works on foreground.</param>
        public SdkEngine(bool createdOnForeground)
        {
            ServiceManager.Clear();
            ServiceManager.ApiConnction = new ApiConnection();
            ServiceManager.BeaconScanner = new Scanner() {DisableFilter = true};
            ServiceManager.LayoutManager = new LayoutManager();
            ServiceManager.StorageService = new StorageService(createdOnForeground);
            ServiceManager.SettingsManager = new SettingsManager();
            ServiceManager.LocationService = _locationService = new LocationService();
            ServiceManager.WriterFactory = new WriterFactory();

            _appIsOnForeground = createdOnForeground;
            Resolver = new Resolver(!createdOnForeground) {EventHistory = _eventHistory = new EventHistory()};
            _nextTimeToProcessDelayedActions = DateTimeOffset.MaxValue;
        }