private bool LinkPackagesToAutomationSequences(List <AutomationSequence> sequencesToRun)
        {
            UpdateDatabasePackageList();
            foreach (AutomationSequence automationSequence in sequencesToRun)
            {
                automationSequence.DatabasePackages = DatabasePackages;
                Logging.Debug("Linking sequence to package reference: {0}, {1}", automationSequence.PackageName, automationSequence.PackageUID);

                DatabasePackage result = DatabasePackages.Find(pack => pack.UID.Equals(automationSequence.PackageUID));
                if (result == null)
                {
                    Logging.Error("A package does not exist in the database matching UID {0}", automationSequence.PackageUID);
                    return(false);
                }

                if (result.PackageName != automationSequence.PackageName)
                {
                    Logging.Warning(Logfiles.AutomationRunner, "The packageName property is out of date. From database: {0}. From Package: {1}", result.PackageName, automationSequence.PackageName);
                }

                automationSequence.Package = result;
            }

            return(true);
        }
        private void MoveStoredProceduresIntoPackages(List <DatabasePackage> packs, List <DatabaseStoredProcedure> sprocs, IFilter packFilter)
        {
            var packSprocs = sprocs.Where(x => !string.IsNullOrEmpty(x.Package)).ToList();

            if (packSprocs.Count == 0)
            {
                return;
            }
            var packList = packSprocs.Select(x => x.Package).Distinct();

            foreach (var packName in packList)
            {
                if (packFilter.Exclude(packName))
                {
                    continue;
                }
                var packContents = sprocs.Where(x => x.Package == packName).ToList();
                var package      = packs.FirstOrDefault(x => string.Equals(x.Name, packName));
                if (package == null)
                {
                    package = new DatabasePackage {
                        Name = packName
                    };
                }
                package.StoredProcedures.AddRange(packContents);
                _databaseSchema.Packages.Add(package);
            }
            sprocs.RemoveAll(x => !string.IsNullOrEmpty(x.Package));
        }
Exemple #3
0
        public static List <DatabasePackage> Packages(DataTable dt)
        {
            List <DatabasePackage> list = new List <DatabasePackage>();

            if (dt.Rows.Count == 0)
            {
                return(list);
            }

            //oracle and ODP
            string key      = "OBJECT_NAME";
            string ownerKey = "OWNER";

            //Devart.Data.Oracle
            if (!dt.Columns.Contains(key))
            {
                key = "NAME";
            }
            if (!dt.Columns.Contains(ownerKey))
            {
                ownerKey = "SCHEMA";
            }

            foreach (DataRow row in dt.Rows)
            {
                DatabasePackage package = new DatabasePackage();
                package.Name        = row[key].ToString();
                package.SchemaOwner = row[ownerKey].ToString();
                list.Add(package);
            }
            return(list);
        }
Exemple #4
0
        private async Task UpdateProcessStep2()
        {
            Logging.Editor("Starting update process step 2");

            DatabasePackage package = PackageNamesListbox.SelectedItems[0] as DatabasePackage;
            //parse download instructions xml files
            XmlDocument downloadDocument = XmlUtils.LoadXmlDocument(Path.Combine(WorkingDirectory, package.PackageName, "_autoUpdate", "download.xml"), XmlLoadType.FromFile);

            if (downloadDocument == null)
            {
                Logging.Editor("Failed to parse download xml document");
                return;
            }

            //parse to class objects
            package.DownloadInstructions = ParseDownloadInstructions(downloadDocument, package.DownloadInstructions.DownloadedDatabaseZipFileLocation);

            //get download URL string based on download instructions type
            string directDownloadURL = string.Empty;

            Logging.Editor("Getting download URL");
            switch (package.DownloadInstructions.DownloadType)
            {
            case DownloadTypes.StaticLink:
                directDownloadURL = package.DownloadInstructions.UpdateURL;
                break;

            case DownloadTypes.WgMods:
                directDownloadURL = await GetWGmodsDownloadLink(package.DownloadInstructions.UpdateURL);

                break;
            }

            //check that download URL is valid
            if (string.IsNullOrWhiteSpace(directDownloadURL))
            {
                Logging.Editor("Download URL is blank", LogLevel.Error);
                return;
            }
            else
            {
                Logging.Editor("Download URL is valid, attempting to download file");
            }

            //create download string and download the file
            string downloadLocation = Path.Combine(WorkingDirectory, package.PackageName, package.DownloadInstructions.DownloadFilename);

            package.DownloadInstructions.DownloadedFileLocation = downloadLocation;

            if (File.Exists(downloadLocation))
            {
                File.Delete(downloadLocation);
            }

            await client.DownloadFileTaskAsync(directDownloadURL, downloadLocation);

            AutoUpdateProgressBar.Value = AutoUpdateProgressBar.Minimum;
            Logging.Editor("File downloaded, finished update process step 2");
        }
Exemple #5
0
        private static DatabasePackage AddPackage(string name, string owner)
        {
            var pack = new DatabasePackage();

            pack.Name        = name;
            pack.SchemaOwner = owner;
            return(pack);
        }
 private void PackageComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (PackageComboBox.SelectedItem is EditorComboBoxItem item)
     {
         SelectedPackage    = item.Package;
         OKButton.IsEnabled = true;
     }
 }
        public override async Task RunTask()
        {
            NetworkCredential networkCredential = new NetworkCredential(AutomationSettings.BigmodsUsername, AutomationSettings.BigmodsPassword);
            string            serverPath        = string.Format("{0}{1}", PrivateStuff.BigmodsFTPUsersRoot, WoTOnlineFolderVersion);

            Logging.Info("Checking if {0} already exists on the server in folder {1}", ZipFileName, WoTOnlineFolderVersion);
            string[] listOfFilesOnServer = await FtpUtils.FtpListFilesFoldersAsync(serverPath, networkCredential);

            int    duplicateIncriment  = 1;
            string nameWithNoExtension = Path.GetFileNameWithoutExtension(ZipFileName);
            string extension           = Path.GetExtension(ZipFileName);
            string newFilename         = ZipFileName;

            while (listOfFilesOnServer.Contains(newFilename))
            {
                Logging.Info("Filename already exists on server, giving it a unique name");
                newFilename = string.Format("{0}_{1}{2}", nameWithNoExtension, duplicateIncriment++.ToString(), extension);
                Logging.Info("Propose {0}", newFilename);
            }
            ZipFileName = newFilename;

            using (WebClient = new WebClient {
                Credentials = networkCredential
            })
            {
                string uploadUrl = string.Format("{0}/{1}", serverPath, ZipFileName);
                Logging.Info(Logfiles.AutomationRunner, "Uploading package");
                Logging.Debug(Logfiles.AutomationRunner, "Upload zip url = {0}, file = {1}", uploadUrl, FilePath);
                //https://stackoverflow.com/questions/2953403/c-sharp-passing-method-as-the-argument-in-a-method
                if (DatabaseAutomationRunner != null)
                {
                    WebClient.UploadProgressChanged += DatabaseAutomationRunner.UploadProgressChanged;
                    WebClient.UploadFileCompleted   += DatabaseAutomationRunner.UploadFileCompleted;
                }
                try
                {
                    await WebClient.UploadFileTaskAsync(uploadUrl, FilePath);

                    DatabasePackage.UpdatePackageName(ZipFileName);
                    FtpUtils.TriggerMirrorSyncAsync();
                    TransferSuccess = true;
                }
                catch (OperationCanceledException) { }
                catch (Exception ex)
                {
                    Logging.Exception(ex.ToString());
                }
                finally
                {
                    if (DatabaseAutomationRunner != null)
                    {
                        WebClient.UploadProgressChanged -= DatabaseAutomationRunner.UploadProgressChanged;
                        WebClient.UploadFileCompleted   -= DatabaseAutomationRunner.UploadFileCompleted;
                    }
                }
            }
        }
Exemple #8
0
 public void BuildPackage(DatabasePackage package)
 {
     try
     {
         var txt = _migrationGenerator.AddPackage(package);
         Clipboard.SetText(txt, TextDataFormat.UnicodeText);
     }
     catch (Exception exception)
     {
         Debug.WriteLine(exception.Message);
     }
 }
 protected virtual void PreProcessTargetPackage()
 {
     //check that the target package exists
     if (TargetPackageUID.Equals("this"))
     {
         targetPackage = DatabasePackage;
     }
     else
     {
         targetPackage = DatabasePackages.Find(package => package.UID.Equals(TargetPackageUID));
     }
 }
Exemple #10
0
        public void SaveUser(User user)
        {
            DatabasePackage dbPackage = new DatabasePackage(_ConnectionString);

            try
            {
                string sqlQuery = string.Empty;

                if (user.ID == 0) // Add a user
                {
                    sqlQuery = "Insert Into User (Name, Password) Values ('" + user.Name + "', '" + user.Password + ")";
                }
                else // Modify a user
                {
                    sqlQuery = "Update User Set Name = '" + user.Name + "', Password = '******' Where ID = " + user.ID;
                }

                dbPackage.CommandText = sqlQuery;
                dbPackage.OpenConnection();
                dbPackage.BeginTransaction();

                if (dbPackage.ExecuteNonQuery() == 0)
                {
                    throw new DataAccessException("Unable to save object.", new Exception());
                }

                dbPackage.CommitTransaction();
            }
            catch (DataDuplicityException ex)
            {
                dbPackage.RollbackTransaction();

                if (ex.ErrorMessage.IndexOf("User_Name_Unique") > 0)
                {
                    throw new DataDuplicityException("User already exist.", ex);
                }
            }
            catch (DataAccessException ex)
            {
                dbPackage.RollbackTransaction();
                throw new DataLayerException("Unable to save object.", ex);
            }
            catch (Exception ex)
            {
                dbPackage.RollbackTransaction();
                throw new DataLayerException("Unable to save object.", ex);
            }
            finally
            {
                dbPackage.CloseConnection();
            }
        }
Exemple #11
0
        public void SaveBook(Book book)
        {
            DatabasePackage dbPackage = new DatabasePackage(_ConnectionString);

            try
            {
                string sqlQuery = string.Empty;

                if (book.ID == 0) // Add a book
                {
                    sqlQuery = "Insert Into Book (Name) Values ('" + book.Name + "')";
                }
                else // Modify a book
                {
                    sqlQuery = "Update Book Set Name = '" + book.Name + "' Where ID = " + book.ID;
                }

                dbPackage.CommandText = sqlQuery;
                dbPackage.OpenConnection();
                dbPackage.BeginTransaction();

                if (dbPackage.ExecuteNonQuery() == 0)
                {
                    throw new DataAccessException("Unable to save object.", new Exception());
                }

                dbPackage.CommitTransaction();
            }
            catch (DataDuplicityException ex)
            {
                dbPackage.RollbackTransaction();

                if (ex.ErrorMessage.IndexOf("Book_Name_Unique") > 0)
                {
                    throw new DataDuplicityException("Book already exist.", ex);
                }
            }
            catch (DataAccessException ex)
            {
                dbPackage.RollbackTransaction();
                throw new DataLayerException("Unable to save object.", ex);
            }
            catch (Exception ex)
            {
                dbPackage.RollbackTransaction();
                throw new DataLayerException("Unable to save object.", ex);
            }
            finally
            {
                dbPackage.CloseConnection();
            }
        }
Exemple #12
0
        private void CreateResult(ResultType resultType, DatabasePackage package, string script)
        {
            var result = new CompareResult
            {
                SchemaObjectType = SchemaObjectType.Package,
                ResultType       = resultType,
                Name             = package.Name,
                SchemaOwner      = package.SchemaOwner,
                Script           = script
            };

            _results.Add(result);
        }
        public void SaveBookTest()
        {
            DatabasePackage databasePackage = new DatabasePackage(_ConnectionString);
            SqlDataReader   reader          = null;

            try
            {
                LibraryRepository libraryRepository = new LibraryRepository(_ConnectionString);

                // Test Add Book

                Book newBook = new Book();
                newBook.Name = "Unit Test Book";

                libraryRepository.SaveBook(newBook);

                databasePackage.CommandText = "Select ID From Book Where Name = 'Unit Test Book'";
                reader = databasePackage.GetReader();

                reader.Read();

                int bookID = databasePackage.FieldToInt(reader["ID"]);

                Assert.AreNotEqual(0, bookID);

                // Test Modify Book

                Book existingBook = libraryRepository.GetBookByID(bookID);
                existingBook.Name = "Unit Test Book (Modified)";
                libraryRepository.SaveBook(existingBook);

                Book modifiedBook = libraryRepository.GetBookByID(bookID);

                Assert.AreEqual("Unit Test Book (Modified)", modifiedBook.Name);

                // Delete newly added book

                libraryRepository.DeleteBook(bookID);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
        }
Exemple #14
0
        public string BuildPackage(DatabasePackage package)
        {
            StringBuilder sb = new StringBuilder();

            try
            {
                sb.Append(m_migrationGenerator.AddPackage(package));
            }
            catch (Exception exception)
            {
                Debug.WriteLine(exception.Message);
            }
            return(sb.ToString());
        }
 private void btnDbPackage_Click(object sender, EventArgs e)
 {
     try
     {
         if (FlushMetadata())
         {
             var dbPackage = new DatabasePackage(_wizard.Connection);
             dbPackage.Write(_wizard.InstallScript);
         }
     }
     catch (Exception ex)
     {
         Utils.HandleError(ex);
     }
 }
Exemple #16
0
        public Task DownloadPackagesAsync(List <DatabasePackage> packagesToDownload)
        {
            if (string.IsNullOrEmpty(UrlBase))
            {
                throw new BadMemeException("UrlBase is empty/null");
            }

            if (string.IsNullOrEmpty(DownloadLocationBase))
            {
                throw new BadMemeException("DownloadLocationBase is empty/null");
            }

            if (Progress == null)
            {
                Logging.Warning("Progress is null, no progress will be reported for this download operation");
            }

            if (CancellationToken == null)
            {
                Logging.Warning("CancellationToken is null, no cancellations will be acknowledged for this download operation");
            }

            downloadProgress = new RelhaxDownloadProgress()
            {
                ParrentTotal = packagesToDownload.Count
            };

            return(Task.Run(() => {
                //load md5 database manager before downloading packages
                if (!databaseManager.DatabaseLoaded)
                {
                    databaseManager.LoadMd5Database(ApplicationConstants.MD5HashDatabaseXmlFile);
                }

                for (int i = 0; i < packagesToDownload.Count; i++)
                {
                    DatabasePackage package = packagesToDownload[i];
                    Logging.Info(LogOptions.ClassName, "Download {0} of {1}, package {2} start", i + 1, packagesToDownload.Count, package.PackageName);
                    Logging.Debug(LogOptions.ClassName, "Download of package {0} from formed URL {1}", package.PackageName, UrlBase + package.ZipFile);
                    DownloadPackage(package);
                    Logging.Info(LogOptions.ClassName, "Download {0} of {1}, package {2} finish", i + 1, packagesToDownload.Count, package.PackageName);
                }
            }));
        }
Exemple #17
0
        public List <Book> GetIssuedBooks()
        {
            DatabasePackage dbPackage = new DatabasePackage(_ConnectionString);
            List <Book>     books     = new List <Book>();
            SqlDataReader   reader    = null;

            try
            {
                dbPackage.CommandText = "Select ID, Name, IssueDate, MemberID From Book Where MemberID is Not Null Order By Name";
                reader = dbPackage.GetReader();

                while (reader.Read())
                {
                    Book book = new Book();

                    book.ID        = dbPackage.FieldToInt(reader["ID"]);
                    book.Name      = dbPackage.FieldToString(reader["Name"]);
                    book.IssueDate = dbPackage.FieldToDateTime(reader["IssueDate"]);
                    book.MemberID  = dbPackage.FieldToInt(reader["MemberID"]);

                    books.Add(book);
                }
            }
            catch (DataAccessException ex)
            {
                throw new DataLayerException("Collection could not populated.", ex);
            }
            catch (Exception ex)
            {
                throw new DataLayerException("Collection could not populated.", ex);
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }

                dbPackage.CloseConnection();
            }

            return(books);
        }
        public void GetBookByIDTest()
        {
            DatabasePackage databasePackage = new DatabasePackage(_ConnectionString);
            SqlDataReader   reader          = null;

            LibraryRepository libraryRepository = new LibraryRepository(_ConnectionString);

            try
            {
                // Add a new book

                Book newBook = new Book();
                newBook.Name = "Unit Test Book";

                libraryRepository.SaveBook(newBook);

                databasePackage.CommandText = "Select ID From Book Where Name = 'Unit Test Book'";
                reader = databasePackage.GetReader();
                reader.Read();

                int bookID = databasePackage.FieldToInt(reader["ID"]);

                // Test the function

                Book book = libraryRepository.GetBookByID(bookID);
                Assert.AreEqual(book.ID, bookID);

                // Delete newly added book

                libraryRepository.DeleteBook(bookID);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
        }
Exemple #19
0
        public override string AddPackage(DatabasePackage databasePackage)
        {
            if (string.IsNullOrEmpty(databasePackage.Definition) || string.IsNullOrEmpty(databasePackage.Body))
            {
                return("-- add package " + databasePackage.Name + " (no sql available)");
            }
            //the body and defintion starts "PACKAGE name AS", so just add CREATE OR REPLACE
            return(string.Format(CultureInfo.InvariantCulture,
                                 @"CREATE OR REPLACE  
{0}
/

CREATE OR REPLACE 
{1}
/
",
                                 databasePackage.Definition,
                                 databasePackage.Body));
        }
Exemple #20
0
        public List <User> GetUsers()
        {
            DatabasePackage dbPackage = new DatabasePackage(_ConnectionString);
            List <User>     users     = new List <User>();
            SqlDataReader   reader    = null;

            try
            {
                dbPackage.CommandText = "Select ID, Name, Password From User Order By Name";
                reader = dbPackage.GetReader();

                while (reader.Read())
                {
                    User user = new User();

                    user.ID       = dbPackage.FieldToInt(reader["ID"]);
                    user.Name     = dbPackage.FieldToString(reader["Name"]);
                    user.Password = dbPackage.FieldToString(reader["Password"]);

                    users.Add(user);
                }
            }
            catch (DataAccessException ex)
            {
                throw new DataLayerException("Collection could not populated.", ex);
            }
            catch (Exception ex)
            {
                throw new DataLayerException("Collection could not populated.", ex);
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }

                dbPackage.CloseConnection();
            }

            return(users);
        }
Exemple #21
0
        public List <Member> GetNoBookIssuedMembers()
        {
            DatabasePackage dbPackage = new DatabasePackage(_ConnectionString);
            List <Member>   members   = new List <Member>();
            SqlDataReader   reader    = null;

            try
            {
                dbPackage.CommandText = "Select ID, Name From Member Where ID Not In (Select MemberID From Book Where MemberID Is Null) Order By Name";
                reader = dbPackage.GetReader();

                while (reader.Read())
                {
                    Member member = new Member();

                    member.ID   = dbPackage.FieldToInt(reader["ID"]);
                    member.Name = dbPackage.FieldToString(reader["Name"]);

                    members.Add(member);
                }
            }
            catch (DataAccessException ex)
            {
                throw new DataLayerException("Collection could not populated.", ex);
            }
            catch (Exception ex)
            {
                throw new DataLayerException("Collection could not populated.", ex);
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }

                dbPackage.CloseConnection();
            }

            return(members);
        }
Exemple #22
0
        private void WritePackage(DatabasePackage package, string directoryFullName, ProjectWriter pw)
        {
            //we'll put stored procedures in subdirectory
            var packDirectory = new DirectoryInfo(Path.Combine(directoryFullName, package.NetName));

            if (!packDirectory.Exists)
            {
                packDirectory.Create();
            }
            var ns = _codeWriterSettings.Namespace;

            if (!string.IsNullOrEmpty(ns))
            {
                ns += "." + package.NetName;
            }

            foreach (var sproc in package.StoredProcedures)
            {
                WriteStoredProcedure(package.NetName, packDirectory.FullName, ns, sproc, pw);
            }
        }
Exemple #23
0
        public Book GetBookByID(int id)
        {
            DatabasePackage dbPackage = new DatabasePackage(_ConnectionString);
            SqlDataReader   reader    = null;

            try
            {
                dbPackage.CommandText = "Select ID, Name, IssueDate, MemberID From Book Where ID = " + id;
                reader = dbPackage.GetReader();

                reader.Read();

                Book book = new Book
                {
                    ID        = id,
                    Name      = dbPackage.FieldToString(reader["Name"]),
                    IssueDate = dbPackage.FieldToDateTime(reader["IssueDate"]),
                    MemberID  = dbPackage.FieldToInt(reader["MemberID"])
                };

                return(book);
            }
            catch (DataAccessException ex)
            {
                throw new DataLayerException("Unable to retrieve data.", ex);
            }
            catch (Exception ex)
            {
                throw new DataLayerException("Unable to retrieve data.", ex);
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
        }
Exemple #24
0
        public User GeUserByID(int id)
        {
            DatabasePackage dbPackage = new DatabasePackage(_ConnectionString);
            SqlDataReader   reader    = null;

            try
            {
                dbPackage.CommandText = "Select ID, Name, Password From User Where ID = " + id;
                reader = dbPackage.GetReader();

                reader.Read();

                User user = new User
                {
                    ID       = id,
                    Name     = dbPackage.FieldToString(reader["Name"]),
                    Password = dbPackage.FieldToString(reader["Password"])
                };

                return(user);
            }
            catch (DataAccessException ex)
            {
                throw new DataLayerException("Unable to retrieve data.", ex);
            }
            catch (Exception ex)
            {
                throw new DataLayerException("Unable to retrieve data.", ex);
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
        }
Exemple #25
0
        public void ReturnBook(int bookID)
        {
            DatabasePackage dbPackage = new DatabasePackage(_ConnectionString);

            try
            {
                dbPackage.CommandText = "Update Book Set IssueDate = null, MemberID = null Where ID = " + bookID;
                dbPackage.OpenConnection();
                dbPackage.BeginTransaction();

                if (dbPackage.ExecuteNonQuery() == 0)
                {
                    throw new DataAccessException("Unable to save object.", new Exception());
                }

                dbPackage.CommitTransaction();
            }
            catch (DataDuplicityException ex)
            {
                dbPackage.RollbackTransaction();
                throw new DataDuplicityException(ex.ErrorMessage, ex);
            }
            catch (DataAccessException ex)
            {
                dbPackage.RollbackTransaction();
                throw new DataLayerException("Unable to save object.", ex);
            }
            catch (Exception ex)
            {
                dbPackage.RollbackTransaction();
                throw new DataLayerException("Unable to save object.", ex);
            }
            finally
            {
                dbPackage.CloseConnection();
            }
        }
Exemple #26
0
        public void DeleteUser(int id)
        {
            DatabasePackage dbPackage = new DatabasePackage(_ConnectionString);

            try
            {
                dbPackage.CommandText = "Delete From User Where ID = " + id;
                dbPackage.OpenConnection();
                dbPackage.BeginTransaction();

                if (dbPackage.ExecuteNonQuery() == 0)
                {
                    throw new DataAccessException("Unable to save object.", new Exception());
                }

                dbPackage.CommitTransaction();
            }
            catch (DataDependencyException ex)
            {
                dbPackage.RollbackTransaction();
                throw new DataDependencyException(ex.ErrorMessage, ex);
            }
            catch (DataAccessException ex)
            {
                dbPackage.RollbackTransaction();
                throw new DataLayerException("Unable to save object.", ex);
            }
            catch (Exception ex)
            {
                dbPackage.RollbackTransaction();
                throw new DataLayerException("Unable to save object.", ex);
            }
            finally
            {
                dbPackage.CloseConnection();
            }
        }
 private void btnDbPackage_Click(object sender, EventArgs e)
 {
   try
   {
     if (FlushMetadata())
     {
       var dbPackage = new DatabasePackage(_wizard.Connection);
       dbPackage.Write(_wizard.InstallScript);
     }
   }
   catch (Exception ex)
   {
     Utils.HandleError(ex);
   }
 }
Exemple #28
0
 public string DropPackage(DatabasePackage package)
 {
     return(_migration.DropPackage(package));
 }
Exemple #29
0
 public string AddPackage(DatabasePackage package)
 {
     return(_migration.AddPackage(package));
 }
 public virtual string AddPackage(DatabasePackage databasePackage)
 {
     return(null); //only applies to Oracle, so see it's override
 }
        private bool ResetApplicationMacros(AutomationSequence sequence)
        {
            Logging.Debug(Logfiles.AutomationRunner, LogOptions.ClassName, "Resetting application macros");

            //check that required automation settings are set for being able to reset macaros
            if (string.IsNullOrEmpty(AutomationRunnerSettings.WoTClientInstallLocation))
            {
                Logging.Error("WoTClientInstallLocation is not set in settings tab!");
                return(false);
            }
            if (!File.Exists(AutomationRunnerSettings.WoTClientInstallLocation))
            {
                Logging.Error("WoTClientInstallLocation file does not exist!");
                return(false);
            }

            DatabasePackage   package           = sequence.Package;
            SelectablePackage selectablePackage = package as SelectablePackage;

            ApplicationMacros.Clear();
            ApplicationMacros.Add(new AutomationMacro()
            {
                Name = "date", Value = DateTime.UtcNow.ToString("yyyy-MM-dd"), MacroType = MacroType.ApplicationDefined
            });
            ApplicationMacros.Add(new AutomationMacro()
            {
                Name = "category.name", Value = (selectablePackage != null) ? selectablePackage.ParentCategory.Name : "null", MacroType = MacroType.ApplicationDefined
            });
            ApplicationMacros.Add(new AutomationMacro()
            {
                Name = "name", Value = (selectablePackage != null) ? selectablePackage.NameFormatted : "null", MacroType = MacroType.ApplicationDefined
            });
            ApplicationMacros.Add(new AutomationMacro()
            {
                Name = "packageName", Value = package.PackageName, MacroType = MacroType.ApplicationDefined
            });
            ApplicationMacros.Add(new AutomationMacro()
            {
                Name = "packageUID", Value = package.UID, MacroType = MacroType.ApplicationDefined
            });
            ApplicationMacros.Add(new AutomationMacro()
            {
                Name = "zipfile", Value = package.ZipFile, MacroType = MacroType.ApplicationDefined
            });
            ApplicationMacros.Add(new AutomationMacro()
            {
                Name = "level", Value = (selectablePackage != null) ? selectablePackage.Level.ToString() : "null", MacroType = MacroType.ApplicationDefined
            });
            ApplicationMacros.Add(new AutomationMacro()
            {
                Name = "patchGroup", Value = package.PatchGroup.ToString(), MacroType = MacroType.ApplicationDefined
            });
            ApplicationMacros.Add(new AutomationMacro()
            {
                Name = "installGroup", Value = package.InstallGroupWithOffset.ToString(), MacroType = MacroType.ApplicationDefined
            });
            ApplicationMacros.Add(new AutomationMacro()
            {
                Name = "clientVersion", Value = WoTClientVersion, MacroType = MacroType.ApplicationDefined
            });
            ApplicationMacros.Add(new AutomationMacro()
            {
                Name = "onlineFolderVersion", Value = WoTModpackOnlineFolderVersion, MacroType = MacroType.ApplicationDefined
            });
            ApplicationMacros.Add(new AutomationMacro()
            {
                Name = "author", Value = package.Author, MacroType = MacroType.ApplicationDefined
            });
            ApplicationMacros.Add(new AutomationMacro()
            {
                Name = "version", Value = package.Version, MacroType = MacroType.ApplicationDefined
            });
            ApplicationMacros.Add(new AutomationMacro()
            {
                Name = "applicationPath", Value = ApplicationConstants.ApplicationStartupPath, MacroType = MacroType.ApplicationDefined
            });
            ApplicationMacros.Add(new AutomationMacro()
            {
                Name = "relhaxTemp", Value = ApplicationConstants.RelhaxTempFolderPath, MacroType = MacroType.ApplicationDefined
            });
            ApplicationMacros.Add(new AutomationMacro()
            {
                Name = "workDirectory", Value = string.Format("{0}\\{1}", ApplicationConstants.RelhaxTempFolderPath, package.PackageName), MacroType = MacroType.ApplicationDefined
            });
            ApplicationMacros.Add(new AutomationMacro()
            {
                Name = "automationRepoRoot", Value = AutomationRepoPathEscaped, MacroType = MacroType.ApplicationDefined
            });
            ApplicationMacros.Add(new AutomationMacro()
            {
                Name = "clientPath", Value = Path.GetDirectoryName(AutomationRunnerSettings.WoTClientInstallLocation)
            });
            return(true);
        }