コード例 #1
0
        /// <summary>
        /// 取得指定网站网页的响应信息
        /// </summary>
        /// <param name="strUrl">网站网页的URL</param>
        /// <param name="proxyModel">代理服务器设置</param>
        /// <param name="methodModel">Method验证信息</param>
        /// <returns>返回网站网页的响应信息字符串</returns>
        public string GetHttpHtml(string strUrl, ProxyModel proxyModel, MethodModel methodModel)
        {
            Encoding encoding         = Encoding.Default;
            DateTime pageLastModified = DateTime.Now;

            return(this.GetHttpHtml(strUrl, proxyModel, methodModel, ref encoding, ref pageLastModified));
        }
コード例 #2
0
        public static EntityModel Parse(ProxyModel parent, EntityMetadata metadata)
        {
            var entityModel = new EntityModel(
                parent,
                metadata.LogicalName,
                metadata.SchemaName,
                metadata.NormalizedName(),
                metadata.PluralName(),
                metadata.PrimaryIdAttribute,
                metadata.PrimaryNameAttribute,
                metadata.IsAuditable()
                );

            var fields = metadata.Attributes
                         .Select(a => FieldParser.Parse(entityModel, a)).ToList();

            fields.ForEach(f =>
            {
                if (f.DisplayName == entityModel.DisplayName)
                {
                    f.DisplayName += "1";
                }
            });

            fields = fields.OrderBy(f => f.DisplayName).ToList();

            entityModel.Fields = fields;

            entityModel.RelationshipsOneToMany  = metadata.OneToManyRelationships.Select(r => RelationshipParser.Parse(entityModel, eRelationshipType.OneToMany, r)).OrderBy(r => r.DisplayName);
            entityModel.RelationshipsManyToOne  = metadata.ManyToOneRelationships.Select(r => RelationshipParser.Parse(entityModel, eRelationshipType.ManyToOne, r)).OrderBy(r => r.DisplayName);
            entityModel.RelationshipsManyToMany = metadata.ManyToManyRelationships.Select(r => RelationshipParser.Parse(entityModel, eRelationshipType.ManyToMany, r)).OrderBy(r => r.DisplayName);

            return(entityModel);
        }
コード例 #3
0
        /// <summary>
        /// 取得指定网站网页的响应信息
        /// </summary>
        /// <param name="strUrl">网站网页的URL</param>
        /// <param name="encoding">返回编码</param>
        /// <param name="pageLastModified">返回网站网页时间</param>
        /// <returns>返回网站网页的响应信息字符串</returns>
        public string GetHttpHtml(string strUrl, ref Encoding encoding, ref DateTime pageLastModified)
        {
            MethodModel methodModel = new MethodModel();
            ProxyModel  proxyModel  = new ProxyModel();

            return(this.GetHttpHtml(strUrl, proxyModel, methodModel, ref encoding, ref pageLastModified));
        }
コード例 #4
0
        public ProxyModel Get(string mlbUrl, bool isJson = false)
        {
            var url = WebUtility.UrlDecode(mlbUrl);
            var loader = new DataLoader();
            var data = loader.GetString(url);

            var model = new ProxyModel(data, isJson);

            return model;
        }
コード例 #5
0
        // GET: Proxy/Proxy
        public ActionResult Index(string mlbUrl, bool isJson = false)
        {
            var url    = WebUtility.UrlDecode(mlbUrl);
            var loader = new DataLoader();
            var data   = loader.GetString(url);

            var model = new ProxyModel(data, isJson);

            return(View(model));
        }
コード例 #6
0
ファイル: ProxyJSClass.cs プロジェクト: h3y/.netHTML
 public ProxyJSClass()
 {
     using (var request = new HttpRequest())
     {
         request.UserAgent = Http.ChromeUserAgent();
         request.Get("http://proxy.am/api.php?key=oh8jdxakyr");
         string response = request.Get("http://proxy.am/list/socks.php?t=light&switch").ToString();
         proxyModel       = JsonConvert.DeserializeObject <ProxyModel>(response);
         Global.LoadProxy = new List <data>(proxyModel.data);
     }
 }
コード例 #7
0
        /// <summary>
        /// Initializes a new instance of the
        /// <see cref="Dexyon.MvvmCrossObjectList.Core.ViewModels.ExampleOverviewViewModel"/> class.
        /// </summary>
        public ExampleOverviewViewModel()
        {
            _currentPerson = new Person()
            {
                FullName   = "Jelle Damen",
                BirthDate  = new System.DateTime(1987, 2, 10),
                BirthPlace = "Hoofddorp",
                //HasChildren = false
            };

            CurrentPerson = new ProxyModel <Person>(_currentPerson, () => {
                RaisePropertyChanged(() => CurrentPerson);
            });
        }
コード例 #8
0
        /// <summary>
        /// Initializes a new instance of the
        /// <see cref="Dexyon.MvvmCrossObjectList.Core.ViewModels.ExampleOverviewViewModel"/> class.
        /// </summary>
        public ExampleOverviewViewModel()
        {
            _currentPerson = new Person ()
            {
                FullName = "Jelle Damen",
                BirthDate = new System.DateTime(1987,2,10),
                BirthPlace = "Hoofddorp",
                //HasChildren = false
            };

            CurrentPerson = new ProxyModel<Person>(_currentPerson,()=>{
                RaisePropertyChanged(()=> CurrentPerson);
            });
        }
コード例 #9
0
ファイル: ProxyWindow.xaml.cs プロジェクト: zha0/rsmaster
        private ProxyModel GetProxyDetails()
        {
            var proxy = new ProxyModel();

            Invoke(() =>
            {
                proxy.Alias    = TxtBoxProxyAlias.Text != string.Empty ? TxtBoxProxyAlias.Text : null;
                proxy.Host     = TxtBoxProxyHost.Text != string.Empty ? TxtBoxProxyHost.Text : null;
                proxy.Port     = TxtBoxProxyPort.Text != string.Empty ? TxtBoxProxyPort.Text : null;
                proxy.Username = TxtBoxProxyUsername.Text != string.Empty ? TxtBoxProxyUsername.Text : null;
                proxy.Password = TxtBoxProxyPassword.Text != string.Empty ? TxtBoxProxyPassword.Text : null;
                proxy.Type     = ComboBoxProxyType.Text;
            });

            return(proxy);
        }
コード例 #10
0
ファイル: ProxyWindow.xaml.cs プロジェクト: zha0/rsmaster
        private void SetProxyDetails(ProxyModel model)
        {
            if (model is null)
            {
                return;
            }

            Invoke(() =>
            {
                TxtBoxProxyAlias.Text           = model.Alias;
                TxtBoxProxyHost.Text            = model.Host;
                TxtBoxProxyPort.Text            = model.Port;
                TxtBoxProxyUsername.Text        = model.Username;
                TxtBoxProxyPassword.Text        = model.Password;
                ComboBoxProxyType.SelectedIndex = Math.Max(ComboBoxProxyType.Items.IndexOf(model.Type), 0);
            });
        }
コード例 #11
0
        public void BuildProxies(ProxyModel model)
        {
            _ = model ?? throw new ArgumentNullException("model is required.");

            var session = new TextTemplatingSession
            {
                ["Namespace"] = Settings?.Namespace ?? "Proxy",
                ["Model"]     = model
            };

            Host host = new Host(Settings, session);

            host.Message += (sender, args) => { RaiseMessage(args.Message); };

            string input = File.ReadAllText(host.TemplateFile);

            var engine = new Mono.TextTemplating.TemplatingEngine();

            var output = engine.ProcessTemplate(input, host);

            if (host.Errors.Count > 0)
            {
                foreach (var error in host.Errors)
                {
                    RaiseMessage(error.ToString(), "", eMessageType.Error);
                }

                return;
            }

            var defaultFileName = Path.ChangeExtension(
                Path.Combine(
                    host.OutputPath,
                    Path.GetFileName(host.TemplateFile)),
                host.FileExtension);

            if (output?.Length > 0)
            {
                CreateFile(defaultFileName, output);
            }
            else if (File.Exists(defaultFileName))
            {
                RaiseMessage(string.Format("Deleting {0}.", defaultFileName), "", eMessageType.Info);
                File.Delete(defaultFileName);
            }
        }
コード例 #12
0
ファイル: ProxysAddTest.cs プロジェクト: kartik1001/RuiJi.Net
        public void Add()
        {
            var files = System.IO.Directory.GetFiles(@"d:\download");

            foreach (var item in files)
            {
                var f = System.IO.File.ReadAllText(item);

                var arr = JArray.Parse(f);
                foreach (var a in arr)
                {
                    var proxy = new ProxyModel();
                    proxy.Ip   = a["metas"]["ip"].ToString();
                    proxy.Port = a["metas"]["port"].Value <int>();

                    ProxyLiteDb.AddOrUpdate(proxy);
                }
            }
        }
コード例 #13
0
        public IActionResult Test(string email, string password)
        {
            ProxyModel proxyModel = new ProxyModel(email, password);
            Object     result     = proxyModel.Check();

            if (!(result is RegisteredUserModel) && !(result is UnregistredUserModel) &&
                !(result is LocalAdministratorModel) && !(result is MainAdministratorModel) &&
                !(result is OrganizerModel) && result == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            if (result is RegisteredUserModel)
            {
                HttpContext.Session.SetString("role", "Registred");
                HttpContext.Session.SetInt32("id", (result as RegisteredUserModel).UserModelId);
                return(RedirectToAction("Index", "Home"));
            }

            if (result is OrganizerModel)
            {
                HttpContext.Session.SetString("role", "Organizer");
                HttpContext.Session.SetInt32("id", (result as OrganizerModel).OrganizerModelId);
                return(RedirectToAction("Index", "Home"));
            }

            if (result is LocalAdministratorModel)
            {
                HttpContext.Session.SetString("role", "Local");
                HttpContext.Session.SetInt32("id", (result as LocalAdministratorModel).AdministratorModelId);
                return(RedirectToAction("Index", "Home"));
            }

            if (result is MainAdministratorModel)
            {
                HttpContext.Session.SetString("role", "Main");
                HttpContext.Session.SetInt32("id", (result as MainAdministratorModel).AdministratorModelId);
                return(RedirectToAction("Index", "Home"));
            }

            return(RedirectToAction("Index", "Home"));
        }
コード例 #14
0
        /// <summary>
        /// Возвращает массив прокси полученный по API сервиса.
        /// </summary>
        public string[] GetProxiesFromApi()
        {
            // https://htmlweb.ru/analiz/proxy_list.php

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://htmlweb.ru/json/proxy/get?country=RU&perpage=380&short");

            request.Proxy = null;
            WebResponse response = (HttpWebResponse)request.GetResponse();

            ProxyModel proxy = new ProxyModel();

            using (Stream stream = response.GetResponseStream())
            {
                using (StreamReader reader = new StreamReader(stream))
                {
                    string responseBody = reader.ReadToEnd();
                    if (responseBody != null && responseBody != "")
                    {
                        Dictionary <string, string> items = JsonConvert.DeserializeObject <Dictionary <string, string> >(responseBody);
                        string[] proxies = new string[items.Values.Count];

                        int i = 0;
                        foreach (string value in items.Values)
                        {
                            if (value.Length > 2)
                            {
                                proxies[i] = value;
                            }
                            i++;
                        }

                        proxy.Proxies   = proxies;
                        proxy.AddedDate = DateTime.Now;
                    }
                    response.Close();
                }
            }

            return(proxy.Proxies);
        }
コード例 #15
0
        public ProxyModel BuildModel(IEnumerable <EntityMetadata> entityMetadata, IEnumerable <SdkMessageMetadata> messageMetadata)
        {
            var proxyModel = new ProxyModel(this.TypeConverter);

            var entities = entityMetadata
                           .Select(e => EntityParser.Parse(proxyModel, e))
                           .OrderBy(e => e.DisplayName);

            var globals = proxyModel.GlobalOptionSets = GetGlobalOptionsFromEntities(entities)
                                                        .OrderBy(o => o.DisplayName);

            var messages = messageMetadata
                           .Select(m => MessageParser.Parse(m))
                           .OrderBy(m => m.SchemaName);

            proxyModel.Entities         = entities;
            proxyModel.GlobalOptionSets = globals;
            proxyModel.Messages         = messages;

            RaiseMessage("Generated Proxy Model...");

            return(proxyModel);
        }
コード例 #16
0
        /// <summary>
        /// 提交Method信息
        /// </summary>
        /// <param name="proxyModel">代理服务器设置</param>
        /// <param name="methodModel">Method验证信息</param>
        /// <returns></returns>
        public bool SetMethod(ProxyModel proxyModel, MethodModel methodModel)
        {
            bool isPostOk = false;

            try
            {
                if (!String.IsNullOrEmpty(methodModel.Post) && !String.IsNullOrEmpty(methodModel.PostUrl))
                {
                    HttpWebRequest httpWebRequest = (HttpWebRequest)HttpWebRequest.Create(methodModel.PostUrl);

                    #region 代理服务器
                    if (proxyModel.ProxyAddress != String.Empty)
                    {
                        WebProxy webProxy = new WebProxy(proxyModel.ProxyAddress + ":" + proxyModel.ProxyPort, false);
                        webProxy.Credentials = new NetworkCredential(proxyModel.ProxyUserName, proxyModel.ProxyPassword, proxyModel.ProxyDomain);
                        httpWebRequest.Proxy = webProxy;
                    }
                    #endregion 代理服务器

                    #region 伪造浏览器数据进行伪装访问,避免被防采集程序过滤,并避开ASP常用的POST检查
                    System.Random random    = new System.Random();
                    int           intRandom = random.Next(0, HttpWebRequestUserAgent.Length - 1);     //随机一个UserAgent
                    httpWebRequest.UserAgent = HttpWebRequestUserAgent[intRandom];
                    try
                    {
                        httpWebRequest.Referer = this.ConvertUrlRoot(methodModel.PostUrl);                      //指明来源网页,可以将这里替换成要采集页面的主页
                    }
                    catch
                    {
                    }
                    httpWebRequest.ContentType = "application/x-www-form-urlencoded";
                    httpWebRequest.Accept      = "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
                    #endregion 伪造浏览器数据进行伪装访问,避免被防采集程序过滤,并避开ASP常用的POST检查

                    #region 包装HttpWebRequest
                    httpWebRequest.Credentials       = CredentialCache.DefaultCredentials;
                    httpWebRequest.Timeout           = HTTP_TIME_OUT;
                    httpWebRequest.AllowAutoRedirect = true;
                    #endregion 包装HttpWebRequest

                    #region 提交Method.Post信息
                    httpWebRequest.CookieContainer = this.m_CookieContainer;
                    byte[] byteRequest = Encoding.Default.GetBytes(methodModel.Post);
                    httpWebRequest.Method        = Method.Post.ToString();
                    httpWebRequest.ContentLength = byteRequest.Length;
                    Stream stream = httpWebRequest.GetRequestStream();
                    stream.Write(byteRequest, 0, byteRequest.Length);
                    stream.Close();
                    #endregion 提交Method.Post信息

                    isPostOk = true;

                    HttpWebResponse httpWebResponse;
                    try
                    {
                        httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
                    }
                    catch (WebException ex)
                    {
                        httpWebResponse = (HttpWebResponse)ex.Response;
                    }

                    httpWebRequest.Abort();
                    httpWebResponse.Close();
                }
                else
                {
                    isPostOk = false;
                }
            }
            catch
            {
                isPostOk = false;
            }
            return(isPostOk);
        }
コード例 #17
0
 public ProxyPresenter(IProxyView view) : base(view)
 {
     _model = new ProxyModel(ViewInfo);
 }
コード例 #18
0
 public ProxySwitcherViewModel(MainViewModel mainPage)
 {
     MainPage              = mainPage;
     _proxyDataModel       = new ProxyModel();
     _cachedProxyDataModel = new ProxyModel();
 }
コード例 #19
0
        public void ShouldBeAbleToRenderService()
        {
            ProxyModel model = new ProxyModel(typeof(Echo));

            OutLine(model.Render(), ConsoleColor.Cyan);
        }
コード例 #20
0
 public async Task <string> Get(int id)
 {
     return(await ProxyModel.GetValue(id));
 }
コード例 #21
0
 public async Task <string> Put(int id, [FromBody] ValueDTO data)
 {
     return(await ProxyModel.PutValue(id, data.Value));
 }
コード例 #22
0
        /// <summary>
        /// 取得指定网站网页的响应信息
        /// </summary>
        /// <param name="strUrl">网站网页的URL</param>
        /// <param name="proxyModel">代理服务器设置</param>
        /// <param name="methodModel">Method验证信息</param>
        /// <param name="encoding">返回编码</param>
        /// <param name="pageLastModified">返回网站网页时间</param>
        /// <returns>返回网站网页的响应信息字符串</returns>
        public string GetHttpHtml(string strUrl, ProxyModel proxyModel, MethodModel methodModel, ref Encoding encoding, ref DateTime pageLastModified)
        {
            #region 开始时间
            DateTime dateTimeBegin = DateTime.Now;
            #endregion 开始时间

            encoding = Encoding.Default;
            string strResult = String.Empty;
            try
            {
                HttpWebRequest httpWebRequest = (HttpWebRequest)HttpWebRequest.Create(strUrl);

                #region 代理服务器
                if (proxyModel.ProxyAddress != String.Empty)
                {
                    WebProxy webProxy = new WebProxy(proxyModel.ProxyAddress + ":" + proxyModel.ProxyPort, false);
                    webProxy.Credentials = new NetworkCredential(proxyModel.ProxyUserName, proxyModel.ProxyPassword, proxyModel.ProxyDomain);
                    httpWebRequest.Proxy = webProxy;
                }
                #endregion 代理服务器

                #region 伪造浏览器数据进行伪装访问,避免被防采集程序过滤,并避开ASP常用的POST检查
                System.Random random    = new System.Random();
                int           intRandom = random.Next(0, HttpWebRequestUserAgent.Length - 1); //随机一个UserAgent
                httpWebRequest.UserAgent = HttpWebRequestUserAgent[intRandom];
                try
                {
                    httpWebRequest.Referer = strUrl;                  //指明来源网页,可以将这里替换成要采集页面的主页
                }
                catch
                {
                }
                httpWebRequest.ContentType = "application/x-www-form-urlencoded";
                httpWebRequest.Accept      = "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
                #endregion 伪造浏览器数据进行伪装访问,避免被防采集程序过滤,并避开ASP常用的POST检查

                #region 包装HttpWebRequest
                httpWebRequest.Credentials       = CredentialCache.DefaultCredentials;
                httpWebRequest.Timeout           = HTTP_TIME_OUT;
                httpWebRequest.AllowAutoRedirect = true;
                #endregion 包装HttpWebRequest

                #region 调用Cookie
                this.SetMethod(proxyModel, methodModel);               //提交Method信息
                httpWebRequest.CookieContainer = this.m_CookieContainer;
                #endregion 调用Cookie

                HttpWebResponse httpWebResponse;
                try
                {
                    httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
                }
                catch (WebException ex)
                {
                    httpWebResponse = (HttpWebResponse)ex.Response;
                }

                #region 获取最后一次修改响应内容的日期和时间
                try
                {
                    pageLastModified = httpWebResponse.LastModified;
                }
                catch (Exception ex)
                {
                    string strTemp = "StackTrace:" + ex.StackTrace + "\r\nMessage:" + ex.Message + "\r\nURL:" + strUrl;
                }
                #endregion 获取最后一次修改响应内容的日期和时间

                #region 自动识别网页编码,并读取内容

                strResult = this.GetHttpHtmlDecode(httpWebResponse, ref encoding);

                #endregion 自动识别网页编码,并读取内容

                #region 自动识别失败原因
                if (strResult == String.Empty)
                {
                    try
                    {
                        strResult = new StreamReader(httpWebResponse.GetResponseStream(), Encoding.Default).ReadToEnd();
                    }
                    catch (Exception ex)
                    {
                        strResult = ex.Message.Replace("\r", String.Empty).Replace("\n", String.Empty);
                    }
                }
                #endregion 自动识别失败原因

                httpWebRequest.Abort();
                httpWebResponse.Close();
            }
            catch (Exception ex)
            {
                string strTemp = "StackTrace:" + ex.StackTrace + "\r\nMessage:" + ex.Message + "\r\nURL:" + strUrl;
            }

            #region 结束时间
            DateTime dateTimeEnd = DateTime.Now;
            #endregion 结束时间

            #region 输出URLResult

            #endregion  输出URLResult

            #region 滤去无用的并影响分析效率的字符串 如:VIEWSTATE
            if (strResult.Trim() != String.Empty)
            {
                foreach (string oldValue in ContainUselessTag)
                {
                    if (oldValue != String.Empty)
                    {
                        Regex           r  = new Regex(oldValue, RegexOptions.IgnoreCase | RegexOptions.Compiled);
                        MatchCollection mc = r.Matches(strResult);
                        for (int i = 0; i < mc.Count; i++)
                        {
                            if (mc[i].Value.Length > 512)
                            {
                                strResult = strResult.Replace(mc[i].Value, String.Empty).Trim();
                            }
                        }
                        r  = null;
                        mc = null;
                    }
                }
            }

            #endregion 滤去无用的并影响分析效率的字符串  如:VIEWSTATE

            return(strResult);
        }
コード例 #23
0
 public async Task <string> Delete(int id)
 {
     return(await ProxyModel.DeleteValue(id));
 }
コード例 #24
0
        public object UpdateProxy(ProxyModel proxy)
        {
            ProxyLiteDb.AddOrUpdate(proxy);

            return(true);
        }