示例#1
0
        internal static void ByDeal(Models.Condition Condition, ref List <DataLayer.DataManager.dbCondition> SelectConditions)
        {
            DataLayer.DealType DealType = DataLayer.DealType.All;

            Enum.TryParse <DataLayer.DealType>(Condition.Deal, out DealType);

            SelectConditions.Add((DataLayer.Post CurrentPost) =>
            {
                if (DealType == DataLayer.DealType.All)
                {
                    return(true);
                }
                else
                if (CurrentPost.DealType == DealType)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            });
        }
示例#2
0
        public IHttpActionResult UpdateDb()
        {
            String Answer = "Nothing";

            try
            {
                List <String> Urls    = new List <string>();
                List <String> Animals = new List <string>()
                {
                    "dogs",
                    "cats",
                    "birds",
                    "rodents",
                    "reptile",
                    "fish",
                    "insects",
                    "horses",
                    "Домашний-скот",
                    "exotic"
                };
                using (var Parser = new PageParser())
                {
                    List <String> Types = new List <string>()
                    {
                        "sale", "buy", "love", "free"
                    };

                    List <DataLayer.Post> ParsedPosts = new List <DataLayer.Post>();

                    foreach (String AnimalPage in Animals)
                    {
                        foreach (String Type in Types)
                        {
                            using (var ZooParser = new Content.ZooParser())
                            {
                                Parser.OnParsed = (String ParsedUrl) =>
                                {
                                    if (ParsedUrl != "")
                                    {
                                        DataLayer.DealType Dt = DataLayer.DealType.All;
                                        Enum.TryParse <DataLayer.DealType>(Type, out Dt);

                                        DataLayer.Animal An = DataLayer.Animal.All;
                                        Enum.TryParse <DataLayer.Animal>(AnimalPage, out An);

                                        ZooParser.OnParsed = (DataLayer.Post ParsedPost) =>
                                        {
                                            ParsedPosts.Add(ParsedPost);
                                        };

                                        if (AnimalPage != "Домашний-скот")
                                        {
                                            ZooParser.ParsePost(ParsedUrl, An, Dt);
                                        }
                                        else
                                        {
                                            ZooParser.ParsePost(ParsedUrl, DataLayer.Animal.Home, Dt);
                                        }
                                    }
                                };
                                Parser.ParsePage("http://www.zoo-zoo.ru/" + AnimalPage + "/" + Type + "/");
                            }
                        }
                    }

                    DataLayer.DataManager.AddList = ParsedPosts;
                    Answer = "True";
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Answer = "False";
            }
            return(Ok(Answer));
        }