// This method gets the list of shops from SP and keeps the text ready to auto complete
        private void PrepareShopTextForAutoComplete()
        {
            string errorCode = null;
            string errorText = null;

            ShopProcedures.ExecuteGetStoreInfoWithShortName(GlobalDataAccessor.Instance.OracleDA,
                                                            out topsShopInfoDict, out clxShopInfoDict, out errorCode, out errorText);
            autoComp = new AutoCompleteStringCollection();

            List <string> keylist = new List <string>(topsShopInfoDict.Keys);

            // Loop through list and add all TOPS stores
            foreach (string key in keylist)
            {
                autoComp.Add(key);
                //Console.WriteLine(key + "," + shopInfoDict[key]);
            }

            // Loop through list and add all Cashlinx stores
            keylist = new List <string>(clxShopInfoDict.Keys);
            foreach (string key in keylist)
            {
                autoComp.Add(key);
            }


            transfer_destination_secondary_txtBox.AutoCompleteCustomSource = autoComp;
            transfer_source_secondary_txtBox.AutoCompleteCustomSource      = autoComp;
        }
示例#2
0
        private void customButtonFind_Click(object sender, EventArgs e)
        {
            if (customTextBoxDestShopNo.isValid)
            {
                //If the shop number entered is valid, call data layer
                //to get the store information
                SiteId storeInfo = new SiteId();

                ShopProcedures.ExecuteGetStoreInfo(GlobalDataAccessor.Instance.OracleDA,
                                                   customTextBoxDestShopNo.Text.ToString(), ref storeInfo, out errorCode, out errorText);
                if (storeInfo != null)
                {
                    destinationStoreDataFound = true;
                    destShopName               = storeInfo.StoreName;
                    labelDestAddr1.Text        = storeInfo.StoreAddress1;
                    labelDestAddr2.Text        = storeInfo.StoreCityName + "," + storeInfo.State + " " + storeInfo.StoreZipCode;
                    labelDestManager.Text      = storeInfo.StoreManager;
                    labelDestPhone.Text        = storeInfo.StorePhoneNo;
                    customButtonSubmit.Enabled = !string.IsNullOrEmpty(storeInfo.StoreName);
                }
            }
            else
            {
                MessageBox.Show(@"Please enter a valid destination shop number");
            }
        }
示例#3
0
 public IActionResult ShopAdd()
 {
     if (HttpContext.Session.GetString("username") == "admin")
     {
         ShopProcedures pro  = new ShopProcedures();
         var            shop = pro.GetShopTypes();
         return(View(shop));
     }
     else
     {
         return(RedirectToAction("login", "authorization"));
     }
 }
示例#4
0
 public IActionResult shopEdit(int ID)
 {
     if (HttpContext.Session.GetString("username") == "admin")
     {
         ShopProcedures shop   = new ShopProcedures();
         var            result = shop.GetShopInfo(ID);
         return(View(result));
     }
     else
     {
         return(RedirectToAction("login", "authorization"));
     }
 }
示例#5
0
 public IActionResult shopPage(int ID = 1)
 {
     if (HttpContext.Session.GetString("username") == "admin")
     {
         ShopProcedures pro  = new ShopProcedures();
         var            shop = pro.GetShopsPage(pro.SelectShop(), ID);
         return(View(shop));
     }
     else
     {
         return(RedirectToAction("login", "authorization"));
     }
 }
        private void LoadWorkstations()
        {
            DataTable CDWorkstationsTable;
            string    errorcode;
            string    errormesg;

            try
            {
                customDataGridViewWorkstations.Rows.Clear();
                bool retval = ShopProcedures.GetAllWorkstations(
                    GlobalDataAccessor.Instance.OracleDA,
                    GlobalDataAccessor.Instance.CurrentSiteId.StoreNumber,
                    out CDWorkstationsTable, out errorcode, out errormesg);
                if (retval && CDWorkstationsTable != null && CDWorkstationsTable.Rows.Count > 0)
                {
                    workstationRowCount = CDWorkstationsTable.Rows.Count;
                    foreach (DataRow dgvr in CDWorkstationsTable.Rows)
                    {
                        string shopNumber = dgvr.ItemArray[2].ToString();
                        string name       = dgvr.ItemArray[1].ToString();
                        string status     = dgvr.ItemArray[3].ToString();


                        DataGridViewTextBoxCell shopcell   = new DataGridViewTextBoxCell();
                        DataGridViewTextBoxCell statuscell = new DataGridViewTextBoxCell();
                        DataGridViewTextBoxCell namecell   = new DataGridViewTextBoxCell();
                        shopcell.Value   = shopNumber;
                        namecell.Value   = name;
                        statuscell.Value = status;

                        namecell.MaxInputLength  = 100;
                        namecell.Style.Alignment = DataGridViewContentAlignment.MiddleLeft;

                        DataGridViewRow dgRow;
                        using (dgRow = new DataGridViewRow())
                        {
                            dgRow.Cells.Insert(0, namecell);
                            dgRow.Cells.Insert(1, statuscell);
                            dgRow.Cells.Insert(2, shopcell);
                            customDataGridViewWorkstations.Rows.Add(dgRow);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                BasicExceptionHandler.Instance.AddException("Error trying to load workstations", new ApplicationException(ex.Message));
                Close();
            }
        }
 private void LoadStoreData(string storeNumber)
 {
     try
     {
         //data table to load store info
         string sErrorCode;
         string sErrorMessage;
         ShopProcedures.ExecuteGetStoreInfo(this.OracleDA, storeNumber, ref currentSiteId,
                                            out sErrorCode, out sErrorMessage);
     }
     catch (Exception ex)
     {
         BasicExceptionHandler.Instance.AddException(
             "LoadStoreData failed",
             new ApplicationException("Load store data failed", ex));
     }
 }
示例#8
0
        public IActionResult shopEdit(int ID, string name, string address, string Type)
        {
            try
            {
                if (HttpContext.Session.GetString("username") == "admin")
                {
                    ShopProcedures shop = new ShopProcedures();
                    shop.ShopUpdate(ID, name, address, Type);

                    return(RedirectToAction("shoppage", "Shop"));
                }
                else
                {
                    return(RedirectToAction("login", "authorization"));
                }
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Error", "Home"));
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        private bool retrieveCashDrawerDetails()
        {
            DesktopSession cds = GlobalDataAccessor.Instance.DesktopSession;

            this.cashDrawers = new List <CashDrawerVO>();
            string    storeNumber = cds.CurrentSiteId.StoreNumber;
            DataTable storeCashDrawerList;
            DataTable availCashDrawerUsersList;
            DataTable assignCashDrawerUsersList;
            DataTable auxCashDrawerUsersList;
            string    errorCode;
            string    errorText;

            if (!ShopProcedures.ExecuteGetCashDrawerDetails(
                    GlobalDataAccessor.Instance.OracleDA,
                    storeNumber,
                    out storeCashDrawerList,
                    out availCashDrawerUsersList,
                    out assignCashDrawerUsersList,
                    out auxCashDrawerUsersList,
                    out errorCode,
                    out errorText))
            {
                MessageBox.Show("Cannot retrieve cash drawer details for this store");
                return(false);
            }

            //Load cash drawers
            if (storeCashDrawerList != null && storeCashDrawerList.IsInitialized &&
                storeCashDrawerList.Rows != null && storeCashDrawerList.Rows.Count > 0)
            {
                foreach (DataRow dR in storeCashDrawerList.Rows)
                {
                    if (Utilities.GetStringValue(dR["name"]).Contains("SAFE") || Utilities.GetStringValue(dR["name"]).Contains("safe"))
                    {
                        continue;
                    }
                    CashDrawerVO cDrawer = new CashDrawerVO();

                    cDrawer.Id             = Utilities.GetStringValue(dR["id"]);
                    cDrawer.Name           = Utilities.GetStringValue(dR["name"]);
                    cDrawer.OpenFlag       = Utilities.GetStringValue(dR["openflag"]);
                    cDrawer.RegisterUserId = Utilities.GetStringValue(dR["registeruserid"]);
                    cDrawer.NetName        = Utilities.GetStringValue(dR["netname"]);
                    cDrawer.BranchId       = Utilities.GetStringValue(dR["branchid"]);

                    this.cashDrawers.Add(cDrawer);
                }
            }

            //Load available cash drawer users
            this.availableUsers = new List <CashDrawerUserVO>();
            if (availCashDrawerUsersList != null && availCashDrawerUsersList.IsInitialized &&
                availCashDrawerUsersList.Rows != null && availCashDrawerUsersList.Rows.Count > 0)
            {
                foreach (DataRow dR in availCashDrawerUsersList.Rows)
                {
                    CashDrawerUserVO cDrawUsr = getCashDrawerUser(dR);
                    this.availableUsers.Add(cDrawUsr);
                }
            }

            //Load assigned cash drawer users
            if (assignCashDrawerUsersList != null && assignCashDrawerUsersList.IsInitialized &&
                assignCashDrawerUsersList.Rows != null && assignCashDrawerUsersList.Rows.Count > 0)
            {
                foreach (DataRow dR in assignCashDrawerUsersList.Rows)
                {
                    CashDrawerUserVO cDrawUsr = getCashDrawerUser(dR);
                    this.assignedPrimaryUsers.Add(cDrawUsr);
                }
            }


            //Load auxiliary assigned cash drawer users
            if (auxCashDrawerUsersList != null && auxCashDrawerUsersList.IsInitialized &&
                auxCashDrawerUsersList.Rows != null && auxCashDrawerUsersList.Rows.Count > 0)
            {
                foreach (DataRow dR in auxCashDrawerUsersList.Rows)
                {
                    CashDrawerUserVO cDrawUsr = getCashDrawerUser(dR);
                    cDrawUsr.ConnectedId = Utilities.GetStringValue(dR["ccduid"]);
                    cDrawUsr.RegisterId  = Utilities.GetStringValue(dR["cashdrawerid"]);
                    this.assignedAuxiliaryUsers.Add(cDrawUsr);
                }
            }

            //Build user map
            this.buildInitalAssignedUserMap();

            //Load data into shop cash mgmt form
            this.loadDataIntoForm();

            return(true);
        }
        private void insertCashDrawerAssignmentChanges()
        {
            bool          success           = false;
            List <string> successfulUpdates = new List <string>();

            if (pendingChanges)
            {
                var userId          = GlobalDataAccessor.Instance.DesktopSession.FullUserName;
                var transactionDate = ShopDateTime.Instance.ShopDate.ToShortDateString();

                var workStationId = GlobalDataAccessor.Instance.CurrentSiteId.TerminalId;
                if (CollectionUtilities.isEmpty(this.cashDrawers))
                {
                    return;
                }
                foreach (var cvo in this.cashDrawers)
                {
                    var mapping = this.cashDrawerUserMap[cvo];
                    if (mapping == null)
                    {
                        continue;
                    }

                    if (mapping.Left == null)
                    {
                        continue;
                    }
                    //Check if anything changed with this cashdrawer
                    var cvo1      = cvo;
                    var idChanged = (from id in updatedCashDrawerId
                                     where id == cvo1.Id
                                     select id).FirstOrDefault();
                    if (idChanged == null)
                    {
                        continue;
                    }
                    string   primaryUserId = mapping.Left.Id;
                    string[] auxUsers      = null;
                    if (CollectionUtilities.isNotEmpty(mapping.Right))
                    {
                        auxUsers = new string[mapping.Right.Count];
                        int cnt = 0;
                        foreach (var cdUsrVo in mapping.Right)
                        {
                            auxUsers[cnt] = cdUsrVo.Id;
                            cnt++;
                        }
                    }
                    var insRes = DialogResult.Retry;
                    while (insRes == DialogResult.Retry)
                    {
                        string errorCode;
                        string errorText;
                        if (!ShopProcedures.ExecuteUpdateCashDrawerDetails(
                                null, primaryUserId, auxUsers,
                                cvo.Id, cvo.BranchId, workStationId, userId, transactionDate,
                                out errorCode, out errorText))
                        {
                            FileLogger.Instance.logMessage(LogLevel.ERROR, this,
                                                           "ShopProcedures.ExecuteUpdateCashDrawerDetails failed: {0}, {1}", errorCode, errorText);
                            insRes = MessageBox.Show("Could not submit shop cash drawer changes for drawer " + cvo.Name +
                                                     "\nWould you like to retry?",
                                                     "Shop Cash Error Message", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
                        }
                        else
                        {
                            successfulUpdates.Add(cvo.Name);
                            success = true;
                            break;
                        }
                    }
                }
                if (success)
                {
                    StringBuilder cdId = new StringBuilder();
                    foreach (string s in successfulUpdates)
                    {
                        cdId.Append(s + ",");
                    }
                    MessageBox.Show("Cashdrawer assignment was successful for cashdrawers " + cdId);
                }
                else
                if (updatedCashDrawerId.Count > 0)
                {
                    MessageBox.Show("There were errors assigning users to cash drawers");
                }
            }
        }
示例#11
0
        public bool GenerateMCDSlipDocument()
        {
            storeNumber  = GlobalDataAccessor.Instance.CurrentSiteId.StoreNumber;
            reportNumber = "CL-OP-68";
            DataTable checkInfoDetails;
            string    errorCode;
            string    errorText;

            //Get the report data
            ShopProcedures.GetStoreManualCheckDepositData(GlobalDataAccessor.Instance.OracleDA,
                                                          GlobalDataAccessor.Instance.CurrentSiteId.StoreId,
                                                          ShopDateTime.Instance.ShopDate,
                                                          out checkInfoDetails, out errorCode, out errorText);
            if (checkInfoDetails == null || checkInfoDetails.Rows.Count == 0)
            {
                FileLogger.Instance.logMessage(LogLevel.ERROR, this, "No data returned from stored procedure for manual check deposit slips " + errorText);
                return(false);
            }
            //Initialize fonts
            RptFont =
                FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.NORMAL);
            this.HeaderTitleFont =
                new Font(BaseFont.CreateFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1252, BaseFont.NOT_EMBEDDED), 10);

            this.MCDSlipReportTitle =
                @"Check Cash Deposit Slip";

            document = new Document(PageSize.LETTER);
            document.AddTitle(MCDSlipReportTitle);
            PdfPTable table = new PdfPTable(8);

            rptFileName =
                SecurityAccessor.Instance.EncryptConfig.ClientConfig.GlobalConfiguration.BaseLogPath + "\\MCD" + DateTime.Now.ToString("MMddyyyyhhmmssFFFFFFF") + ".pdf";
            PdfWriter     writer = PdfWriter.GetInstance(document, new FileStream(rptFileName, FileMode.Create));
            MCDPageEvents events = new MCDPageEvents();

            writer.PageEvent = events;
            document.SetPageSize(PageSize.LETTER);
            document.SetMargins(0, 0, 10, 45);

            Image image = Image.GetInstance(Properties.Resources.logo, BaseColor.WHITE);

            image.ScalePercent(25);

            //Insert the report header
            InsertReportHeader(table, image);

            document.Open();
            document.Add(table);

            PdfPTable newtable = new PdfPTable(4);

            //Insert the column headers
            InsertColumnHeaders(newtable);
            table.HeaderRows = 7;
            decimal totalCheckAmount = 0;
            int     totalNumChecks   = 0;

            foreach (DataRow dr in checkInfoDetails.Rows)
            {
                string  makerName   = Common.Libraries.Utility.Utilities.GetStringValue(dr["makername"]);
                string  cdName      = Utilities.GetStringValue(dr["username"]);
                decimal chkAmount   = Utilities.GetDecimalValue(dr["checkamount"]);
                string  depositDate = Utilities.GetDateTimeValue(dr["creationdate"]).FormatDate();
                totalNumChecks++;
                totalCheckAmount += chkAmount;
                PdfPCell pCell = new PdfPCell();
                pCell.Colspan             = 1;
                pCell.HorizontalAlignment = Element.ALIGN_JUSTIFIED;
                pCell.Border = Rectangle.NO_BORDER;
                pCell.Phrase = new Phrase(makerName, RptFont);
                newtable.AddCell(pCell);
                pCell.Phrase = new Phrase(cdName, RptFont);
                newtable.AddCell(pCell);
                pCell.Phrase = new Phrase(depositDate, RptFont);
                newtable.AddCell(pCell);
                pCell.Phrase = new Phrase(String.Format("{0:n}", chkAmount), RptFont);
                pCell.HorizontalAlignment = Element.ALIGN_RIGHT;
                newtable.AddCell(pCell);
            }

            //Add a blank line before summary
            newtable.AddCell(generateBlankLine(8));

            //Insert summary table
            PdfPCell newCell = new PdfPCell(new Paragraph("", RptFont));

            newCell.HorizontalAlignment = Element.ALIGN_LEFT;
            newCell.Border  = Rectangle.TOP_BORDER;
            newCell.Colspan = 4;
            newtable.AddCell(newCell);
            newCell.Colspan             = 1;
            newCell.HorizontalAlignment = Element.ALIGN_LEFT;
            newCell.Border = Rectangle.NO_BORDER;
            newCell.Phrase = new Phrase("Count of all Checks", RptFont);
            newtable.AddCell(newCell);
            newCell.Phrase = new Phrase(totalNumChecks.ToString(), RptFont);
            newtable.AddCell(newCell);
            newCell.Phrase = new Phrase("Total Amount of all Checks:", RptFont);
            newtable.AddCell(newCell);
            newCell.Phrase = new Phrase(string.Format("{0:n}", totalCheckAmount), RptFont);
            newCell.HorizontalAlignment = Element.ALIGN_RIGHT;
            newtable.AddCell(newCell);
            newCell = new PdfPCell(new Paragraph("", RptFont));
            newCell.HorizontalAlignment = Element.ALIGN_LEFT;
            newCell.Border  = Rectangle.BOTTOM_BORDER;
            newCell.Colspan = 4;
            newtable.AddCell(newCell);

            document.Add(newtable);

            //Insert report footer
            PdfPTable finalSummaryTable = new PdfPTable(8);

            finalSummaryTable.TotalWidth = 500f;
            InsertReportFooter(ref finalSummaryTable);

            float yAbsolutePosition = newtable.CalculateHeights(true);

            finalSummaryTable.WriteSelectedRows(0, -1, document.LeftMargin + 30, yAbsolutePosition + 30, writer.DirectContent);

            document.Close();

            //Print and save the document
            PrintDocument();

            return(true);
        }
示例#12
0
        public IActionResult shopPage(string ID, string name, string Address, string Type, string name1, string searchComponent)
        {
            try
            {
                if (HttpContext.Session.GetString("username") == "admin")
                {
                    if (name1 != null)
                    {
                        ViewBag.name1 = name1;
                        if (searchComponent == "name")
                        {
                            ShopProcedures shop        = new ShopProcedures();
                            var            shop_result = shop.searchShop(name1, null);

                            ViewBag.searchComponent = "name";


                            return(View(shop_result));
                        }
                        else if (searchComponent == "type")
                        {
                            ShopProcedures shop        = new ShopProcedures();
                            var            shop_result = shop.searchShop(null, null, name1);
                            ViewBag.searchComponent = "type";
                            return(View(shop_result));
                        }
                        else if (searchComponent == "Address")
                        {
                            ShopProcedures shop        = new ShopProcedures();
                            var            shop_result = shop.searchShop(null, name1);
                            ViewBag.searchComponent = "Address";
                            return(View(shop_result));
                        }
                    }


                    if (Convert.ToInt32(ID) != 0)
                    {
                        ShopProcedures shop = new ShopProcedures();
                        shop.ShopRemove(Convert.ToInt32(ID));

                        ShopProcedures selectshop  = new ShopProcedures();
                        var            shop_result = selectshop.GetShopsPage(selectshop.SelectShop(), 1);
                        return(View(shop_result));
                    }
                    else
                    {
                        //string image_url = uploadfile(formFile);
                        ShopProcedures Shop = new ShopProcedures();
                        //product.ProductAdd(name, company, image_url);
                        var shoptype = Shop.GetShopType(Type);
                        Shop.ShopAdd(name, Address, shoptype.Id);

                        ShopProcedures pro      = new ShopProcedures();
                        int            lastpage = (pro.SelectShop().Count() / 5) + 1;
                        var            shop     = pro.GetShopsPage(pro.SelectShop(), lastpage);
                        return(View(shop));
                    }
                }
                else
                {
                    return(RedirectToAction("login", "authorization"));
                }
            }
            catch (Exception ex)
            {
                Response.Redirect("/Home/Error");
                return(View());
            }
        }
        public override void PerformAuthorization()
        {
            if (FileLogger.Instance.IsLogInfo)
            {
                FileLogger.Instance.logMessage(LogLevel.INFO, this, "Performing user authorization...");
            }
            LoggedInUserSecurityProfile = new UserVO();
            this.userState = UserDesktopState.NOTLOGGEDIN;
            //Ensure the LDAP is connected
            if (PawnLDAPAccessor.Instance.State ==
                PawnLDAPAccessor.LDAPState.DISCONNECTED)
            {
                string loginDN;
                string pwdPolicyCN;
                string searchDN;
                string userIdKey;
                string userPwd;

                var conf        = SecurityAccessor.Instance.EncryptConfig;
                var ldapService =
                    conf.GetLDAPService(
                        out loginDN,
                        out searchDN,
                        out userIdKey,
                        out userPwd,
                        out pwdPolicyCN);//,
                //out userName);
                if (FileLogger.Instance.IsLogDebug)
                {
                    FileLogger.Instance.logMessage(LogLevel.DEBUG, this, "- Connecting to LDAP server:{0}{1}",
                                                   System.Environment.NewLine, ldapService);
                }
                PawnLDAPAccessor.Instance.InitializeConnection(
                    conf.DecryptValue(ldapService.Server),
                    conf.DecryptValue(ldapService.Port),
                    loginDN,
                    userPwd,
                    pwdPolicyCN,
                    searchDN,
                    userIdKey);
            }
            var attemptCount = 1;

            do
            {
                bool lockedOut;
                bool needPasswordChange;
                bool wantsPasswordChange;
                var  fullAuth = this.PerformLDAPAuthentication(
                    ref attemptCount,
                    out lockedOut,
                    out needPasswordChange,
                    out wantsPasswordChange);
                if (FileLogger.Instance.IsLogInfo)
                {
                    FileLogger.Instance.logMessage(
                        LogLevel.INFO, this,
                        "Authorization attempt: Count = {0}, IsLockedOut = {1}, NeedsPwdChange = {2}, WantsPwdChange = {3}",
                        attemptCount,
                        lockedOut,
                        needPasswordChange,
                        wantsPasswordChange);
                }
                var    outVal = 0;
                string errCode, errTxt;
                if (!LoginCancel && fullAuth)
                {
                    var retVal = ShopProcedures.ExecuteUpdateSelectUserInfoActivated(
                        username.ToLowerInvariant(), -1, out outVal, out errCode, out errTxt);
                    if (retVal == false || outVal == 0 ||
                        errCode != "0")
                    {
                        MessageBox.Show(
                            "The system has determined that you are not an active user.  " +
                            "Please contact Shop System Support. " +
                            "The application will now exit.",
                            "Application Security",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Stop);
                        try
                        {
                            Application.Exit();
                        }
                        catch
                        {
                            throw new ApplicationException(
                                      "Application has exited due to security violation");
                        }
                        finally
                        {
                            throw new ApplicationException(
                                      "Application has exited due to security violation");
                        }
                    }
                }
                if (!LoginCancel &&
                    fullAuth == false)
                {
                    if (lockedOut)
                    {
                        /*ShopProcedures.ExecuteUpdateSelectUserInfoActivated(
                         *  username.ToLowerInvariant(), 0, out outVal, out errCode, out errTxt);*/
                        MessageBox.Show(
                            "The maximum number of attempted failed logins has been exceeded.  " +
                            "The user account is now locked. " +
                            "Please contact Shop System Support. " +
                            "The application will now exit.",
                            "Application Security",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Stop);
                        try
                        {
                            Application.Exit();
                        }
                        catch
                        {
                            throw new ApplicationException(
                                      "Application has exited due to security violation");
                        }
                        finally
                        {
                            throw new ApplicationException(
                                      "Application has exited due to security violation");
                        }
                    }

                    if (needPasswordChange)
                    {
                        MessageBox.Show(
                            "Your password has expired. " +
                            "The application will now exit.",
                            "Application Security",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Exclamation);
                        try
                        {
                            Application.Exit();
                        }
                        catch
                        {
                            throw new ApplicationException(
                                      "Application has exited due to an expired password");
                        }
                        finally
                        {
                            throw new ApplicationException(
                                      "Application has exited due to an expired password");
                        }
                    }
                }
                if (!LoginCancel && fullAuth == false)
                {
                    this.userState = UserDesktopState.NOTLOGGEDIN;
                    break;
                }
                else
                {
                    break;
                }
            }while (this.userState != UserDesktopState.LOGGEDIN);

            if (!LoginCancel && this.userState == UserDesktopState.LOGGEDIN)
            {
                if (FileLogger.Instance.IsLogInfo)
                {
                    FileLogger.Instance.logMessage(LogLevel.INFO, this, "User {0} successfully authorized", FullUserName);
                }

                //Get role information
                //The logged in user's security profile will be stored in LoggedInUserSecurityProfile object after the call
                string errorCode;
                string errorMesg;
                if (!SecurityProfileProcedures.GetUserSecurityProfile(FullUserName, string.Empty,
                                                                      GlobalDataAccessor.Instance.CurrentSiteId.StoreNumber, "N",
                                                                      this, out errorCode, out errorMesg))
                {
                    BasicExceptionHandler.Instance.AddException(
                        "Security Profile could not be loaded for the logged in user. Cannot Authorize",
                        new ApplicationException());
                    MessageBox.Show(
                        "User's security profile could not be loaded. Exiting the application");
                    Application.Exit();
                }
                else
                {
                    if (FileLogger.Instance.IsLogInfo)
                    {
                        FileLogger.Instance.logMessage(LogLevel.INFO, this, "User {0} security profile retrieved", FullUserName);
                    }
                    //If the logged in user is not an auditor, display an error message and exit the application
                    if (!SecurityProfileProcedures.CanUserViewResource(
                            "AuditAppAccess", this.LoggedInUserSecurityProfile, this))
                    {
                        MessageBox.Show("You do not have sufficient security privileges to utilize this Audit application. Exiting the application");
                        Application.Exit();
                    }
                }

                if (userState == UserDesktopState.LOGGEDIN)
                {
                    //Set the password in the users security profile
                    LoggedInUserSecurityProfile.UserCurrentPassword = password;
                }
            }
        }
        /// <summary>
        /// Initializes common secured machine names and ports from PAWNSEC as well as some common init tasks
        /// - Exception Handler
        /// - Oracle connection
        /// - Couch service
        /// - Database time
        /// - Shop date & time
        /// - Site Id
        /// - Main application logger
        /// - Cashlinx PDA URL
        /// </summary>
        /// <param name="dSession"> </param>
        /// <param name="confRef"></param>
        /// <param name="appName"> </param>
        /// <param name="auditLogEnabled"> </param>
        /// <param name="exceptionHandler"> </param>
        /// <param name="multiConnect"></param>
        /// <param name="keyedConnect"></param>
        /// <param name="key"></param>
        /// <param name="auditLogEnabledChangeHandler"> </param>
        /// <param name="auditLogHandler"> </param>
        public void Init(
            DesktopSession dSession,
            EncryptedConfigContainer confRef,
            string appName,
            AuditLogEnabledChangeHandler auditLogEnabledChangeHandler,
            AuditLogHandler auditLogHandler,
            bool auditLogEnabled,
            Func <bool> exceptionHandler = null,
            bool multiConnect            = false,
            bool keyedConnect            = false,
            string key = null)
        {
            //Get DesktopSession instance
            this.desktopSession = dSession;

            if (this.desktopSession == null)
            {
                throw new ApplicationException("DesktopSession is null! Exiting!");
            }

            //Setup exception handler
            var exHandler = BasicExceptionHandler.Instance;

            exHandler.PrintStackTrace = true;
            if (exceptionHandler != null)
            {
                exHandler.setExceptionCallback(exceptionHandler);
            }
            else
            {
                exHandler.setExceptionCallback(exceptionCallbackMethod);
            }

            //Get client config for DB connection
            var clientConfigDB = confRef.GetOracleDBService();

            this.OracleDA = new OracleDataAccessor(
                confRef.DecryptValue(clientConfigDB.DbUser),
                confRef.DecryptValue(clientConfigDB.DbUserPwd),
                confRef.DecryptValue(clientConfigDB.Server),
                confRef.DecryptValue(clientConfigDB.Port),
                confRef.DecryptValue(clientConfigDB.AuxInfo),
                confRef.DecryptValue(clientConfigDB.Schema),
                (uint)confRef.ClientConfig.StoreConfiguration.FetchSizeMultiplier,
                multiConnect,
                keyedConnect,
                key);

            if (!this.OracleDA.Initialized)
            {
                throw new ApplicationException("Oracle data accessor is not initialized.  Cannot interact with the database. Exiting!");
            }

            //Get client config for Couch connection
            var clientDocDb = confRef.GetCouchDBService();

            if (clientDocDb != null)
            {
                this.CouchDBConnector = new SecuredCouchConnector(
                    confRef.DecryptValue(clientDocDb.Server),
                    confRef.DecryptValue(clientDocDb.Port),
                    DesktopSession.SSL_PORT,
                    confRef.DecryptValue(clientDocDb.Schema),
                    confRef.DecryptValue(clientDocDb.DbUser),
                    confRef.DecryptValue(clientDocDb.DbUserPwd),
                    DesktopSession.SECURE_COUCH_CONN);
            }
            else
            {
                throw new ApplicationException("Cannot initialize secured document server connection! Exiting!");
            }

            //Retrieve database time
            DateTime time;

            ShopProcedures.ExecuteGetDatabaseTime(this.OracleDA, out time);
            this.DatabaseTime = time;

            //Set shop date time
            var storeConf = confRef.ClientConfig.StoreConfiguration;

            ShopDateTime.Instance.setOffsets(0, 0, 0, 0, 0, 0, 0);
            ShopDateTime.Instance.SetDatabaseTime(this.DatabaseTime);
            ShopDateTime.Instance.SetPawnSecOffsetTime(storeConf);

            //Initialize the site
            this.currentSiteId             = new SiteId();
            this.currentSiteId.StoreNumber = confRef.ClientConfig.StoreSite.StoreNumber;

            //Load store information
            LoadStoreData(currentSiteId.StoreNumber);

            //Finalize site info population
            this.currentSiteId.TerminalId    = confRef.ClientConfig.ClientConfiguration.WorkstationId;
            this.currentSiteId.Alias         = confRef.ClientConfig.StoreSite.Alias;
            this.currentSiteId.Company       = confRef.ClientConfig.StoreSite.CompanyNumber;
            this.currentSiteId.CompanyNumber = confRef.ClientConfig.StoreSite.CompanyNumber;
            this.currentSiteId.Date          = ShopDateTime.Instance.ShopDate;
            this.currentSiteId.State         = confRef.ClientConfig.StoreSite.State;
            this.currentSiteId.LoanAmount    = 0.00M;

            try
            {
                //Initialize the logger
                this.initializeLogger(appName);

                //Initialize audit logger
                this.initializeAuditLogger(auditLogEnabledChangeHandler, auditLogHandler, auditLogEnabled);
            }
            catch (Exception eX)
            {
                throw new ApplicationException("One or both primary loggers failed to initialize!", eX);
            }

            //Retrieve URL
            var pdaUrlObj = confRef.GetURL();

            if (pdaUrlObj != null)
            {
                this.CashlinxPDAURL = confRef.DecryptValue(pdaUrlObj.AuxInfo);
            }
            else
            {
                throw new ApplicationException("Cannot determine CashlinxPDA URL! Exiting!");
            }
        }