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);
        }
Example #2
0
 public bool DeleteEntity(YearlyWorkingDay amount)
 {
     YearlyWorkingDay am = amount;
     if (am == null) return false;
     if (am.WorkingDay < DateTime.Now.Date || UCCountryEdit.IsEstimationExist(am.WorkingDay, Country.ID)) return false;
     
         try
         {
             ClientEnvironment.YearlyWorkingDayService.DeleteByID(am.ID);
             YearlyWorkingDay removing = ListOfClosedDays.GetItemByID(am.ID);
             if (removing != null) 
             {
                 ListOfClosedDays.Remove(removing);
                 UpdateEnableButton();
                 return true;
             }
         }
         catch (ValidationException)
         {
             ErrorMessage("CantDeleteYearlyAppearance");
             return false;
         }
         catch (EntityException ex)
         {
             ProcessEntityException(ex);
             return false;
         }
     return false;
 }