private void Form1_Load(object sender, EventArgs e)//ao carregar o form, valida a licenca de uso { using (var db = new Banco()) { var consulta = db.Otimizacao.ToList(); if (consulta.Count == 0) { var formAtivador = new Ativacao(); formAtivador.ShowDialog(); } else { bool ativado = false; foreach (var x in consulta) { if (x.unification == MacAPI.obterMAC()) { ativado = true; } } if (ativado) { //Proseguir com o login normalmente... maquina autorizada } else { var formAtivador = new Ativacao(); formAtivador.ShowDialog(); } } } }
public IActionResult InativarReativarLivro(InativarLivroModel model) { Livro l = _facade.GetAllInclude(new Livro { CodigoBarras = model.CodigoBarras }); string msg; if (l.Inativo) { l.Inativo = !l.Inativo; Ativacao a = new Ativacao { CategoriaId = model.Motivo, Livro = l }; msg = _facade.Cadastrar(a); } else { l.Inativo = !l.Inativo; Inativacao i = new Inativacao { CategoriaId = model.Motivo, Livro = l }; msg = _facade.Cadastrar(i); } if (!String.IsNullOrEmpty(msg)) { TempData["Alert"] = msg; } return(RedirectToAction(nameof(ConfigLoja))); }
public string Validar(EntidadeDominio e) { Ativacao a = (Ativacao)e; Livro l = a.Livro; if (l.Estoque <= 0) { return("Esse livro não pode ser ativado pois seu estoque está zerado. Faça uma entrada de estoque e tente novamente.\n"); } return(""); }
static void Main(string[] args) { Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException); if (args.Length <= 0 || args[0].ToUpper() != "MIRROR") { MessageBox.Show("O Sistema de oficina mecânica não pode ser executado diretamente. Favor executar o arquivo Atalho.exe", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Warning); Environment.Exit(Environment.ExitCode); } Global.DriveRede = args[1]; Global.LocalPath = @"C:"; int conexaomirror = int.Parse(args[2]); FileInfo arquivo = new FileInfo(@"C:\Windows\AppPatch\Custom\{306eee73-a574-495b-b47a-eb68e5a5c101}.sdb"); if (arquivo.Exists) { Global.LocalPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); } FileInfo arquivo2003 = new FileInfo(@"C:\Windows\AppPatch\Custom\{3bc43a9b-22d7-40aa-88c8-1f78e055031f}.sdb"); if (arquivo2003.Exists) { Global.LocalPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); } #region SEGURANÇA DO ARQUIVO DE CONFIGURAÇÃO DO SISTEMA List <MechTech.Entities.ConexoesDTO> conexoes = new MechTech.Entities.ConexoesDTO().Deserializar(); Global.ConnectionStringPg = "host=" + conexoes[conexaomirror].Servidor + ";Port=" + conexoes[conexaomirror].Porta + ";Database=" + conexoes[conexaomirror].Banco + ";User="******";Password="******";Unicode=False;Protocol=2"; string[] tags = Global.ConnectionStringPg.Split(';'); tags[2] = "Database=gersys"; Global.ConnectionStringGerSys = tags[0] + ";" + tags[1] + ";" + tags[2] + ";" + tags[3] + ";" + tags[4] + ";" + tags[5] + ";" + tags[6]; #endregion Thread.CurrentThread.CurrentCulture = new CultureInfo("pt-BR"); Thread.CurrentThread.CurrentUICulture = new CultureInfo("pt-BR"); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.DoEvents(); Global.Sistema = Enumeradores.Sistema.MECHTECH; Global.LicencaUso = "DEMONSTRAÇÃO"; DevExpress.UserSkins.BonusSkins.Register(); Ativacao wsativ = new Ativacao(); #region Ativação try { AtivacaoDAO ativacaoDao = new AtivacaoDAO(); bool Ativou = false; int dias = 0; string ip = wsativ.GetIp(); Ativou = ativacaoDao.VerificaSeClienteAtivou(); if (Ativou) { string razao = ativacaoDao.getRazaoCliente(); if (wsativ.VerificaAtivacao(razao)) { wsativ.FecharConexao(); Global.LicencaUso = razao.ToUpper(); Application.Run(new frmPrincipal()); } else { MessageBox.Show("Desculpe-nos, mas sua licença expirou. Por favor, entre em contato com nosso suporte.", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Warning); Application.Exit(); } } else { if (wsativ.VerificaIpNoServidor(ip)) { dias = wsativ.VerificarDiasDemonstracao(ip); if (dias == 9999) { MessageBox.Show("Desculpe-nos, mas não foi possível verificar a data da máquina.\n" + "Verifique sua conexão de internet.", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Warning); Application.Exit(); } } else { wsativ.GravarIp(ip); } } if (dias > 0) { wsativ.FecharConexao(); Application.Run(new frmPrincipal()); } else if (dias < 0) { if (MessageBox.Show("O período de demonstração expirou. É necessário ativar o sistema para continuar, deseja fazê-lo agora?", "Atenção", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { Application.Run(new MechTech.Atalho.frmAtivacao()); } } } catch (Exception ex) { wsativ.FecharConexao(); MessageBox.Show(ex.StackTrace); } #endregion }