Ejemplo n.º 1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="searches"></param>
 /// <param name="context"></param>
 /// <param name="result"></param>
 public void LoadUPRsFromBuildingsBlockingCollection(List <Uri> searches, JSONContext context, BlockingCollection <SearchAutoCompleteResult> result = null)
 {
     if (result == null)
     {
         result = DomLoader.BlockingCollectionUPRs;
     }
     //context.Configuration.AutoDetectChangesEnabled = false;
     //Загрузка с сайта
     using (CancellationTokenSource ts = new CancellationTokenSource())
     {
         Task t1 = Task.Run(() => DomLoader.UPRsFromHouses(searches, Encoding.UTF8, result));
         //запись найденных
         Task t2 = Task.Run(() =>
         {
             SearchAutoCompleteResult upr = new SearchAutoCompleteResult();
             foreach (var n in result.GetConsumingEnumerable())
             {
                 try
                 {
                     context.UPRs.AddOrUpdate(up => up.Url, n);
                     context.SaveChanges();
                     Logger.Logger.Info(string.Join(" ", "ВНЕСЕНО", n.Value, result.Count));
                 }
                 catch (Exception) { }
             }
             context.SaveChanges();
             ts.Cancel();
         });
         Task.WaitAll(new Task[] { t1, t2 });
     }
 }
Ejemplo n.º 2
0
 public void AppendAddresses()
 {
     using (JSONContext context = new JSONContext("integra"))
     {
         //context.ownerRawAddresses.AddRange(rospt_Ru_Loader.Load(new DirectoryInfo("C:\\Users\\Bushmakin\\Downloads\\www.rospt.ru").GetFiles(), true));
         context.SaveChanges();
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 ///
 /// </summary>
 public void LoadBuildings()
 {
     using (JSONContext context = new JSONContext(ConnectionString))
     {
         var addressList = context.AO_60562s.OrderBy(o => o.ADDRESS).Select(s => s.ADDRESS).ToList();
         var ttt         = DomLoader.LoadBuildings(addressList, Encoding.UTF8);
         context.UPRs.AddOrUpdate(up => new { up.Url }, ttt.Distinct().ToArray());
         context.SaveChanges();
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public async Task LoadBuildingsAsync()
        {
            using (JSONContext context = new JSONContext(ConnectionString))
            {
                var addressList = context.AO_60562s.ToList().Select(s => s.ADDRESS).ToList();
                await DomLoader.LoadBuildingsAsync(addressList, Encoding.UTF8);

                //context.UPRs.AddOrUpdate(up=>new {up.Url },ttt.Distinct().ToArray());
                context.SaveChanges();
            }
        }
Ejemplo n.º 5
0
        public void Update(List <List <OMK002_2013_1> > input)
        {
            int counter = 0;

            foreach (List <OMK002_2013_1> block in input)
            {
                using (JSONContext context = new JSONContext(ConnectionString))
                {
                    block.RemoveAll(x => x.global_id == null);
                    counter += block.Count;
                    context.OMK002_2013_1s.AddOrUpdate(block.ToArray());
                    Logger.Logger.Info(string.Join(" ", typeof(OMK002_2013_1).Name, "Сохранено", block.Count.ToString(), "всего", counter.ToString()));
                    context.SaveChanges();
                }
            }
        }
Ejemplo n.º 6
0
        public void Update(List <List <SearchAutoCompleteResult> > input)
        {
            int counter = 0;

            foreach (List <SearchAutoCompleteResult> block in input)
            {
                using (JSONContext context = new JSONContext(ConnectionString))
                {
                    //block.RemoveAll(x => x.global_id == null);
                    counter += block.Count;
                    context.UPRs.AddRange(block.ToArray());
                    Logger.Logger.Info(string.Join(" ", typeof(Data_54518).Name, "Сохранено", block.Count.ToString(), "всего", counter.ToString()));
                    context.SaveChanges();
                }
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Обновляет Дома, внесенные в таблицу, но имеющие незаполненные поля. Обновление по фирме-управляшке не производится
        /// </summary>
        /// <param name="encoding"></param>
        public void UpdateHouses(Encoding encoding)
        {
            JSONContext         context = new JSONContext();
            IEnumerable <House> houses  =
                (from _house in context.Houses
                 where _house.Address == null
                 select _house).ToList();

            foreach (House house in houses)
            {
                Uri    _houseuri = new Uri(BaseUri, house.UriString);
                string _html     = DownloadString(_houseuri, encoding, null);
                DecodeHouse(house, _html);
                context.SaveChanges();
                Logger.Logger.Info(_houseuri.ToString());
            }
        }
Ejemplo n.º 8
0
        public void Update <T>(IEnumerable <IQueryable <T> > input, UpdateDelegateTwo <T> updater, Expression <Func <Data_2624_8684, object> > comparer)
        {
            int counter = 0;

            foreach (IEnumerable <T> block in input)
            {
                using (JSONContext context = new JSONContext(ConnectionString))
                {
                    foreach (T row in block)
                    {
                        updater(row);
                    }
                    //context.AddOrUpdate(comparer, block.ToArray());
                    Logger.Logger.Info(string.Join(" ", typeof(Data_2624_8684).Name, "Сохранено", block.Count().ToString(), "всего", counter.ToString()));
                    context.SaveChanges();
                }
            }
        }
Ejemplo n.º 9
0
        public List <UPRsite> LoadUpr(IEnumerable <SearchAutoCompleteResult> uprs, Encoding encoding)
        {
            var uprsites    = new List <UPRsite>();
            var context     = new JSONContext();
            var updatedUprs =
                (from upr in uprs
                 //join _old in context.UPRsites.ToList() on _upr.ID equals _old.ID into l
                 //from _left in l
                 select upr).ToList();

            foreach (var upr in updatedUprs)
            {
                var uprsite = LoadUpr(upr, encoding);
                uprsites.Add(uprsite);
                context.UPRsites.Add(uprsite);
                //var mergedUprSites = new List<UPRsite>();
                //context.UPRsites.AddOrUpdate(_uPRsites.ToArray());
                context.SaveChanges();
            }
            return(uprsites);
        }
Ejemplo n.º 10
0
        public void Update(List <List <AO_60562> > input)
        {
            int counter = 0;

            foreach (List <AO_60562> block in input)
            {
                using (JSONContext context = new JSONContext(ConnectionString))
                {
                    block.RemoveAll(x => x.Global_ID == null);
                    counter += block.Count;
                    foreach (AO_60562 row in block)
                    {
                        if (row.GeoData == null)
                        {
                            row.GeoData = new GeoData();
                        }
                    }
                    context.AO_60562s.AddOrUpdate(block.ToArray());
                    Logger.Logger.Info(string.Join(" ", typeof(AO_60562).Name, "Сохранено", block.Count.ToString(), "всего", counter.ToString()));
                    context.SaveChanges();
                }
            }
        }
Ejemplo n.º 11
0
 public void Save(Todo todo)
 {
     context.Todos.Add(todo);
     context.SaveChanges();
 }
Ejemplo n.º 12
0
 public void AddEntity(T entity)
 {
     JSONContext.Add(entity);
     JSONContext.SaveChanges();
 }
Ejemplo n.º 13
0
 public void Save(BitOfNews bitOfNews)
 {
     context.News.Add(bitOfNews);
     context.SaveChanges();
 }
Ejemplo n.º 14
0
        /// <summary>
        ///
        /// </summary>
        public void UpdateOrganizationsByDomMosRu()
        {
            using (JSONContext jscontext = new JSONContext())
                using (UNSModel unscontext = new UNSModel())
                {
                    Regex          reHref   = new Regex("&#\\d+;");
                    List <UPRsite> inserted = (from upr in jscontext.UPRsites
                                               select upr).ToList();
                    foreach (UPRsite uprsite in inserted)
                    {
                        uprsite.InfTableRows.ToList();
                        var          ogrn         = FirstVal(uprsite.InfTableRows.Where(p => p.Name.Trim() == "Основной государственный регистрационный номер (ОГРН):" ? true : false).Select(p => p.Value));
                        var          inn          = FirstVal(uprsite.InfTableRows.Where(p => p.Name != null && p.Name.Trim() == "Идентификационный номер налогоплательщика(ИНН):" ? true : false).Select(p => p.Value));
                        var          shname       = FirstVal(uprsite.InfTableRows.Where(p => p.Name != null && p.Name.Trim() == "Сокращенное наименование" ? true : false).Select(p => p.Value));
                        var          uaddress     = FirstVal(uprsite.InfTableRows.Where(p => p.Name != null && p.Name.Trim() == "Место государственной регистрации юридического лица(место нахождения юридического лица):" ? true : false).Select(p => p.Value));
                        var          form         = FirstVal(uprsite.InfTableRows.Where(p => p.Name != null && p.Name.Trim() == "Организационно-правовая форма" ? true : false).Select(p => p.Value));
                        var          orgType      = unscontext.OrganizationTypes.Where(ot => ot.FullTypeName.Trim() == form ? true : false).FirstOrDefault();
                        var          fio          = FirstVal(uprsite.InfTableRows.Where(p => p.Name.Trim() == "ФИО руководителя (председателя)" ? true : false).Select(p => p.Value));
                        Organization organization = new Organization()
                        {
                            Id               = uprsite.ID,
                            FullName         = uprsite.Name,
                            OGRN             = ogrn,
                            INN              = inn,
                            ShortName        = shname,
                            UrAddress        = uaddress,
                            OrganizationType = orgType
                        };

                        //organization.DirectorPosition.Add(dirpos);
                        if (organization.OGRN != null)
                        {
                            unscontext.Organizations.AddOrUpdate(p => new { p.OGRN }, organization);
                        }
                        else
                        {
                            unscontext.Organizations.AddOrUpdate(p => new { p.Id }, organization);
                        }
                        jscontext.SaveChanges();
                        if (fio.Any())
                        {
                            var dirpos = (new AccountantGeneralPosition()
                            {
                                PositionType = new PersonPositionType()
                                {
                                    PositionType = ""
                                },
                                Person = new Person()
                                {
                                    Family = fio, Id = Guid.NewGuid()
                                },
                                InstDocument = new Document()
                                {
                                    DocumentName = ""
                                },
                                //Organization_Id = organization.Id
                            });
                            //unscontext.AccountantGeneralPositions.AddOrUpdate(p => p.Organization_Id, dirpos);
                            jscontext.SaveChanges();
                        }
                    }
                }
        }