示例#1
0
        public ModelConexao GetConfigConexoes()
        {
            ModelConexao objRet = null;
            string       sPath  = Util.GetPastaConfiguracao() + "\\SpedConfig.xml";

            if (sPath != "")
            {
                if (File.Exists(sPath))
                {
                    objRet = SerializeClassToXml.DeserializeClasse <ModelConexao>(sPath);
                }
            }
            return(objRet);
        }
示例#2
0
        public void Salvar(Conexao conexao)
        {
            if (conexao.PROPRIEDADES["dbname"].Split(':')[1] != "")
            {
                string sPath = Util.GetPastaConfiguracao();
                if (sPath == "")
                {
                    throw new Exception("Configure um diretório na rede para salvar as conexões.");
                }
                sPath += "\\SpedConfig.xml";
                ItemConn conn = null;
                if (ConfigConn == null)
                {
                    ConfigConn          = new ModelConexao();
                    ConfigConn.CONEXOES = new List <ItemConn>();
                    conn = new ItemConn();
                    ConfigConn.CONEXOES.Add(conn);
                }
                else
                {
                    if (ConfigConn.CONEXOES.Where(c => c.NAME == conexao.NOME).Count() > 0)
                    {
                        conn = ConfigConn.CONEXOES.FirstOrDefault(c => c.NAME == conexao.NOME);
                    }
                    else
                    {
                        conn = new ItemConn();
                        ConfigConn.CONEXOES.Add(conn);
                    }
                }
                conn.NAME            = conexao.NOME;
                ConfigConn.bCOMPLETO = conexao.bCOMPLETO;
                conn.PATH            = conexao.PROPRIEDADES["dbname"];

                SerializeClassToXml.SerializeClasse <ModelConexao>(ConfigConn, sPath);


                //Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                //config.ConnectionStrings.ConnectionStrings[conexao.NOME].ConnectionString =
                //    this.GetConnectionString(conexao);
                //if (conexao.NOME == "DBArquivoSpedFiscal" || conexao.NOME == "DBArquivoSpedContabil")
                //{
                //    config.AppSettings.Settings.Remove("ActiveRecordDialect");
                //    config.AppSettings.Settings.Add("ActiveRecordDialect", "NHibernate.Dialect.FirebirdDialect");
                //}
                //config.Save(ConfigurationSaveMode.Modified, false);
                //ConfigurationManager.RefreshSection("connectionStrings");
            }
        }
示例#3
0
        public void RemoveConexao(Conexao conexao)
        {
            string sPath = Util.GetPastaConfiguracao();

            if (sPath == "")
            {
                throw new Exception("Configure um diretório na rede para salvar as conexões.");
            }
            sPath     += "\\SpedConfig.xml";
            ConfigConn = GetConfigConexoes();

            if (ConfigConn != null)
            {
                if (ConfigConn.CONEXOES.Where(c => c.NAME == conexao.NOME).Count() > 0)
                {
                    ConfigConn.CONEXOES.Remove(ConfigConn.CONEXOES.FirstOrDefault(c => c.NAME == conexao.NOME));
                }
                SerializeClassToXml.SerializeClasse <ModelConexao>(ConfigConn, sPath);
            }
        }
示例#4
0
        public Conexao Obter(string nomeConexao)
        {
            Conexao conexao = null;

            ConfigConn = GetConfigConexoes();
            if (ConfigConn != null)
            {
                if (ConfigConn.CONEXOES.Where(c => c.NAME == nomeConexao).Count() > 0)
                {
                    conexao           = new Conexao();
                    conexao.NOME      = nomeConexao;
                    conexao.bCOMPLETO = ConfigConn.bCOMPLETO;
                    conexao.PROPRIEDADES.Add("dbname", ConfigConn.CONEXOES.FirstOrDefault(c => c.NAME == nomeConexao).PATH);
                    conexao.PROPRIEDADES.Add("Driver", "{Firebird/InterBase(r) driver}");
                    conexao.PROPRIEDADES.Add("Dialect", "3");
                    conexao.PROPRIEDADES.Add("uid", "SYSDBA");
                    conexao.PROPRIEDADES.Add("pwd", "masterkey");
                    conexao.sNM_EMPRESA = this.GetNomeBaseEmpresa(conexao);
                }
            }
            return(conexao);
        }
示例#5
0
        private void CarregaMenus()
        {
            tsBasico.Visible     = false;
            tsContabil.Visible   = false;
            tsContimatic.Visible = false;
            tsFull1.Visible      = false;
            tsFull2.Visible      = false;
            tsLorenzon1.Visible  = false;
            tsLorenzon2.Visible  = false;
            Conexao      cx   = null;
            ModelConexao conn = _ConfigConnectionsController.ConexoesService.GetConfigConexoes();

            if (conn != null)
            {
                if (conn.CONEXOES.Count > 0)
                {
                    if (conn.CONEXOES.Where(c => c.NAME == "DBArquivoSpedContmatic").Count() > 0)
                    {
                        cx = _ConfigConnectionsController.ObterConexao("DBArquivoSpedContmatic");
                        if (cx.bCOMPLETO)
                        {
                            tsContimatic.Visible = true;
                        }
                    }
                    if (conn.CONEXOES.Where(c => c.NAME == "DBArquivoSpedContabil").Count() > 0)
                    {
                        cx = _ConfigConnectionsController.ObterConexao("DBArquivoSpedContabil");
                        if (cx.bCOMPLETO)
                        {
                            tsContabil.Visible = true;
                        }
                    }

                    if (conn.CONEXOES.Where(c => c.NAME == "DBArquivoSpedFiscal").Count() > 0)
                    {
                        tsBasico.Visible = true;

                        if (conn.bCOMPLETO)
                        {
                            tsFull1.Visible = true;
                            tsFull2.Visible = true;
                        }

                        cx = _ConfigConnectionsController.ObterConexao("DBArquivoSpedFiscal");


                        if (cx.sNM_EMPRESA.ToUpper().Equals("LORENZON"))
                        {
                            tsLorenzon1.Visible = true;
                            tsLorenzon2.Visible = true;
                        }
                    }
                }
            }
            cx = null;
            cx = _ConfigConnectionsController.ConexoesService.Obter("DBArquivoSpedFiscal");
            if (cx != null)
            {
                Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                config.ConnectionStrings.ConnectionStrings["DBArquivoSpedFiscal"].ConnectionString = _ConfigConnectionsController.ConexoesService.GetConnectionString(cx);
                config.Save(ConfigurationSaveMode.Modified, false);
                ConfigurationManager.RefreshSection("connectionStrings");
                cx = null;
            }
            cx = _ConfigConnectionsController.ConexoesService.Obter("DBArquivoSpedContabil");
            if (cx != null)
            {
                Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                config.ConnectionStrings.ConnectionStrings["DBArquivoSpedContabil"].ConnectionString = _ConfigConnectionsController.ConexoesService.GetConnectionString(cx);
                config.Save(ConfigurationSaveMode.Modified, false);
                ConfigurationManager.RefreshSection("connectionStrings");
                cx = null;
            }
            cx = _ConfigConnectionsController.ConexoesService.Obter("DBArquivoSpedContmatic");
            if (cx != null)
            {
                Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                config.ConnectionStrings.ConnectionStrings["DBArquivoSpedContmatic"].ConnectionString = _ConfigConnectionsController.ConexoesService.GetConnectionString(cx);
                config.Save(ConfigurationSaveMode.Modified, false);
                ConfigurationManager.RefreshSection("connectionStrings");
                cx = null;
            }
        }