protected override void OnStartup(StartupEventArgs e) { //ResetSplashCreated = new ManualResetEvent(false); //// Create a new thread for the splash screen to run on //SplashThread = new Thread(ShowSplash); //SplashThread.SetApartmentState(ApartmentState.STA); //SplashThread.IsBackground = true; //SplashThread.Name = "Splash Screen"; //SplashThread.Start(); //// Wait for the blocker to be signaled before continuing. This is essentially the same as: while(ResetSplashCreated.NotSet) {} //ResetSplashCreated.WaitOne(); //var initType = ConfigurationManager.AppSettings["initDbType"]; //if (Settings.Default.Lix == null) //{ // new RequisicaoLicencaView().ShowDialog(); // if (Settings.Default.Lix == null) // { // Process.GetCurrentProcess().Kill(); // } //Settings.Default.Lix = new LicencaConcedida(); // Apagar após o fim dos testes do serviço //if (!Services.SuporteClient.LicenceActivated(Settings.Default.Lix.Codigo)) //{ // Services.SuporteClient.Log("Cliente:" + Settings.Default.Lix.Documento // + "\nErro ao carregar aplicação.\n Código do erro: x0:001\n"); //} //} //else //{ //} var initType = ConfigurationManager.AppSettings["initDbType"]; //DataBaseManager.CnnStr = ConfigurationManager.AppSettings["cnnDeploy"]; if (!string.IsNullOrEmpty(initType)) { switch (initType) { case "init": DataBaseManager.InitDb(); break; case "update": DataBaseManager.UpdateDb(); break; } } Configuracao = ConfiguracaoGeralRepository.GetById(1); Ncms = new ObservableCollection <Ncm>(NcmRepository.GetList()); Csts = new ObservableCollection <Cst>(CstRepository.GetList()); CstCofins = new ObservableCollection <CstCofins>(CstCofinsRepository.GetList()); CstIpi = new ObservableCollection <CstIpi>(CstIpiRepository.GetList()); CstPis = new ObservableCollection <CstPis>(CstPisRepository.GetList()); Cfops = new ObservableCollection <Cfop>(CfopRepository.GetList()); base.OnStartup(e); //SplashThread.Interrupt(); }
public MainWindow() { InitializeComponent(); try { App.Ncms = new ObservableCollection <Ncm>(NcmRepository.GetList()); App.Csts = new ObservableCollection <Cst>(CstRepository.GetList()); App.CstPis = new ObservableCollection <CstPis>(CstPisRepository.GetList()); App.CstCofins = new ObservableCollection <CstCofins>(CstCofinsRepository.GetList()); App.CstIpi = new ObservableCollection <CstIpi>(CstIpiRepository.GetList()); } catch (Exception ex) { Utils.GerarLog(ex); ModelBase.MensagemErroBancoDados("Erro ao carregar aplicação.\n\n" + ex.Message + "\n\nA aplicação será encerrada para evitar danos ao banco de dados."); Process.GetCurrentProcess().Kill(); } Model = new RetaguardaModel(); Model.TelaAberta += model_TelaAberta; DataContext = Model; //NHibernateHttpModule.Session.FlushMode = FlushMode.Commit; //foreach (var produto in ProdutoRepository.GetList()) //{ // if (produto.Tributacao == null) // { // produto.Tributacao = new Tributacao(); // } // if (produto.Ncm.Codigo.Contains("1902200")) // { // produto.Tributacao.TipoTributacaoIcms = SituacaoTributaria.Tributado; // produto.Tributacao.IcmsDevedor = 2.75M; // } // ProdutoRepository.Save(produto); //} //var pessoa = PessoaFisicaRepository.GetByLogin("admin"); //if (pessoa != null) //{ // var forms = new FormularioDictionary(); // foreach (var form in forms.Values) // { // pessoa.PermissaoFormulario.Add(new PermissaoFormularioPessoaFisica() // { // Formulario = form.Value, // Edita = false, // Exclui = false, // Insere = false, // Pesquisa = true // }); // } // PessoaFisicaRepository.Save(pessoa); //} //try //{ // var empresa = new PessoaJuridica() // { // Cnpj = "13049042000169", // RazaoSocial = "BONE PIZZA FRIOS BEBIDAS LTDA ME", // NomeFantasia = "BONE PIZZA FILIAL ESTANCIA", // DataAbertura = DateTime.Parse("01/01/2012"), // InscricaoEstadual = "271371099", // DataCadastro = DateTime.Now, // ContatoTelefonicos = new PessoaTelefone[] { // new PessoaTelefone() // { // DdiPais = "55", // DddTelefone = "79", // Numero = "35229059", // TelefoneTipo = TelefoneTipo.Comercial // }, // new PessoaTelefone() // { // DdiPais = "55", // DddTelefone = "79", // Numero = "99193007", // TelefoneTipo = TelefoneTipo.Comercial // } // }, // Enderecos = new PessoaEndereco[] // { // new PessoaEndereco() // { // Logradouro = "RUA PEDRO HOMEM DA COSTA", // Numero = "292", // Endereco = EnderecoRepository.GetByCep("492000000"), // InformadoManualmente = true, // TipoEndereco = TipoEndereco.Comercial // } // } // }; // empresa.Enderecos[0].Pessoa = empresa; // empresa.ContatoTelefonicos[0].Pessoa = empresa; // empresa.ContatoTelefonicos[1].Pessoa = empresa; // PessoaJuridicaRepository.Save(empresa); // ModelBase.MensagemInformativa("Empresa cadastrada com sucesso. Identificador: " + empresa.Id); //} //catch (Exception ex) //{ // ModelBase.MensagemErroBancoDados(ex.Message); //} }