private HwgrToWgr FillWgrName(HwgrToWgr entity) { if (entity != null) { WGR related = ClientEnvironment.WGRService.FindById(entity.WGR_ID); if (related != null) { entity.WgrName = related.Name; } } return(entity); }
private string GetWgrName(long wgrid) { WGR h = null; if (m_diction.TryGetValue(wgrid, out h)) { return(h.Name); } else { return(String.Empty); } }
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)); } }