Esempio n. 1
0
        public void Register()
        {
            try
            {
                var installed = new DomainSerializer("DomainsInstalled.json");

                foreach (var repository in
                         from domain in installed.Get()
                         let catalog = DbConvention.GetDbNameByConvention(domain.DomainName)
                                       select new AddInstalledDomainProcedure
                {
                    DomainName = domain.DomainName,
                    AdminEmail = domain.AdminEmail,
                    SkipValidation = true,
                    _Catalog = catalog
                })
                {
                    repository.Execute();
                }
            }
            catch (NpgsqlException ex)
            {
                Log.Error("Could not execute AddInstalledDomainProcedure. Exception: {Exception}", ex);
            }
        }
Esempio n. 2
0
        public static void Add(ApprovedDomain tenant)
        {
            string database = DbConvention.GetDbNameByConvention(tenant.DomainName);

            using (var db = DbProvider.Get(FrapidDbServer.GetSuperUserConnectionString(database)).GetDatabase())
            {
                dynamic poco = new ExpandoObject();
                poco.domain_name = tenant.DomainName;
                poco.admin_email = tenant.AdminEmail;

                db.Insert("account.installed_domains", "domain_id", true, poco);
            }
        }
Esempio n. 3
0
        public void Register()
        {
            try
            {
                var installed = new DomainSerializer("DomainsInstalled.json");

                foreach (var domain in installed.Get())
                {
                    string database = DbConvention.GetDbNameByConvention(domain.DomainName);
                    InstalledDomains.Add(database, domain.DomainName, domain.AdminEmail);
                }
            }
            catch (Exception ex)
            {
                Log.Error("Could not execute AddInstalledDomainProcedure. Exception: {Exception}", ex);
            }
        }
Esempio n. 4
0
        public override void Initialize()
        {
            this.TemplateName = this.Line.GetTokenOn(2);

            string type = this.Line.GetTokenOn(4);

            if (type.ToLower().Equals("instance"))
            {
                this.InstanceName = this.Line.GetTokenOn(5);
                return;
            }

            this.DomainName = this.Line.GetTokenOn(5);

            if (IsNullOrWhiteSpace(this.DomainName))
            {
                return;
            }

            this.InstanceName = DbConvention.GetDbNameByConvention(this.DomainName);
        }
Esempio n. 5
0
        public void Execute(IJobExecutionContext context)
        {
            ThreadPool.QueueUserWorkItem(callback =>
            {
                var server      = new DbServer();
                string fileName = DateTimeOffset.UtcNow.Ticks.ToString();
                var domains     = DbConvention.GetDomains();

                foreach (var domain in domains)
                {
                    string tenant    = DbConvention.GetDbNameByConvention(domain.DomainName);
                    string directory = this.GetBackupDirectory(domain, tenant);


                    var agent = this.GetAgent(server, fileName, tenant, directory);

                    try
                    {
                        agent.Backup(
                            done =>
                        {
                            var backup = new Resources(tenant, directory, fileName);

                            backup.AddTenantDataToBackup();
                            backup.Compress();
                            backup.Clean();
                        },
                            error =>
                        {
                            Log.Error($"Could not backup because and error occurred. \n\n{error}");
                        });
                    }
                    catch (Exception ex)
                    {
                        Log.Error("Exception occurred executing the backup job. {Exception}.", ex);
                    }
                }
            });
        }