示例#1
0
        public void SetItemCount()
        {
            string url = Rooturl + (string.Equals(Item.ToLower(), "characters") ? "people" : Item.ToLower());
            //IRequestHandler requestHandler = new HttpWebRequestHandler();
            //string response = requestHandler.GetRestItems(url);

            string response = ClassHttp.GetRestItem(url);


            ItemCount = Convert.ToUInt16(JObject.Parse(response).SelectToken("count"));
            Pages     = Convert.ToUInt16(Math.Ceiling(ItemCount / (double)10));
        }
示例#2
0
        public override void Main()
        {
            ProcessName = "Task";
            var filmItems = GetRestItemsFilm();

            Task[] tasks = new Task[filmItems.Count];

            for (int i = 0; i < filmItems.Count; i++)
            {
                string uri  = filmItems[i];
                Task   task = ClassHttp.MyTaskRequest(uri);
                tasks[i] = task;
            }

            Task.WaitAll(tasks);
        }
示例#3
0
        public void GetFilmItems()
        {
            char[]   chars = new char[] { '[', '\r', '\n', ']', ' ', '\"' };
            string[] s     = new string[] { "\",\r\n  \"" };
            string   url   = Rooturl + "films/?search=" + Title;

            string response = ClassHttp.GetRestItem(url);

            //IRequestHandler requestHandler = new HttpWebRequestHandler();
            //string response = requestHandler.GetRestItems(url);
            JToken TokenFilm = JObject.Parse(response).SelectToken("results")[0];
            string r         = Rooturl + (string.Equals(Item.ToLower(), "characters") ? "people" : Item.ToLower());
            string items     = TokenFilm[Item].ToString().TrimStart(chars).TrimEnd(chars).Replace(r, null);

            FilmItems = items.Split(s, StringSplitOptions.None).ToList().Select(x => x.Trim('/')).ToList();
        }
示例#4
0
        public void DoWork()
        {
            const string f   = "Current thread: {0}, {1}";
            string       url = Rooturl + (string.Equals(Item.ToLower(), "characters") ? "people" : Item.ToLower()) + "?page=" + PageX;

            var response = ClassHttp.GetRestItem(url);


            //IRequestHandler requestHandler = new HttpWebRequestHandler();
            //string response = requestHandler.GetRestItems(url);
            JToken token = JObject.Parse(response).SelectToken("results");
            string r     = Rooturl + (string.Equals(Item.ToLower(), "characters") ? "people" : Item.ToLower());

            for (int i = 0; i < token.Count(); i++)
            {
                string n = token[i]["url"].ToString().Replace(r, null).Trim('/');

                if (_filmItems.Contains(n))
                {
                    string property = token[i][Property].ToString();
                    Console.WriteLine(f, Thread.CurrentThread.ManagedThreadId, property);
                }
            }
        }