Esempio n. 1
0
        public void UpdateMethods()
        {
            LookupFileReader xlsReader = new LookupFileReader(_log);

            Dictionary <string, MethodInfo> methodLookup = xlsReader.ReadMethodsFromExcel();

            foreach (string productCode in methodLookup.Keys)
            {
                var productInfo = _apiReader.ReadProductFromApi(productCode);
                var productDesc = productInfo.productDescription;
                methodLookup[productCode].MethodDescription = productDesc;
            }

            _log.LogWrite(String.Format("Found {0} distinct methods.", methodLookup.Count));
            string connString = ConfigurationManager.ConnectionStrings["OdmConnection"].ConnectionString;

            using (SqlConnection connection = new SqlConnection(connString))
            {
                foreach (MethodInfo meth in methodLookup.Values)
                {
                    try
                    {
                        object methodID = SaveOrUpdateMethod(meth, connection);
                    }
                    catch (Exception ex)
                    {
                        _log.LogWrite("error updating method: " + meth.MethodDescription + " " + ex.Message);
                    }
                }
            }
            _log.LogWrite("UpdateMethods OK: " + methodLookup.Count.ToString() + " methods.");
        }
Esempio n. 2
0
        /// <summary>
        /// Returns a dictionary with entries: Neon short site code: latest data URL
        /// </summary>
        /// <param name="productCode"></param>
        /// <returns></returns>
        public Dictionary <string, string> GetSitesForProduct(string productCode)
        {
            var neonProduct      = _apiReader.ReadProductFromApi(productCode);
            var productSiteCodes = neonProduct.siteCodes;

            var siteDataUrls = new Dictionary <string, string>();

            foreach (var siteCode in productSiteCodes)
            {
                var shortCode   = siteCode.siteCode;
                var dataUrls    = siteCode.availableDataUrls;
                var lastDataUrl = dataUrls.Last();
                siteDataUrls.Add(shortCode, lastDataUrl);
            }
            return(siteDataUrls);
        }