Beispiel #1
0
        private static void Execute(String Country, int Carrier)
        {
            Dictionary<string, AddressHolder> dirAddress = LoadDropPoints(Carrier, Country);
            if (dirAddress != null && dirAddress.Count > 0)
            {
                DropPointService Importer = new DropPointService();
                int no_records = Importer.CountExistingDropPoints(Country, Carrier);

                if (Math.Abs(no_records - dirAddress.Count) < no_records * 0.1 || no_records == 0 || forceReload)
                {
                    foreach (AddressHolder address in dirAddress.Values)
                    {

                        Importer.AddDropPoint(address);
                        Console.Write("take zip : " + address.Zip);

                    }
                    Logger.Debug(String.Format("Update database with {0} records", Importer.CountListDropPoints()));
                    Importer.SaveToDatabase();
                    Logger.Debug("Update done");

                }
                else
                {
                    String error = String.Format("Import of drop points from carrierId = {0} and Country = {1} is not runned due to mismatch between existing data {2} records and imported data {3} records", Carrier, Country, no_records, dirAddress.Count);
                    Logger.Error(error);
                    SendErrorMail("Import of drop points not executed", error);
                }
            }
        }