Exemple #1
0
 /// <summary>
 /// Вычисляем значение хеша на основе информации об объекте
 /// </summary>
 /// <param name="dirtyApartment">Объект для вычисления</param>
 public static void CreateHashForApartment(DirtyApartments dirtyApartment)
 {
     dirtyApartment.Hash = Services.GetHash(dirtyApartment.Балкон.Trim().ToLower() +
                         dirtyApartment.Край.Trim().ToLower() +
                         dirtyApartment.Город.Trim().ToLower() +
                         dirtyApartment.Район.Trim().ToLower() +
                         dirtyApartment.Массив.Trim().ToLower() +
                         dirtyApartment.Ориентир.Trim().ToLower() +
                         dirtyApartment.Планировка.Trim().ToLower() +
                         dirtyApartment.Материал.Trim().ToLower() +
                         dirtyApartment.Санузел.Trim().ToLower() +
                         dirtyApartment.ТипПлиты.Trim().ToLower() +
                         dirtyApartment.Дом.Trim().ToLower() +
                         dirtyApartment.Общая.Trim().ToLower() +
                         dirtyApartment.Жилая.Trim().ToLower() +
                         dirtyApartment.Кухня.Trim().ToLower() +
                         dirtyApartment.ЗаголовокОбъявления.Trim().ToLower() +
                         dirtyApartment.ТекстОбъявления.Trim().ToLower() +
                         dirtyApartment.Комнат.Trim().ToLower() +
                         // dirtyApartment.Лоджия.Trim().ToLower() +
                         dirtyApartment.Примечание.Trim().ToLower() +
                         dirtyApartment.Телефон1.Trim().ToLower() +
                         dirtyApartment.Телефон2.Trim().ToLower() +
                         dirtyApartment.Телефон3.Trim().ToLower() +
                         dirtyApartment.Телефон4.Trim().ToLower() +
                         dirtyApartment.Улица.Trim().ToLower() +
                         dirtyApartment.Этаж.Trim().ToLower() +
                         dirtyApartment.Этажность.Trim().ToLower());
 }
Exemple #2
0
 /// <summary>
 /// Вычисляем значение хеша для посредника на основе информации об объекте
 /// </summary>
 public static string CreateHashForBroker(DirtyApartments apartment)
 {
     return Services.GetHash(apartment.Имя.Trim().ToLower() +
                                    apartment.Телефон1.Trim().ToLower() +
                                    apartment.Телефон2.Trim().ToLower() +
                                    apartment.Телефон3.Trim().ToLower() +
                                    apartment.Телефон4.Trim().ToLower());
 }
 public bool Add(DirtyApartments da)
 {
     bool flag = false;
     try
     {
         lock (ap)
         {
             ap.Add(da);
             lock (added_aps)
             added_aps.Add(da.AddressParsing);
             flag = true;
         }
     }
     catch (Exception ex) { Console.WriteLine("Произошла ошибка добавления объявления " + ex.Message); }
     return flag;
 }
 //САДом
 protected override void SetHouseUnderConstruction(HtmlDocument page, DirtyApartments dirtyApartment)
 {
 }
 //ТипОтделки
 protected override void SetFurnishType(HtmlDocument page, DirtyApartments dirtyApartment)
 {
 }
 //ГодПостройки
 protected override void SetYearOfConstruction(HtmlDocument page, DirtyApartments dirtyApartment)
 {
 }
 //Лоджия
 protected override void SetLoggia(HtmlDocument page, DirtyApartments dirtyApartment)
 {
 }
 //ТекстОбъявления
 protected override void SetAdText(HtmlDocument page, DirtyApartments dirtyApartment)
 {
     //dirtyApartment.ТекстОбъявления = "";
 }
        //Фото
        protected override void SetPhoto(HtmlDocument page, DirtyApartments dirtyApartment)
        {


        }
 //КварталСдачи
 protected override void SetQuarterOfDelivery(HtmlDocument page, DirtyApartments dirtyApartment)
 {
     // dirtyApartment.КварталСдачи = "";
 }
 //Застройщик
 protected override void SetDeveloper(HtmlDocument page, DirtyApartments dirtyApartment)
 {
     // dirtyApartment.Застройщик = "";
 }
 //ТипКонтактногоЛица
 protected override void SetTypeOfContactPerson(HtmlDocument page, DirtyApartments dirtyApartment)
 {
     // dirtyApartment.ТипКонтактногоЛица = "";
 }
        //компания
        protected override void SetCompanyName(HtmlDocument page, DirtyApartments dirtyApartment)
        {

        }
        //дата объявления
        protected override void SetAdDate(HtmlDocument page, DirtyApartments dirtyApartment)
        {

        }
        //материал стен
        protected override void SetWallMaterial(HtmlDocument page, DirtyApartments dirtyApartment)
        {

        }
        //№ дома
        protected override void SetHouseNumber(HtmlDocument page, DirtyApartments dirtyApartment)
        {

        }
        //стикер
        protected override void SetSticker(string sticker, DirtyApartments dirtyApartment)
        {
            // готовим строку - xml документ
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load(new StringReader(sticker));

            var res = xmlDoc.GetElementsByTagName("operation");
            foreach (XmlElement e in res)
            {
                dirtyApartment.Операция = e.InnerText;
                break;
            }
            res = null;

            res = xmlDoc.GetElementsByTagName("rooms");
            foreach (XmlElement e in res)
            {
                dirtyApartment.Комнат = e.InnerText;
                dirtyApartment.НаименованиеОбъекта = e.InnerText;
                break;
            }
            res = null;

            res = xmlDoc.GetElementsByTagName("district");
            foreach (XmlElement e in res)
            {
                dirtyApartment.Район = e.InnerText;
                break;
            }
            res = null;

            res = xmlDoc.GetElementsByTagName("landmark");
            foreach (XmlElement e in res)
            {
                dirtyApartment.Ориентир = e.InnerText;
                break;
            }
            res = null;

            res = xmlDoc.GetElementsByTagName("street");
            foreach (XmlElement e in res)
            {
                dirtyApartment.Улица  = e.InnerText;
                break;
            }
            res = null;

            res = xmlDoc.GetElementsByTagName("furniture");
            foreach (XmlElement e in res)
            {
                dirtyApartment.Массив = e.InnerText; //мебель
                break;
            }
            res = null;
            res = xmlDoc.GetElementsByTagName("technics");
            foreach (XmlElement e in res)
            {
                dirtyApartment.ТипОтделки = e.InnerText; //техника
                break;
            }
            res = null;
            res = xmlDoc.GetElementsByTagName("square");
            foreach (XmlElement e in res)
            {
                dirtyApartment.Общая = e.InnerText; 
                break;
            }
            res = null;
            res = xmlDoc.GetElementsByTagName("price");
            foreach (XmlElement e in res)
            {
                dirtyApartment.Цена = e.InnerText.Replace(" ","");
                break;
            }
            res = null;
            res = xmlDoc.GetElementsByTagName("txt");
            foreach (XmlElement e in res)
            {
                dirtyApartment.Примечание = e.InnerText;
                break;
            }
            res = null;
            res = xmlDoc.GetElementsByTagName("contacts");
            foreach (XmlElement e in res)
            {
                string phones = e.InnerText;
                phones = phones.Replace("-", "").Replace(" ", "").Replace("т.","");
                string ph1 = Regex.Match(phones, @"(\d{7,11})").Groups[1].Value;
                if (!string.IsNullOrEmpty(ph1))
                {
                    dirtyApartment.Телефон1 = ph1;
                    dirtyApartment.Имя = ((!string.IsNullOrEmpty(phones.Replace(ph1, ""))) ? phones.Replace(ph1, "") : null);
                }
                break;
            }
            res = null;

            res = xmlDoc.GetElementsByTagName("id");
            if (res != null)
            {
                foreach (XmlElement e in res)
                {
                    dirtyApartment.НомерОбъявления = e.InnerText;
                    HtmlDocument page = new HtmlDocument();
                    page = getDopDoc(e.InnerText);

                    if (page != null)
                    {
                        //дата
                        //<b>Объявление подано</b> 19.11.2014<br>
                        string date = Regex.Match(page.DocumentNode.InnerHtml, @"<b>Объявление подано</b>\s*(.*?)\s*(?=<br>|$)").Groups[1].Value;
                        if (!String.IsNullOrEmpty(date))
                            dirtyApartment.ДатаОбъявления = date;
                        else
                        {
                            dirtyApartment.ДатаОбъявления = DateTime.Today.ToString("yyyy-MM-dd");
                        }
                        //оплата
                        string opl = Regex.Match(page.DocumentNode.InnerHtml, @"<b>Оплата:</b>\s*(.*?)\s*(?=<br>|$)").Groups[1].Value;
                        if (!String.IsNullOrEmpty(opl))
                            dirtyApartment.ТипОплатыУслуг = opl;
                        //<b>Услуги:</b> 60<br><b>Оплата:</b> за месяц вперед<br>
                        //услуги
                        string usl = Regex.Match(page.DocumentNode.InnerHtml, @"<b>Услуги:</b>\s*(.*?)\s*<br>").Groups[1].Value;
                        if (!String.IsNullOrEmpty(usl))
                            dirtyApartment.Примечание += " Услуги: " + usl;
                        //фоточки
                        var phts = page.DocumentNode.SelectNodes("//div[@class='bordered-image']/a");
                        if (phts != null)
                        {
                            List<string> photos = new List<string>();
                            foreach (HtmlNode n in phts)
                            {
                                photos.Add("http://24arenta.ru" + n.Attributes["href"].Value);
                            }
                            dirtyApartment.Фото = SavePhoto(photos);
                        }
                    }
                    else
                    {
 
                    }
                    break;
                }
 
            }


        }
        //ГодСдачи
        protected override void SetYearOfDelivery(HtmlDocument page, DirtyApartments dirtyApartment)
        {

        }
        //ТипПлиты Кухонная плита
        protected override void SetCooker(HtmlDocument page, DirtyApartments dirtyApartment)
        {
            //dirtyApartment.ТипПлиты = "";

        }
 //Новостройка - дата сдачи (+вид Объекта, Операция, номер объявления)
 protected override void SetNewBuilding(HtmlDocument page, DirtyApartments dirtyApartment)
 { }
 //Массив
 protected override void SetMicrodistrict(HtmlDocument page, DirtyApartments dirtyApartment)
 {
 }
        //жилая площадь
        protected override void SetLivingArea(HtmlDocument page, DirtyApartments dirtyApartment)
        {

        }
 //ЗаключенЭксклюзивныйДоговор
 protected override void SetSignedAnExclusiveAgreement(DirtyApartments dirtyApartment)
 {
 }
        //площадь кухни
        protected override void SetKitchenArea(HtmlDocument page, DirtyApartments dirtyApartment)
        {

        }
        //Балкон
        protected override void SetBalcony(HtmlDocument page, DirtyApartments dirtyApartment)
        {

        }
        //ЗаголовокОбъявления
        protected override void SetAdCaption(HtmlDocument page, DirtyApartments dirtyApartment)
        {

        }
        //ЖК
        protected override void SetHousingComplex(HtmlDocument page, DirtyApartments dirtyApartment)
        {

        }
        //операция
        protected override void SetOperation(DirtyApartments dirtyApartment)
        {

        }
 protected override bool CheckData(DirtyApartments dirtyApartment)
 {
     return true;
 }
 //ТипОплатыУслуг
 protected override void SetTypeOfPayment(HtmlDocument page, DirtyApartments dirtyApartment)
 {
 }