示例#1
0
        private void WorkerOnDoWork(object sender, DoWorkEventArgs doWorkEventArgs)
        {
            var args = (Tuple <decimal, decimal, int>)doWorkEventArgs.Argument;
            var res  = GetAllImagesNamesOnPoint(args.Item1, args.Item2, args.Item3);

            CompareInfo.Clear();
            CompareInfo.AddRange(res);

            NeedToUpdate?.Invoke(this, null);
        }
示例#2
0
        public static NeedToUpdate NeedToUpdateCookie(string url, string end = "utf-8", bool isJav = false, CookieContainer cc = null)
        {
            NeedToUpdate ret = new NeedToUpdate();

            ret.Content = new Model.JavModels.HtmlResponse();

            try
            {
                GC.Collect();
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                request.Credentials = CredentialCache.DefaultCredentials;
                request.Proxy       = null;
                request.Timeout     = 90000;
                request.UserAgent   = string.Format(UserAgent, GetChromeVersion());
                request.Method      = "GET";

                if (isJav)
                {
                    request.CookieContainer = cc;
                }

                request.KeepAlive = true;
                HttpWebResponse response   = (HttpWebResponse)request.GetResponse();
                Stream          dataStream = response.GetResponseStream();
                StreamReader    reader     = new StreamReader(dataStream, Encoding.GetEncoding(end));

                ret.Content.Content = reader.ReadToEnd();
                reader.Close();
                dataStream.Close();
                response.Close();
            }
            catch (Exception e)
            {
                if (e.Message == Error)
                {
                    ret.Content.Success = false;
                    ret.Need            = true;
                    return(ret);
                }
            }

            ret.Content.Success = true;
            ret.Need            = false;
            return(ret);
        }