public SearchController(IDependencyInjector di) :
     base(di,
          di.GetInstance <IAzureSearch <RegisterPersonModel> >(),
          di.GetInstance <IAzureSearch <RegisterBusinessModel> >(),
          di.GetInstance <IPersonFilterManager>(),
          di.GetInstance <IBusinessFilterManager>(),
          di.GetInstance <IFamilyProvider>(),
          "(isInPreg or isInHpr or isInFlr)", new[] { "nin", "hprNrStr", "hprName", "pregName", "difiEmail", "difiPhoneNumber" }, surveillanceSearchOrderBy: new [] { "pregName", "hprName" })
 {
 }
        protected void Application_Stop()
        {
            var logger = _di.GetInstance <ILog>();
            var id     = Guid.NewGuid().ToString();

            logger.Debug($"[{id}] Hodor-Web: Shutdown requested");
            logger.Debug($"[{id}] Hodor-Web: Closing connections");
        }
Пример #3
0
        private static async Task <IJsonStorage <LatestSurveillanceResult> > GetLatestResultForMyTeam(Team project, IDependencyInjector di)
        {
            var mockedDb = new JsonStorageDictionaryDb <LatestSurveillanceResult>();

            (await LatestSurveillanceResult.GetLatestSurveillanceResult(project, di.GetInstance <IJsonStorage <LatestSurveillanceResult> >()))
            .ToList()
            .ForEach(element => mockedDb.Post(element));

            return(mockedDb);
        }
Пример #4
0
        public static async Task <IEnumerable <Surveillance> > GetPossibleSurveillances(Team teamForLoggedInUser, Hit hit, IDependencyInjector di, IJsonStorage <LatestSurveillanceResult> surveilResultDb)
        {
            var surveilDb = di.GetInstance <ITableStorageDb <SurveilledItem> >();

            var result = new List <Surveillance>();
            var surveillanceActions = di.GetAllInstancesOf <ISurveillanceAction>();

            foreach (var isurveillance in surveillanceActions.Where(s => s.ApplicableForHit(hit)))
            {
                var s = await GetSurveillance(hit, isurveillance, teamForLoggedInUser, surveilDb, surveilResultDb);

                result.Add(s);
            }

            return(result);
        }
        public object GetService(Type serviceType)
        {
            try
            {
                if (IgnoreThese.Contains(serviceType.Name))
                {
                    return(null);
                }

                return(Di.GetInstance(serviceType));
            }
            catch (ResolutionFailedException)
            {
                return(null);
            }
        }
Пример #6
0
 protected BaseExecuteTestStep(IDependencyInjector injector)
 {
     _injector = injector;
     Log       = injector.GetInstance <ILog>();
 }
 public IConstantsProvider GetConstantsProvider() => Di.GetInstance <IConstantsProvider>();
 public FilterController(IDependencyInjector di) : base(di)
 {
     _personFilterManager   = di.GetInstance <IPersonFilterManager>();
     _businessFilterManager = di.GetInstance <IBusinessFilterManager>();
     _queryDb = di.GetInstance <IJsonStorage <SearchQuery> >();
 }
 public DetailsController(IDependencyInjector di) : base(di)
 {
     _detailsProvider = di.GetInstance <IDetailsProvider>();
 }
Пример #10
0
 public static List <SurveilledItem> GetAllSurveillanceItems(IDependencyInjector di)
 {
     return(GetAllSurveillanceItems(di.GetInstance <ITableStorageDb <SurveilledItem> >(), di.GetAllInstancesOf <ISurveillanceAction>()));
 }
Пример #11
0
 public SurveillanceController(IDependencyInjector di) : base(di, di.GetInstance <IAzureSearch <RegisterPersonModel> >(), di.GetInstance <IJsonStorage <BuildIndexComplete> >())
 {
 }
Пример #12
0
        public async Task <bool> DoAsync(QueueItem msg, ILog logger)
        {
            var    simpleQMsg = JsonConvert.DeserializeObject <Tuple <string, string> >(msg.GetContentAsJson());
            string partitionKey, rowKey;

            SurveilledItem.ParsePartitionkeyAndRowkey(simpleQMsg, out partitionKey, out rowKey);

            var suveillanceItem = await _di.GetInstance <ITableStorageDb <SurveilledItem> >().GetAsync(partitionKey, rowKey);

            if (suveillanceItem == null)
            {
                logger.Error($"Tried to find surveillanceitem with partitionkey={partitionKey} and rowkey={rowKey}, but couldnt find it");
                return(true);
            }
            var surveillanceAction = TryGetSurveillanceAction(suveillanceItem, logger);

            if (surveillanceAction == null)
            {
                return(true);
            }

            Impersonate(suveillanceItem.RegisteredByUsername, logger);

            var surveillanceResult = await surveillanceAction.Check(suveillanceItem, _di);

            if (surveillanceResult == null)
            {
                return(true);
            }

            //fixing commonidentifier on old objects. can remove this code in the future
            if (string.IsNullOrEmpty(suveillanceItem.CommonIdentifier) && !string.IsNullOrEmpty(surveillanceResult.CommonIdentifier))
            {
                try
                {
                    suveillanceItem.CommonIdentifier = surveillanceResult.CommonIdentifier;
                    await _di.GetInstance <ITableStorageDb <SurveilledItem> >().InsertAsync(suveillanceItem, true, true);
                }
                catch (Exception e)
                {
                    logger.Warn("Fail when linking surveillance to suveillanceItem. suveillanceItem: " + JsonConvert.SerializeObject(surveillanceResult), e);
                }
            }

            var msgResult = surveillanceResult.Success
                ? "Surveillanceresult was successfull. Found no deviation"
                : "Surveillanceresult failed. Text: " + surveillanceResult.ErrorText + Environment.NewLine + "Compared object: " + suveillanceItem.ContentAsJson + " with " + surveillanceResult.ContentAsJson;

            logger.Info(msgResult);

            var latestResult = new LatestSurveillanceResult()
            {
                ActionKey = surveillanceResult.ActionKey,
                ActionInstanceIdentifier = surveillanceResult.ActionInstanceIdentifier,
                Id                     = surveillanceResult.Id,
                ContentAsJson          = surveillanceResult.ContentAsJson,
                TeamProjectInt         = surveillanceResult.TeamProjectInt,
                CheckedAt              = surveillanceResult.CheckedAt,
                ErrorText              = surveillanceResult.ErrorText,
                RegisterEnvironmentInt = surveillanceResult.RegisterEnvironmentInt,
                RegisteredBy           = surveillanceResult.RegisteredBy,
                Success                = surveillanceResult.Success
            };

            if (PostResults)
            {
                await _di.GetInstance <IJsonStorage <SurveillanceResult> >().Post(surveillanceResult);

                return(await _di.GetInstance <IJsonStorage <LatestSurveillanceResult> >().Put(latestResult));
            }

            return(true);
        }
Пример #13
0
 public TagController(IDependencyInjector di) : base(di, di.GetInstance <IAzureSearch <RegisterPersonModel> >(), di.GetInstance <IAzureSearch <RegisterBusinessModel> >())
 {
 }