Beispiel #1
0
        public MainWindow()
        {
            InitializeComponent();

            SplashScreen spScreen = new SplashScreen("Logo grande 3.png");

            spScreen.Show(true);
            Init();
            StaticParametros.SetTipoApp("Client");
        }
Beispiel #2
0
        public void Parametro()
        {
            var       sessao         = AuxiliarNhibernate.AbrirSessao();
            var       ParametroDAO   = new ParametroDAO(sessao);
            var       ParametroDBDAO = new ParametroDB_DAO(sessao);
            Processos process        = new Processos();

            StaticParametros.SetTipoApp("Service");
            int ctrl = 0;

            try
            {
                var ret = ParametroDAO.BuscarPorID(1);//Armazenamento.GetParametros();
                //var retdb = ParametroDBDAO.BuscarPorID(1);
                var retdb = ParametroDBDAO.BuscarTodos();
                try
                {
                    StaticParametros.SetGeraLogs(ret.GeraLog);
                    if (File.Exists(ret.CaminhoToke))
                    {
                        ctrl++;
                        StaticParametros.SetDirToke(ret.CaminhoToke);

                        if (DefineToken(StaticParametros.GetDirToke()) == false)
                        {
                            this.Stop();
                        }
                        if (VerificaProcessoRun() == false)
                        {
                            Thread t = new Thread(process.VerificaParaAtualizar);
                            t.Name = "UpdaterWorker";
                            t.Start();
                        }
                        else
                        {
                            Log("Feche o integrador para iniciar o serviço.", 2);
                            this.Stop();
                        }
                    }
                }
                catch (Exception)
                {
                    Log("Não foi possivel localizar as informações, por favor, abra o integrador e defina os parametros novamente.", 2);
                    this.Stop();
                }

                try
                {
                    if (Directory.Exists(ret.CaminhoDir))
                    {
                        ctrl++;
                        StaticParametros.SetDirOrigem(ret.CaminhoDir);
                        process.CriarPastas();
                    }
                }
                catch (Exception)
                {
                }

                try
                {
                    if (retdb.Count == 1)
                    {
                        StaticParametersDB.SetListBanco(retdb[0]);
                        if (retdb[0].Grupo == 0 || retdb[0].Token == null || retdb[0].Token == "")
                        {
                            throw new Exception();
                        }
                        StaticParametersDB.Setcurrent(retdb[0].Id);
                    }
                    else if (retdb.Count > 1)
                    {
                        foreach (var p in retdb)
                        {
                            StaticParametersDB.SetListBanco(p);
                        }
                        foreach (var p in retdb)
                        {
                            if (p.Grupo == 0 || p.Token == null || p.Token == "")
                            {
                                throw new Exception();
                            }
                        }
                        StaticParametersDB.Setcurrent(retdb[0].Id);
                    }
                    else
                    {
                        throw new Exception();
                    }
                    StaticParametros.SetIntegraBanco(true);
                    ctrl++;
                }
                catch (Exception)
                {
                    StaticParametros.SetIntegraBanco(false);
                }

                if (ctrl < 2)
                {
                    Log("Não foi possivel localizar as informações, por favor, abra o integrador e defina os parametros novamente.", 2);
                    this.Stop();
                }
            }
            catch
            {
                StreamWriter vWriter = new StreamWriter(@"c:\vch\log\logServico.log", true);
                vWriter.WriteLine("--------------------------------------------------");
                vWriter.WriteLine("Erro " + DateTime.Now.ToString());
                vWriter.Flush();
                vWriter.Close();
                sessao.Close();
                this.Stop();
            }

            sessao.Close();
        }