Exemple #1
0
        public override bool Execute()
        {
            Log.LogMessage(MessageImportance.Normal, "Project File  :  {0}", SsasProjectFile);
            Log.LogMessage(MessageImportance.Normal, "Target File   :  {0}", SsasTargetFile);
            Log.LogMessage(MessageImportance.Normal, "Server Edition:  {0}", SsasServerEdition);

            // Validate Project File Exists
            if (!File.Exists(SsasProjectFile))
            {
                throw new FileNotFoundException(string.Format("'{0}' does not exist.", SsasProjectFile));
            }

            try
            {
                Database database = ProjectHelper.DeserializeProject(SsasProjectFile);

                // ... Verify our project doesn't have any errors ...
                ValidationResultCollection results;

                bool isValidated = ProjectHelper.ValidateDatabase(database, SsasServerEdition, out results);

                // If the database doesn't validate (i.e., a build error)
                // log the errors and return failure.
                foreach (ValidationResult result in results)
                {
                    Log.LogError(result.Description);
                }

                if (!isValidated)
                {
                    return(false);
                }

                // Build the .ASDatabase file
                ProjectHelper.GenerateASDatabaseFile(database, SsasTargetFile);
            }
            catch (Exception ex)
            {
                Log.LogErrorFromException(ex);
                return(false);
            }

            return(true);
        }