コード例 #1
0
        /// <summary>
        /// Handles the Click event of the Next control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param>
        private void Next_Click(object sender, RoutedEventArgs e)
        {
            bool membershipCodeValid = ValidateMembershipCode(MembershipTextBox.Text);

            if (membershipCodeValid)
            {
                User user = BaseController.LoggedOnUser;
                try
                {
                    bool isAddBetteryMemberSuccess;
                    using (KioskServiceClient proxy = new KioskServiceClient())
                    {
                        isAddBetteryMemberSuccess = proxy.AddBetteryMember(user.FirstName, user.LastName, user.Email, user.Password, user.Zipcode.ToString(CultureInfo.CurrentCulture), user.IsEmailSubscription, user.SubscriptionPlan);
                    }

                    if (isAddBetteryMemberSuccess)
                    {
                        Start page = new Start();
                        this.NavigationService.Navigate(page);
                    }
                }
                catch (Exception ex)
                {
                    // TODO: log error message
                }
            }
        }
コード例 #2
0
        private void SigninButton_Click(object sender, RoutedEventArgs e)
        {
            BetteryBusyIndicator.IsBusy = true;

            MessageText.Text = string.Empty;

            _worker.RunWorkerAsync();

            try
            {
                KioskServiceClient BKioskService = new KioskServiceClient();
                BetteryMember      betteryMember = BKioskService.AuthenticateUser(UserName.Text, Password.Password);
                // TODO: Persist Logged-in Member data for use during checkout, etc.

                BaseController.LoggedOnUser = new User(UserName.Text, Password.Password)
                {
                    BatteriesCheckedOut = betteryMember.BatteriesCheckedOut,
                    BatteriesInPlan     = betteryMember.BatteriesInPlan,
                    CustomerProfileID   = betteryMember.CustomerProfileID,
                    FirstName           = betteryMember.MemberFirstName,
                    MemberID            = betteryMember.MemberID,
                    LastName            = betteryMember.MemberLastName,
                    OutstandingCredit   = betteryMember.OutstandingCredit,
                };

                this.NavigationService.GoBack();
            }
            catch (Exception)
            {
                BaseController.LoggedOnUser = null;
            }
        }
コード例 #3
0
        /// <summary>
        /// Saves the registration user.
        /// </summary>
        /// <returns>Save registration user of state</returns>
        public static bool?SaveRegistrationUser()
        {
            bool?isSuccess = true;

            BetteryUser user = BaseController.RegistrationUser;

            using (KioskServiceClient client = new KioskServiceClient())
            {
                try
                {
                    string    Hash;
                    string    Salt;
                    HashUtils hashUtils = new HashUtils();
                    hashUtils.GetHashAndSaltString(user.Password, out Hash, out Salt);
                    user.PasswordDigest = Hash + Salt;
                    isSuccess           = client.AddBetteryMember(user.MemberFirstName, user.MemberLastName, user.Email, user.PasswordDigest, user.ZipCode, user.GetEmails, 0);
                }
                catch (Exception ex)
                {
                    Logger.Log(EventLogEntryType.Error, ex, BaseController.StationId);
                    BaseController.RaiseOnThrowExceptionEvent();
                    isSuccess = null;
                }
                finally
                {
                    client.Close();
                }
            }

            return(isSuccess);
        }
コード例 #4
0
 /// <summary>
 /// Authorizes the dot net alert.
 /// </summary>
 /// <param name="authorizeException">The authorize exception.</param>
 public static void AuthorizeDotNetAlert(Exception authorizeException)
 {
     try
     {
         using (KioskServiceClient bKioskService = new KioskServiceClient())
         {
             bKioskService.AuthorizeDotNetAlert(BaseController.StationId, authorizeException.Message);
             bKioskService.Close();
         }
     }
     catch (Exception ex)
     {
         Logger.Log(EventLogEntryType.Error, ex, BaseController.StationId);
     }
 }
コード例 #5
0
 /// <summary>
 /// Updates the membership profile.
 /// </summary>
 /// <param name="MemberID">The member ID.</param>
 /// <param name="CustomerProfileID">The customer profile ID.</param>
 /// <param name="PaymentProfileID">The payment profile ID.</param>
 public static void UpdateMembershipProfile(int MemberID, string CustomerProfileID, string PaymentProfileID)
 {
     using (KioskServiceClient client = new KioskServiceClient())
     {
         try
         {
             client.UpdateProfile(MemberID, CustomerProfileID, PaymentProfileID);
         }
         catch (Exception ex)
         {
             throw new KioskException(ex.Message, ex);
         }
         finally
         {
             client.Close();
         }
     }
 }
コード例 #6
0
        /// <summary>
        /// Transactions the failure alert.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <returns></returns>
        public static bool TransactionFailureAlert(string message)
        {
            bool result = false;

            try
            {
                using (KioskServiceClient bKioskService = new KioskServiceClient())
                {
                    bKioskService.TransactionFailureAlert(BaseController.StationId, message);
                    bKioskService.Close();
                }
            }
            catch (Exception ex)
            {
                Logger.Log(EventLogEntryType.Error, ex, BaseController.StationId);
            }

            return(result);
        }
コード例 #7
0
        /// <summary>
        /// Pings the service.
        /// </summary>
        /// <returns></returns>
        public static bool PingService()
        {
            bool result = false;

            try
            {
                using (KioskServiceClient bKioskService = new KioskServiceClient())
                {
                    result = bKioskService.KioskPing();
                    bKioskService.Close();
                }
            }
            catch (Exception ex)
            {
                Logger.Log(EventLogEntryType.Error, ex, BaseController.StationId);
                result = false;
            }

            return(result);
        }
コード例 #8
0
 /// <summary>
 /// Updates the membership profile.
 /// </summary>
 /// <param name="MemberID">The member ID.</param>
 /// <param name="CustomerProfileID">The customer profile ID.</param>
 /// <param name="PaymentProfileID">The payment profile ID.</param>
 /// <param name="BatteriesInPlan">The batteries in plan.</param>
 /// <param name="newAccountBalance">The new account balance.</param>
 /// <param name="raiseEvent">if set to <c>true</c> [raise event].</param>
 /// <param name="isUpgrade">if set to <c>true</c> [is upgrade].</param>
 public static void UpdateMembershipProfile(int MemberID, string CustomerProfileID, string PaymentProfileID, int BatteriesInPlan, decimal newAccountBalance, bool raiseEvent, bool isUpgrade)
 {
     using (KioskServiceClient client = new KioskServiceClient())
     {
         try
         {
             client.UpdateMembership(MemberID, CustomerProfileID, PaymentProfileID, BatteriesInPlan, newAccountBalance, isUpgrade);
         }
         catch (Exception ex)
         {
             if (raiseEvent)
             {
                 throw new KioskException(ex.Message, ex);
             }
         }
         finally
         {
             client.Close();
         }
     }
 }
コード例 #9
0
        /// <summary>
        /// Checks the email.
        /// </summary>
        /// <param name="email">The email.</param>
        /// <returns>Is Valid Email</returns>
        public static bool CheckEmail(string email)
        {
            bool isSuccess;

            using (KioskServiceClient client = new KioskServiceClient())
            {
                try
                {
                    isSuccess = !client.CheckEmail(email);
                }
                catch (Exception ex)
                {
                    Logger.Log(EventLogEntryType.Error, ex, BaseController.StationId);
                    BaseController.RaiseOnThrowExceptionEvent();
                    isSuccess = false;
                }
                finally
                {
                    client.Close();
                }
            }

            return(isSuccess);
        }
コード例 #10
0
        /// <summary>
        /// Vends the empty case.
        /// </summary>
        /// <param name="totalEmptyCases">The total empty cases.</param>
        public static void VendEmptyCase(int totalEmptyCases)
        {
            var  totalBins        = BaseDAL.GetTotalQuantitybyProduct(ProductTypes.Cartridge);
            bool isVendBinSuccess = false;

            int vendedFreeCases = 0;

            if (totalBins > 0)
            {
                VendEventArgs vendEventArgs = new VendEventArgs(totalEmptyCases);

                try
                {
                    List <BinProduct> cartridgeBins = BaseDAL.GetBinsbyProduct(ProductTypes.Cartridge);
                    foreach (BinProduct bin in cartridgeBins)
                    {
                        if (totalEmptyCases == 0)
                        {
                            break;
                        }

                        if (bin.Quantity > 0)
                        {
                            BinProduct decrementBin = new BinProduct {
                                BinId = bin.BinId, Quantity = 0
                            };

                            for (int i = 0; i < bin.Quantity; i++)
                            {
                                if (totalEmptyCases == 0)
                                {
                                    break;
                                }

                                isVendBinSuccess = BaseController.SendCommandToSerialPort(bin.BinId);

                                if (isVendBinSuccess)
                                {
                                    totalEmptyCases--;
                                    vendedFreeCases++;
                                    decrementBin.Quantity++;
                                    if (OnVending != null)
                                    {
                                        vendEventArgs.VendedEmptyCases = vendedFreeCases;
                                        OnVendingCase.Invoke(vendEventArgs);
                                    }
                                }
                                else
                                {
                                    BaseDAL.DisableBin(bin.BinId);
                                    AlertController.TransactionFailureAlert("Bin " + bin.BinId.ToString() + " Disabled");
                                    // Don't continue iterating through bin
                                    break;
                                }
                            }

                            if (isVendBinSuccess && decrementBin.Quantity > 0)
                            {
                                BaseDAL.DecrementBinInventory(decrementBin);
                            }
                            isVendBinSuccess = false;
                        }
                    }

                    using (KioskServiceClient proxy = new KioskServiceClient())
                    {
                        //  Update the members remaining free cases.
                        proxy.EmptyCaseVend(BaseController.LoggedOnUser.MemberId, vendedFreeCases);
                        proxy.Close();
                    }
                }
                catch (Exception ex)
                {
                    Logger.Log(EventLogEntryType.Error, ex, BaseController.StationId);
                    AlertController.TransactionFailureAlert(ex.Message);
                    BaseController.RaiseOnThrowExceptionEvent();
                }
            }
        }
コード例 #11
0
        /// <summary>
        /// Gets the promotional amount.
        /// </summary>
        /// <param name="promotionalCode">The promotional code.</param>
        /// <returns></returns>
        public static decimal?GetPromotionalAmount(string promotionalCode, out string invalidReason)
        {
            decimal?promoCredit = null;
            Promo   promo       = new Promo();

            invalidReason = String.Empty;

            using (KioskServiceClient proxy = new KioskServiceClient())
            {
                try
                {
                    promo = proxy.GetPromoCredit(promotionalCode);
                    switch (promo.PromoType)
                    {
                    case Bettery.Kiosk.Common.Constants.PromotionType.Purchase:
                        if ((BaseController.SelectedBettery.AaVend + BaseController.SelectedBettery.AaaVend) > BaseController.SelectedBettery.AaReturn)
                        {
                            return(promo.Amount);
                        }
                        else
                        {
                            invalidReason = Constants.Messages.InvalidNewPurchasePromotionCode;
                            return(0M);
                        }

                    case Bettery.Kiosk.Common.Constants.PromotionType.Swap:
                        if ((BaseController.SelectedBettery.AaVend > 0 && BaseController.SelectedBettery.AaReturn > 0) || (BaseController.SelectedBettery.AaaVend > 0 && BaseController.SelectedBettery.AaReturn > 0))
                        {
                            return(promo.Amount);
                        }
                        else
                        {
                            invalidReason = Constants.Messages.InvalidSwapPromotionCode;
                            return(0M);
                        }

                    case Bettery.Kiosk.Common.Constants.PromotionType.SwapAndPurchase:
                        if ((BaseController.SelectedBettery.AaVend > 0) || (BaseController.SelectedBettery.AaaVend > 0))
                        {
                            return(promo.Amount);
                        }
                        else
                        {
                            return(0M);
                        }

                    default:
                        return(0M);
                    }
                }
                catch (Exception ex)
                {
                    Logger.Log(EventLogEntryType.Error, ex, BaseController.StationId);
                    BaseController.RaiseOnThrowExceptionEvent();
                }
                finally
                {
                    proxy.Close();
                }
            }

            return(promoCredit);
        }
コード例 #12
0
        /// <summary>
        /// Authenticates the user.
        /// </summary>
        /// <param name="userName">Name of the user.</param>
        /// <param name="password">The password.</param>
        /// <returns></returns>
        public static bool?AuthenticateUser(string userName, string password)
        {
            BetteryMember betteryMember;

            using (KioskServiceClient bKioskService = new KioskServiceClient())
            {
                try
                {
                    betteryMember = bKioskService.AuthenticateUser(userName, password);
                }
                catch (Exception ex)
                {
                    Logger.Log(EventLogEntryType.Error, ex, BaseController.StationId);
                    BaseController.RaiseOnThrowExceptionEvent();

                    return(null);
                }
                finally
                {
                    bKioskService.Close();
                }
            }

            if (betteryMember != null)
            {
                BaseController.LoggedOnUser = new BetteryUser(userName, password)
                {
                    BatteriesCheckedOut = betteryMember.BatteryPacksCheckedOut,
                    BatteriesInPlan     = betteryMember.BatteryPacksInPlan,
                    CustomerProfileId   = betteryMember.CustomerProfileID,
                    PaymentProfileId    = betteryMember.PaymentProfileID,
                    FreeCasesRemaining  = betteryMember.FreeCases,
                    Email                  = userName,
                    MemberFirstName        = betteryMember.MemberFirstName,
                    MemberId               = betteryMember.MemberID,
                    MemberLastName         = betteryMember.MemberLastName,
                    MemberTotalBatteries   = betteryMember.MemberTotalBatteries,
                    OutstandingCredit      = betteryMember.AccountBalance,
                    CCOnFileExPireDate     = betteryMember.CCExPireDate,
                    CCOnFileLastFourDigits = betteryMember.CCLastFourDigits,
                    GroupID                = betteryMember.GroupID
                };

                BaseController.LoggedOnUser.NewBatteriesInPlan = BaseController.LoggedOnUser.BatteriesInPlan;

                if (OnLogin != null)
                {
                    //Reset selection amount
                    if (BaseController.LoggedOnUser.BatteriesInPlan > 0)
                    {
                        if (BaseController.SelectedBettery != null)
                        {
                            BaseController.CalcCharges(0, 0, BaseController.GetBatteriesMode);

                            if (BaseController.RecentViewOfCurrentFlow == Constants.ViewName.Checkout || BaseController.RecentViewOfCurrentFlow == Constants.ViewName.TransactionSummary || BaseController.RecentViewOfCurrentFlow == Constants.ViewName.CreditSwap)
                            {
                                if (BaseController.SelectedBettery.ReturnedCartridges > 0)
                                {
                                    BaseController.RecentViewOfCurrentFlow = Constants.ViewName.GetBatteries;
                                }
                                else
                                {
                                    BaseController.RecentViewOfCurrentFlow = Constants.ViewName.Selection;
                                }
                            }
                        }
                    }

                    OnLogin.Invoke(null, EventArgs.Empty);
                }

                return(true);
            }

            return(false);
        }
コード例 #13
0
ファイル: Login.xaml.cs プロジェクト: paulmposton/68818072
 private void LoginButton_Click(object sender, RoutedEventArgs e)
 {
     KioskServiceClient BKiosk = new KioskServiceClient();
     //bool authed = BKiosk.AuthenticateUser(UserName.Text, Password.Text);
 }