Exemple #1
0
        public BackupAutomatico StartBackupCupom()
        {
            var filePath = $"{Path}\\CFe\\Autorizadas\\bkp";

            if (Directory.Exists(filePath))
            {
                var di = new DirectoryInfo(filePath);
                foreach (var file in di.GetFiles("*.xml"))
                {
                    object obj = new
                    {
                        token      = Program.TOKEN,
                        id_empresa = IniFile.Read("idEmpresa", "APP"),
                        id_backup  = "N9TT-9G0A-B7FQ-RANC"
                    };

                    var jo = new RequestApi().URL(Program.URL_BASE + "/api/backup/cupom").Content(obj, Method.POST)
                             .AddFile("arquivo", file.FullName).Response();

                    if (jo["error"]?.ToString() == "False")
                    {
                        new Log().Add("BACKUPS", "[CUPOM] Backup realizado com sucesso", Log.LogType.info);
                        file.Delete();
                    }
                    else
                    {
                        new Log().Add("BACKUPS", "[CUPOM] Falha no backup", Log.LogType.info);
                    }
                }
            }

            return(this);
        }
Exemple #2
0
        public dynamic GetDados()
        {
            content = new RequestApi().URL(URL + $"?token={TOKEN}&cnpj={CNPJ}&codigo={Codigo}&uf={UF}&ex=0&descricao={Descricao}&unidadeMedida={Medida}&valor={Valor}&gtin={CodeBarras}")
                      .Content()
                      .Response();

            return(content);
        }
Exemple #3
0
        public BackupAutomatico StartBackup()
        {
            var dateNow  = DateTime.Now.ToString("dd-MM-yyyy");
            var filePath = $"{PathDB}\\{dateNow}.fbk";

            var isNumeric = int.TryParse(PathDB.Substring(0, 1), out var n);

            if (isNumeric)
            {
                return(this);
            }

            if (!File.Exists(filePath))
            {
                var backupSvc = new FbBackup
                {
                    ConnectionString = $"character set=NONE;initial catalog={new Connect().GetDatabase()};user id={_user};data source={_host};user id={_db};Password={_pass};Pooling=true;Dialect=3"
                };

                backupSvc.BackupFiles.Add(new FbBackupFile(filePath, 8192));
                backupSvc.Verbose = true;
                backupSvc.Options = FbBackupFlags.IgnoreLimbo;
                backupSvc.Execute();
            }

            object obj = new
            {
                token      = Program.TOKEN,
                id_empresa = IniFile.Read("idEmpresa", "APP"),
                id_backup  = "N9TT-9G0A-B7FQ-RANC"
            };

            var jo = new RequestApi().URL(Program.URL_BASE + "/api/backup").Content(obj, Method.POST)
                     .AddFile("arquivo", filePath).Response();

            if (jo == null)
            {
                new Log().Add("BACKUPS", "[DB] Falha no backup", Log.LogType.info);
            }
            else if (jo["error"]?.ToString() == "False")
            {
                new Log().Add("BACKUPS", "[DB] Backup realizado com sucesso", Log.LogType.info);
                CleanBackups(PathDB);
            }
            else
            {
                new Log().Add("BACKUPS", "[DB] Falha no backup", Log.LogType.info);
            }

            return(this);
        }