Esempio n. 1
0
        private static HistoricalEvents FormatHistoricalEvents(DataTable dbReturn)
        {
            try
            {
                var reformat = new HistoricalEvents
                {
                    UrlQuery       = Convert.ToString(dbReturn.Rows[0].ItemArray[0]),
                    IpQuery        = Convert.ToString(dbReturn.Rows[0].ItemArray[1]),
                    HashQuery      = Convert.ToString(dbReturn.Rows[0].ItemArray[2]),
                    UrlScore       = Convert.ToInt32(dbReturn.Rows[0].ItemArray[3]),
                    IpScore        = Convert.ToInt32(dbReturn.Rows[0].ItemArray[4]),
                    HashScore      = Convert.ToInt32(dbReturn.Rows[0].ItemArray[5]),
                    UrlWeight      = Convert.ToInt32(dbReturn.Rows[0].ItemArray[6]),
                    IpWeight       = Convert.ToInt32(dbReturn.Rows[0].ItemArray[7]),
                    HashWeight     = Convert.ToInt32(dbReturn.Rows[0].ItemArray[8]),
                    UrlIncrement   = Convert.ToInt32(dbReturn.Rows[0].ItemArray[9]),
                    IpIncrement    = Convert.ToInt32(dbReturn.Rows[0].ItemArray[10]),
                    HashIncrement  = Convert.ToInt32(dbReturn.Rows[0].ItemArray[11]),
                    UrlMultiplier  = Convert.ToInt32(dbReturn.Rows[0].ItemArray[12]),
                    IpMultiplier   = Convert.ToInt32(dbReturn.Rows[0].ItemArray[13]),
                    HashMultiplier = Convert.ToInt32(dbReturn.Rows[0].ItemArray[14])
                };

                return(reformat);
            }
            catch (Exception e)
            {
                Fido_EventHandler.SendEmail("Fido Error", "Fido Failed: {0} Unable to format historical event alerts return." + e);
            }
            return(null);
        }
Esempio n. 2
0
 private void GivenWeHaveDeletedTheProject()
 {
     HistoricalEvents.Add(new ProjectDeleted(UserId, _projectId, DateTime.UtcNow)
     {
         Version = HistoricalEvents.Count
     });
 }
Esempio n. 3
0
 private void GivenWeHaveCreatedTheSystem()
 {
     HistoricalEvents.Add(new EvelynEvent.SystemCreated(UserId, Constants.EvelynSystem, DateTimeOffset.UtcNow)
     {
         Version = HistoricalEvents.Count
     });
 }
Esempio n. 4
0
 private void GivenWeHaveRegisteredAnAccount()
 {
     HistoricalEvents.Add(new EvelynEvent.AccountRegistered(UserId, Constants.EvelynSystem, _accountId, DateTimeOffset.UtcNow)
     {
         Version = HistoricalEvents.Count
     });
 }
Esempio n. 5
0
 private void GivenWeHaveDeletedTheProject()
 {
     HistoricalEvents.Add(new ProjectDeleted(UserId, _projectId, DateTimeOffset.UtcNow)
     {
         Version = _projectEventCount
     });
     _projectEventCount++;
     _projectLastModifiedVersion = _projectEventCount - 1;
 }
Esempio n. 6
0
        protected void GivenWeHaveCreatedAProjectWith(Guid id)
        {
            var projectCreated = DataFixture.Create <ProjectCreated>();

            projectCreated.Id      = id;
            projectCreated.Version = HistoricalEvents.Count;

            HistoricalEvents.Add(projectCreated);
        }
Esempio n. 7
0
 private void GivenWeHaveAddedAnotherEnvironment()
 {
     _environment2Key = DataFixture.Create <string>();
     HistoricalEvents.Add(new EnvironmentAdded(UserId, _projectId, _environment2Key, DataFixture.Create <string>(), DateTimeOffset.UtcNow)
     {
         Version = HistoricalEvents.Count
     });
     _environment2Version = HistoricalEvents.Count - 1;
 }
Esempio n. 8
0
        protected void GivenWeHaveAddedAnEnvironmentWith(Guid projectedId, string environmentKey)
        {
            var environmentAdded = DataFixture.Create <EnvironmentAdded>();

            environmentAdded.Id      = projectedId;
            environmentAdded.Key     = environmentKey;
            environmentAdded.Version = HistoricalEvents.Count;

            HistoricalEvents.Add(environmentAdded);
        }
Esempio n. 9
0
        private void GivenWeHaveAlreadyCreatedAProject()
        {
            _existingProjectId = DataFixture.Create <Guid>();

            HistoricalEvents.Add(new AccountEvent.ProjectCreated(UserId, _accountId, _existingProjectId, DateTime.UtcNow)
            {
                Version = HistoricalEvents.Count
            });
            _accountVersion++;
        }
Esempio n. 10
0
        private void GivenWeHaveRegisteredAnAccount()
        {
            _accountId = DataFixture.Create <Guid>();

            HistoricalEvents.Add(new Core.WriteModel.Account.Events.AccountRegistered(UserId, _accountId, DateTimeOffset.UtcNow)
            {
                Version = _accountEventCount
            });
            _accountEventCount++;
        }
Esempio n. 11
0
        private void GivenWeHaveChangedTheToggleState()
        {
            UserId          = DataFixture.Create <string>();
            _newToggleValue = DataFixture.Create <bool>().ToString();

            HistoricalEvents.Add(new ToggleStateChanged(UserId, _projectId, _environmentKey, _toggleKey, _newToggleValue, DateTimeOffset.UtcNow)
            {
                Version = HistoricalEvents.Count
            });
            _toggleStateVersion = HistoricalEvents.Count - 1;
        }
Esempio n. 12
0
        private void GivenWeHaveAddedAToggleToTheProject()
        {
            _toggleKey  = DataFixture.Create <string>();
            _toggleName = DataFixture.Create <string>();

            HistoricalEvents.Add(new ToggleAdded(UserId, _projectId, _toggleKey, _toggleName, DateTime.UtcNow)
            {
                Version = HistoricalEvents.Count
            });
            _projectVersion++;
        }
Esempio n. 13
0
        private void GivenWeHaveAddedAToggle()
        {
            _existingToggleKey  = DataFixture.Create <string>();
            _existingToggleName = DataFixture.Create <string>();

            HistoricalEvents.Add(new ToggleAdded(UserId, _projectId, _existingToggleKey, _existingToggleName, DateTimeOffset.UtcNow)
            {
                Version = HistoricalEvents.Count
            });
            _projectVersion = HistoricalEvents.Count - 1;
        }
Esempio n. 14
0
        private void GivenWeHaveAddedAnEnvironment()
        {
            _existingEnvironmentKey  = DataFixture.Create <string>();
            _existingEnvironmentName = DataFixture.Create <string>();

            HistoricalEvents.Add(new EnvironmentAdded(UserId, _projectId, _existingEnvironmentKey, _existingEnvironmentName, DateTime.UtcNow)
            {
                Version = HistoricalEvents.Count
            });
            _projectVersion++;
        }
Esempio n. 15
0
        public void GetOngoingEvents(int millisecondsToSleep)
        {
            //read time interval for catching up from database or app.config
            //calculate minutes (buckets) of data to process via calls to New Relic API
            var timeIntervals = 1.0D;

            //issue a http request for each timeInterval to New Relic API
            var apiKeyType  = 2;
            var apiEndpoint = _apiEndPointService.GetEndPoint(apiKeyType);

            if (timeIntervals > 0)
            {
                for (double x = 1; x <= timeIntervals; x++)
                {
                    var nRsqlQuery          = string.Format(apiEndpoint.NRSQLSyntax, x, QUERYLIMIT);
                    var newRelicHttpRequest = new NewRelicHttpRequest(apiEndpoint, new RootObject(),
                                                                      nRsqlQuery);
                    var interval = Convert.ToInt32(Math.Floor(timeIntervals));
                    newRelicHttpRequest.RootObject =
                        _newRelicService.GetTransactionsSinceLastInterval(new TimeSpan(0, interval, 0), QUERYLIMIT);
                    //calculate hashed value for each returned set of data
                    var didGenerateHashByteValue = newRelicHttpRequest.RootObject.IterateOverEventExecutingAction <Event>
                                                       ((e) => { e.HashedByteValue = e.GenerateHashedByteValue(_hashingAlgorithm); });
                    //store values to database
                    if (didGenerateHashByteValue && newRelicHttpRequest?.RootObject != null)
                    {
                        //weed out duplicate events within rootobject
                        WeedOutDuplicateEvents(HistoricalEvents, newRelicHttpRequest.RootObject);

                        //save rootobject to database
                        var rootObject = _rootObjectService.SaveRootObject(newRelicHttpRequest.RootObject);

                        //add events to HistoricalEvents
                        var listOfNewEvents = newRelicHttpRequest?.RootObject?.results?.First()?.events?.ToList();
                        if (listOfNewEvents != null)
                        {
                            foreach (var eventObj in listOfNewEvents)
                            {
                                if (!HistoricalEvents.Contains(eventObj))
                                {
                                    HistoricalEvents.Add(eventObj);
                                }
                            }
                            Console.WriteLine("Added {0} events.", listOfNewEvents.Count);
                        }
                    }
                }
            }
            Console.WriteLine("ImportProcess.GetOngoingEvents() completed for {0} intervals.", timeIntervals);
        }
Esempio n. 16
0
        protected void GivenWeHaveAddedAnEnvironmentStateWith(Guid projectId, string environmentKey, int version, IEnumerable <KeyValuePair <string, string> > toggleStates = null)
        {
            var environmentStateAdded = new EnvironmentStateAdded(
                DataFixture.Create <string>(),
                projectId,
                environmentKey,
                DateTime.UtcNow,
                toggleStates)
            {
                Version = version
            };

            HistoricalEvents.Add(environmentStateAdded);
        }
Esempio n. 17
0
        private void GivenWeHaveCreatedAProject()
        {
            _projectId = DataFixture.Create <Guid>();

            HistoricalEvents.Add(new Core.WriteModel.Account.Events.ProjectCreated(UserId, _accountId, _projectId, DateTimeOffset.UtcNow)
            {
                Version = _accountEventCount
            });
            _accountEventCount++;

            GivenWeHaveCreatedAProjectWith(_projectId, _projectEventCount);
            _projectEventCount++;
            _projectLastModifiedVersion = _projectEventCount - 1;
        }