Example #1
0
        /// <summary>
        /// Validates configurations and sets required fields
        /// </summary>
        public void Validate(DynamoDBContext context)
        {
            if (IsVersion)
            {
                Utils.ValidateVersionType(MemberType);    // no conversion is possible, so type must be a nullable primitive
            }
            if (IsHashKey && IsRangeKey)
            {
                throw new InvalidOperationException("Property " + PropertyName + " cannot be both hash and range key");
            }

            if (ConverterType != null)
            {
                if (!Utils.CanInstantiateConverter(ConverterType) || !Utils.ImplementsInterface(ConverterType, typeof(IPropertyConverter)))
                {
                    throw new InvalidOperationException("Converter for " + PropertyName + " must be instantiable with no parameters and must implement IPropertyConverter");
                }

                this.Converter = Utils.InstantiateConverter(ConverterType, context) as IPropertyConverter;
            }

            IPropertyConverter converter;

            if (context.ConverterCache.TryGetValue(MemberType, out converter) && converter != null)
            {
                this.Converter = converter;
            }

            foreach (var index in Indexes)
            {
                IndexNames.AddRange(index.IndexNames);
            }
        }
Example #2
0
        /// <summary>
        /// Validates configurations and sets required fields
        /// </summary>
        public void Validate()
        {
            if (IsVersion)
            {
                Utils.ValidateVersionType(MemberType);    // no conversion is possible, so type must be a nullable primitive
            }
            if (IsHashKey && IsRangeKey)
            {
                throw new InvalidOperationException("Property " + PropertyName + " cannot be both hash and range key");
            }

            if (IsKey || IsGSIKey)
            {
                if (Converter == null && !Utils.IsPrimitive(MemberType))
                {
                    throw new InvalidOperationException("Key " + PropertyName + " must be of primitive type");
                }
            }

            foreach (var index in Indexes)
            {
                IndexNames.AddRange(index.IndexNames);
            }

            if (ConverterType != null)
            {
                if (!Utils.CanInstantiate(ConverterType) || !Utils.ImplementsInterface(ConverterType, typeof(IPropertyConverter)))
                {
                    throw new InvalidOperationException("Converter for " + PropertyName + " must be instantiable with no parameters and must implement IPropertyConverter");
                }

                this.Converter = Utils.Instantiate(ConverterType) as IPropertyConverter;
            }
        }
        private static IndexNames ObtainIndexName(string tabName)
        {
            IndexNames indexNames = IndexNames.None;

            switch (tabName)
            {
            case SnP500:
                indexNames |= IndexNames.SnP;
                break;

            case NASDAQ100:
                indexNames |= IndexNames.Nasdaq;
                break;

            case IndexTracker:
                indexNames |= IndexNames.Index;
                break;

            default:
                indexNames = IndexNames.None;
                break;
            }

            return(indexNames);
        }
        public static ISearchIndexClient GetIndexClient(IndexNames indexName)
        {
            ISearchIndexClient indexClient;

            if (_memoryCache.TryGetValue(indexName.ToString(), out indexClient))
            {
                return(indexClient);
            }
            indexClient = SearchServiceClient.Indexes.GetClient(indexName.ToString());
            _memoryCache.Set(indexName.ToString(), indexClient);
            return(indexClient);
        }
Example #5
0
        public async Task <IActionResult> Get(string strIdxNm, IndexNames indexSelector)
        {
            switch (indexSelector)
            {
            case IndexNames.SnP:
                break;

            case IndexNames.Nasdaq:
                break;

            case IndexNames.Both:
                break;

            case IndexNames.Index:
                break;

            default:
                return(StatusCode(StatusCodes.Status400BadRequest, "Cannot process request"));
            }
            _logger.LogDebug($"Getting data only for {strIdxNm}");

            try
            {
                var records = await _appRepository.GetAllAsync <SlickChartFirmNamesDB>(r => r.Index.HasFlag(indexSelector));

                if (records.Count == 0)
                {
                    return(StatusCode(StatusCodes.Status204NoContent, "No records found"));
                }
                var retRcds = _mapper.Map <List <SlickChartFirmNames> >(records);
                return(Ok(retRcds));
            }
            catch (Exception ex)
            {
                _logger.LogError($"Error occurred while getting securities for {indexSelector}\n\t {ex.Message}");
            }
            return(StatusCode(StatusCodes.Status500InternalServerError, "Something went wrong while performing Get operation"));
        }
        private bool ExtractSsData(string tabName)
        {
            var excelRange  = new ExcelRange(new ExcelCell("A", 1), new ExcelCell("G", 600));
            var exSheet     = excelSheetAdapter.GetFromPath(fileFullPath, tabName, excelRange, true);
            var exMapResult = exSheetMapper.Map <SlickChartExtract>(exSheet);
            var a1          = exMapResult.ParsedModels;

            if (exMapResult.IsFailure)
            {
                return(false);
            }
            if (exMapResult.IsSuccess)
            {
                var tmpslickChartFirmNames = a1.Select(a => a.Value).OrderBy(r => r.Company).ToDictionary(x => x.Symbol, x => x.Company);

                //slickChartExtracts.AddRange(a1.Select(a => a.Value));
                IndexNames indexNames = ObtainIndexName(tabName);
                foreach (var keyValuePair in tmpslickChartFirmNames)
                {
                    var key    = keyValuePair.Key;
                    var result = slickChartFirmNames.Where(r => r.Symbol.Equals(key)).FirstOrDefault();
                    if (result == null)
                    {
                        result = new SlickChartFirmNames
                        {
                            Company = keyValuePair.Value,
                            Symbol  = key,
                            Index   = IndexNames.None
                        };
                        slickChartFirmNames.Add(result);
                    }
                    result.Index |= indexNames;
                }
            }
            return(true);
        }