Exemple #1
0
        public static Gesat_Company LoadCompany(string url, Gesat_HeaderCompany header, string urlFile = null, bool reload = false, bool loadImage = false)
        {
            Gesat_LoadCompanyFromWeb load = new Gesat_LoadCompanyFromWeb(url, header, urlFile, reload, loadImage);

            load.Load();
            return(load.Data);
        }
Exemple #2
0
        public static Gesat_Company LoadCompany(string url, Gesat_HeaderCompany header, bool reload, bool loadImage)
        {
            Gesat_LoadCompany load = new Gesat_LoadCompany(url, header);

            load.Load(reload, loadImage);
            return(load.Data);
        }
Exemple #3
0
 public Gesat_LoadCompanyFromWeb(string url, Gesat_HeaderCompany header, string urlFile = null, bool reload = false, bool loadImage = false)
 {
     _header    = header;
     _url       = url;
     _urlFile   = urlFile;
     _reload    = reload;
     _loadImage = loadImage;
 }
Exemple #4
0
 public Gesat_LoadCompany2(string url, Gesat_HeaderCompany header)
     : base(url)
 {
     _header = header;
     //_imageCacheDirectory = __imageCacheDirectory;
     SetXmlParameters(__useXml);
     SetMongoParameters(__useMongo, __mongoServer, __mongoDatabase, __mongoCollectionName);
 }
Exemple #5
0
 public Gesat_LoadCompany(string url, Gesat_HeaderCompany header)
     : base(url)
 {
     _header = header;
     //_postIdRegex = __postIdRegex;
     _useUrlCache         = __useUrlCache;
     _cacheDirectory      = __cacheDirectory;
     _imageCacheDirectory = __imageCacheDirectory;
     _documentXml         = __documentXml;
     _documentMongoDb     = __documentMongoDb;
     _mongoServer         = __mongoServer;
     _mongoDatabase       = __mongoDatabase;
     _mongoCollectionName = __mongoCollectionName;
 }
Exemple #6
0
 public Gesat_LoadCompanyFromWeb2(string url, Gesat_HeaderCompany header, bool reload = false, bool loadImage = false)
     : base(url, reload: reload)
 {
     _header = header;
     SetRequestParameters(new HttpRequestParameters_v1()
     {
         encoding = Encoding.UTF8
     });
     if (__useUrlCache)
     {
         SetUrlCache(new UrlCache_v1(__cacheDirectory, __urlFileNameType));
     }
     _loadImage = loadImage;
 }
Exemple #7
0
        protected override void SetXml(XElement xelement)
        {
            XXElement xeSource = new XXElement(xelement);

            _data = new Gesat_HeaderPage();
            // <div class="PAGENAVIGLIST">
            // <a href="/Gesat/EtablissementList-10-10.html" title="page suivante">&gt;</a>&nbsp;
            _data.urlNextPage = GetUrl(xeSource.XPathValue("//div[@class='PAGENAVIGLIST']//a[@title='page suivante']/@href"));
            // <div class="ETABLISSEMENT STAR-1 ODD"> <div class="ETABLISSEMENT STAR-0 ODD"> <div class="ETABLISSEMENT STAR-1 EVEN">
            IEnumerable <XXElement>    xeHeaders = xeSource.XPathElements("//div[starts-with(@class, 'ETABLISSEMENT STAR-')]");
            List <Gesat_HeaderCompany> headers   = new List <Gesat_HeaderCompany>();

            foreach (XXElement xeHeader in xeHeaders)
            {
                Gesat_HeaderCompany header = new Gesat_HeaderCompany();
                header.sourceUrl       = _url;
                header.loadFromWebDate = DateTime.Now;

                //<span class="NOM"><a title="ESAT BETTY LAUNAY-MOULIN VERT" href="/Gesat/Hauts-de-Seine,92/Bois-Colombes,35494/esat-betty-launay-moulin-vert-competences-et-handicap-92,e1837/">ESAT BETTY LAUNAY-MOULIN VERT</a></span>
                //_header.companyName = xeHeader.ExplicitXPathValue(".//span[@class='NOM']//a//text()");
                XXElement xe = xeHeader.XPathElement(".//span[@class='NOM']//a");
                if (xe != null)
                {
                    header.url = GetUrl(xe.ExplicitXPathValue("@href"));
                    //header.name = xe.ExplicitXPathValue(".//text()", _trimFunc1);
                    header.name = _trimFunc1(xe.ExplicitXPathValue(".//text()"));
                }
                //<span class="VILLE">E.S.A.T.<br />Bois-Colombes (92)</span>
                xe = xeHeader.XPathElement(".//span[@class='VILLE']");
                if (xe != null)
                {
                    //IEnumerator<string> texts = xe.DescendantTextList().GetEnumerator();
                    IEnumerator <string> texts = xe.DescendantTexts().GetEnumerator();
                    if (texts.MoveNext())
                    {
                        header.type = texts.Current.Trim();
                    }
                    else
                    {
                        Trace.CurrentTrace.WriteLine("error companyType not found");
                    }
                    if (texts.MoveNext())
                    {
                        header.location = texts.Current.Trim();
                    }
                    else
                    {
                        Trace.CurrentTrace.WriteLine("error companyLocation not found");
                    }
                }
                // <span class="TELEPHONE">01 47 86 11 48</span>
                //header.phone = xeHeader.ExplicitXPathValue(".//span[@class='TELEPHONE']//text()", _trimFunc1);
                header.phone = _trimFunc1(xeHeader.ExplicitXPathValue(".//span[@class='TELEPHONE']//text()"));
                //<img info_bulle="Signataire de la charte Ethique et Valeurs" border="0" alt="/images/bullesGesat/pictoCharte.png" src="/images/bullesGesat/pictoCharte.png" style=" border: 0;" />
                //<img info_bulle="Lauréat des trophées HandiResponsables 2013" border="0" alt="/images/bullesGesat/LAURIERS-OR-2013.png" src="/images/bullesGesat/LAURIERS-OR-2013.png" style=" border: 0;" />
                //header.infos = xeHeader.XPathValues(".//img/@info_bulle", _trimFunc1);
                header.infos = xeHeader.XPathValues(".//img/@info_bulle").Select(_trimFunc1).ToArray();
                //_header.SetInfo(xeHeader.XPathValues(".//img/@info_bulle"));
                headers.Add(header);
            }
            _data.headerCompanies = headers.ToArray();
        }