예제 #1
0
파일: Test.cs 프로젝트: sangkyunyoon/ConnId
        /// <summary>
        /// Method for convenient testing of local connectors.
        /// </summary>
        public APIConfiguration CreateTestConfiguration(SafeType <Connector> clazz,
                                                        Configuration config)
        {
            LocalConnectorInfoImpl info = new LocalConnectorInfoImpl();

            info.ConnectorConfigurationClass = SafeType <Configuration> .Get(config);

            info.ConnectorClass          = (clazz);
            info.ConnectorDisplayNameKey = ("DUMMY_DISPLAY_NAME");
            info.ConnectorKey            = (
                new ConnectorKey(clazz.RawType.Name + ".bundle",
                                 "1.0",
                                 clazz.RawType.Name));
            info.Messages = (this.CreateDummyMessages());
            APIConfigurationImpl rv = new APIConfigurationImpl();

            rv.IsConnectorPoolingSupported = (
                IsConnectorPoolingSupported(clazz));
            ConfigurationPropertiesImpl properties =
                CSharpClassProperties.CreateConfigurationProperties(config);

            rv.ConfigurationProperties = (properties);
            rv.ConnectorInfo           = (info);
            rv.SupportedOperations     = (
                FrameworkUtil.GetDefaultSupportedOperations(clazz));
            info.DefaultAPIConfiguration = (
                rv);
            return(rv);
        }
예제 #2
0
        public Retorno RetornaListaMesa(string strParametro, bool blnLivre = true, bool blnOcupado = true)
        {
            var objRetorno = new Retorno();

            try
            {
                var query = _objCtx.tbMesa.AsNoTracking().OrderBy(mes => mes.mes_codigo).AsQueryable();
                if (!blnLivre)
                {
                    query = query.Where(mes => mes.mes_status != enStatusMesa.L.ToString()).AsQueryable();
                }
                if (!blnOcupado)
                {
                    query = query.Where(ped => ped.mes_status != enStatusMesa.O.ToString()).AsQueryable();
                }
                objRetorno.intCodigoErro = 0;
                objRetorno.objRetorno    = query.OrderBy(mes => mes.mes_codigo).ToList();
            }
            catch (Exception ex)
            {
                FrameworkUtil.LogErro(ex);
                objRetorno.intCodigoErro        = 16;
                objRetorno.strMsgErro           = ex.Message;
                objRetorno.strExceptionToString = ex.ToString();
            }
            return(objRetorno);
        }
예제 #3
0
        public Retorno RetornaListaAuditoria(int intCodRegistro, object objTabela)
        {
            var objRetorno = new Retorno();

            try
            {
                var strNomeTabela = objTabela.GetType().Name.Split('_')[0];
                var arrAuditoria  = _objCtx.tbAuditoria
                                    .Include(audo => audo.tbAuditoriaOperacao)
                                    .Include(fun => fun.tbFuncionario).AsNoTracking()
                                    .Where(aud => aud.aud_nomeTabela == strNomeTabela && aud.aud_codigoRegistro == intCodRegistro)
                                    .OrderBy(aud => aud.aud_codigo)
                                    .ToList();
                objRetorno.intCodigoErro = 0;
                objRetorno.objRetorno    = arrAuditoria;
            }
            catch (Exception ex)
            {
                FrameworkUtil.LogErro(ex);
                objRetorno.intCodigoErro        = 16;
                objRetorno.strMsgErro           = ex.Message;
                objRetorno.strExceptionToString = ex.ToString();
            }
            return(objRetorno);
        }
예제 #4
0
        public Retorno SalvarConfiguracao(tbConfiguracao objConfiguracao, int intFunCodigo)
        {
            var objRetorno   = new Retorno();
            var strValidacao = ValidaConfiguracao(objConfiguracao);

            try
            {
                if (strValidacao == string.Empty)
                {
                    var objConfiguracaoContexto = _objCtx.tbConfiguracao.FirstOrDefault();
                    _objCtx.Entry(objConfiguracaoContexto).CurrentValues.SetValues(objConfiguracao);
                    _objCtx.SaveChanges();
                    using (var objBll = new Auditoria(ref _objCtx, ref _objTransacao))
                        objBll.SalvarAuditoria(objConfiguracao.cfg_codigo, enOperacao.Alteracao, objConfiguracao, intFunCodigo);
                    objRetorno = RetornaConfiguracao();
                }
                else
                {
                    objRetorno.intCodigoErro = 48;
                    objRetorno.strMsgErro    = strValidacao;
                }
            }
            catch (Exception ex)
            {
                FrameworkUtil.LogErro(ex);
                objRetorno.intCodigoErro        = 16;
                objRetorno.strMsgErro           = ex.Message;
                objRetorno.strExceptionToString = ex.ToString();
            }
            return(objRetorno);
        }
예제 #5
0
        public Retorno RetornaListaPedidoEntrega(bool blnProducao, bool blnEntrega, bool blnFinalizado, bool blnExcluido, int intFunCodigo, int intCaiCodigo, int intSkip, int intTake)
        {
            var objRetorno = new Retorno();

            try
            {
                List <int> arrCaiCodigo = new List <int>();
                if (intCaiCodigo > 0)
                {
                    arrCaiCodigo.Add(intCaiCodigo);
                }
                else
                {
                    arrCaiCodigo = _objCtx.tbCaixa.AsNoTracking()
                                   .Where(cai => cai.cai_dataFechamento == null)
                                   .Select(cai => cai.cai_codigo)
                                   .ToList();
                }

                var arrPedido = _objCtx.tbPedido.Include(fun => fun.tbFuncionarioEntregador)
                                .Include(ppr => ppr.tbPedidoProduto)
                                .Include(fpg => fpg.tbFormaPagamento).AsNoTracking()
                                .Where(ped => ped.ped_origem == "E" && arrCaiCodigo.Contains(ped.cai_codigo)).AsQueryable();
                if (!blnProducao)
                {
                    arrPedido = arrPedido.Where(ped => ped.ped_status != "P").AsQueryable();
                }
                if (!blnEntrega)
                {
                    arrPedido = arrPedido.Where(ped => ped.ped_status != "E").AsQueryable();
                }
                if (!blnFinalizado)
                {
                    arrPedido = arrPedido.Where(ped => ped.ped_status != "F").AsQueryable();
                }
                if (!blnExcluido)
                {
                    arrPedido = arrPedido.Where(ped => ped.ped_status != "X").AsQueryable();
                }
                if (intFunCodigo > 0)
                {
                    arrPedido = arrPedido.Where(ped => ped.fun_funcionarioEntregador == intFunCodigo).AsQueryable();
                }

                objRetorno.intCodigoErro = 0;
                if (intSkip == 0)
                {
                    objRetorno.intQtdeRegistro = arrPedido.Count();
                }
                objRetorno.objRetorno = arrPedido.OrderBy(ped => ped.ped_codigo).Skip(intSkip).Take(intTake).ToList();
            }
            catch (Exception ex)
            {
                FrameworkUtil.LogErro(ex);
                objRetorno.intCodigoErro        = 16;
                objRetorno.strMsgErro           = ex.Message;
                objRetorno.strExceptionToString = ex.ToString();
            }
            return(objRetorno);
        }
예제 #6
0
 /// <summary>
 /// Initializes the static instance.
 /// </summary>
 static Document()
 {
     if (!FrameworkUtil.IsCompatibleWithFramework())
     {
         throw new Exception("NXKit is only compatible with Frameworks targeting .NET 4.5 or above.");
     }
 }
        public void TestConfigurationProperty()
        {
            ConfigurationPropertyImpl v1 = new ConfigurationPropertyImpl();

            v1.Order             = (1);
            v1.IsConfidential    = (true);
            v1.IsRequired        = true;
            v1.Name              = ("foo");
            v1.HelpMessageKey    = ("help key");
            v1.DisplayMessageKey = ("display key");
            v1.GroupMessageKey   = ("group key");
            v1.Value             = ("bar");
            v1.ValueType         = (typeof(string));
            v1.Operations        = FrameworkUtil.AllAPIOperations();

            ConfigurationPropertyImpl v2 = (ConfigurationPropertyImpl)
                                           CloneObject(v1);

            Assert.AreEqual(1, v2.Order);
            Assert.IsTrue(v2.IsConfidential);
            Assert.IsTrue(v2.IsRequired);
            Assert.AreEqual("foo", v2.Name);
            Assert.AreEqual("help key", v2.HelpMessageKey);
            Assert.AreEqual("display key", v2.DisplayMessageKey);
            Assert.AreEqual("group key", v2.GroupMessageKey);
            Assert.AreEqual("bar", v2.Value);
            Assert.AreEqual(typeof(string), v2.ValueType);
            Assert.IsTrue(CollectionUtil.Equals(
                              FrameworkUtil.AllAPIOperations(), v2.Operations));
        }
예제 #8
0
        public Retorno SalvarEntregador(tbPedido objPedido, int intFunCodigo)
        {
            var objRetorno = new Retorno();

            try
            {
                objPedido.tbFuncionarioEntregador = null;
                objPedido.tbPedidoProduto         = null;
                objPedido.tbFormaPagamento        = null;
                objPedido.ped_status      = enStatusPedido.E.ToString();//"E";
                objPedido.ped_dataEntrega = DateTime.Now;
                var objPedidoContexto = _objCtx.tbPedido.FirstOrDefault(ped => ped.ped_codigo == objPedido.ped_codigo);
                _objCtx.Entry(objPedidoContexto).CurrentValues.SetValues(objPedido);
                _objCtx.SaveChanges();
                using (var objBll = new Auditoria(ref _objCtx, ref _objTransacao))
                    objBll.SalvarAuditoria(objPedido.ped_codigo, enOperacao.Outro, objPedido, intFunCodigo);
                objRetorno = RetornaPedido(objPedido.ped_codigo, null, enOrigemPedido.Entrega);
            }
            catch (Exception ex)
            {
                FrameworkUtil.LogErro(ex);
                objRetorno.intCodigoErro        = 16;
                objRetorno.strMsgErro           = ex.Message;
                objRetorno.strExceptionToString = ex.ToString();
            }
            return(objRetorno);
        }
예제 #9
0
        public Retorno RetornaPedidoComanda(int intNumero)
        {
            var objRetorno = new Retorno();

            try
            {
                tbMesa objMesa = null;
                objMesa = _objCtx.tbMesa.AsNoTracking().Include(ped => ped.tbPedido.tbFuncionario).FirstOrDefault(mes => mes.mes_numero == intNumero);
                if (objMesa != null)
                {
                    objRetorno.intCodigoErro = 0;
                    objRetorno.objRetorno    = objMesa;
                }
                else
                {
                    objRetorno.intCodigoErro = 48;
                    objRetorno.strMsgErro    = "Registro não encontrado";
                }
            }
            catch (Exception ex)
            {
                FrameworkUtil.LogErro(ex);
                objRetorno.intCodigoErro        = 16;
                objRetorno.strMsgErro           = ex.Message;
                objRetorno.strExceptionToString = ex.ToString();
            }
            return(objRetorno);
        }
예제 #10
0
        public Retorno RetornaPedido(int intCodigo, enNavegacao?enDirecao, enOrigemPedido enOrigem)
        {
            var objRetorno = new Retorno();

            try
            {
                var      strOrigem = ((char)enOrigem).ToString();
                tbPedido objPedido = null;
                if (enDirecao == null)
                {
                    objPedido = _objCtx.tbPedido.AsNoTracking().Include(ppr => ppr.tbPedidoProduto.Select(pro => pro.tbProduto))
                                .Include(cli => cli.tbCliente)
                                .Include(cen => cen.tbCliente.tbClienteEndereco.Select(bai => bai.tbBairro))
                                .Include(ctl => ctl.tbCliente.tbClienteTelefone)
                                .Include(fun => fun.tbFuncionarioEntregador)
                                .Include(fpg => fpg.tbFormaPagamento)
                                .FirstOrDefault(ped => ped.ped_codigo == intCodigo && ped.ped_origem == strOrigem);
                }
                if (enDirecao == enNavegacao.Proximo)
                {
                    objPedido = _objCtx.tbPedido.AsNoTracking().Include(ppr => ppr.tbPedidoProduto.Select(pro => pro.tbProduto))
                                .Include(cli => cli.tbCliente)
                                .Include(cen => cen.tbCliente.tbClienteEndereco.Select(bai => bai.tbBairro))
                                .Include(ctl => ctl.tbCliente.tbClienteTelefone)
                                .Include(fun => fun.tbFuncionarioEntregador)
                                .Include(fpg => fpg.tbFormaPagamento)
                                .Where(ped => ped.ped_codigo > intCodigo && ped.ped_origem == strOrigem)
                                .OrderBy(ped => ped.ped_codigo).FirstOrDefault();
                }
                if (enDirecao == enNavegacao.Anterior)
                {
                    objPedido = _objCtx.tbPedido.AsNoTracking().Include(ppr => ppr.tbPedidoProduto.Select(pro => pro.tbProduto))
                                .Include(cli => cli.tbCliente)
                                .Include(cen => cen.tbCliente.tbClienteEndereco.Select(bai => bai.tbBairro))
                                .Include(ctl => ctl.tbCliente.tbClienteTelefone)
                                .Include(fun => fun.tbFuncionarioEntregador)
                                .Include(fpg => fpg.tbFormaPagamento)
                                .Where(ped => ped.ped_codigo < intCodigo && ped.ped_origem == strOrigem)
                                .OrderByDescending(ped => ped.ped_codigo).FirstOrDefault();
                }
                if (objPedido != null)
                {
                    objRetorno.intCodigoErro = 0;
                    objRetorno.objRetorno    = objPedido;
                }
                else
                {
                    objRetorno.intCodigoErro = 48;
                    objRetorno.strMsgErro    = "Registro não encontrado";
                }
            }
            catch (Exception ex)
            {
                FrameworkUtil.LogErro(ex);
                objRetorno.intCodigoErro        = 16;
                objRetorno.strMsgErro           = ex.Message;
                objRetorno.strExceptionToString = ex.ToString();
            }
            return(objRetorno);
        }
예제 #11
0
        public Retorno RetornaListaFormaPagamento(string strCodigo, string strNome, int intSkip, int intTake)
        {
            var objRetorno = new Retorno();

            try
            {
                var arrFormaPagamento = _objCtx.tbFormaPagamento.AsNoTracking().Include(fpt => fpt.tbFormaPagamentoTipo).AsQueryable();
                if (!string.IsNullOrWhiteSpace(strCodigo))
                {
                    int intCodigo = Convert.ToInt32(strCodigo);
                    arrFormaPagamento = arrFormaPagamento.Where(fpg => fpg.fpg_codigo == intCodigo).AsQueryable();
                }
                if (!string.IsNullOrWhiteSpace(strNome))
                {
                    arrFormaPagamento = arrFormaPagamento.Where(fpg => fpg.fpg_descricao.Contains(strNome)).AsQueryable();
                }
                objRetorno.intCodigoErro = 0;
                if (intSkip == 0)
                {
                    objRetorno.intQtdeRegistro = arrFormaPagamento.Count();
                }
                objRetorno.objRetorno = arrFormaPagamento.OrderByDescending(fpg => fpg.fpg_codigo).Skip(intSkip).Take(intTake).ToList();
            }
            catch (Exception ex)
            {
                FrameworkUtil.LogErro(ex);
                objRetorno.intCodigoErro        = 16;
                objRetorno.strMsgErro           = ex.Message;
                objRetorno.strExceptionToString = ex.ToString();
            }
            return(objRetorno);
        }
예제 #12
0
        public Retorno RetornaListaClienteGrupo(string strCodigo, string strNome, int intSkip, int intTake)
        {
            var objRetorno = new Retorno();

            try
            {
                var arrClienteGrupo = _objCtx.tbClienteGrupo.AsNoTracking().AsQueryable();
                if (!string.IsNullOrWhiteSpace(strCodigo))
                {
                    int intCodigo = Convert.ToInt32(strCodigo);
                    arrClienteGrupo = arrClienteGrupo.Where(cgr => cgr.cgr_codigo == intCodigo).AsQueryable();
                }
                if (!string.IsNullOrWhiteSpace(strNome))
                {
                    arrClienteGrupo = arrClienteGrupo.Where(cgr => cgr.cgr_nome.Contains(strNome)).AsQueryable();
                }
                objRetorno.intCodigoErro = 0;
                if (intSkip == 0)
                {
                    objRetorno.intQtdeRegistro = arrClienteGrupo.Count();
                }
                objRetorno.objRetorno = arrClienteGrupo.OrderByDescending(cgr => cgr.cgr_codigo).Skip(intSkip).Take(intTake).ToList();
            }
            catch (Exception ex)
            {
                FrameworkUtil.LogErro(ex);
                objRetorno.intCodigoErro        = 16;
                objRetorno.strMsgErro           = ex.Message;
                objRetorno.strExceptionToString = ex.ToString();
            }
            return(objRetorno);
        }
예제 #13
0
        public Retorno RetornaConfiguracao()
        {
            var objRetorno = new Retorno();

            try
            {
                var objConfiguracao = _objCtx.tbConfiguracao.AsNoTracking().FirstOrDefault();
                if (objConfiguracao != null)
                {
                    objRetorno.intCodigoErro = 0;
                    objRetorno.objRetorno    = objConfiguracao;
                }
                else
                {
                    objRetorno.intCodigoErro = 48;
                    objRetorno.strMsgErro    = "Registro não encontrado";
                }
            }
            catch (Exception ex)
            {
                FrameworkUtil.LogErro(ex);
                objRetorno.intCodigoErro        = 16;
                objRetorno.strMsgErro           = ex.Message;
                objRetorno.strExceptionToString = ex.ToString();
            }
            return(objRetorno);
        }
        public Object Process(Object result)
        {
            if (result == null)
            {
                return(true);
            }

            if (result is ConnectorObject)
            {
                return(_handler.Handle(result as ConnectorObject));
            }

            var cobld = new ConnectorObjectBuilder();
            var res   = result as Hashtable;

            foreach (String key in res.Keys)
            {
                var attrName  = key;
                var attrValue = res[key];
                if ("__UID__".Equals(attrName))
                {
                    if (attrValue == null)
                    {
                        throw new ConnectorException("Uid can not be null");
                    }
                    cobld.SetUid(attrValue.ToString());
                }
                else if ("__NAME__".Equals(attrName))
                {
                    if (attrValue == null)
                    {
                        throw new ConnectorException("Name can not be null");
                    }
                    cobld.SetName(attrValue.ToString());
                }
                else
                {
                    if (attrValue == null)
                    {
                        cobld.AddAttribute(ConnectorAttributeBuilder.Build(attrName));
                    }
                    else if (attrValue.GetType() == typeof(Object[]) || attrValue.GetType() == typeof(System.Collections.ICollection))
                    {
                        var list = new Collection <object>();
                        foreach (var val in (ICollection)attrValue)
                        {
                            list.Add(FrameworkUtil.IsSupportedAttributeType(val.GetType()) ? val : val.ToString());
                        }
                        cobld.AddAttribute(ConnectorAttributeBuilder.Build(attrName, list));
                    }
                    else
                    {
                        cobld.AddAttribute(ConnectorAttributeBuilder.Build(attrName, attrValue));
                    }
                }
            }
            cobld.ObjectClass = _objectClass;
            return(_handler.Handle(cobld.Build()));
        }
예제 #15
0
        public void PreparaTelaPrincipal()
        {
            //Construindo o Menu
            List <tbMenu> arrMenuAux = new List <tbMenu>();

            foreach (tbMenu objMenu in FrameworkUtil.objConfigStorage.objPerfilAcesso.tbPerfilAcessoMenu
                     .Where(pam => pam.pam_permiteVisualizacao == true && pam.tbMenu.men_codigoPai == null)
                     .Select(pam => pam.tbMenu).OrderBy(men => men.men_ordem))
            {
                tbMenu objMenuItem = new tbMenu()
                {
                    men_imagem = objMenu.men_imagem, men_cabecalho = objMenu.men_cabecalho, men_nomeControle = objMenu.men_nomeControle
                };
                AgrupaMenuItem(ref objMenuItem, objMenu.men_codigo);
                arrMenuAux.Add(objMenuItem);
            }
            arrMenu = new List <tbMenu>(arrMenuAux);

            //Construindo a ToolBar
            List <tbMenu> arrToolBarAux = new List <tbMenu>();

            foreach (tbMenu objToolBar in FrameworkUtil.objConfigStorage.objPerfilAcesso.tbPerfilAcessoMenu
                     .Where(pam => pam.pam_toolBar == true &&
                            pam.tbMenu.men_nomeControle != null &&
                            pam.pam_permiteVisualizacao == true).Select(per => per.tbMenu))
            {
                arrToolBarAux.Add(new tbMenu()
                {
                    men_imagem = objToolBar.men_imagem, men_cabecalho = objToolBar.men_cabecalho, men_nomeControle = objToolBar.men_nomeControle
                });
            }
            //Adicionaodo o botão para sair
            arrToolBarAux.Add(new tbMenu()
            {
                men_imagem = "../Imagens/Menu/50.png", men_cabecalho = "Sair", men_nomeControle = "SairViewModel"
            });

            arrToolBar = new List <tbMenu>(arrToolBarAux);

            //Construindo a StatusBar
            strFuncionario = FrameworkUtil.objConfigStorage.objFuncionario.fun_nome;
            strVersao      = FrameworkUtil.RetornaVersao();
            strEmpresa     = FrameworkUtil.objConfigStorage.objEmpresa.emp_nomeFantasia;
            strData        = DateTime.Now.ToString("dd/MM/yyyy");

            //Verificando a existencia dos arquivos da logo
            if (FrameworkUtil.objConfigStorage.objEmpresa.emp_logoFormato != null)
            {
                string[] arrCaminhoArquivo = Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory, "logo.*", SearchOption.AllDirectories).ToArray();
                for (int i = 0; i < arrCaminhoArquivo.Length; i++)
                {
                    File.Delete(arrCaminhoArquivo[i]);
                }
                if (FrameworkUtil.objConfigStorage.objEmpresa.emp_logo != null)
                {
                    File.WriteAllBytes(AppDomain.CurrentDomain.BaseDirectory + "logo" + FrameworkUtil.objConfigStorage.objEmpresa.emp_logoFormato, FrameworkUtil.objConfigStorage.objEmpresa.emp_logo);
                }
            }
        }
예제 #16
0
 public EFContexto()
     : base(FrameworkUtil.RetornaStringConexao(), true)
 {
     this.Configuration.ProxyCreationEnabled     = false;
     this.Configuration.LazyLoadingEnabled       = false;
     this.Configuration.AutoDetectChangesEnabled = false;
     Database.SetInitializer(new EFContextoInitializer());
     //Database.SetInitializer<EFContexto>(new EFContextoInitializer());
     //Database.SetInitializer(new MigrateDatabaseToLatestVersion<EFContexto, BSFood.Migrations.Configuration>("BSFood.DataAccess.EFContexto"));
 }
예제 #17
0
        private static ICollection <SafeType <APIOperation> > TranslateOperations(SafeType <SPIOperation>[] ops)
        {
            ICollection <SafeType <APIOperation> > set =
                new HashSet <SafeType <APIOperation> >();

            foreach (SafeType <SPIOperation> spi in ops)
            {
                CollectionUtil.AddAll(set, FrameworkUtil.Spi2Apis(spi));
            }
            return(set);
        }
예제 #18
0
 protected override void OnStartup(StartupEventArgs e)
 {
     EventManager.RegisterClassHandler(typeof(TextBox), TextBox.KeyDownEvent, new KeyEventHandler(TextBox_KeyDown));
     EventManager.RegisterClassHandler(typeof(CheckBox), CheckBox.KeyDownEvent, new KeyEventHandler(CheckBox_KeyDown));
     EventManager.RegisterClassHandler(typeof(ComboBox), ComboBox.KeyDownEvent, new KeyEventHandler(ComboBox_KeyDown));
     EventManager.RegisterClassHandler(typeof(RadioButton), RadioButton.KeyDownEvent, new KeyEventHandler(RadioButton_KeyDown));
     EventManager.RegisterClassHandler(typeof(PasswordBox), PasswordBox.KeyDownEvent, new KeyEventHandler(PasswordBox_KeyDown));
     //EventManager.RegisterClassHandler(typeof(TabItem), TabItem.KeyDownEvent, new KeyEventHandler(TabItem_KeyDown));
     FrameworkUtil.CarregarConfiguracao();
     FrameworkUtil.objGerenciaCupom = new GerenciaCupom();
     this.StartupUri = new System.Uri("View/winPrincipal.xaml", System.UriKind.Relative);
 }
예제 #19
0
        public Retorno ExcluirCliente(int intCodigo)
        {
            var objRetorno = new Retorno();

            try
            {
                //Cria um contexto isolado para a trasacao de exclusao
                using (var objContexto = new EFContexto())
                {
                    //Inicia uma transacao no contexto isolado
                    using (var transacao = objContexto.Database.BeginTransaction())
                    {
                        try
                        {
                            var objCliente = objContexto.tbCliente.Include(cen => cen.tbClienteEndereco)
                                             .Include(ctl => ctl.tbClienteTelefone).FirstOrDefault(cli => cli.cli_codigo == intCodigo);
                            if (objCliente != null)
                            {
                                objContexto.tbClienteEndereco.RemoveRange(objCliente.tbClienteEndereco);
                                objContexto.tbClienteTelefone.RemoveRange(objCliente.tbClienteTelefone);
                                objContexto.tbCliente.Remove(objCliente);
                                objContexto.SaveChanges();
                                transacao.Commit();

                                objRetorno.intCodigoErro = 0;
                                objRetorno.objRetorno    = true;
                            }
                            else
                            {
                                objRetorno.intCodigoErro = 48;
                                objRetorno.strMsgErro    = "Cliente não encontrado para exclusão";
                            }
                        }
                        catch (Exception)
                        {
                            //Se deu erro é porque o perfil tem  registros relacionado
                            transacao.Rollback();
                            objRetorno.intCodigoErro = 48;
                            objRetorno.strMsgErro    = "Cliente não pode ser excluido pois há registros relacionados ao mesmo";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                FrameworkUtil.LogErro(ex);
                objRetorno.intCodigoErro        = 16;
                objRetorno.strMsgErro           = ex.Message;
                objRetorno.strExceptionToString = ex.ToString();
            }
            return(objRetorno);
        }
예제 #20
0
 private static bool IsSupported(ConnectorAttributeInfo cai, object value)
 {
     if (!FrameworkUtil.IsSupportedAttributeType(value.GetType()))
     {
         LOG.Debug("Unsupported attribute type ... calling ToString (Name: \'{0}\' Type: \'{1}\' String Value: \'{2}\'",
                   cai.Name, value.GetType(), value.ToString());
         return(false);
     }
     else
     {
         return(true);
     }
 }
예제 #21
0
        public Retorno FecharMesa(tbMesa objMesa, int intFunCodigo)
        {
            var objRetorno   = new Retorno();
            var strValidacao = ValidaFechamentoMesa(objMesa);

            try
            {
                if (strValidacao == string.Empty)
                {
                    if (objMesa.tbPedido.ped_codigo > 0)
                    {
                        objMesa.tbPedido.ped_status = enStatusPedido.F.ToString();
                        using (var objBllPedido = new Pedidos())
                        {
                            objRetorno = objBllPedido.SalvarPedido(objMesa.tbPedido, enOrigemPedido.Comanda, intFunCodigo);
                        }
                        if (objRetorno.intCodigoErro == 0)
                        {
                            objMesa.tbPedido   = null;
                            objMesa.mes_status = enStatusMesa.L.ToString();//"L";
                            objMesa.ped_codigo = null;
                            var objMesaContexto = _objCtx.tbMesa.FirstOrDefault(mes => mes.mes_codigo == objMesa.mes_codigo);
                            _objCtx.Entry(objMesaContexto).CurrentValues.SetValues(objMesa);
                            _objCtx.SaveChanges();
                            using (var objBll = new Auditoria(ref _objCtx, ref _objTransacao))
                                objBll.SalvarAuditoria(objMesa.mes_codigo, enOperacao.Outro, objMesa, intFunCodigo);

                            objRetorno = RetornaMesa(objMesa.mes_codigo);
                        }
                    }
                    else
                    {
                        objRetorno.intCodigoErro = 48;
                        objRetorno.strMsgErro    = "Pedido não encontrado!";
                    }
                }
                else
                {
                    objRetorno.intCodigoErro = 48;
                    objRetorno.strMsgErro    = strValidacao;
                }
            }
            catch (Exception ex)
            {
                FrameworkUtil.LogErro(ex);
                objRetorno.intCodigoErro        = 16;
                objRetorno.strMsgErro           = ex.Message;
                objRetorno.strExceptionToString = ex.ToString();
            }
            return(objRetorno);
        }
예제 #22
0
        public Retorno RetornaCliente(int intCodigo, enNavegacao?enDirecao)
        {
            var objRetorno = new Retorno();

            try
            {
                tbCliente objCliente = null;
                if (enDirecao == null)
                {
                    objCliente = _objCtx.tbCliente.Include(cen => cen.tbClienteEndereco.Select(bai => bai.tbBairro))
                                 .Include(ctl => ctl.tbClienteTelefone).Include(cgr => cgr.tbClienteGrupo)
                                 .AsNoTracking()
                                 .FirstOrDefault(cli => cli.cli_codigo == intCodigo || cli.tbClienteTelefone.Any(ctl => ctl.ctl_numero.Equals(intCodigo.ToString())));
                }
                if (enDirecao == enNavegacao.Proximo)
                {
                    objCliente = _objCtx.tbCliente.Include(cen => cen.tbClienteEndereco.Select(bai => bai.tbBairro))
                                 .Include(ctl => ctl.tbClienteTelefone)
                                 .Include(cgr => cgr.tbClienteGrupo).AsNoTracking()
                                 .Where(cli => cli.cli_codigo > intCodigo)
                                 .OrderBy(cli => cli.cli_codigo).FirstOrDefault();
                }
                if (enDirecao == enNavegacao.Anterior)
                {
                    objCliente = _objCtx.tbCliente.Include(cen => cen.tbClienteEndereco.Select(bai => bai.tbBairro))
                                 .Include(ctl => ctl.tbClienteTelefone)
                                 .Include(cgr => cgr.tbClienteGrupo).AsNoTracking()
                                 .Where(cli => cli.cli_codigo < intCodigo)
                                 .OrderByDescending(cli => cli.cli_codigo).FirstOrDefault();
                }
                if (objCliente != null)
                {
                    objRetorno.intCodigoErro = 0;
                    objRetorno.objRetorno    = objCliente;
                }
                else
                {
                    objRetorno.intCodigoErro = 48;
                    objRetorno.strMsgErro    = "Registro não encontrado";
                }
            }
            catch (Exception ex)
            {
                FrameworkUtil.LogErro(ex);
                objRetorno.intCodigoErro        = 16;
                objRetorno.strMsgErro           = ex.Message;
                objRetorno.strExceptionToString = ex.ToString();
            }
            return(objRetorno);
        }
예제 #23
0
        public Retorno ExcluirFornecedor(int intCodigo)
        {
            var objRetorno = new Retorno();

            try
            {
                //Cria um contexto isolado para a trasacao de exclusao
                using (var objContexto = new EFContexto())
                {
                    //Inicia uma transacao no contexto isolado
                    using (var transacao = objContexto.Database.BeginTransaction())
                    {
                        try
                        {
                            var objFornecedor = objContexto.tbFornecedor.FirstOrDefault(forn => forn.for_codigo == intCodigo);
                            if (objFornecedor != null)
                            {
                                //Tenta excluir o perfil no contexto isolado
                                objContexto.tbFornecedor.Remove(objFornecedor);
                                objContexto.SaveChanges();
                                transacao.Commit();

                                objRetorno.intCodigoErro = 0;
                                objRetorno.objRetorno    = true;
                            }
                            else
                            {
                                objRetorno.intCodigoErro = 48;
                                objRetorno.strMsgErro    = "Fornecedor não encontrado para exclusão";
                            }
                        }
                        catch (Exception)
                        {
                            //Se deu erro é porque o perfil tem  registros relacionado
                            transacao.Rollback();
                            objRetorno.intCodigoErro = 48;
                            objRetorno.strMsgErro    = "Fornecedor não pode ser excluido pois há registros relacionados ao mesmo";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                FrameworkUtil.LogErro(ex);
                objRetorno.intCodigoErro        = 16;
                objRetorno.strMsgErro           = ex.Message;
                objRetorno.strExceptionToString = ex.ToString();
            }
            return(objRetorno);
        }
예제 #24
0
        CreateDefaultAPIConfiguration(LocalConnectorInfoImpl localInfo)
        {
            SafeType <Connector> connectorClass =
                localInfo.ConnectorClass;
            APIConfigurationImpl rv     = new APIConfigurationImpl();
            Configuration        config =
                localInfo.ConnectorConfigurationClass.CreateInstance();
            bool pooling = IsPoolingSupported(connectorClass);

            rv.IsConnectorPoolingSupported = pooling;
            rv.ConfigurationProperties     = (CSharpClassProperties.CreateConfigurationProperties(config));
            rv.ConnectorInfo       = (localInfo);
            rv.SupportedOperations = (FrameworkUtil.GetDefaultSupportedOperations(connectorClass));
            return(rv);
        }
예제 #25
0
 private void Salvar(object objParam)
 {
     Validate();
     if (!HasErrors)
     {
         string strMensagem;
         if (FrameworkUtil.SalvarConfiguracao(FrameworkUtil.objConfigLocal, out strMensagem))
         {
             ((Window)objParam).Close();
         }
         else
         {
             MessageBox.Show(strMensagem, "Atenção", MessageBoxButton.OK, MessageBoxImage.Warning);
         }
     }
 }
예제 #26
0
        public Retorno RetornaFuncionario(int intCodigo, enNavegacao?enDirecao)
        {
            var objRetorno = new Retorno();

            try
            {
                tbFuncionario objFuncionario = null;
                if (enDirecao == null)
                {
                    objFuncionario = _objCtx.tbFuncionario.Include(pac => pac.tbPerfilAcesso)
                                     .AsNoTracking()
                                     .FirstOrDefault(fun => fun.fun_codigo == intCodigo);
                }
                if (enDirecao == enNavegacao.Proximo)
                {
                    objFuncionario = _objCtx.tbFuncionario
                                     .Include(pac => pac.tbPerfilAcesso).AsNoTracking()
                                     .Where(fun => fun.fun_codigo > intCodigo)
                                     .OrderBy(fun => fun.fun_codigo).FirstOrDefault();
                }
                if (enDirecao == enNavegacao.Anterior)
                {
                    objFuncionario = _objCtx.tbFuncionario
                                     .Include(pac => pac.tbPerfilAcesso).AsNoTracking()
                                     .Where(fun => fun.fun_codigo < intCodigo)
                                     .OrderByDescending(fun => fun.fun_codigo).FirstOrDefault();
                }
                if (objFuncionario != null)
                {
                    objRetorno.intCodigoErro = 0;
                    objRetorno.objRetorno    = objFuncionario;
                }
                else
                {
                    objRetorno.intCodigoErro = 48;
                    objRetorno.strMsgErro    = "Registro não encontrado";
                }
            }
            catch (Exception ex)
            {
                FrameworkUtil.LogErro(ex);
                objRetorno.intCodigoErro        = 16;
                objRetorno.strMsgErro           = ex.Message;
                objRetorno.strExceptionToString = ex.ToString();
            }
            return(objRetorno);
        }
예제 #27
0
        public Retorno ExcluirProdutoGrupo(int intCodigo)
        {
            var objRetorno = new Retorno();

            try
            {
                using (var objContexto = new EFContexto())
                {
                    using (var transacao = objContexto.Database.BeginTransaction())
                    {
                        try
                        {
                            var objProdutoGrupo = objContexto.tbProdutoGrupo.Include(psgr => psgr.tbProdutoSubGrupo).FirstOrDefault(pgr => pgr.pgr_codigo == intCodigo);
                            if (objProdutoGrupo != null)
                            {
                                objContexto.tbProdutoSubGrupo.RemoveRange(objProdutoGrupo.tbProdutoSubGrupo);
                                objContexto.tbProdutoGrupo.Remove(objProdutoGrupo);
                                objContexto.SaveChanges();
                                transacao.Commit();

                                objRetorno.intCodigoErro = 0;
                                objRetorno.objRetorno    = true;
                            }
                            else
                            {
                                objRetorno.intCodigoErro = 48;
                                objRetorno.strMsgErro    = "Produto Grupo não encontrado para exclusão";
                            }
                        }
                        catch (Exception)
                        {
                            transacao.Rollback();
                            objRetorno.intCodigoErro = 48;
                            objRetorno.strMsgErro    = "Produto Grupo não pode ser excluido pois há registros relacionados ao mesmo";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                FrameworkUtil.LogErro(ex);
                objRetorno.intCodigoErro        = 16;
                objRetorno.strMsgErro           = ex.Message;
                objRetorno.strExceptionToString = ex.ToString();
            }
            return(objRetorno);
        }
예제 #28
0
        public Retorno ExcluirFormaPagamento(int intCodigo)
        {
            var objRetorno = new Retorno();

            try
            {
                using (var objContexto = new EFContexto())
                {
                    using (var transacao = objContexto.Database.BeginTransaction())
                    {
                        try
                        {
                            var objFormaPagamento = objContexto.tbFormaPagamento.FirstOrDefault(fpg => fpg.fpg_codigo == intCodigo);
                            if (objFormaPagamento != null)
                            {
                                objContexto.tbFormaPagamento.Remove(objFormaPagamento);
                                objContexto.SaveChanges();
                                transacao.Commit();

                                objRetorno.intCodigoErro = 0;
                                objRetorno.objRetorno    = true;
                            }
                            else
                            {
                                objRetorno.intCodigoErro = 48;
                                objRetorno.strMsgErro    = "FormaPagamento não encontrado para exclusão";
                            }
                        }
                        catch (Exception)
                        {
                            transacao.Rollback();
                            objRetorno.intCodigoErro = 48;
                            objRetorno.strMsgErro    = "FormaPagamento não pode ser excluido pois há registros relacionados ao mesmo.";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                FrameworkUtil.LogErro(ex);
                objRetorno.intCodigoErro        = 16;
                objRetorno.strMsgErro           = ex.Message;
                objRetorno.strExceptionToString = ex.ToString();
            }
            return(objRetorno);
        }
        public void TestAPIConfiguration()
        {
            ConfigurationPropertyImpl prop1 = new ConfigurationPropertyImpl();

            prop1.Order             = (1);
            prop1.IsConfidential    = (true);
            prop1.Name              = ("foo");
            prop1.HelpMessageKey    = ("help key");
            prop1.DisplayMessageKey = ("display key");
            prop1.GroupMessageKey   = ("group key");
            prop1.Value             = ("bar");
            prop1.ValueType         = (typeof(string));
            prop1.Operations        = null;

            ConfigurationPropertiesImpl props1 = new ConfigurationPropertiesImpl();

            props1.Properties = (CollectionUtil.NewReadOnlyList <ConfigurationPropertyImpl>(prop1));

            APIConfigurationImpl v1 = new APIConfigurationImpl();

            v1.ConnectorPoolConfiguration  = (new ObjectPoolConfiguration());
            v1.ConfigurationProperties     = (props1);
            v1.IsConnectorPoolingSupported = (true);
            v1.ProducerBufferSize          = (200);
            v1.SupportedOperations         = (FrameworkUtil.AllAPIOperations());
            IDictionary <SafeType <APIOperation>, int> map =
                CollectionUtil.NewDictionary <SafeType <APIOperation>, int>(SafeType <APIOperation> .Get <CreateApiOp>(), 6);

            v1.TimeoutMap = (map);

            APIConfigurationImpl v2 = (APIConfigurationImpl)
                                      CloneObject(v1);

            Assert.IsTrue(!Object.ReferenceEquals(v1, v2));
            Assert.IsNotNull(v2.ConnectorPoolConfiguration);
            Assert.IsNotNull(v2.ConfigurationProperties);
            Assert.AreEqual(v1.ConnectorPoolConfiguration, v2.ConnectorPoolConfiguration);
            Assert.AreEqual(v1.ConfigurationProperties, v2.ConfigurationProperties);
            Assert.IsTrue(v2.IsConnectorPoolingSupported);
            Assert.AreEqual(200, v2.ProducerBufferSize);
            Assert.IsTrue(CollectionUtil.SetsEqual(
                              FrameworkUtil.AllAPIOperations(),
                              v2.SupportedOperations));
            Assert.AreEqual(map, v2.TimeoutMap);
        }
예제 #30
0
        public Retorno RetornaFornecedor(int intCodigo, enNavegacao?enDirecao)
        {
            var objRetorno = new Retorno();

            try
            {
                tbFornecedor objFornecedor = null;
                if (enDirecao == null)
                {
                    objFornecedor = _objCtx.tbFornecedor
                                    .AsNoTracking()
                                    .FirstOrDefault(forn => forn.for_codigo == intCodigo);
                }
                if (enDirecao == enNavegacao.Proximo)
                {
                    objFornecedor = _objCtx.tbFornecedor.AsNoTracking()
                                    .Where(forn => forn.for_codigo > intCodigo)
                                    .OrderBy(forn => forn.for_codigo).FirstOrDefault();
                }
                if (enDirecao == enNavegacao.Anterior)
                {
                    objFornecedor = _objCtx.tbFornecedor.AsNoTracking()
                                    .Where(forn => forn.for_codigo < intCodigo)
                                    .OrderByDescending(forn => forn.for_codigo).FirstOrDefault();
                }
                if (objFornecedor != null)
                {
                    objRetorno.intCodigoErro = 0;
                    objRetorno.objRetorno    = objFornecedor;
                }
                else
                {
                    objRetorno.intCodigoErro = 48;
                    objRetorno.strMsgErro    = "Registro não encontrado";
                }
            }
            catch (Exception ex)
            {
                FrameworkUtil.LogErro(ex);
                objRetorno.intCodigoErro        = 16;
                objRetorno.strMsgErro           = ex.Message;
                objRetorno.strExceptionToString = ex.ToString();
            }
            return(objRetorno);
        }