private void ResetCredentialsInDBToDefaults(ParcelService Service)
        {
            var CurrentDBList = DBContext.Credentials.ToList();

            foreach (CredentialData credentials in CurrentDBList)
            {
                if (Service == ParcelService.FedEx)
                {
                    var DefaultCredentials = new FedExCredentialsData();

                    credentials.FedExCredentials.UserKey       = DefaultCredentials.UserKey;
                    credentials.FedExCredentials.UserPassword  = DefaultCredentials.UserPassword;
                    credentials.FedExCredentials.AccountNumber = DefaultCredentials.AccountNumber;
                    credentials.FedExCredentials.MeterNumber   = DefaultCredentials.MeterNumber;
                }

                if (Service == ParcelService.UPS)
                {
                    var DefaultCredentials = new UPSCredentialsData();

                    credentials.UPSCredentials.Username            = DefaultCredentials.Username;
                    credentials.UPSCredentials.Password            = DefaultCredentials.Password;
                    credentials.UPSCredentials.AccessLicenseNumber = DefaultCredentials.AccessLicenseNumber;
                }

                if (Service == ParcelService.USPS)
                {
                    var DefaultCredentials = new USPSCredentialsData();

                    credentials.POSTALCredentials.UserID = DefaultCredentials.UserID;
                }
            }

            DBContext.SaveChanges();
        }
Esempio n. 2
0
 public void UpdateCredentialInformation(USPSCredentialsData NewUSPSData)
 {
     if (!String.IsNullOrWhiteSpace(NewUSPSData.UserID))
     {
         USPS.UserID = NewUSPSData.UserID;
     }
 }
        private void RetrieveCredentialsOnLoad()
        {
            var CurrentDBList = DBContext.Credentials.ToList();

            foreach (CredentialData credentials in CurrentDBList)
            {
                FedExCredentialsData NewFedExData = new FedExCredentialsData();
                NewFedExData.UserKey       = (B64Decode(credentials.FedExCredentials.UserKey));
                NewFedExData.UserPassword  = (B64Decode(credentials.FedExCredentials.UserPassword));
                NewFedExData.AccountNumber = (B64Decode(credentials.FedExCredentials.AccountNumber));
                NewFedExData.MeterNumber   = (B64Decode(credentials.FedExCredentials.MeterNumber));

                TrackingServiceControl.UpdateCredentialInformation(NewFedExData);

                UPSCredentialsData NewUPSData = new UPSCredentialsData();
                NewUPSData.Username            = (B64Decode(credentials.UPSCredentials.Username));
                NewUPSData.Password            = (B64Decode(credentials.UPSCredentials.Password));
                NewUPSData.AccessLicenseNumber = (B64Decode(credentials.UPSCredentials.AccessLicenseNumber));

                TrackingServiceControl.UpdateCredentialInformation(NewUPSData);

                USPSCredentialsData NewUSPSData = new USPSCredentialsData();
                NewUSPSData.UserID = (B64Decode(credentials.POSTALCredentials.UserID));

                TrackingServiceControl.UpdateCredentialInformation(NewUSPSData);
            }
        }
        private void StoreAndUpdateCredentials(USPSCredentialsData NewUSPSData)
        {
            var CurrentDBList = DBContext.Credentials.ToList();

            foreach (CredentialData credentials in CurrentDBList)
            {
                credentials.POSTALCredentials.UserID = B64Encode(NewUSPSData.UserID);
            }

            DBContext.SaveChanges();
        }
        private void UpdateUSPSAccount_Click(object sender, RoutedEventArgs e)
        {
            //show progress bar
            Progress.Visibility = System.Windows.Visibility.Visible;

            if (UpdateUSPSToDefaults_CheckBox.IsChecked == false)
            {
                var NewUSPSData = new USPSCredentialsData();

                //Populate object with updated values
                NewUSPSData.UserID = USPSUserID.Text;

                //Send new information to UPSManager via TrackingControl
                TrackingServiceControl.UpdateCredentialInformation(NewUSPSData);

                //Update the database with the new credentials
                StoreAndUpdateCredentials(NewUSPSData);

                //blank entry fields
                USPSUserID.Text = "";
            }
            else
            {
                //Trigger a reset to defaults in memory
                TrackingServiceControl.ResetCredentialsToDefaults(ParcelService.USPS);

                //Trigger a reset to defaults in database
                ResetCredentialsInDBToDefaults(ParcelService.USPS);

                //Blank fields on reset to defaults, uncheck box
                USPSUserID.Text = "";
                UpdateUSPSToDefaults_CheckBox.IsChecked = true;
            }

            USPSCredentialEntry_PopUp.IsOpen = false;
            ProgressBarVisibilityDelay();
        }
 public void UpdateCredentialInformation(USPSCredentialsData NewUSPSData)
 {
     if (!String.IsNullOrWhiteSpace(NewUSPSData.UserID))
     {
         USPS.UserID = NewUSPSData.UserID;
     }
 }
        private void UpdateUSPSAccount_Click(object sender, RoutedEventArgs e)
        {
            //show progress bar
            Progress.Visibility = System.Windows.Visibility.Visible;

            if (UpdateUSPSToDefaults_CheckBox.IsChecked == false)
            {
                var NewUSPSData = new USPSCredentialsData();

                //Populate object with updated values
                NewUSPSData.UserID = USPSUserID.Text;

                //Send new information to UPSManager via TrackingControl
                TrackingServiceControl.UpdateCredentialInformation(NewUSPSData);

                //Update the database with the new credentials
                StoreAndUpdateCredentials(NewUSPSData);

                //blank entry fields
                USPSUserID.Text = "";
            }
            else
            {
                //Trigger a reset to defaults in memory
                TrackingServiceControl.ResetCredentialsToDefaults(ParcelService.USPS);

                //Trigger a reset to defaults in database
                ResetCredentialsInDBToDefaults(ParcelService.USPS);

                //Blank fields on reset to defaults, uncheck box
                USPSUserID.Text = "";
                UpdateUSPSToDefaults_CheckBox.IsChecked = true;
            }

            USPSCredentialEntry_PopUp.IsOpen = false;
            ProgressBarVisibilityDelay();
        }
        private void ResetCredentialsInDBToDefaults(ParcelService Service)
        {
            var CurrentDBList = DBContext.Credentials.ToList();

            foreach (CredentialData credentials in CurrentDBList)
            {
                if (Service == ParcelService.FedEx)
                {
                    var DefaultCredentials = new FedExCredentialsData();

                    credentials.FedExCredentials.UserKey = DefaultCredentials.UserKey;
                    credentials.FedExCredentials.UserPassword = DefaultCredentials.UserPassword;
                    credentials.FedExCredentials.AccountNumber = DefaultCredentials.AccountNumber;
                    credentials.FedExCredentials.MeterNumber = DefaultCredentials.MeterNumber;
                }

                if (Service == ParcelService.UPS)
                {
                    var DefaultCredentials = new UPSCredentialsData();

                    credentials.UPSCredentials.Username = DefaultCredentials.Username;
                    credentials.UPSCredentials.Password = DefaultCredentials.Password;
                    credentials.UPSCredentials.AccessLicenseNumber = DefaultCredentials.AccessLicenseNumber;
                }

                if (Service == ParcelService.USPS)
                {
                    var DefaultCredentials = new USPSCredentialsData();

                    credentials.POSTALCredentials.UserID = DefaultCredentials.UserID;
                }
            }

            DBContext.SaveChanges();
        }
        private void RetrieveCredentialsOnLoad()
        {
            var CurrentDBList = DBContext.Credentials.ToList();

            foreach (CredentialData credentials in CurrentDBList)
            {
                FedExCredentialsData NewFedExData = new FedExCredentialsData();
                NewFedExData.UserKey = (B64Decode(credentials.FedExCredentials.UserKey));
                NewFedExData.UserPassword = (B64Decode(credentials.FedExCredentials.UserPassword));
                NewFedExData.AccountNumber = (B64Decode(credentials.FedExCredentials.AccountNumber));
                NewFedExData.MeterNumber = (B64Decode(credentials.FedExCredentials.MeterNumber));

                TrackingServiceControl.UpdateCredentialInformation(NewFedExData);

                UPSCredentialsData NewUPSData = new UPSCredentialsData();
                NewUPSData.Username = (B64Decode(credentials.UPSCredentials.Username));
                NewUPSData.Password = (B64Decode(credentials.UPSCredentials.Password));
                NewUPSData.AccessLicenseNumber = (B64Decode(credentials.UPSCredentials.AccessLicenseNumber));

                TrackingServiceControl.UpdateCredentialInformation(NewUPSData);

                USPSCredentialsData NewUSPSData = new USPSCredentialsData();
                NewUSPSData.UserID = (B64Decode(credentials.POSTALCredentials.UserID));

                TrackingServiceControl.UpdateCredentialInformation(NewUSPSData);
            }
        }
        private void StoreAndUpdateCredentials(USPSCredentialsData NewUSPSData)
        {
            var CurrentDBList = DBContext.Credentials.ToList();

            foreach (CredentialData credentials in CurrentDBList)
            {
                credentials.POSTALCredentials.UserID = B64Encode(NewUSPSData.UserID);
            }

            DBContext.SaveChanges();
        }