private void CreateWorkplaceCommandHandler() { Presentation.Workplace sendingWorkplace = GetWorkplace(); WebViewModel viewModel = (WebViewModel) sendingWorkplace.CurrentViewModel; Presentation.Workplace workplace = WebContext.WorkplaceManager.CreateWorkplace(); workplace.ActivateView(viewModel); }
public async Task <List <PersonaViewModel> > BusquedaPaginada(WebViewModel pagina, string busqueda) { var lista = new List <PersonaViewModel>(); for (int i = 0; i < 1000; i = i + 25) { HtmlWeb web = new HtmlWeb(); var htmlDoc = await web.LoadFromWebAsync(pagina.UrlBusquedaPaginada.Replace("{0}", busqueda).Replace("lim=0", "lim=" + i.ToString()).Replace("{aniofin}", DateTime.Now.Year.ToString())); var nodos = htmlDoc.DocumentNode.SelectNodes(pagina.Selector); if (nodos != null) { foreach (var nodo in nodos) { if (nodo.InnerText.ToUpper().Contains("NOMBRE") || nodo.InnerText.ToUpper().Contains("PERSONA")) { continue; } var nuevo = new PersonaViewModel(); nuevo.Nombre = nodo.InnerText; nuevo.Conservador = pagina.Comuna; nuevo.Url = pagina.UrlBusquedaPaginada.Replace("{0}", busqueda).Replace("lim=0", "lim=" + i.ToString()).Replace("{aniofin}", DateTime.Now.Year.ToString()); lista.Add(nuevo); } } else { break; } } return(lista); }
private void Initialize() { if (!String.IsNullOrEmpty(Request.QueryString["dashboardId"])) { dashboardWebViewModel = WebViewModel.Parse(Convert.ToInt32(Request.QueryString["dashboardId"])); } else { dashboardWebViewModel = WebViewModel.Parse(101); } PrepareAjaxPage(); }
public async Task <List <PersonaViewModel> > BusquedaAjaxTablaDinamica(WebViewModel pagina, string busqueda) { var lista = new List <PersonaViewModel>(); using (var client = new HttpClient()) { var parametros = new Dictionary <string, string>(); foreach (var item in pagina.Params.ToList()) { parametros.Add(item.Key, item.Value.Replace("{0}", busqueda)); } var content = new FormUrlEncodedContent(parametros); var response = await client.PostAsync(pagina.UrlBusqueda, content); //var response = client.GetAsync(pagina.UrlBusqueda).Result; if (response.IsSuccessStatusCode) { var htmlBody = await response.Content.ReadAsStringAsync(); var htmlDoc = new HtmlDocument(); htmlDoc.LoadHtml(htmlBody); var nodos = htmlDoc.DocumentNode.SelectNodes(pagina.Selector); List <string> nodosFiltrados = new List <string>(); if (nodos != null) { foreach (var nodo in nodos) { if (nodo.InnerText.Contains("Nombre 1")) { nodosFiltrados.Add(nodo.InnerText.Replace("Nombre 1", "").Trim()); } } } if (nodos != null) { foreach (var item in nodosFiltrados) { if (string.IsNullOrEmpty(item)) { continue; } var nuevo = new PersonaViewModel(); nuevo.Nombre = item; nuevo.Conservador = pagina.Comuna; nuevo.Url = pagina.UrlBusqueda.Replace("{0}", busqueda); lista.Add(nuevo); } } } } return(lista); }
private void LoadViewCommandHandler() { string viewName = GetCommandParameter("viewName", true); string userInterfaceItemId = GetCommandParameter("userInterfaceItemId", false); WebViewModel viewModel = (WebViewModel) ViewModel.Parse(viewName); string viewParameters = viewModel.GetQueryString(Request.QueryString); viewParameters += (viewParameters.Length != 0 ? "&" : String.Empty) + "dashboardId=" + userInterfaceItemId; Presentation.Workplace workplace = GetWorkplace(); workplace.ActivateView(viewModel, viewParameters); }
private void CreateViewCommandHandler() { string viewName = GetCommandParameter("viewName", true); WebViewModel viewModel = (WebViewModel) ViewModel.Parse(viewName); string viewParameters = viewModel.GetQueryString(Request.QueryString); Presentation.Workplace workplace = WebContext.WorkplaceManager.CreateWorkplace(); workplace.ActivateView(viewModel, viewParameters); }
public IActionResult Index(string Title, int PageIndex = 1, int PageSize = 20) { base.Parameters["Title"] = Title; PagedList <EXArticleViewModel> data = exArticleService.GetListByPage(Title, PageIndex, PageSize); WebViewModel <EXArticleViewModel> model = new WebViewModel <EXArticleViewModel> { PagedList = data, Parameters = Parameters }; return(View(model)); }
public IActionResult CategoryManage(string Title = "", int PageIndex = 1, int PageSize = 20) { base.Parameters["Title"] = Title; PagedList <MaterialsCategoryViewModel> data = materialsService.GetCategoryListByPage(Title, PageIndex, PageSize); WebViewModel <MaterialsCategoryViewModel> model = new WebViewModel <MaterialsCategoryViewModel> { PagedList = data, Parameters = Parameters }; return(View(model)); }
private void BackHistoryCommandHandler() { Presentation.Workplace workplace = GetWorkplace(); string[] history = workplace.NavigationHistory.Back().Split('?'); WebViewModel viewModel = (WebViewModel) ViewModel.Parse(history[0]); if (history.Length == 1) { workplace.ActivateView(viewModel); } else { workplace.ActivateView(viewModel, history[1]); } }
public WebView(WebViewModel viewModel, JavaScriptBridge javaScriptBridge) { DataContext = viewModel; InitializeComponent(); // After the bridge receives a message that triggers loading of a new url, we need to set the focus out of the // cefsharp browser. Otherwise a nasty bug occurs making the cefsharp embedded browser unable to set // the :focus meta tag. javaScriptBridge.OnNavigationEventReceived += sender => { Application.Current.Dispatcher.Invoke(() => { Ghost.Focus(); }); }; }
public async Task <List <PersonaViewModel> > BusquedaPaginada2(WebViewModel pagina, string busqueda) { var lista = new List <PersonaViewModel>(); for (int i = 1; i <= 40; i++) { HtmlWeb web = new HtmlWeb(); var htmlDoc = new HtmlDocument(); var apellido = ""; var nombre = ""; if (busqueda.Contains("/")) { apellido = busqueda.Split('/')[0]; nombre = busqueda.Split('/')[1]; htmlDoc = await web.LoadFromWebAsync(pagina.UrlBusquedaPaginada2.Replace("{0}", apellido).Replace("{1}", nombre).Replace("pag=0", "pag=" + i.ToString())); } else { htmlDoc = await web.LoadFromWebAsync(pagina.UrlBusquedaPaginada2.Replace("{0}", busqueda).Replace("pagina=0", "pagina=" + i.ToString())); } var nodos = htmlDoc.DocumentNode.SelectNodes(pagina.Selector); if (nodos != null) { foreach (var nodo in nodos) { if (nodo.InnerText.ToUpper().Contains("NOMBRE") || nodo.InnerText.ToUpper().Contains("PERSONA") || string.IsNullOrEmpty(nodo.InnerText) || nodo.InnerText.Contains("\r\n")) { if (nodos.Count == 1) { i = 40; } continue; } var nuevo = new PersonaViewModel(); nuevo.Nombre = nodo.InnerText; nuevo.Conservador = pagina.Comuna; nuevo.Url = busqueda.Contains("/") ? (pagina.UrlBusquedaPaginada2.Replace("{0}", apellido).Replace("{1}", nombre).Replace("pag=0", "pag=" + i.ToString())) : (pagina.UrlBusquedaPaginada2.Replace("{0}", busqueda).Replace("pagina=0", "pagina=" + i.ToString())); lista.Add(nuevo); } } else { break; } } return(lista); }
public async Task <List <PersonaViewModel> > BusquedaUrlColumnasSeparadas(WebViewModel pagina, string busqueda) { var lista = new List <PersonaViewModel>(); HtmlWeb web = new HtmlWeb(); var htmlDoc = new HtmlDocument(); var apellido = ""; var nombre = ""; if (busqueda.Contains("/")) { apellido = busqueda.Split('/')[0]; nombre = busqueda.Split('/')[1]; htmlDoc = web.Load(pagina.UrlBusqueda.Replace("{0}", apellido).Replace("{1}", nombre)); } else { htmlDoc = await web.LoadFromWebAsync(pagina.UrlBusqueda.Replace("{0}", busqueda)); } var nodos = htmlDoc.DocumentNode.SelectNodes(pagina.Selector); var nodos2 = htmlDoc.DocumentNode.SelectNodes(pagina.Selector2); if (nodos != null && nodos2 != null) { for (int i = 0; i < nodos.Count(); i++) { if (nodos[i].InnerText.ToUpper().Contains("NOMBRE") || nodos[i].InnerText.ToUpper().Contains("PERSONA") || nodos[i].InnerText.ToUpper().Contains("PATERNO") || nodos[i].InnerText.ToUpper().Contains("APELLIDO")) { continue; } var nuevo = new PersonaViewModel(); nuevo.Nombre = nodos[i].InnerText + " " + nodos2[i].InnerText; nuevo.Conservador = pagina.Comuna; nuevo.Url = busqueda.Contains("/") ? pagina.UrlBusqueda.Replace("{0}", apellido).Replace("{1}", nombre) : pagina.UrlBusqueda.Replace("{0}", busqueda); lista.Add(nuevo); } } return(lista); }
public async Task <List <PersonaViewModel> > BusquedaUrl(WebViewModel pagina, string busqueda) { var lista = new List <PersonaViewModel>(); HtmlWeb web = new HtmlWeb(); var htmlDoc = new HtmlDocument(); var apellido = ""; var nombre = ""; if (busqueda.Contains("/")) { apellido = busqueda.Split('/')[0]; nombre = busqueda.Split('/')[1]; htmlDoc = await web.LoadFromWebAsync(pagina.UrlBusqueda.Replace("{0}", apellido).Replace("{1}", nombre).Replace("{aniofin}", DateTime.Now.Year.ToString())); } else { htmlDoc = await web.LoadFromWebAsync(pagina.UrlBusqueda.Replace("{0}", busqueda).Replace("{aniofin}", DateTime.Now.Year.ToString())); } var nodos = htmlDoc.DocumentNode.SelectNodes(pagina.Selector); if (nodos != null) { foreach (var nodo in nodos) { if (nodo.InnerText.ToUpper().Contains("NOMBRE") || nodo.InnerText.ToUpper().Contains("PERSONA") || nodo.InnerText.ToUpper().Contains("PATERNO") || string.IsNullOrEmpty(nodo.InnerText)) { continue; } var nuevo = new PersonaViewModel(); nuevo.Nombre = nodo.InnerText; nuevo.Conservador = pagina.Comuna; nuevo.Url = busqueda.Contains("/") ? pagina.UrlBusqueda.Replace("{0}", apellido).Replace("{1}", nombre).Replace("{aniofin}", DateTime.Now.Year.ToString()) : pagina.UrlBusqueda.Replace("{0}", busqueda).Replace("{aniofin}", DateTime.Now.Year.ToString()); lista.Add(nuevo); } } return(lista); }
public async Task <List <PersonaViewModel> > BusquedaAjaxPorAnio(WebViewModel pagina, string busqueda) { var lista = new List <PersonaViewModel>(); using (var client = new HttpClient()) { for (int i = 1980; i <= DateTime.Now.Year; i++) { var parametros = new Dictionary <string, string>(); foreach (var item in pagina.Params.ToList()) { parametros.Add(item.Key, item.Value.Replace("{0}", busqueda).Replace("{anio}", i.ToString())); } var content = new FormUrlEncodedContent(parametros); var response = await client.PostAsync(pagina.UrlBusqueda, content); if (response.IsSuccessStatusCode) { var htmlBody = await response.Content.ReadAsStringAsync(); var jsonn = JObject.Parse(htmlBody); if (jsonn["obj"]["recordsTotal"].ToString() != "0") { foreach (var item in jsonn["obj"]["data"]) { //System.Diagnostics.Debug.WriteLine(i); var nuevo = new PersonaViewModel(); nuevo.Nombre = item["titular"].ToString(); nuevo.Conservador = pagina.Comuna; nuevo.Url = pagina.Url; lista.Add(nuevo); } } } } } return(lista); }
public async Task <List <PersonaViewModel> > BusquedaAjax(WebViewModel pagina, string busqueda) { var lista = new List <PersonaViewModel>(); var apellido = ""; var nombre = ""; string[] nonceSplit; var nonce = ""; var separados = false; if (busqueda.Contains("/")) { apellido = busqueda.Split('/')[0]; nombre = busqueda.Split('/')[1]; separados = true; } using (var client = new HttpClient()) { var parametros = new Dictionary <string, string>(); if (!string.IsNullOrEmpty(pagina.SelectorNonce)) { var llamadoGet = await client.GetAsync(pagina.Url); var llamadoGetContent = await llamadoGet.Content.ReadAsStringAsync(); var htmlDocGet = new HtmlDocument(); htmlDocGet.LoadHtml(llamadoGetContent); var nonce2 = htmlDocGet.DocumentNode.SelectNodes(pagina.SelectorNonce); nonceSplit = nonce2[0].OuterHtml.Split("value="); nonce = nonceSplit[1].Substring(1, 10); } foreach (var item in pagina.Params.ToList()) { if (separados) { parametros.Add(item.Key, item.Value.Replace("{0}", apellido).Replace("{1}", nombre).Replace("{nonce}", nonce).Replace("{aniofin}", DateTime.Now.Year.ToString())); } else { parametros.Add(item.Key, item.Value.Replace("{0}", busqueda).Replace("{5}", "Ñ").Replace("{nonce}", nonce).Replace("{aniofin}", DateTime.Now.Year.ToString())); } } var content = new FormUrlEncodedContent(parametros); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("*/*")); var response = await client.PostAsync(pagina.UrlBusqueda, content); //var response = client.GetAsync(pagina.UrlBusqueda).Result; if (response.IsSuccessStatusCode) { var htmlBody = await response.Content.ReadAsStringAsync(); var htmlDoc = new HtmlDocument(); htmlDoc.LoadHtml(htmlBody); if (pagina.Json) { var jsonn = JObject.Parse(htmlBody); if (jsonn[pagina.AtributoJson].ToString() != "No se han encontrado coincidencias" && jsonn[pagina.AtributoJson].ToString() != "0") { if (pagina.Url == "https://cbrlosandes.cl/consulta-propiedad/") { for (int i = 0; i < int.Parse(jsonn[pagina.AtributoJson].ToString()); i++) { var nuevo = new PersonaViewModel(); //System.Diagnostics.Debug.WriteLine(i); nuevo.Nombre = jsonn["data"][i][1].ToString(); nuevo.Conservador = pagina.Comuna; nuevo.Url = pagina.Url; lista.Add(nuevo); } } else { foreach (var item in jsonn["content"]["list"]) { var nuevo = new PersonaViewModel(); nuevo.Nombre = item["nombre"].ToString().Replace("{", "").Replace("}", ""); nuevo.Conservador = pagina.Comuna; nuevo.Url = pagina.Url; lista.Add(nuevo); } } } } else { var nodos = htmlDoc.DocumentNode.SelectNodes(pagina.Selector); if (nodos != null) { foreach (var nodo in nodos) { if (nodo.InnerText.ToUpper().Contains("COMPRADOR") || string.IsNullOrEmpty(nodo.InnerHtml)) { continue; } var nuevo = new PersonaViewModel(); nuevo.Nombre = nodo.InnerText.Replace(" ", ""); nuevo.Conservador = pagina.Comuna; nuevo.Url = pagina.Url; lista.Add(nuevo); } } } } } return(lista); }
public Web() { InitializeComponent(); DataContext = new WebViewModel(); }
public async Task <List <PersonaViewModel> > BusquedaAjaxToken2(WebViewModel pagina, string busqueda) { var lista = new List <PersonaViewModel>(); var apellido = busqueda.Split('/')[0]; var nombre = busqueda.Split('/')[1]; using (var client = new HttpClient()) { var responseGet = await client.GetAsync(pagina.UrlBusqueda); var htmlBodyGet = await responseGet.Content.ReadAsStringAsync(); var htmlDocGet = new HtmlDocument(); htmlDocGet.LoadHtml(htmlBodyGet); var EVENTVALIDATIONSelector = htmlDocGet.DocumentNode.SelectNodes(pagina.SelectorEventValidation); var EVENTVALIDATIONSplit = EVENTVALIDATIONSelector[0].OuterHtml.Split("value="); var EVENTVALIDATION = EVENTVALIDATIONSplit[1].Substring(1, EVENTVALIDATIONSplit[1].Length - 3); var VIEWSTATESelector = htmlDocGet.DocumentNode.SelectNodes(pagina.SelectorState); var VIEWSTATESplit = VIEWSTATESelector[0].OuterHtml.Split("value="); var VIEWSTATE = VIEWSTATESplit[1].Substring(1, VIEWSTATESplit[1].Length - 3); var callBackSplit = htmlBodyGet.Split("callbackState':'"); var callBackSplit2 = callBackSplit[1].Split("','"); var callBackState = callBackSplit2[0]; var cookieContent = responseGet.Headers.FirstOrDefault(x => x.Key == "Set-Cookie").Value.First().Split(" ")[0]; var tokenCookie = cookieContent.Split("="); var name = tokenCookie[0]; var value = tokenCookie[1]; var parametros = new Dictionary <string, string>(); foreach (var item in pagina.Params.ToList()) { parametros.Add(item.Key.Replace("{4}", "ñ"), item.Value.Replace("{0}", apellido).Replace("{1}", nombre).Replace("{VIEWSTATE}", VIEWSTATE).Replace("{EVENTVALIDATION}", EVENTVALIDATION).Replace("{callbackState}", callBackState)); } var content = new FormUrlEncodedContent(parametros); content.Headers.Add("Cookie", $"{name}={value}"); var response = await client.PostAsync(pagina.UrlBusqueda, content); if (response.IsSuccessStatusCode) { var htmlBody = await response.Content.ReadAsStringAsync(); var htmlDoc = new HtmlDocument(); htmlDoc.LoadHtml(htmlBody); var nodos = htmlDoc.DocumentNode.SelectNodes(pagina.Selector); if (nodos != null) { foreach (var nodo in nodos) { if (nodo.InnerText.ToUpper().Contains("COMPRADOR") || nodo.InnerText.ToUpper().Contains("&NBSP;") || nodo.InnerText.ToUpper().Contains("NOMBRE")) { continue; } var nuevo = new PersonaViewModel(); nuevo.Nombre = nodo.InnerText; nuevo.Conservador = pagina.Comuna; nuevo.Url = pagina.UrlBusqueda.Replace("{0}", busqueda); lista.Add(nuevo); } } } } return(lista); }
public WebPage(WebViewModel viewModel) { InitializeComponent(); BindingContext = _viewModel = viewModel; }
public WebViewModel Post([FromBody] WebViewModel viewModel) { return(_webPortalService.PostCreateViewModel(viewModel)); }
public async Task <List <PersonaViewModel> > BusquedaPagina(WebViewModel pagina, string busqueda) { var lista = new List <PersonaViewModel>(); Stopwatch timeTotal = new Stopwatch(); // Creación del Stopwatch. timeTotal.Start(); long maxTime = 0; _logger.LogInformation($"Inicio Busqueda Fecha[" + DateTime.Now + "] - Conservador[" + pagina.Comuna + "] - Nombre[" + busqueda + "]"); Stopwatch sw = new Stopwatch(); // Creación del Stopwatch. if (!string.IsNullOrEmpty(pagina.UrlBusqueda) && pagina.Ajax == false && pagina.UrlBusquedaColumnasSeparadas == false) { try { sw.Start(); lista.AddRange(await BusquedaUrl(pagina, busqueda)); sw.Stop(); _logger.LogInformation("Tiempo transcurrido: {0}", sw.Elapsed.ToString("hh\\:mm\\:ss\\.fff")); } catch (Exception ex) { _logger.LogError($"Error Busqueda Fecha[" + DateTime.Now + "] - Conservador[" + pagina.Comuna + "] - Nombre[" + busqueda + "] - Error[" + ex.Message + "]"); } } if (pagina.UrlBusquedaColumnasSeparadas == true && pagina.Ajax == false) { try { sw.Start(); lista.AddRange(await BusquedaUrlColumnasSeparadas(pagina, busqueda)); sw.Stop(); _logger.LogInformation("Tiempo transcurrido: {0}", sw.Elapsed.ToString("hh\\:mm\\:ss\\.fff")); } catch (Exception ex) { _logger.LogError($"Error Busqueda Fecha[" + DateTime.Now + "] - Conservador[" + pagina.Comuna + "] - Nombre[" + busqueda + "] - Error[" + ex.Message + "]"); } } if (!string.IsNullOrEmpty(pagina.UrlBusquedaPaginada)) { try { sw.Start(); lista.AddRange(await BusquedaPaginada(pagina, busqueda)); sw.Stop(); _logger.LogInformation("Tiempo transcurrido: {0}", sw.Elapsed.ToString("hh\\:mm\\:ss\\.fff")); } catch (Exception ex) { _logger.LogError($"Error Busqueda Fecha[" + DateTime.Now + "] - Conservador[" + pagina.Comuna + "] - Nombre[" + busqueda + "] - Error[" + ex.Message + "]"); } } if (!string.IsNullOrEmpty(pagina.UrlBusquedaPaginada2)) { try { sw.Start(); lista.AddRange(await BusquedaPaginada2(pagina, busqueda)); sw.Stop(); _logger.LogInformation("Tiempo transcurrido: {0}", sw.Elapsed.ToString("hh\\:mm\\:ss\\.fff")); } catch (Exception ex) { _logger.LogError($"Error Busqueda Fecha[" + DateTime.Now + "] - Conservador[" + pagina.Comuna + "] - Nombre[" + busqueda + "] - Error[" + ex.Message + "]"); } } if (string.IsNullOrEmpty(pagina.PaginaAjax) && string.IsNullOrEmpty(pagina.AnioAjax) && pagina.Ajax == true && pagina.AjaxTablaDinamica == false && pagina.Token == false && pagina.Token2 == false) { try { sw.Start(); lista.AddRange(await BusquedaAjax(pagina, busqueda)); sw.Stop(); _logger.LogInformation("Tiempo transcurrido: {0}", sw.Elapsed.ToString("hh\\:mm\\:ss\\.fff")); } catch (Exception ex) { _logger.LogError($"Error Busqueda Fecha[" + DateTime.Now + "] - Conservador[" + pagina.Comuna + "] - Nombre[" + busqueda + "] - Error[" + ex.Message + "]"); } } if (!string.IsNullOrEmpty(pagina.PaginaAjax)) { try { sw.Start(); lista.AddRange(await BusquedaAjaxPaginada(pagina, busqueda)); sw.Stop(); _logger.LogInformation("Tiempo transcurrido: {0}", sw.Elapsed.ToString("hh\\:mm\\:ss\\.fff")); } catch (Exception ex) { _logger.LogError($"Error Busqueda Fecha[" + DateTime.Now + "] - Conservador[" + pagina.Comuna + "] - Nombre[" + busqueda + "] - Error[" + ex.Message + "]"); } } if (!string.IsNullOrEmpty(pagina.AnioAjax)) { try { sw.Start(); lista.AddRange(await BusquedaAjaxPorAnio(pagina, busqueda)); sw.Stop(); _logger.LogInformation("Tiempo transcurrido: {0}", sw.Elapsed.ToString("hh\\:mm\\:ss\\.fff")); } catch (Exception ex) { _logger.LogError($"Error Busqueda Fecha[" + DateTime.Now + "] - Conservador[" + pagina.Comuna + "] - Nombre[" + busqueda + "] - Error[" + ex.Message + "]"); } } if (pagina.AjaxTablaDinamica) { try { sw.Start(); lista.AddRange(await BusquedaAjaxTablaDinamica(pagina, busqueda)); sw.Stop(); _logger.LogInformation("Time elapsed: {0}", sw.Elapsed.ToString("hh\\:mm\\:ss\\.fff")); } catch (Exception ex) { _logger.LogError($"Error Busqueda Fecha[" + DateTime.Now + "] - Conservador[" + pagina.Comuna + "] - Nombre[" + busqueda + "] - Error[" + ex.Message + "]"); } } if (pagina.Token == true) { try { sw.Start(); lista.AddRange(await BusquedaAjaxToken(pagina, busqueda)); sw.Stop(); _logger.LogInformation("Time elapsed: {0}", sw.Elapsed.ToString("hh\\:mm\\:ss\\.fff")); } catch (Exception ex) { _logger.LogError($"Error Busqueda Fecha[" + DateTime.Now + "] - Conservador[" + pagina.Comuna + "] - Nombre[" + busqueda + "] - Error[" + ex.Message + "]"); } } if (pagina.Token2 == true) { try { sw.Start(); lista.AddRange(await BusquedaAjaxToken2(pagina, busqueda)); sw.Stop(); _logger.LogInformation("Time elapsed: {0}", sw.Elapsed.ToString("hh\\:mm\\:ss\\.fff")); } catch (Exception ex) { _logger.LogError($"Error Busqueda Fecha[" + DateTime.Now + "] - Conservador[" + pagina.Comuna + "] - Nombre[" + busqueda + "] - Error[" + ex.Message + "]"); } } maxTime = sw.ElapsedMilliseconds > maxTime ? sw.ElapsedMilliseconds : maxTime; _logger.LogInformation($"Fin Busqueda Fecha[" + DateTime.Now + "] - Conservador[" + pagina.Comuna + "] - Nombre[" + busqueda + "] - Resultados Encontrados[" + lista.Count() + "]"); return(lista); }
public Web() { InitializeComponent(); DataContext = new WebViewModel(); }
public WebExplorerView(WebViewModel viewModel) { InitializeComponent(); DataContext = ViewModel = viewModel; viewModel.Closed += async(sender, args) => await DestroyWindowAsync(); }
public override void OnApplyTemplate() { //csCommon.Resources.FloatingStyles fs = new FloatingStyles(); //var ct = fs.FindName("SimpleFloatingStyle") as ControlTemplate; base.OnApplyTemplate(); if (DesignerProperties.GetIsInDesignMode(this)) return; AppStateSettings.Instance.FullScreenFloatingElementChanged += InstanceFullScreenFloatingElementChanged; if (_fe.Style != null) { SetBinding(StyleProperty, new Binding { Source = _fe, Path = new PropertyPath("Style"), Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }); } //this.Style = this.FindResource("SimpleContainer") as Style; _svi.BorderThickness = new Thickness(0, 0, 0, 0); _svi.SingleInputRotationMode = (_fe.RotateWithFinger) ? SingleInputRotationMode.Default : SingleInputRotationMode.Disabled; _svi.ContainerManipulationDelta += _svi_ScatterManipulationDelta; _fe.ScatterViewItem = _svi; if (!_fe.ShowShadow) { SurfaceShadowChrome ssc; ssc = _svi.Template.FindName("shadow", _svi) as SurfaceShadowChrome; _svi.BorderBrush = null; _svi.Background = null; if (ssc != null) ssc.Visibility = Visibility.Hidden; } var closeButton = GetTemplateChild("PART_Close") as Button; if (closeButton != null) closeButton.Click += CloseButtonClick; _partAssociation = GetTemplateChild("PART_Association") as Line; _partContent = GetTemplateChild("PART_Content") as Grid; _partPreview = GetTemplateChild("PART_Preview") as FrameworkElement; _partStream = GetTemplateChild("PART_Stream") as SurfaceButton; _cpView = GetTemplateChild("cpView") as FrameworkElement; if (_fe == null) return; DataContext = _fe; _fe.CloseRequest += FeCloseRequest; _fe.ResetRequest += _fe_ResetRequest; _svi.SetBinding(WidthProperty, new Binding {Source = _fe, Path = new PropertyPath("Width"), Mode = BindingMode.Default}); _svi.SetBinding(HeightProperty, new Binding {Source = _fe, Path = new PropertyPath("Height"), Mode = BindingMode.Default}); _resize = GetTemplateChild("bResize") as Border; if (_resize != null) { SetResize(_resize); } UpdateAssociatedLine(); var resizeBack = GetTemplateChild("bResize1") as Border; if (resizeBack != null) { SetResize(resizeBack); } _cc = GetTemplateChild("cpView") as ContentControl; // check for document, if not exist use ModelInstance if (_fe.Document != null) { IDocument vm = null; _fe.ConnectChannel = _fe.Document.Channel; _fe.ConnectMessage = _fe.Document.ToString(); switch (_fe.Document.FileType) { case FileTypes.image: vm = new ImageViewModel {Doc = _fe.Document}; break; case FileTypes.imageFolder: vm = new ImageFolderViewModel {Doc = _fe.Document}; break; case FileTypes.xps: vm = new XpsViewModel {Doc = _fe.Document}; break; case FileTypes.video: vm = new VideoViewModel {Doc = _fe.Document}; break; case FileTypes.web: vm = new WebViewModel {Doc = _fe.Document}; break; case FileTypes.html: vm = new HtmlViewModel {Doc = _fe.Document}; break; } if (vm != null) { var b = ViewLocator.LocateForModel(vm, null, null) as FrameworkElement; if (b != null) { b.Width = double.NaN; b.Height = double.NaN; b.HorizontalAlignment = HorizontalAlignment.Stretch; b.VerticalAlignment = VerticalAlignment.Stretch; ViewModelBinder.Bind(vm, b, null); if (_cc != null) _cc.Content = b; } } } else if (_fe.ModelInstance != null) { try { var b = ViewLocator.LocateForModel(_fe.ModelInstance, null, null) as FrameworkElement; if (b != null) { b.HorizontalAlignment = HorizontalAlignment.Stretch; b.VerticalAlignment = VerticalAlignment.Stretch; ViewModelBinder.Bind(_fe.ModelInstance, b, null); if (_cc != null) _cc.Content = b; } } catch (Exception e) { Logger.Log("Floating Container", "Error adding floating element", e.Message, Logger.Level.Error); } } UpdateBackInstance(); if (_fe.DockingStyle == DockingStyles.None) if (_partPreview != null) _partPreview.Visibility = Visibility.Collapsed; _svi.PreviewTouchDown += (e, s) => { if (_svi.TouchesOver.Count() == 4) { SwitchFullscreen(); s.Handled = true; _svi.ReleaseAllTouchCaptures(); } //return; // FIXME TODO: Unreachable code // if (!InteractiveSurface.PrimarySurfaceDevice.IsFingerRecognitionSupported) // return; // // // _touchDown = DateTime.Now; // if (s.TouchDevice.GetIsFingerRecognized()) { // _fe.OriginalOrientation = s.Device.GetOrientation(this); // //double angle = s.TouchDevice.GetOrientation(Application.Current.MainWindow); // //_reverse = (angle < 180); // } // // if (!s.TouchDevice.GetIsFingerRecognized() && // !s.TouchDevice.GetIsTagRecognized()) { // if (!string.IsNullOrEmpty(_fe.ConnectChannel) && // DateTime.Now > _lastBlobEvent.AddSeconds(1)) { // AppStateSettings.Instance.Imb.SendMessage(_fe.ConnectChannel, // _fe.ConnectMessage); // s.Handled = true; // _lastBlobEvent = DateTime.Now; // } // } //Console.WriteLine(d.ToString()); }; //_svi.PreviewTouchUp += (e, s) => // { // if (!_fe.Large && _touchDown.AddMilliseconds(300) > DateTime.Now && _fe.LastContainerPosition!=null) // { // ResetLastPosition(); // } // }; _svi.PreviewMouseDown += (e, s) => { _touchDown = DateTime.Now; }; _svi.PreviewMouseUp += (e, s) => { if (!_fe.Large && _touchDown.AddMilliseconds(300) > DateTime.Now && _fe.LastContainerPosition != null) { ResetLastPosition(); } }; if (_fe.IsFullScreen) { FrameworkElement fe = Application.Current.MainWindow; _svi.Center = new Point(fe.Width/2, fe.Height/2); _svi.Width = fe.Width; _svi.Height = fe.Height; _svi.Opacity = _fe.OpacityNormal; } if (_partStream != null) { _partStream.Click += _partStream_Click; } //b.HorizontalAlignment = HorizontalAlignment.Stretch; //b.VerticalAlignment = VerticalAlignment.Stretch; }
public async Task <List <PersonaViewModel> > BusquedaAjaxPaginada(WebViewModel pagina, string busqueda) { var lista = new List <PersonaViewModel>(); var apellido = ""; var nombre = ""; var separados = false; if (busqueda.Contains("/")) { apellido = busqueda.Split('/')[0]; nombre = busqueda.Split('/')[1]; separados = true; } using (var client = new HttpClient()) { for (int i = pagina.InicioPagina != null ? pagina.InicioPagina.Value : 0; i < 1000; i = i + int.Parse(pagina.PaginaAjax)) { var parametros = new Dictionary <string, string>(); foreach (var item in pagina.Params.ToList()) { if (separados) { parametros.Add(item.Key, item.Value.Replace("{0}", apellido).Replace("{1}", nombre).Replace("{pagina}", i.ToString()).Replace("{aniofin}", DateTime.Now.Year.ToString())); } else { parametros.Add(item.Key, item.Value.Replace("{0}", busqueda).Replace("{pagina}", i.ToString()).Replace("{aniofin}", DateTime.Now.Year.ToString())); } } var content = new FormUrlEncodedContent(parametros); var response = await client.PostAsync(pagina.UrlBusqueda.Replace("{pagina}", i.ToString()), content); //var response = client.GetAsync(pagina.UrlBusqueda).Result; if (response.IsSuccessStatusCode) { var htmlBody = await response.Content.ReadAsStringAsync(); var htmlDoc = new HtmlDocument(); htmlDoc.LoadHtml(htmlBody); var nodos = htmlDoc.DocumentNode.SelectNodes(pagina.Selector); if (pagina.UrlBusquedaColumnasSeparadas) { var nodos2 = htmlDoc.DocumentNode.SelectNodes(pagina.Selector2); if (nodos2 != null) { for (int j = 0; j < nodos2.Count; j++) { var nuevo = new PersonaViewModel(); nuevo.Nombre = nodos[j].InnerText + " " + nodos2[j].InnerHtml; nuevo.Conservador = pagina.Comuna; nuevo.Url = pagina.Url; lista.Add(nuevo); } } else { break; } } else { if (nodos != null) { foreach (var nodo in nodos) { if (nodo.InnerText.ToUpper().Contains("COMPRADOR") || nodo.InnerText.ToUpper().Contains("PERSONA") || nodo.InnerText.ToUpper().Contains("PROPIETARIO")) { if (nodos.Count() == 1) { i = 1000; break; } continue; } var nuevo = new PersonaViewModel(); nuevo.Nombre = nodo.InnerText; nuevo.Conservador = pagina.Comuna; nuevo.Url = pagina.Url; lista.Add(nuevo); } } else { break; } } } } } return(lista); }