Beispiel #1
0
        public override void Init(IServiceContainer serviceContainer, IDictionary <string, string> jobArgsDictionary)
        {
            base.Init(serviceContainer, jobArgsDictionary);

            Configuration = _serviceProvider.GetRequiredService <IOptionsSnapshot <InitializationConfiguration> >().Value;

            GalleryDatabase = GetDatabaseRegistration <GalleryDbConfiguration>();

            Source = CloudStorageAccount.Parse(Configuration.Source);

            PrimaryDestination = CloudStorageAccount.Parse(Configuration.PrimaryDestination);

            if (!string.IsNullOrEmpty(Configuration.SecondaryDestination))
            {
                SecondaryDestination = CloudStorageAccount.Parse(Configuration.SecondaryDestination);
            }

            SourceContainerName      = Configuration.SourceContainerName ?? DefaultPackagesContainerName;
            DestinationContainerName = Configuration.DestinationContainerName ?? DefaultPackagesArchiveContainerName;

            SourceContainer               = Source.CreateCloudBlobClient().GetContainerReference(SourceContainerName);
            PrimaryDestinationContainer   = PrimaryDestination.CreateCloudBlobClient().GetContainerReference(DestinationContainerName);
            SecondaryDestinationContainer = SecondaryDestination?.CreateCloudBlobClient().GetContainerReference(DestinationContainerName);

            CursorBlobName = Configuration.CursorBlob ?? DefaultCursorBlobName;
        }
        public override bool Init(IDictionary <string, string> jobArgsDictionary)
        {
            try
            {
                PackageDatabase = new SqlConnectionStringBuilder(
                    JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.PackageDatabase));

                Source = CloudStorageAccount.Parse(
                    JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.Source));

                PrimaryDestination = CloudStorageAccount.Parse(
                    JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.PrimaryDestination));

                var secondaryDestinationCstr = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.SecondaryDestination);
                SecondaryDestination = string.IsNullOrEmpty(secondaryDestinationCstr) ? null : CloudStorageAccount.Parse(secondaryDestinationCstr);

                SourceContainerName = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.SourceContainerName) ?? DefaultPackagesContainerName;

                DestinationContainerName = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.DestinationContainerName) ?? DefaultPackagesArchiveContainerName;

                SourceContainer               = Source.CreateCloudBlobClient().GetContainerReference(SourceContainerName);
                PrimaryDestinationContainer   = PrimaryDestination.CreateCloudBlobClient().GetContainerReference(DestinationContainerName);
                SecondaryDestinationContainer = SecondaryDestination?.CreateCloudBlobClient().GetContainerReference(DestinationContainerName);

                CursorBlobName = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.CursorBlob) ?? DefaultCursorBlobName;

                // Initialized successfully
                return(true);
            }
            catch (Exception ex)
            {
                Trace.TraceError(ex.ToString());
            }
            return(false);
        }
        public override void Init(IDictionary <string, string> jobArgsDictionary)
        {
            PackageDatabase = new SqlConnectionStringBuilder(
                JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.PackageDatabase));

            Source = CloudStorageAccount.Parse(
                JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.Source));

            PrimaryDestination = CloudStorageAccount.Parse(
                JobConfigurationManager.GetArgument(jobArgsDictionary, JobArgumentNames.PrimaryDestination));

            var secondaryDestinationCstr = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.SecondaryDestination);

            SecondaryDestination = string.IsNullOrEmpty(secondaryDestinationCstr) ? null : CloudStorageAccount.Parse(secondaryDestinationCstr);

            SourceContainerName = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.SourceContainerName) ?? DefaultPackagesContainerName;

            DestinationContainerName = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.DestinationContainerName) ?? DefaultPackagesArchiveContainerName;

            SourceContainer               = Source.CreateCloudBlobClient().GetContainerReference(SourceContainerName);
            PrimaryDestinationContainer   = PrimaryDestination.CreateCloudBlobClient().GetContainerReference(DestinationContainerName);
            SecondaryDestinationContainer = SecondaryDestination?.CreateCloudBlobClient().GetContainerReference(DestinationContainerName);

            CursorBlobName = JobConfigurationManager.TryGetArgument(jobArgsDictionary, JobArgumentNames.CursorBlob) ?? DefaultCursorBlobName;
        }
        private void FixupPrimaryDestination(Destination previousValue, bool skipKeys = false)
        {
            if (IsDeserializing)
            {
                return;
            }

            if (previousValue != null && previousValue.PrimaryPrefCustomers.Contains(this))
            {
                previousValue.PrimaryPrefCustomers.Remove(this);
            }

            if (PrimaryDestination != null)
            {
                if (!PrimaryDestination.PrimaryPrefCustomers.Contains(this))
                {
                    PrimaryDestination.PrimaryPrefCustomers.Add(this);
                }

                PrimaryDestinationID = PrimaryDestination.DestinationID;
            }
            else if (!skipKeys)
            {
                PrimaryDestinationID = null;
            }

            if (ChangeTracker.ChangeTrackingEnabled)
            {
                if (ChangeTracker.OriginalValues.ContainsKey("PrimaryDestination") &&
                    (ChangeTracker.OriginalValues["PrimaryDestination"] == PrimaryDestination))
                {
                    ChangeTracker.OriginalValues.Remove("PrimaryDestination");
                }
                else
                {
                    ChangeTracker.RecordOriginalValue("PrimaryDestination", previousValue);
                }
                if (PrimaryDestination != null && !PrimaryDestination.ChangeTracker.ChangeTrackingEnabled)
                {
                    PrimaryDestination.StartTracking();
                }
            }
        }
Beispiel #5
0
        public void Write(GamePacketWriter writer)
        {
            writer.Write(ServerUniqueId);
            writer.Write(BIgnoreCooldown);
            PrimaryDestination.Write(writer);

            writer.Write(TargetInfoData.Count, 8u);
            TargetInfoData.ForEach(u => u.Write(writer));

            writer.Write(InitialPositionData.Count, 8u);
            InitialPositionData.ForEach(u => u.Write(writer));

            writer.Write(TelegraphPositionData.Count, 8u);
            TelegraphPositionData.ForEach(u => u.Write(writer));

            writer.Write(MissileInfoData.Count, 8u);
            MissileInfoData.ForEach(u => u.Write(writer));

            writer.Write(Phase);
        }
        protected internal override async Task Execute()
        {
            // Configure defaults as needed
            PackageDatabase      = PackageDatabase ?? Config.Sql.GetConnectionString(KnownSqlConnection.Legacy);
            Source               = Source ?? Config.Storage.Legacy;
            PrimaryDestination   = PrimaryDestination ?? Config.Storage.Legacy;
            SecondaryDestination = SecondaryDestination ?? Config.Storage.Backup;

            if (Source == null)
            {
                throw new ArgumentNullException("Source cannot be null");
            }

            if (PrimaryDestination == null)
            {
                throw new ArgumentNullException("Primary Destination cannot be null");
            }

            if (PackageDatabase == null)
            {
                throw new ArgumentNullException("PackageDatabase cannot be null");
            }

            SourceContainer = Source.CreateCloudBlobClient().GetContainerReference(
                String.IsNullOrEmpty(SourceContainerName) ? BlobContainerNames.LegacyPackages : SourceContainerName);
            PrimaryDestinationContainer = PrimaryDestination.CreateCloudBlobClient().GetContainerReference(
                String.IsNullOrEmpty(DestinationContainerName) ? BlobContainerNames.Backups : DestinationContainerName);
            SecondaryDestinationContainer = SecondaryDestination == null ? null : SecondaryDestination.CreateCloudBlobClient().GetContainerReference(
                String.IsNullOrEmpty(DestinationContainerName) ? BlobContainerNames.Backups : DestinationContainerName);
            CursorBlob = String.IsNullOrEmpty(CursorBlob) ? DefaultCursorBlob : CursorBlob;

            Log.PreparingToArchive(Source.Credentials.AccountName, SourceContainer.Name, PrimaryDestination.Credentials.AccountName, PrimaryDestinationContainer.Name, PackageDatabase.DataSource, PackageDatabase.InitialCatalog);
            await Archive(PrimaryDestinationContainer);

            if (SecondaryDestinationContainer != null)
            {
                Log.PreparingToArchive2(SecondaryDestination.Credentials.AccountName, SecondaryDestinationContainer.Name);
                await Archive(SecondaryDestinationContainer);
            }
        }