Ejemplo n.º 1
0
        public CountInfo PrepareToUpdate(DateTimeOffset lastUpdateBrands,
                                         DateTimeOffset lastUpdateCatalogs,
                                         DateTimeOffset lastUpdateDirectories,
                                         DateTimeOffset lastUpdateProductDirections,
                                         DateTimeOffset lastUpdatePhotos,
                                         bool needLoadPhotos,
                                         List <long> ids)
        {
            CountInfo countInfo;

            int maxPhotos = 1000;

            if (ids.Count() > maxPhotos)
            {
                int countPages = ids.Count / maxPhotos;

                for (int i = 0; i < countPages; i++)
                {
                    List <long> idsList = ids.Skip(maxPhotos * i).Take(maxPhotos).ToList();
                    PrepareToUpdatePhotos(lastUpdatePhotos, needLoadPhotos, idsList);
                }

                ids = ids.Skip(maxPhotos * countPages).Take(maxPhotos).ToList();
            }

            using (PricelistServiceClient webService = GetWebService())
            {
                SecurityInfo securityInfo = CreateSecurityInfo();
                countInfo = webService.PrepareToUpdate(securityInfo,
                                                       lastUpdateBrands,
                                                       lastUpdateCatalogs,
                                                       lastUpdateDirectories,
                                                       lastUpdateProductDirections,
                                                       lastUpdatePhotos,
                                                       needLoadPhotos,
                                                       ids.ToArray());
                webService.Close();
            }

            return(countInfo);
        }