示例#1
0
        public void MapEvent_DTO_EffectiveAuthorizationRevoked_Returns_Domain_EffectiveAuthorizationRevoked_With_Valid_Values()
        {
            //Arrange
            var dtoEffectiveAuthorizationRevokedEvent = new EffectiveAuthorizationRevokedEvent();

            dtoEffectiveAuthorizationRevokedEvent.EffectiveAuthorization = new EffectiveAuthorization(string1, new ExternalId(string2, string3), new Permission(string4, string5, string6), new ExternalId(string7, string8));
            dtoEffectiveAuthorizationRevokedEvent.UntilDateTime          = referenceDateTime;

            //Act
            var domainEffectiveAuthorizationRevokedEvent = DomainAdapter.MapEvent(dtoEffectiveAuthorizationRevokedEvent);

            //Assert
            Assert.IsNotNull(domainEffectiveAuthorizationRevokedEvent);
            Assert.IsNotNull(domainEffectiveAuthorizationRevokedEvent.EffectiveAuthorization);

            Assert.AreEqual(dtoEffectiveAuthorizationRevokedEvent.UntilDateTime, domainEffectiveAuthorizationRevokedEvent.Until);

            Assert.AreEqual(dtoEffectiveAuthorizationRevokedEvent.EffectiveAuthorization.TenantId, domainEffectiveAuthorizationRevokedEvent.EffectiveAuthorization.TenantId);

            Assert.AreEqual(dtoEffectiveAuthorizationRevokedEvent.EffectiveAuthorization.Permission.Application, domainEffectiveAuthorizationRevokedEvent.EffectiveAuthorization.Permission.Application);
            Assert.AreEqual(dtoEffectiveAuthorizationRevokedEvent.EffectiveAuthorization.Permission.Description, domainEffectiveAuthorizationRevokedEvent.EffectiveAuthorization.Permission.Description);
            Assert.AreEqual(dtoEffectiveAuthorizationRevokedEvent.EffectiveAuthorization.Permission.Id, domainEffectiveAuthorizationRevokedEvent.EffectiveAuthorization.Permission.Id);

            Assert.AreEqual(dtoEffectiveAuthorizationRevokedEvent.EffectiveAuthorization.Target.Context, domainEffectiveAuthorizationRevokedEvent.EffectiveAuthorization.Target.Context);
            Assert.AreEqual(dtoEffectiveAuthorizationRevokedEvent.EffectiveAuthorization.Target.Id, domainEffectiveAuthorizationRevokedEvent.EffectiveAuthorization.Target.Id);

            Assert.AreEqual(dtoEffectiveAuthorizationRevokedEvent.EffectiveAuthorization.User.Context, domainEffectiveAuthorizationRevokedEvent.EffectiveAuthorization.User.Context);
            Assert.AreEqual(dtoEffectiveAuthorizationRevokedEvent.EffectiveAuthorization.User.Id, domainEffectiveAuthorizationRevokedEvent.EffectiveAuthorization.User.Id);
        }
示例#2
0
        public void MapEffectiveAuthorization_DTO_With_Target_Returns_Domain_EffectiveAuthorization_With_Valid_Values()
        {
            //Arrange
            var dtoEffectiveAuthorization = new EffectiveAuthorization(string1, new ExternalId(string2, string3), new Permission(string4, string5, string6), new ExternalId(string7, string8));

            //Act
            var domainEffectiveAuthorization = DomainAdapter.MapEffectiveAuthorization(dtoEffectiveAuthorization);

            //Assert
            Assert.IsNotNull(domainEffectiveAuthorization);
            Assert.IsNotNull(domainEffectiveAuthorization.Permission);
            Assert.IsNotNull(domainEffectiveAuthorization.User);
            Assert.IsNotNull(domainEffectiveAuthorization.Target);

            Assert.AreEqual(string1, domainEffectiveAuthorization.TenantId);

            Assert.AreEqual(dtoEffectiveAuthorization.Permission.Application, domainEffectiveAuthorization.Permission.Application);
            Assert.AreEqual(dtoEffectiveAuthorization.Permission.Description, domainEffectiveAuthorization.Permission.Description);
            Assert.AreEqual(dtoEffectiveAuthorization.Permission.Id, domainEffectiveAuthorization.Permission.Id);

            Assert.AreEqual(dtoEffectiveAuthorization.Target.Context, domainEffectiveAuthorization.Target.Context);
            Assert.AreEqual(dtoEffectiveAuthorization.Target.Id, domainEffectiveAuthorization.Target.Id);

            Assert.AreEqual(dtoEffectiveAuthorization.User.Context, domainEffectiveAuthorization.User.Context);
            Assert.AreEqual(dtoEffectiveAuthorization.User.Id, domainEffectiveAuthorization.User.Id);
        }
示例#3
0
        public JsonResult UpdateWorkhours(string data)
        {
            List <UpdateWorksInfo> list = JsonConvert.DeserializeObject <List <UpdateWorksInfo> >(data);
            string info = DomainAdapter.UpdateWorkHoursInfo(list);

            return(Json(info, JsonRequestBehavior.AllowGet));
        }
示例#4
0
        public object Evaluate(DomainAdapter theFixture, CellProcessor processor) {
            cells.ValueAt(0).SetAttribute(CellAttribute.Syntax, CellAttributeValue.SyntaxKeyword);

            var cellCount = cells.Branches.Count;
            if (cellCount < 2) throw MakeException("missing cells");
            var identifier = cells.ValueAt(1).Text;
            if (newIdentifier.Equals(identifier)) {
                cells.ValueAt(1).SetAttribute(CellAttribute.Syntax, CellAttributeValue.SyntaxKeyword);
                return new MethodPhrase(cells.Skip(1)).EvaluateNew(processor);
            }
            if (typeIdentifier.Equals(identifier)) {
                cells.ValueAt(1).SetAttribute(CellAttribute.Syntax, CellAttributeValue.SyntaxKeyword);
                if (cellCount < 3) throw MakeException("missing cells");
                cells.ValueAt(2).SetAttribute(CellAttribute.Syntax, CellAttributeValue.SyntaxSUT);
                return processor.ParseTree(typeof (Type), cells.Branches[2]).Value;
            }
            if (currentIdentifier.Equals(identifier)) {
                cells.ValueAt(1).SetAttribute(CellAttribute.Syntax, CellAttributeValue.SyntaxKeyword);
                return theFixture.SystemUnderTest;
            }
            var fixture = theFixture as FlowInterpreter;
            if (fixture == null) throw MakeException("flow fixture required");

            return processor.Get<Symbols>().HasValue(identifier)
                ? processor.Get<Symbols>().GetValue(identifier)
                : fixture.ExecuteFlowRowMethod(processor, cells);
        }
示例#5
0
        public async Task <IActionResult> LogEffectiveAutorizationRevokedEvent([FromBody] EffectiveAuthorizationRevokedEvent eAEvent)
        {
            var innerEvent = DomainAdapter.MapEvent(eAEvent);

            var id = await _effectiveAuthorizationLogging.AddAuthLogAsync(innerEvent);

            eAEvent.SetId(id);

            return(Created("EffectiveAuthorizationRevoked", eAEvent));
        }
示例#6
0
        public JsonResult JsonForHandson()
        {
            List <StaffWorkHoursInfo> list = new List <StaffWorkHoursInfo>();

            for (int i = -4; i < 4; i++)
            {
                list.AddRange(DomainAdapter.getWorkHoursForAll(DateTime.Now.AddDays(i * -7)));
            }
            string[][] res = listFormater(list);
            return(Json(res, JsonRequestBehavior.AllowGet));
        }
示例#7
0
        static void Main(string[] args)
        {
            

            DomainAdapter da = new DomainAdapter(@"C:\Test",
                "TEST", new DomainArgs { Compiler=true, UpdateWatch= true, WatchFilter=new string[]{"*.cs"} });
            da.Log = new ConsoleEventLogImpl();
            da.Load();
          
            Console.Read();
        }
示例#8
0
        static void Main(string[] args)
        {
            DomainAdapter da = new DomainAdapter(@"C:\Test",
                                                 "TEST", new DomainArgs {
                Compiler = true, UpdateWatch = true, WatchFilter = new string[] { "*.cs" }
            });

            da.Log = new ConsoleEventLogImpl();
            da.Load();

            Console.Read();
        }
示例#9
0
        public DomainAdapter AddDomain(string name, string path, bool updateWatch, string[] filter, bool compiler)
        {
            DomainAdapter domainAdapter = new DomainAdapter(path, name, new DomainArgs
            {
                Compiler    = compiler,
                WatchFilter = filter,
                UpdateWatch = updateWatch
            });

            this.mDomains.Add(domainAdapter);
            return(domainAdapter);
        }
示例#10
0
        public void MapExternalId_Returns_Domain_ExternalId_With_Valid_Values()
        {
            //Arrange
            var dtoExternalId = new ExternalId(string1, string2);

            //Act
            var domainExternalId = DomainAdapter.MapExternalId(dtoExternalId);

            //Assert
            Assert.IsNotNull(domainExternalId);
            Assert.AreEqual(dtoExternalId.Id, domainExternalId.Id);
            Assert.AreEqual(dtoExternalId.Context, domainExternalId.Context);
        }
示例#11
0
        public void MapPermission_Returns_Domain_Permission_With_Valid_Values()
        {
            //Arrange
            var dtoPermission = new Permission(string1, string2, string3);

            //Act
            var domainPermission = DomainAdapter.MapPermission(dtoPermission);

            //Assert
            Assert.IsNotNull(domainPermission);
            Assert.AreEqual(dtoPermission.Application, domainPermission.Application);
            Assert.AreEqual(dtoPermission.Description, domainPermission.Description);
            Assert.AreEqual(dtoPermission.Id, domainPermission.Id);
        }
        public async Task <GenerateReport> InsertAndTriggerGenerateReport(ReportingEvent reportingEventDto)
        {
            var reportingEvent = DomainAdapter.MapReportingEvent(reportingEventDto);

            _logger.LogInformation("Inserting record to the FileInformation Table");
            await _fileInformationRepository.UpdateRecord(FileInformation.Get(reportingEvent, new Uri("https://raetgdprtbldev.blob.core.windows.net"), "HashProcessing", "Processing"));

            string message = JsonConvert.SerializeObject(reportingEvent);

            _logger.LogInformation("Adding message to report-file-queue");
            _azureQueueStorageRepository.AddAsync(message);
            return(new GenerateReport()
            {
                FileName = reportingEvent.FileName, Guid = reportingEvent.Guid
            });
        }
示例#13
0
        public JsonResult WorkHoursForDay(string day, string type)
        {
            DateTime dt = DateTime.Parse(day);

            switch (type)
            {
            case "last":
                var res = DomainAdapter.getWorkHoursForAll(dt.AddDays(-7));
                return(Json(res, JsonRequestBehavior.AllowGet));

            case "next":
                res = DomainAdapter.getWorkHoursForAll(dt.AddDays(7));
                return(Json(res, JsonRequestBehavior.AllowGet));

            default:
                return(Json(""));
            }
        }
        public object Evaluate(DomainAdapter theFixture, CellProcessor processor)
        {
            cells.ValueAt(0).SetAttribute(CellAttribute.Syntax, CellAttributeValue.SyntaxKeyword);

            var cellCount = cells.Branches.Count;

            if (cellCount < 2)
            {
                throw MakeException("missing cells");
            }
            var identifier = cells.ValueAt(1).Text;

            if (newIdentifier.Equals(identifier))
            {
                cells.ValueAt(1).SetAttribute(CellAttribute.Syntax, CellAttributeValue.SyntaxKeyword);
                return(new MethodPhrase(cells.Skip(1)).EvaluateNew(processor));
            }
            if (typeIdentifier.Equals(identifier))
            {
                cells.ValueAt(1).SetAttribute(CellAttribute.Syntax, CellAttributeValue.SyntaxKeyword);
                if (cellCount < 3)
                {
                    throw MakeException("missing cells");
                }
                cells.ValueAt(2).SetAttribute(CellAttribute.Syntax, CellAttributeValue.SyntaxSUT);
                return(processor.ParseTree(typeof(Type), cells.Branches[2]).Value);
            }
            if (currentIdentifier.Equals(identifier))
            {
                cells.ValueAt(1).SetAttribute(CellAttribute.Syntax, CellAttributeValue.SyntaxKeyword);
                return(theFixture.SystemUnderTest);
            }
            var fixture = theFixture as FlowInterpreter;

            if (fixture == null)
            {
                throw MakeException("flow fixture required");
            }

            return(processor.Get <Symbols>().HasValue(identifier)
                ? processor.Get <Symbols>().GetValue(identifier)
                : fixture.ExecuteFlowRowMethod(processor, cells));
        }
        public async Task Process(string fileUrl)
        {
            var allTasks  = new List <Task>();
            var semaphore = new SemaphoreSlim(10, 10);
            var filecount = 0;
            var data      = await _azureBlobStorageRepository.FetchFileAsync(fileUrl);

            var events = Serializer.Deserialize <List <DTOs.EffectiveAuthorizationGrantedEvent> >(data);

            _logger.LogInformation($"Process Start Time {DateTime.Now}");
            events.ForEach(async(eventData) =>
            {
                var mapEventData    = DomainAdapter.MapEvent(eventData);
                var serlializedJson = "";
                await semaphore.WaitAsync();
                allTasks.Add(
                    Task.Run(async() =>
                {
                    try
                    {
                        Interlocked.Increment(ref filecount);
                        await _writeRawEventStorage.WriteRawEventAsync(mapEventData);
                        serlializedJson = JsonConvert.SerializeObject(mapEventData);
                        _dataEnrichmentBusiness.Process(serlializedJson.ToString());
                        _logger.LogInformation($"Data Enrichment Count : {filecount}");
                    }
                    catch (Exception ex)
                    {
                        _logger.LogError($"The Initial Load Failed due to : {ex.ToString()}");
                        _logger.LogError($"The failed Event Data is : {eventData.EffectiveAuthorization},{eventData.FromDateTime},{eventData.Id}");
                    }
                    finally
                    {
                        semaphore.Release();
                        _logger.LogInformation($"Released in finally");
                    }
                }));
            });
            await Task.WhenAll(allTasks);

            _logger.LogInformation($"Data Enrichment Completed");
            _logger.LogInformation($"Process End Time {DateTime.Now}");
        }
示例#16
0
        public void LoadConfig(string config = "containerSection")
        {
            this.mSectionName = config;
            string           pattern       = "^([^\\\\]+)$";
            ContainerSection configSection = this.GetConfigSection();

            if (configSection != null)
            {
                foreach (DomainConf domainConf in configSection.Domains)
                {
                    string text = domainConf.Path;
                    if (Regex.IsMatch(text, pattern))
                    {
                        text = AppDomain.CurrentDomain.BaseDirectory + text;
                    }
                    if (!Directory.Exists(text))
                    {
                        if (this.Log != null)
                        {
                            this.Log.Error("<{1}> domain {0} path notfound!", new object[]
                            {
                                text,
                                domainConf.Name
                            });
                        }
                    }
                    else
                    {
                        DomainAdapter domainAdapter = this.AddDomain(domainConf.Name, text, domainConf.UpdateWatch, domainConf.WatchFilter.Split(new char[]
                        {
                            '|'
                        }), domainConf.Compiler);
                        domainAdapter["config"] = domainConf;
                    }
                }
            }
        }
示例#17
0
        public void Reload()
        {
            if (this.Log != null)
            {
                this.Log.Info("reload domain container ...");
            }
            string           pattern       = "^([^\\\\]+)$";
            ContainerSection configSection = this.GetConfigSection();

            if (configSection != null)
            {
                IEnumerator enumerator = configSection.Domains.GetEnumerator();
                try
                {
                    DomainConf conf;
                    while (enumerator.MoveNext())
                    {
                        conf = (DomainConf)enumerator.Current;
                        string text = conf.Path;
                        if (Regex.IsMatch(text, pattern))
                        {
                            text = AppDomain.CurrentDomain.BaseDirectory + text;
                        }
                        DomainAdapter domainAdapter = this.mDomains.Find((DomainAdapter i) => i.AppName == conf.Name);
                        if (domainAdapter != null)
                        {
                            DomainConf domainConf = (DomainConf)domainAdapter["config"];
                            if (conf.Path != domainConf.Path || conf.Compiler != domainConf.Compiler || conf.UpdateWatch != domainConf.UpdateWatch || conf.WatchFilter != domainConf.WatchFilter)
                            {
                                domainAdapter.UnLoad();
                                this.mDomains.Remove(domainAdapter);
                                domainAdapter = null;
                            }
                        }
                        if (!Directory.Exists(text))
                        {
                            if (this.Log != null)
                            {
                                this.Log.Error("<{1}> domain {0} path notfound!", new object[]
                                {
                                    text,
                                    conf.Name
                                });
                            }
                        }
                        else
                        {
                            if (domainAdapter == null)
                            {
                                if (this.Log != null)
                                {
                                    this.Log.Info("load <{0}> domain.", new object[]
                                    {
                                        conf.Name
                                    });
                                }
                                domainAdapter = this.AddDomain(conf.Name, text, conf.UpdateWatch, conf.WatchFilter.Split(new char[]
                                {
                                    '|'
                                }), conf.Compiler);
                                domainAdapter.Log = this.Log;
                                domainAdapter.Load();
                                domainAdapter["config"] = conf;
                            }
                        }
                    }
                }
                finally
                {
                    IDisposable disposable = enumerator as IDisposable;
                    if (disposable != null)
                    {
                        disposable.Dispose();
                    }
                }
            }
        }