Esempio n. 1
0
        private void FillJsonProperties <TEntity>(HtmlXPathTemplatePattern[] patterns, HtmlNode node, JsonObject json)
        {
            foreach (HtmlXPathTemplatePattern rawPattern in patterns)
            {
                HtmlNode childNode;
                try
                {
                    childNode =
                        new Iif <HtmlNode>(
                            () => new IsEmptyString(rawPattern.XPathSelector),
                            node,
                            new SelectFirstChildNode(
                                node,
                                rawPattern.XPathSelector));
                }
                catch (XPathException e)
                {
                    throw new InvalidDataException($"{rawPattern.XPathSelector}", e);
                }

                if (childNode != null)
                {
                    if (!new IsEmptyString(rawPattern.InnerTextVariable))
                    {
                        json.AddKeyValue(
                            rawPattern.InnerTextVariable,
                            new Iif <string>(
                                () => _options.TrimValues,
                                new TrimText(childNode.InnerText),
                                childNode.InnerText ?? ""));
                    }

                    if (rawPattern.HasAttributeVariables)
                    {
                        var pairs = rawPattern.GetAttributeVariables();
                        foreach (KeyValuePair <string, string> pair in pairs)
                        {
                            string from = pair.Key;
                            string to   = pair.Value;
                            json.AddKeyValue(
                                to,
                                new Iif <string>(
                                    () => _options.TrimValues,
                                    new TrimText(childNode.Attributes[from].Value),
                                    childNode.Attributes[from].Value ?? ""));
                        }
                    }

                    if (rawPattern.HasChildren)
                    {
                        FillJsonProperties <TEntity>(rawPattern.GetChildren(), childNode, json);
                    }
                }
            }
        }
Esempio n. 2
0
        public string GetUrl()
        {
            string    textToSearch         = new ReplaceChar(_searchText, ' ', '+');
            Iif <int> searchIntTitleOnlyIf = new Iif <int>(() => _searchInTitlesOnly, 1, 0);
            string    url =
                new Iif <string>(
                    () => _pageNumber == -1,
                    new FormatString(
                        _settings.UrlFormat,
                        textToSearch,
                        searchIntTitleOnlyIf),
                    new FormatString(
                        _settings.PageUrlFormat,
                        _pageNumber,
                        textToSearch,
                        searchIntTitleOnlyIf));

            return(url);
        }
        public override int[] ObtenerIds()
        {
            List <int> ids = new List <int>();

            ids.Add((int)Iif.Condicion(this.OrdenAbierta).Entonces(0).Sino(1));
            ids.Add(this.PresentadorDeposito.Entidad.Id);
            ids.Add(this.PresentadorProveedor.Entidad.Id);

            if (this.OrdenGenerada)
            {
                foreach (dynamic item in this.Ordenes)
                {
                    if (item.seleccionado)
                    {
                        ids.Add(item.Id);
                    }
                }
            }

            return(ids.ToArray());
        }
        public override void ConfigurarCamposValores(Proveedor entidad)
        {
            this.CamposValores.Add("codigo", entidad.Codigo);
            this.CamposValores.Add("nombre", (entidad.RazonSocial == null) ? string.Empty : entidad.RazonSocial);
            //this.CamposValores.Add("domicilio", entidad.Domicilio.ToString());
            this.CamposValores.Add("domicilio", entidad.Domicilio == null ? string.Empty : entidad.Domicilio);

            this.CamposValores.Add("copostal", entidad.Localidad == null ? string.Empty : entidad.Localidad.Codigo);
            this.CamposValores.Add("localidad", entidad.Localidad == null ? string.Empty : entidad.Localidad.Nombre);


            //this.CamposValores.Add("telefono", entidad.Telefonos != null && entidad.Telefonos.FirstOrDefault() != null ? entidad.Telefonos.FirstOrDefault().Numero : string.Empty);

            var telefonos = string.Empty;

            foreach (var tel in entidad.Telefonos)
            {
                if (!tel.Numero.Trim().Equals(string.Empty))
                {
                    telefonos += tel.Numero.Trim() + " + ";
                }
            }
            this.SetearValores("telefono", telefonos, string.Empty); //09/02/15 - NUEVO UPDATE 11.11.15

            this.CamposValores.Add("cuit", entidad.Cuit != null ? entidad.Cuit : string.Empty);
            this.CamposValores.Add("condiva", CondicionAnteIva(entidad.CondicionAnteIva));
            //this.CamposValores.Add("saldo", entidad.DatosOld.saldo);
            //this.CamposValores.Add("porcomis", entidad.DatosOld.porcomis);
            this.CamposValores.Add("calcula", Iif.Condicion(entidad.DatosOld.CalculoBodegas).Entonces(1).Sino(0));
            this.CamposValores.Add("logistica", Iif.Condicion(entidad.DatosOld.ComisionLogistica).Entonces(1).Sino(0));
            this.CamposValores.Add("agperiibb", Iif.Condicion(entidad.EsAgentePercepcionIIBB).Entonces(1).Sino(0));
            this.CamposValores.Add("agperiva", Iif.Condicion(entidad.EsAgentePercepcionIVA).Entonces(1).Sino(0));
            //this.CamposValores.Add("cliente", entidad.DatosOld.cliente);
            this.CamposValores.Add("cjarubro", entidad.ConceptoDeMovimiento != null && entidad.ConceptoDeMovimiento.FirstOrDefault() != null ? entidad.ConceptoDeMovimiento.FirstOrDefault().Codigo : string.Empty);
            //this.CamposValores.Add("saldo_ini", entidad.DatosOld.saldoinicial);
            //this.CamposValores.Add("menos_sald", entidad.DatosOld.menosSaldo);
            this.CamposValores.Add("asociado", (entidad.DatosOld.Fletero != null) ? entidad.DatosOld.Fletero.Codigo : string.Empty); //este falta -> YA NO! Check, pocho
            this.CamposValores.Add("empresa", Iif.Condicion(entidad.DatosOld.EsSubempresa).Entonces(1).Sino(0));
            //this.CamposValores.Add("obs", entidad.Observaciones != null && entidad.Observaciones.FirstOrDefault() != null ? entidad.Observaciones.FirstOrDefault().Nombre : string.Empty);
            string obs = string.Empty;

            foreach (var obser in entidad.Observaciones)
            {
                if (obser.Nombre != null)
                {
                    obs += "- " + obser.FechaHora.ToString() + ": " + obser.Nombre.Trim() + " + "; //.Replace(System.Environment.NewLine, " ");
                }
            }
            for (int i = 0; i < obs.Count();)
            {
                if (i != 0)
                {
                    obs = obs.Insert(i, "'+'");
                }
                i += 254;
            }
            this.SetearValores("obs", obs, "");

            this.CamposValores.Add("factura", Iif.Condicion(entidad.DatosOld.EmiteComprobantes).Entonces(1).Sino(0));
            this.CamposValores.Add("deposito", entidad.DatosOld != null && entidad.DatosOld.Deposito != null ? entidad.DatosOld.Deposito.Codigo : string.Empty);
            this.CamposValores.Add("sucursal", entidad.DatosOld != null && entidad.DatosOld.PuntoDeVenta != null ? entidad.DatosOld.PuntoDeVenta.ToString() : string.Empty);
            this.CamposValores.Add("preventa", Iif.Condicion(entidad.DatosOld.CargaPedidos).Entonces(1).Sino(0));
            //this.CamposValores.Add("tercero",Iif.Condicion
            //this.CamposValores.Add("habilitado",
            //this.CamposValores.Add("frio"
            //this.CamposValores.Add("reinspc_san"
            //this.CamposValores.Add("kiosko"
            this.CamposValores.Add("exento_iibb", Iif.Condicion(entidad.CondicionAnteIIBB == CondicionAnteIIBB.NoCorrespondeExento || entidad.CondicionAnteIIBB == CondicionAnteIIBB.NoAsignado).Entonces(1).Sino(0));
            this.CamposValores.Add("iibb", entidad.Iibb != null ? entidad.Iibb.ToString() : string.Empty);
            this.CamposValores.Add("plazo_entrega", entidad.DatosOld.PlazoEntregaDias);
            this.CamposValores.Add("condicion", entidad.VencimientoPagos);
            //this.CamposValores.Add("estado",
            //this.CamposValores.Add("empresa_rel")
            this.CamposValores.Add("inactivo", Iif.Condicion(entidad.EstadoProveedor == EstadoProveedor.Suspendido).Entonces(1).Sino(0));
            this.CamposValores.Add("tipoprov", entidad.TipoProveedor == null ? string.Empty : entidad.TipoProveedor.Codigo);
            var ppago = entidad.ProntoPago.FirstOrDefault();

            if (ppago != null)
            {
                this.CamposValores.Add("ppago_dias", ppago.ProntoPagoDias);
                this.CamposValores.Add("ppago_desc", ppago.ProntoPagoDesc);
            }
            else
            {
                this.CamposValores.Add("ppago_dias", 0);
                this.CamposValores.Add("ppago_desc", 0);
            }
            this.CamposValores.Add("banco", entidad.Bancos != null && entidad.Bancos.FirstOrDefault() != null ? entidad.Bancos.FirstOrDefault().Codigo : string.Empty);
            this.CamposValores.Add("requieredatos", Iif.Condicion(entidad.RequiereDatosDeAutorizacion).Entonces(1).Sino(0));
        }