protected override void readCSVFile(CachedCsvReader csv) { #if(UseHeaders) int systemID1Index = csv.GetFieldIndex(_VLID); int regionNameIndex = csv.GetFieldIndex(_RegionName); #else int systemID1Index = _VLIDIndex; int regionNameIndex = _RegionNameIndex; #endif Dictionary<string, Region> dbRegionHash = getDBRegionList(); Dictionary<string, long> countrySysKeyIDKey = getDBCountryListSysKeyIDKey(); List<Region> importRegionList = new List<Region>(); int i = 1; while (csv.ReadNextRecord()) { csvDataNextRow(); string regionName = csv[regionNameIndex]; string keyCountry = csv[systemID1Index]; string keyRegion = keyCountry + regionName; if (!dbRegionHash.ContainsKey(keyRegion)) { if (countrySysKeyIDKey.ContainsKey(keyCountry)) { Region region = new Region(); region.CountryID = countrySysKeyIDKey[keyCountry]; region.LanguageID = SharedConsts.NeutralLangId; region.Name = regionName; region.Import = true; region.RegionSysID = regionName; importRegionList.Add(region); dbRegionHash.Add(keyRegion, region); } else { message(string.Format(GetLocalized("CountryNotExistsDB"), _CurrentRow, _VLID, keyCountry)); } } else { message(string.Format(GetLocalized("RegiontExistsDB"), i, keyRegion)); } i++; } csvDataEndRead(); SaveOrUpdateList<Region>(_RegionService, importRegionList); }
protected override void readCSVFile(CachedCsvReader csv) { #if(UseHeaders) int systemID1Index = csv.GetFieldIndex(_VLID); int workingDayIndex = csv.GetFieldIndex(_WorkingDay); #else int systemID1Index = _VLIDIndex; int workingDayIndex = _WorkingDayIndex; #endif Dictionary<string, YearlyWorkingDay> dbWorkingDayHash = getDBWorkingDayList(); Dictionary<string, long> countrySysKeyIDKey = getDBCountryListSysKeyIDKey(); List<YearlyWorkingDay> importWDayList = new List<YearlyWorkingDay>(); while (csv.ReadNextRecord()) { csvDataNextRow(); string workingDay = csv[workingDayIndex]; string keyCountry = csv[systemID1Index]; string keyWorkingDay = keyCountry + workingDay; if (!dbWorkingDayHash.ContainsKey(keyWorkingDay)) { if (countrySysKeyIDKey.ContainsKey(keyCountry)) { YearlyWorkingDay yearlyWorkingDay = new YearlyWorkingDay(); yearlyWorkingDay.CountryID = countrySysKeyIDKey[keyCountry]; yearlyWorkingDay.WorkingDay = DateTime.ParseExact(workingDay, "yyyyMMdd", null); importWDayList.Add(yearlyWorkingDay); dbWorkingDayHash.Add(keyWorkingDay, yearlyWorkingDay); } else { message(string.Format(GetLocalized("CountryNotExistsDB"), _CurrentRow, _VLID, keyCountry)); } } else { message(string.Format(GetLocalized("WorkingDayExistsDB"), _CurrentRow)); } } csvDataEndRead(); SaveList<YearlyWorkingDay>(_IContryServise.YearlyWorkingDayService, importWDayList); }
protected override void readCSVFile(CachedCsvReader csv) { #if(UseHeaders) int systemID1Index = csv.GetFieldIndex(_VLID); int systemID2Index = csv.GetFieldIndex(_CountryID); int countryNameIndex = csv.GetFieldIndex(_CountryName); #else int systemID1Index = _VLIDIndex; int systemID2Index = _CountryIDIndex; int countryNameIndex = _CountryNameIndex; #endif Dictionary<string, Country> dbCountryHash = getDBCountryListSysKey(); List<Country> importCountryList = new List<Country>(); Country country; while (csv.ReadNextRecord()) { csvDataNextRow(); string key = csv[systemID1Index]; if (dbCountryHash.ContainsKey(key)) { country = dbCountryHash[key]; } else { country = new Country(); country.SystemID2 = csv[systemID2Index]; } country.Name = csv[countryNameIndex]; country.Import = true; country.CountryLanguage = SharedConsts.NeutralLangId; country.LanguageID = SharedConsts.NeutralLangId; country.SystemID1 = byte.Parse(csv[systemID1Index]); if (country.IsNew && !dbCountryHash.ContainsKey(key)) dbCountryHash.Add(key, country); if (!importCountryList.Contains(country)) importCountryList.Add(country); else message(string.Format(GetLocalized("CountryExists"), _CurrentRow, _VLID, key)); } csvDataEndRead(); SaveOrUpdateList<Country>(_IContryServise, importCountryList); }
protected override void readCSVFile(CachedCsvReader csv) { #if(UseHeaders) int worldIDIndex = csv.GetFieldIndex(_WorldID); int hwgr_IDIndex = csv.GetFieldIndex(_HWGR_ID); int hwgr_NameIndex = csv.GetFieldIndex(_HWGR_Name); #else int worldIDIndex = _WorldIDIndex; int hwgr_IDIndex = _HWGR_IDIndex; int hwgr_NameIndex = _HWGR_NameIndex; #endif Dictionary<string, ImportFileHWGRData> data = new Dictionary<string, ImportFileHWGRData>(); //Add HWGR while (csv.ReadNextRecord()) { csvDataNextRow(); int worldID = int.Parse(csv[worldIDIndex]); int hwgrID = int.Parse(csv[hwgr_IDIndex]); string hwgrName = csv[hwgr_NameIndex]; string key = worldID.ToString() + hwgrID.ToString(); if (!data.ContainsKey(key)) data.Add(key, new ImportFileHWGRData(_CurrentRow ,new ImportHWGRData(hwgrID, worldID, hwgrName))); else message(string.Format(GetLocalized("HWGRExists"), _CurrentRow, _WorldID, worldID, _HWGR_ID, hwgrID)); } csvDataEndRead(); List<ImportHWGRData> list = new List<ImportHWGRData>(data.Count); foreach (ImportFileHWGRData value in data.Values) list.Add(value.Data); SaveDataResult saveDataResult = _StoreService.HWGRService.ImportHWGR(list); list = (List<ImportHWGRData>)saveDataResult.Data; foreach (ImportHWGRData value in list) { string key = value.World_SystemID.ToString() + value.HWGR_SystemID.ToString(); message(string.Format(GetLocalized("WorldNotExistsDB"), data[key].RecordNumber, _WorldID, value.World_SystemID)); } }
protected override void readCSVFile(CachedCsvReader csv) { #if(UseHeaders) int countryIDIndex = csv.GetFieldIndex(_VLID); int feastDateIndex = csv.GetFieldIndex(_FeastDate); #else int countryIDIndex = _VLIDIndex; int feastDateIndex = _FeastDateIndex; #endif Dictionary<string, ImportFeastsData> data = new Dictionary<string, ImportFeastsData>(); int i = 1; while (csv.ReadNextRecord()) { csvDataNextRow(); int countryID = int.Parse(csv[countryIDIndex]); DateTime feastDate = DateTime.ParseExact(csv[feastDateIndex], "yyyyMMdd", null); string key = countryID.ToString() + feastDate.ToString(); if (!data.ContainsKey(key)) data.Add(key, new ImportFeastsData(i, new ImportDaysData(countryID, feastDate))); else message(string.Format(GetLocalized("FeastExists"), i, _CountryID, countryID, _FeastDate, feastDate)); i++; } csvDataEndRead(); List<ImportDaysData> list = new List<ImportDaysData>(data.Count); foreach (ImportFeastsData value in data.Values) list.Add(value.Data); SaveDataResult saveDataResult = _FeastService.ImportFeasts(list); list = (List<ImportDaysData>)saveDataResult.Data; foreach (ImportDaysData value in list) { string key = value.CountryID.ToString() + value.Date.ToString(); message(string.Format(GetLocalized("CountryNotExistsDB"), data[key].RecordNumber, _VLID, value.CountryID)); } }
protected override void readCSVFile(CachedCsvReader csv) { #if(UseHeaders) int worldIDIndex = csv.GetFieldIndex(_WorldID); int worldNameIndex = csv.GetFieldIndex(_WorldName); #else int worldIDIndex = _WorldIDIndex; int worldNameIndex = _WorldNameIndex; #endif Dictionary<string, World> dbWorldHash = getDBWorldHash(); Dictionary<long, Store> dbStoreHash = getDBStoreList(); Dictionary<string, StoreToWorld> dbStore_WorldHash = getStore_WorldHash(); List<World> worldSaveList = new List<World>(); List<StoreToWorld> store_WorldSaveList = new List<StoreToWorld>(); bool isNew= false; while (csv.ReadNextRecord()) { csvDataNextRow(); string worldID = csv[worldIDIndex]; string worldName = csv[worldNameIndex]; string key = worldID; World world; if (dbWorldHash.ContainsKey(key)) { world = dbWorldHash[key]; } else { world = new World(); } world.ExSystemID = int.Parse(worldID); world.LanguageID = SharedConsts.NeutralLangId; world.Name = worldName; world.WorldTypeID = WorldType.World; world.Import = true; if (!worldSaveList.Contains(world)) worldSaveList.Add(world); else message(string.Format(GetLocalized("WorldExists"), _CurrentRow, _WorldID, worldID)); if (world.IsNew && !dbWorldHash.ContainsKey(key)) { dbWorldHash.Add(key, world); isNew= true; } } csvDataEndRead(); SaveOrUpdateList<World>(_IStoreService.WorldService,worldSaveList); if (isNew) dbWorldHash = getDBWorldHash(); foreach (Store store in dbStoreHash.Values) { foreach (World world in dbWorldHash.Values) { string key= store.ID.ToString () + world.ID.ToString (); if (!dbStore_WorldHash.ContainsKey(key)) { StoreToWorld store_world = new StoreToWorld(world.ID, store.ID); store_WorldSaveList.Add(store_world); dbStore_WorldHash.Add(key, store_world); } } } if (dbStoreHash.Count == 0) message(GetLocalized("StoresNotExistsDB")); SaveList<StoreToWorld>(_IStoreService.StoreToWorldService, store_WorldSaveList); }
protected override void readCSVFile(CachedCsvReader csv) { #if(UseHeaders) int worldIDIndex = csv.GetFieldIndex(_WorldID); int hwgr_IDIndex = csv.GetFieldIndex(_HWGR_ID); int wgr_IDIndex = csv.GetFieldIndex(_WGR_ID); int wgr_NameIndex = csv.GetFieldIndex(_WGR_Name); #else int worldIDIndex = _WorldIDIndex; int hwgr_IDIndex = _HWGR_IDIndex; int wgr_IDIndex = _WGR_IDIndex; int wgr_NameIndex = _WGR_NameIndex; #endif Dictionary<string, ImportDataWGR> data = new Dictionary<string, ImportDataWGR>(); Dictionary<long, WGR> dbwgrHash = getDBwgrHash(); List<WGR> wgrSaveList = new List<WGR>(); //Add WGR int i = 1; while (csv.ReadNextRecord()) { csvDataNextRow(); int worldID = int.Parse(csv[worldIDIndex]); int hwgrID = int.Parse(csv[hwgr_IDIndex]); int wgrID = int.Parse(csv[wgr_IDIndex]); string wgrName = csv[wgr_NameIndex]; string key = worldID.ToString() + hwgrID.ToString() + wgrID.ToString(); if (!data.ContainsKey(key)) { data.Add(key, new ImportDataWGR(i, hwgrID, worldID, wgrID,wgrName,key)); if (!dbwgrHash.ContainsKey(wgrID)) { WGR wgr = new WGR(wgrID, SharedConsts.NeutralLangId, wgrName); wgr.Import = true; wgrSaveList.Add(wgr); dbwgrHash.Add(wgrID, wgr); } } else { message(string.Format(GetLocalized("WGRExists"), i, _WorldID, worldID, _HWGR_ID, hwgrID, _WGR_ID, wgrID)); } i++; } csvDataEndRead(); if (wgrSaveList.Count > 0) { SaveOrUpdateList<WGR>(_IStoreService.WGRService, wgrSaveList); } //Add HwgrToWgr List<HWGR_WGR_SysValuesShort> list = new List<HWGR_WGR_SysValuesShort>(data.Count); foreach (ImportDataWGR value in data.Values) { list.Add(new HWGR_WGR_SysValuesShort(value.HWGR_ID, value.WorldID, value.WGR_ID)); } SaveDataResult saveDataResult= _IStoreService.HwgrToWgrService.Save_HWGR_WGR_Values(list); list = (List<HWGR_WGR_SysValuesShort>)saveDataResult.Data; foreach (HWGR_WGR_SysValuesShort value in list) { string key = value.World_SystemID.ToString() + value.HWGR_SystemID.ToString() + value.WGR_SystemID.ToString(); message(string.Format(GetLocalized("HWGRNotExistsDB"), data[key].RecordNumber, _WorldID, value.World_SystemID, _HWGR_ID, value.HWGR_SystemID)); } }
protected override void readCSVFile(CachedCsvReader csv) { #if(UseHeaders) int systemID1Index = csv.GetFieldIndex(_VLID); int regionNameIndex = csv.GetFieldIndex(_RegionName); int storeIDIndex = csv.GetFieldIndex(_StoreIDIndex); int cityIndex = csv.GetFieldIndex(_City); int areaIndex = csv.GetFieldIndex(_Area); int adressIndex = csv.GetFieldIndex(_Adress); int storeNameIndex = csv.GetFieldIndex(_StoreName); int postCodeIndex= csv.GetFieldIndex(_PostCode); #else int systemID1Index = _VLIDIndex; int regionNameIndex = _RegionNameIndex; int storeIDIndex = _StoreIDIndexIndex; int cityIndex = _CityIndex; int areaIndex = _AreaIndex; int adressIndex = _AdressIndex; int storeNameIndex = _StoreNameIndex; int postCodeIndex = _PostCodeIndex; #endif Dictionary<long, Store> dbStoreHash = getDBStoreList(); Dictionary<string, Region> dbRegionHash = getDBRegionList(); List<Store> storeSaveList = new List<Store>(); int i = 1; Store store; while (csv.ReadNextRecord()) { csvDataNextRow(); string regionName = csv[regionNameIndex]; string keyCountry = csv[systemID1Index]; string keyRegion = keyCountry + regionName; int storeID = int.Parse(csv[storeIDIndex]); string city = csv[cityIndex]; int area = int.Parse(csv[areaIndex]); string postCode = csv[postCodeIndex].ToUpper().Replace(_null,""); string address = csv[adressIndex]; string storeName = csv[storeNameIndex]; if (dbRegionHash.ContainsKey(keyRegion)) { if (dbStoreHash.ContainsKey(storeID)) { if (dbStoreHash[storeID].ID == 0) { message(string.Format(GetLocalized("StoreExists"), _StoreIDIndex, storeID)); continue; } store = dbStoreHash[storeID]; } else { store = new Store(); } store.RegionID = dbRegionHash[keyRegion].ID; store.LanguageID = SharedConsts.NeutralLangId; store.SystemID = storeID; store.Name = storeName; store.Address = address; store.Number = postCode; store.Area = area; store.City = city; store.Import = true; storeSaveList.Add(store); if (store.ID == 0) { dbStoreHash.Add(storeID, store); } } else message(string.Format(GetLocalized("RegionNotExistsDB"), i, _VLID, keyCountry, _RegionName, regionName)); i++; } csvDataEndRead(); SaveOrUpdateList<Store>(_IStoreService, storeSaveList); _IStoreService.CopyStructureForEmptyStores(); }