Exemplo n.º 1
0
        public SidebarManager(Form formContext, Type formType, FlowLayoutPanel flowPanelA, FlowLayoutPanel flowPanelB, Button buttonToggle, Button buttonToggle2, UserSessionFlags sessionFlags)
        {
            this.formReference = Convert.ChangeType(formContext, formType);

            this.flowPanelA    = flowPanelA;
            this.flowPanelB    = flowPanelB;
            this.buttonToggle  = buttonToggle;
            this.buttonToggle2 = buttonToggle2;

            if (flowPanelA.Size.Height != 0)
            {
                fpa_height = flowPanelA.Size.Height;
            }
            else
            {
                fpa_height = 300;
            }

            this.sessionFlags = sessionFlags;

            if (!sessionFlags.isBranchManager)
            {
                this.buttonToggle2.Text = "Happy Banking";
            }
        }
Exemplo n.º 2
0
        //=====================================================================
        // Window Management Snippets
        //=====================================================================
        private void AccountHistory_Load(object sender, EventArgs e)
        {
            this.panelHeader.MouseDown += new System.Windows.Forms.MouseEventHandler(this.mouseDown);
            foreach (Control control in this.panelHeader.Controls)
            {
                if (!(control.Name.Equals("buttonMinimize") || control.Name.Equals("buttonMaximize") || control.Name.Equals("buttonExit")))
                {
                    control.MouseDown += new System.Windows.Forms.MouseEventHandler(this.mouseDown);
                }
            }

            // Window Max/Min/(Exit or Back)
            this.buttonExit.Click     += new System.EventHandler(this.buttonExit_Click);
            this.buttonMaximize.Click += new System.EventHandler(this.buttonMaximize_Click);
            this.buttonMinimize.Click += new System.EventHandler(this.buttonMinimize_Click);

            // Set Stored Tag
            Type tagType = WindowManager.getTagType(this.Tag);;

            if (tagType != null)
            {
                storedType   = tagType;
                storedObject = Convert.ChangeType(this.Tag, storedType);

                // Determine if the user is a teller / branch manager.
                sessionFlags = WindowManager.setUserSessionFlags(storedObject);
            }
            else
            {
                MessageBox.Show("System Error: Could not convert user information successfully");
                throw new Exception("Type of Form.Tag object is null");
            }

            // Sidebar Toggle
            sidebarManager            = new SidebarManager(this, this.GetType(), flowPanelA, flowPanelB, buttonToggle, buttonToggle2, sessionFlags);
            this.buttonToggle.Click  += new System.EventHandler(this.buttonToggle_Click);
            this.buttonToggle2.Click += new System.EventHandler(this.buttonToggle2_Click);

            // Database Service Initialization
            databaseService = new DatabaseService(onError, onInfo);

            // Datatable Initialization
            dt = new DataTable();
        }
        //=====================================================================
        // Window Management Snippets
        //=====================================================================
        private void Homescreen_Load(object sender, EventArgs e)
        {
            // Mouse Event Handling
            this.panelHeader.MouseDown += new System.Windows.Forms.MouseEventHandler(this.mouseDown);
            foreach (Control control in this.panelHeader.Controls)
            {
                if (!(control.Name.Equals("buttonMinimize") || control.Name.Equals("buttonMaximize") || control.Name.Equals("buttonExit")))
                {
                    control.MouseDown += new System.Windows.Forms.MouseEventHandler(this.mouseDown);
                }
            }

            // Window Max/Min/(Exit or Back)
            this.buttonExit.Click     += new System.EventHandler(this.buttonExit_Click);
            this.buttonMaximize.Click += new System.EventHandler(this.buttonMaximize_Click);
            this.buttonMinimize.Click += new System.EventHandler(this.buttonMinimize_Click);

            // Update Welcome Message
            Type tagType = WindowManager.getTagType(this.Tag);;

            if (tagType != null)
            {
                storedType   = tagType;
                storedObject = Convert.ChangeType(this.Tag, storedType);

                labelPersonalized.Text = storedObject.FirstName + " " + storedObject.LastName + "'s Home";

                // Determine if the user is a teller / branch manager.
                sessionFlags = WindowManager.setUserSessionFlags(storedObject);
            }
            else
            {
                MessageBox.Show("System Error: Could not convert user information successfully");
                throw new Exception("Type of Form.Tag object is null");
            }

            // Sidebar Toggle
            sidebarManager            = new SidebarManager(this, this.GetType(), flowPanelA, flowPanelB, buttonToggle, buttonToggle2, sessionFlags);
            this.buttonToggle.Click  += new System.EventHandler(this.buttonToggle_Click);
            this.buttonToggle2.Click += new System.EventHandler(this.buttonToggle2_Click);
        }
Exemplo n.º 4
0
        /// <summary>Sets the authentication.</summary>
        /// <param name="user">The user.</param>
        /// <param name="flags">Used internally to define local host usage.</param>
        /// <exception cref="WebServerException">
        /// Authentication not allowed!
        /// or
        /// Session belongs to another user!.
        /// </exception>
        public void SetAuthentication(User user, UserSessionFlags flags)
        {
            if (user.ID <= 0)
            {
                throw new ArgumentNullException(nameof(user));
            }

            UserSession userSession = UserSession;

            userSession.Flags = flags;
            if (userSession.ID <= 0)
            {
                throw new WebServerException(WebError.InternalServerError, "Authentication not allowed! SessionMode == {0}!", server.SessionMode);
            }
            if (userSession.UserID > 0 && userSession.UserID != user.ID)
            {
                throw new WebServerException(WebError.InternalServerError, "Session belongs to another user!");
            }

            // set session authenticated
            userSession.Expiration = DateTime.UtcNow + server.SessionTimeout;
            userSession.UserID     = user.ID;

            // update session at db
            if (server.AuthTables.UserSessions is IMemoryTable)
            {
                server.AuthTables.UserSessions.TryUpdate(userSession);
            }
            else
            {
                Task.Factory.StartNew((s) => { server.AuthTables.UserSessions.TryUpdate((UserSession)s); }, userSession);
            }

            // set globals
            UserSession = userSession;
        }
Exemplo n.º 5
0
 /// <summary>Sets the authenticated flag to the request and the session.</summary>
 /// <param name="user">The user.</param>
 /// <param name="flags">Used internally to define local host usage.</param>
 /// <exception cref="InvalidOperationException">IsAuthenticated cannot be set twice!.</exception>
 /// <remarks>This can only be used once per request. Once set this will throw an Exception on any further calls.</remarks>
 public void SetAuthentication(User user, UserSessionFlags flags = 0)
 {
     Data.Session.SetAuthentication(user, flags);
 }