Exemple #1
0
        private HomeConfigs FetchConfigs()
        {
            var logoIcon           = _facade.Lookup <string>(ConfigurationConstants.MainIconKey);
            var myProfileEnabled   = _facade.Lookup <Boolean>(ConfigurationConstants.MyProfileEnabled);
            var clientSideLogLevel = _facade.Lookup <string>(ConfigurationConstants.ClientSideLogLevel);

            return(new HomeConfigs()
            {
                Logo = logoIcon,
                AllowedFileTypes = ApplicationConfiguration.AllowedFilesExtensions,
                MyProfileEnabled = myProfileEnabled,
                I18NRequired = MetadataProvider.GlobalProperties.I18NRequired(),
                ClientName = ApplicationConfiguration.ClientName,
                Environment = ApplicationConfiguration.Profile,
                IsLocal = ApplicationConfiguration.IsLocal(),
                ClientSideLogLevel = clientSideLogLevel,
                SuccessMessageTimeOut = GetSuccessMessageTimeOut(),
                InitTimeMillis = ApplicationConfiguration.SystemBuildDateInMillis
            });
        }
        public override void ExecuteJob()
        {
            var lowerRowstamp = ConfigFacade.Lookup <long>(ConfigurationConstants.R0042Rowstamp);
            var now           = DateTime.Now;

            now = new DateTime(now.Year, now.Month, 1);
            var lastMonth = DateUtil.BeginOfDay(now.AddMonths(-1));


            var beginOfMonth   = DateUtil.BeginOfDay(now);
            var compMetadata   = MetadataProvider.Application("asset");
            var schema         = compMetadata.Schemas()[new ApplicationMetadataSchemaKey("R0042Export")];
            var slicedMetadata = MetadataProvider.SlicedEntityMetadata(schema.GetSchemaKey(), "asset");
            var dto            = new PaginatedSearchRequestDto {
                PageSize = PageSize
            };

            var needsMore   = true;
            var initOfBatch = true;
            var i           = 1;

            while (needsMore)
            {
                Log.InfoFormat("R0042: fetching first {0} items restricted to rowstamp {1}".Fmt(i * PageSize, lowerRowstamp));
                var searchEntityResult          = FetchMore(dto, lastMonth, slicedMetadata, lowerRowstamp, initOfBatch);
                IList <R0042AssetHistory> items = ConvertItems(searchEntityResult.ResultList, beginOfMonth);
                if (!items.Any())
                {
                    break;
                }
                DAO.BulkSave(items);
                var greatestRowstamp = items[items.Count - 1].Rowstamp;

                //there´s at least one extra item, but could be thousands
                needsMore = items.Count == PageSize;
                i++;
                if (greatestRowstamp.HasValue)
                {
                    ConfigFacade.SetValue(ConfigurationConstants.R0042Rowstamp, greatestRowstamp);
                    Log.InfoFormat("R0042: updating rowstamp to {0}".Fmt(greatestRowstamp.Value));
                    lowerRowstamp = greatestRowstamp.Value;
                }

                initOfBatch = false;
            }
        }