CardMaker.Card.Import.GoogleReferenceReader.GetData C# (CSharp) Метод

GetData() публичный Метод

public GetData ( string sGoogleReference, List listData, bool bRemoveFirstRow, string sNameAppend = "" ) : void
sGoogleReference string
listData List
bRemoveFirstRow bool
sNameAppend string
Результат void
        public void GetData(string sGoogleReference, List<List<string>> listData, bool bRemoveFirstRow, string sNameAppend = "")
        {
            var arraySettings = sGoogleReference.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

            if (arraySettings.Length < 3)
            {
                return;
            }

            string sCacheKey = GetCacheKey(sGoogleReference, sNameAppend);
            List<List<string>> listCacheData;
            if (!CardMakerInstance.ForceDataCacheRefresh && m_dictionaryDataCache.TryGetValue(sCacheKey, out listCacheData))
            {
                Logger.AddLogLine("Loading {0} from local cache".FormatString(sCacheKey));
                listData.AddRange(listCacheData);
                return;
            }

            var sSpreadsheetName = arraySettings[1];
            var sSheetName = arraySettings[2] + sNameAppend;

            var bCredentialsError = false;

            List<List<string>> listGoogleData;
            try
            {
                listGoogleData = GoogleSpreadsheet.GetSpreadsheet(m_zSpreadsheetsService, sSpreadsheetName, sSheetName);
            }
            catch (InvalidCredentialsException e)
            {
                Logger.AddLogLine("Credentials exception: " + e.Message);
                bCredentialsError = true;
                listGoogleData = null;
            }
            catch (Exception e)
            {
                Logger.AddLogLine("General exception: " + e.Message);
                listGoogleData = null;
            }

            if (null == listGoogleData)
            {
                Logger.AddLogLine("Failed to load data from Google Spreadsheet." + "[" + sSpreadsheetName + "," + sSheetName + "]" + (bCredentialsError ? " Google reported a problem with your credentials." : string.Empty));
            }
            else
            {
                if (bRemoveFirstRow && listGoogleData.Count > 0)
                {
                    listGoogleData.RemoveAt(0);
                }

                listData.AddRange(listGoogleData);
                if (m_dictionaryDataCache.ContainsKey(sCacheKey))
                {
                    m_dictionaryDataCache.Remove(sCacheKey);
                }
                m_dictionaryDataCache.Add(sCacheKey, listGoogleData);
                m_bCacheUpdated = true;
            }
        }