public UserInfoRepository(DTO.Enums.BackEndOrFrontEndEnum whichEnd)
 {
     _ConnectionString = GetDataFromXml.GetCurrentConnectionString(whichEnd);
     _tableAdapter     = new AccessBEDBTableAdapters.User_Login_InfoTableAdapter();
     _tableAdapter.Connection.ConnectionString = _ConnectionString;
     _userInfoTable = new AccessBEDB.User_Login_InfoDataTable();
 }
Exemplo n.º 2
0
        public static List <DTO.InstallerItem> GetInstallerFiles()
        {
            string currentDirectory     = Directory.GetCurrentDirectory() + "\\";
            string destinationDirectory = Domain.FrontEnd.GetInfo.GetAppDataPath();

            return(GetDataFromXml.GetInstallerManifest(currentDirectory, destinationDirectory));
        }
Exemplo n.º 3
0
        private void reconstructBackEndFromRolloutsFolder(object sender, DoWorkEventArgs e)
        {
            //1. Create back end xml file to be updated.
            CreateXmlFile.CreateBackEndXmlFileInRolloutDirectory();
            var directory          = new DirectoryInfo(this.RollOutDirectory + "Rollouts\\");
            var fileCount          = directory.EnumerateFiles("FE-*.zip").Count();
            int progressPercentage = Convert.ToInt32(((double)1 / (fileCount + 1)) * 100);

            (sender as BackgroundWorker).ReportProgress(progressPercentage, e.Argument);
            int progress = 1;

            //2. Loop through the zipped files in the rollouts folder
            foreach (var file in directory.EnumerateFiles("FE-*.zip"))
            {
                //For each file, read the file into a ZipArchive object
                ZipArchive zipfile = ZipFile.OpenRead(file.FullName);
                //Find the only .xml file in the zip file and extract it to the reconstruction path.
                zipfile.Entries.FirstOrDefault(p => p.Name.Contains(".xml")).ExtractToFile(this.ReconstructionPath, true);
                //Release the object reference in memory to the zip file.
                zipfile.Dispose();
                //Create a rolloutInfo file (which is plain object with only properties and not methods) out of
                //the newly extracted xml file.
                DTO.RolloutInfo rollout = GetDataFromXml.GetReconstructedInfo(this.ReconstructionPath);
                //Add a rollout record with the info in the rollout record.
                UpdateXmlFile.AddRolloutRecord(rollout);
                progressPercentage = Convert.ToInt32(((double)++progress / fileCount) * 100);
                (sender as BackgroundWorker).ReportProgress(progressPercentage, "Reconstructed " + file.Name);
            }
        }
Exemplo n.º 4
0
 public static bool CompareUserInfo(DTO.User user)
 {
     try
     {
         DTO.RolloutInfo currentRollout = GetDataFromXml.GetFrontEndSettings();
         if (user.UserType != currentRollout.UserType)
         {
             return(true);
         }
         if (currentRollout.RolloutVersionNumber !=
             GetDataFromXml.GetCurrentRolloutVersionNumber(DTO.Enums.BackEndOrFrontEndEnum.FrontEnd, user.UserType))
         {
             return(true);
         }
     }
     catch (DTO.Exceptions.CouldNotFindValueException)
     {
         throw;
     }
     //This exception is raised when the front end has yet to be set up (i.e. first launch after install).
     catch (DTO.Exceptions.FrontEndNeedsUpdateException)
     {
         return(true);
     }
     return(false);
 }
 //This will set the last rollout and current version number stats when called. If an exception is raised by either, the labels will
 //simply be hidden.
 private void setStats()
 {
     try
     {
         LastRolloutLabel.Content = "Last Rollout Date: " + GetDataFromXml.GetMostRecentRolloutDate(DTO.Enums.BackEndOrFrontEndEnum.BackEnd);
     }
     catch (Exception)
     {
         LastRolloutLabel.Visibility = System.Windows.Visibility.Hidden;
     }
     try
     {
         versionNumber.Content = "Current Version Numbers: " +
                                 GetDataFromXml.GetCurrentRolloutVersionNumber(DTO.Enums.BackEndOrFrontEndEnum.BackEnd,
                                                                               DTO.Enums.UserTypeEnum.Associate).ToString() +
                                 " (Associate); " +
                                 GetDataFromXml.GetCurrentRolloutVersionNumber(DTO.Enums.BackEndOrFrontEndEnum.BackEnd,
                                                                               DTO.Enums.UserTypeEnum.Admin).ToString() +
                                 " (Admin)";
     }
     catch (Exception)
     {
         versionNumber.Visibility = System.Windows.Visibility.Hidden;
     }
     if (Domain.BackEnd.BackEndSettingsManager.LockoutIsEnabled())
     {
         LockoutSlider.Value = 1;
         lockoutOnLabel();
     }
     else
     {
         LockoutSlider.Value = 0;
         lockoutOffLabel();
     }
 }
 private void setCurrentVersions()
 {
     this.AssociateVersion            = GetDataFromXml.GetCurrentRolloutVersionNumber(DTO.Enums.BackEndOrFrontEndEnum.BackEnd, DTO.Enums.UserTypeEnum.Associate);
     this.AdminVersion                = GetDataFromXml.GetCurrentRolloutVersionNumber(DTO.Enums.BackEndOrFrontEndEnum.BackEnd, DTO.Enums.UserTypeEnum.Admin);
     this.AdminRollbackVersion        = this.AdminVersion;
     this.AssociateRollbackVersion    = this.AssociateVersion;
     this.CurrentVersionLabel.Content = string.Format("Current Versions: {0} (Admin), {1} (Associate)", this.AdminVersion, this.AssociateVersion);
 }
Exemplo n.º 7
0
 public Rollout(string directoryPath, string launchPath, DTO.Enums.UserTypeEnum userType)
 {
     //This will ensure that the directory doesn't use mapped drive letters but instead the
     //full UNC path.
     directoryPath             = PathManager.GetUNCPath(directoryPath);
     this.LaunchFileName       = getLaunchFileName(launchPath);
     this.DirectoryPath        = Validator.ValidateDirectoryPath(directoryPath);
     this.UserType             = userType;
     this.RollOutDirectoryPath = Validator.ValidateDirectoryPath(PathManager.GetRolloutDirectoryPath(DTO.Enums.BackEndOrFrontEndEnum.BackEnd));
     this.BackEndXMLPath       = this.RollOutDirectoryPath + "backend.xml";
     this.VersionNumber        = GetDataFromXml.GetCurrentRolloutVersionNumber(DTO.Enums.BackEndOrFrontEndEnum.BackEnd, this.UserType) + 1;
 }
Exemplo n.º 8
0
        //This will compare the copied files with the current installer manifest files. If a file to be
        //added doesn't exist within the manifest, it will add it to the manifest.
        private void compareWithManifest()
        {
            var             manifest      = GetDataFromXml.GetInstallerManifest(this._installerFilesDirectory, null);
            List <FileInfo> manifestFiles = manifest.Select(p => new FileInfo(p.SourceFilePath)).ToList();

            foreach (FileInfo file in this.CopiedFiles)
            {
                if (!manifestFiles.Any(p => p.Name == file.Name))
                {
                    UpdateXmlFile.AddFileToManifest(this._installerFilesDirectory, file);
                }
            }
        }
 public MainWindow()
 {
     InitializeComponent();
     this.Show();
     //On instantiation, checks to see if back end is installed (i.e. both the BackEndSettings.xml and backend.xml have been created.
     if (!Domain.Validator.BackEndIsInstalled())
     {
         /*If the the backend is not fully installed, checks to see if the back end settings file exists.
          *  If the backend settings file EXISTS, this means that the system has been installed but the backend.xml file has been deleted.
          *  In this case, it the back end will attempt to repair itself (using the TryFixBrokenBackEnd method on the installer.)
          */
         if (Domain.Validator.BackEndSettingsFileExists())
         {
             var result = MessageBox.Show("The backend.xml file cannot be located. AccessLauncher can attempt to reconstruct it from the contents " +
                                          "of the rollouts folder. Would you like AccessLauncher to make this attempt? (If you select \"No\", you " +
                                          "will be redirected to reinstall the back end entirely.) If you select yes, this could take " +
                                          "a minute or more.",
                                          "Backend.xml not found!",
                                          MessageBoxButton.YesNo,
                                          MessageBoxImage.Error,
                                          MessageBoxResult.Yes);
             if (result == MessageBoxResult.Yes)
             {
                 var accessPath          = GetDataFromXml.GetAccessPathFromCurrentConnectionString(DTO.Enums.BackEndOrFrontEndEnum.BackEnd);
                 var installer           = new Domain.BackEnd.Installer(Domain.PathManager.GetRolloutDirectoryPath(DTO.Enums.BackEndOrFrontEndEnum.BackEnd), accessPath);
                 BackgroundWorker worker = new BackgroundWorker();
                 worker.ProgressChanged      += updateValue;
                 worker.RunWorkerCompleted   += worker_RunWorkerCompleted;
                 worker.WorkerReportsProgress = true;
                 installer.TryFixBrokenBackEnd(ref worker);
                 this.ReconstructionPB.Visibility = System.Windows.Visibility.Visible;
             }
             else
             {
                 launchInstaller();
             }
         }
         //If the backend settings file does not exist, the installer window will open and the main window will not actually open.
         else
         {
             launchInstaller();
         }
     }
     //As long as everything is installed correctly, the mainwindow will launch.
     else
     {
         backEndIsInstalled();
     }
 }
Exemplo n.º 10
0
 //This method will return a DTO.RolloutInfo out of this class's properties, adding a date stamp of now.
 private DTO.RolloutInfo makeRolloutInfo(string zipPath)
 {
     return(new DTO.RolloutInfo()
     {
         UserType = this.UserType,
         LaunchFile = this.LaunchFileName,
         RolloutDirectory = this.RollOutDirectoryPath,
         ZipPath = zipPath,
         DateTimeStamp = DateTime.Now,
         RolloutVersionNumber = this.VersionNumber,
         Connection = new DTO.RolloutInfo.ConnectionInfo()
         {
             ConnectionString = GetDataFromXml.GetCurrentConnectionString(DTO.Enums.BackEndOrFrontEndEnum.BackEnd),
             DateSet = DateTime.Now
         }
     });
 }
Exemplo n.º 11
0
        public void Execute()
        {
            //1. Get Installer directory;
            this._installerFilesDirectory = PathManager.GetInstallerFilesDirectory(DTO.Enums.BackEndOrFrontEndEnum.BackEnd);
            //2. Get current launcher version
            this._newLauncherVersion = GetDataFromXml.GetCurrentLauncherVersion(this._installerFilesDirectory) + 1;

            //3. Archive existing files
            archiveExistingFiles();
            //4. Copy each file in the filelist to the installer directory
            copyFiles();
            //5. Compare the file list with the current manifest
            compareWithManifest();

            //6. Update launcher version in backend.xml
            UpdateXmlFile.SetLauncherVersion(this._newLauncherVersion, this._installerFilesDirectory);
        }
Exemplo n.º 12
0
 public static void RollBackVersionNumber(int versionToRollTo, DTO.Enums.UserTypeEnum userType)
 {
     try
     {
         //This will attempt to roll back to the specified version number.
         UpdateXmlFile.RollBackToVersionNumber(versionToRollTo, userType);
     }
     catch (Exception)
     {
         //IF an exception is raised, it will delete the current backend.xml and then repair the back end, restoring it
         //to what it was before the rollback attempt. then it will throw a CouldNotRollBackException.
         var pathToAccess = GetDataFromXml.GetAccessPathFromCurrentConnectionString(DTO.Enums.BackEndOrFrontEndEnum.BackEnd);
         File.Delete(PathManager.GetBackEndXmlPath(DTO.Enums.BackEndOrFrontEndEnum.BackEnd));
         var installer = new Installer(PathManager.GetRolloutDirectoryPath(DTO.Enums.BackEndOrFrontEndEnum.BackEnd), pathToAccess);
         installer.TryFixBrokenBackEnd();
         throw new DTO.Exceptions.CouldNotRollBackException();
     }
 }
Exemplo n.º 13
0
        //This will lock the console window from being closed and notify the user Access is running.
        //It will also change the console color to blue... for funzies.
        private void disableConsoleClose()
        {
            Console.BackgroundColor = ConsoleColor.DarkBlue;
            Console.ForegroundColor = ConsoleColor.White;
            Console.Title           = "P&B Database Launcher - This window must stay open.";
            IntPtr hMenu       = Process.GetCurrentProcess().MainWindowHandle;
            IntPtr hSystemMenu = GetSystemMenu(hMenu, false);

            EnableMenuItem(hSystemMenu, SC_CLOSE, MF_GRAYED);
            RemoveMenu(hSystemMenu, SC_CLOSE, MF_BYCOMMAND);
            Console.Clear();
            Console.WriteLine("The P&B Access Database is now running. Please leave this window open. \n");
            Console.WriteLine("Current user: {0} \nCurrent UserType: {1} \nCurrent RolloutVersion: {2} \nCurrent Launcher Version {3}",
                              _user.Name,
                              _user.UserType,
                              GetDataFromXml.GetFrontEndSettings().RolloutVersionString,
                              GetInfo.GetCurrentLauncherVersion());
            MinimizeConsoleWindow(hMenu);
        }
Exemplo n.º 14
0
        private void reconstructBackEndFromRolloutsFolder()
        {
            //1. Create back end xml file to be updated.
            CreateXmlFile.CreateBackEndXmlFileInRolloutDirectory();
            var directory = new DirectoryInfo(this.RollOutDirectory + "Rollouts\\");

            //2. Loop through the zipped files in the rollouts folder
            foreach (var file in directory.EnumerateFiles("FE-*.zip"))
            {
                //For each file, read the file into a ZipArchive object
                ZipArchive zipfile = ZipFile.OpenRead(file.FullName);
                //Find the only .xml file in the zip file and extract it to the reconstruction path.
                zipfile.Entries.FirstOrDefault(p => p.Name.Contains(".xml")).ExtractToFile(this.ReconstructionPath, true);
                //Release the object reference in memory to the zip file.
                zipfile.Dispose();
                //Create a rolloutInfo file (which is plain object with only properties and not methods) out of
                //the newly extracted xml file.
                DTO.RolloutInfo rollout = GetDataFromXml.GetReconstructedInfo(this.ReconstructionPath);
                //Add a rollout record with the info in the rollout record.
                UpdateXmlFile.AddRolloutRecord(rollout);
            }
        }
Exemplo n.º 15
0
 private static void updateFrontEndXML(DTO.Enums.UserTypeEnum userType)
 {
     DTO.RolloutInfo rollout = GetDataFromXml.GetLatestRollout(userType, DTO.Enums.BackEndOrFrontEndEnum.FrontEnd);
     UpdateXmlFile.UpdateFrontEndXml(rollout);
 }
Exemplo n.º 16
0
        public static int GetCurrentLauncherVersion()
        {
            string installerDirectory = Directory.GetCurrentDirectory() + "\\";

            return(GetDataFromXml.GetCurrentLauncherVersion(installerDirectory));
        }
Exemplo n.º 17
0
 private static void extractZipFile(DTO.Enums.UserTypeEnum userType)
 {
     ZipFile.ExtractToDirectory(GetDataFromXml.GetLatestRollout(userType, DTO.Enums.BackEndOrFrontEndEnum.FrontEnd).ZipPath,
                                GetInfo.GetAppDataPath() + "\\Access Files\\");
 }
Exemplo n.º 18
0
 //This obtains the filepath of the specific file the launcher will open.
 public static string GetLaunchFilePath()
 {
     return(GetAppDataPath() + "\\Access Files\\" + GetDataFromXml.GetLaunchFileName());
 }
Exemplo n.º 19
0
 //This will return true or false depending on whether a global lockout is currently enabled.
 public static bool LockoutIsEnabled()
 {
     return(GetDataFromXml.LockoutIsEnabled(DTO.Enums.BackEndOrFrontEndEnum.FrontEnd));
 }
Exemplo n.º 20
0
 //This will obtain the current launcher version as it is presently pushed out by the Back End manager.
 public static int GetCurrentLauncherVersion()
 {
     return(GetDataFromXml.GetCurrentLauncherVersion(PathManager.GetInstallerFilesDirectory(DTO.Enums.BackEndOrFrontEndEnum.FrontEnd)));
 }
Exemplo n.º 21
0
 //This obtains the current version number for the launcher installed on the user's local computer.
 public static int GetFrontEndLauncherVersion()
 {
     return(GetDataFromXml.GetFrontEndLauncherVersion());
 }