Beispiel #1
0
        private filters addFilter(filters filtresIn, string key, string op, string value)
        {
            filters filtres = filtresIn;

            if (filtres == null)
            {
                filtres = new filters();
            }

            complexFilter compfiltres = new complexFilter();

            compfiltres.key = key;
            associativeEntity ass = new associativeEntity();

            ass.key           = op;
            ass.value         = value;
            compfiltres.value = ass;

            List <complexFilter> tmpLst;

            if (filtres.complex_filter != null)
            {
                tmpLst = filtres.complex_filter.ToList();
            }
            else
            {
                tmpLst = new List <complexFilter>();
            }

            tmpLst.Add(compfiltres);

            filtres.complex_filter = tmpLst.ToArray();

            return(filtres);
        }
    private static filters tanMageFilter(string mageField, string mageOperator, string mageValue, string limit)
    {
        complexFilter myComplexFilter = new complexFilter();

        myComplexFilter.key   = mageField;
        myComplexFilter.value = new associativeEntity {
            key   = mageOperator,
            value = mageValue
        };

        complexFilter myLimitFilter = new complexFilter();

        myLimitFilter.key   = "collection.limit";
        myLimitFilter.value = new associativeEntity {
            key   = "eq",
            value = limit
        };

        filters mageFilters = new filters();

        mageFilters.complex_filter = new complexFilter[] {
            myComplexFilter,
            myLimitFilter
        };
        return(mageFilters);
    }
Beispiel #3
0
        public salesOrderListEntity[] get_open_orders()
        {
            MagentoService mservice = new MagentoService();
            String         mlogin   = mservice.login("admin", "Interconnection123!");

            filters mf = new filters();

            complexFilter[] cpf  = new complexFilter[1];
            complexFilter   mcpf = new complexFilter();

            mcpf.key = "status";
            associativeEntity mas = new associativeEntity();

            mas.key    = "in";
            mas.value  = "pending,processing,approved_clearsale,analysing_clearsale,pending_clearsale";
            mcpf.value = mas;
            cpf[0]     = mcpf;
            //mcpf = new complexFilter();
            //mcpf.key = "status";
            //mas = new associativeEntity();

            //mas.key = "eq";
            //mas.value = "processing";
            //mcpf.value = mas;
            //cpf[1] = mcpf;
            //mcpf = new complexFilter();
            //mcpf.key = "status";
            //mas = new associativeEntity();

            //mas.key = "eq";
            //mas.value = "approved_clearsale";
            //mcpf.value = mas;
            //cpf[2] = mcpf;
            //mcpf = new complexFilter();
            //mcpf.key = "status";
            //mas = new associativeEntity();

            //mas.key = "eq";
            //mas.value = "analysing_clearsale";
            //mcpf.value = mas;
            //cpf[3] = mcpf;
            //mcpf = new complexFilter();
            //mcpf.key = "status";
            //mas = new associativeEntity();

            //mas.key = "eq";
            //mas.value = "pending_clearsale";
            //mcpf.value = mas;
            //cpf[4] = mcpf;
            mf.complex_filter = cpf;
            var soe = mservice.salesOrderList(mlogin, mf);

            return(soe);
        }
Beispiel #4
0
        private filters magentoFilter(string filterField, string filterOperator, string filterValue)
        {
            filters       mFilter     = new filters();
            complexFilter cmplxFilter = new complexFilter();

            cmplxFilter.key   = filterField;
            cmplxFilter.value = new associativeEntity {
                key = filterOperator, value = filterValue
            };

            mFilter.complex_filter = new complexFilter[] { cmplxFilter };

            return(mFilter);
        }
Beispiel #5
0
        private void bbDownload_Click(object sender, EventArgs e)
        {
            if (cbLoja.SelectedItem == null)
            {
                MessageBox.Show("Obrigatório selecionar loja.", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information);
                cbLoja.Focus();
                return;
            }
            if (string.IsNullOrEmpty((cbLoja.SelectedItem as TRegistro_LojaVirtual).UserName))
            {
                MessageBox.Show("Não existe USERNAME cadastrado para loja.", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (string.IsNullOrEmpty((cbLoja.SelectedItem as TRegistro_LojaVirtual).ApiKey))
            {
                MessageBox.Show("Não existe APIKEY cadastrado para loja.", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            MagentoService api    = new MagentoService();
            string         sessao = string.Empty;

            try
            {
                sessao = api.login((cbLoja.SelectedItem as TRegistro_LojaVirtual).UserName, (cbLoja.SelectedItem as TRegistro_LojaVirtual).ApiKey);
                filters         mf  = new filters();
                complexFilter[] cpf = new complexFilter[0];
                if (cbStatus.SelectedIndex > 0)
                {
                    complexFilter mcpf = new complexFilter();
                    mcpf.key = "status";
                    associativeEntity mas = new associativeEntity();
                    mas.key    = "=";
                    mas.value  = cbStatus.SelectedValue.ToString();
                    mcpf.value = mas;
                    Array.Resize(ref cpf, cpf.Length + 1);
                    cpf[cpf.Length - 1] = mcpf;
                }
                if (!string.IsNullOrEmpty(dt_ini.Text.SoNumero()))
                {
                    complexFilter mcpf = new complexFilter();
                    mcpf.key = "created_at";
                    associativeEntity mas = new associativeEntity();
                    mas.key    = "from";
                    mas.value  = DateTime.Parse(dt_ini.Text).ToString("yyyy-MM-dd") + " 00:00:00";
                    mcpf.value = mas;
                    Array.Resize(ref cpf, cpf.Length + 1);
                    cpf[cpf.Length - 1] = mcpf;
                }
                mf.complex_filter = cpf;
                salesOrderListEntity[] lista = api.salesOrderList(sessao, mf);
                if (lista.Length > 0)
                {
                    TList_Pedido lPedido = new TList_Pedido();
                    lista.ToList().ForEach(p =>
                    {
                        object obj = new TCD_Pedido().BuscarEscalar(
                            new TpBusca[]
                        {
                            new TpBusca()
                            {
                                vNM_Campo = "a.Nr_PedidoOrigem",
                                vOperador = "=",
                                vVL_Busca = "'" + p.increment_id.Trim() + "'"
                            }
                        }, "a.nr_pedido");
                        lPedido.Add(new TRegistro_Pedido()
                        {
                            Nr_PedidoOrigem = p.increment_id,
                            Vl_totalpedido  = decimal.Divide(int.Parse(p.grand_total.SoNumero()), 10000),
                            StatusMagento   = p.status,
                            NM_Clifor       = p.firstname.Trim() + " " + p.lastname.Trim(),
                            Nr_pedido       = obj == null ? 0 : decimal.Parse(obj.ToString()),
                            DT_Pedido       = DateTime.Parse(p.created_at)
                        });
                    });
                    bsPedLoja.DataSource = lPedido;
                }
            }
            catch (Exception ex)
            { MessageBox.Show(ex.Message.Trim(), "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); }
            finally
            {
                if (!string.IsNullOrWhiteSpace(sessao))
                {
                    api.endSession(sessao);
                }
            }
        }