/// <summary>
    /// The ValidateUser method is called first during login processing.
    ///
    /// Additional Information: Depending on the implementation of your external authentication mechanism
    /// you may want to consider customizing the login.aspx page to simulate the forms login process, which
    /// will, in turn, call this method to validate the user.
    ///
    /// In an SSO situation, you may have a one-time security token vs. a password, but this token can be
    /// used in the login process and then verified using the ValidateUser method.
    ///
    /// Alternatively, your implementation may choose to call this method directly.
    /// </summary>
    /// <param name="username"></param>
    /// <param name="password"></param>
    /// <returns></returns>
    public override bool ValidateUser(string username, string password)
    {
        bool   isValid   = false;
        string strTicket = "";

        //Get the ticket if it exists
        //strTicket = (string)HttpContext.Current.Request.QueryString["ticket"];
        //string ticket = ticketUtil.CreateTicket(ticketApp, "ecom", Profile.UserName.ToString(), ticketKey, ticketPostUrl);
        strTicket = _ticketUtil.CreateTicket(_ticketApp, "ecom", username, _ticketKey, _secretKey);
        string strTicket2 = strTicket.Substring(7);

        if (strTicket != null)
        {
            string   strCheckAuth = "";
            string[] TicketData;
            char[]   splitter = { '|' };

            strCheckAuth = _ticketUtil.CheckTicket(_ticketApp, strTicket2, _ticketKey, _secretKey);

            if (strCheckAuth.Length > 0)
            {
                ProfileCommon pc = (ProfileCommon)HttpContext.Current.Profile;
                TicketData = strCheckAuth.Split(splitter);

                ProfilesMembershipUser user = GetUser(TicketData[0], true) as ProfilesMembershipUser;

                pc.UserId     = user.UserID;
                pc.UserName   = user.UserName;
                pc.HasProfile = user.HasProfile;
                pc.ProfileId  = user.ProfileID;

                isValid = true;
            }
        }

        return(isValid);
    }
Exemplo n.º 2
0
        private void lblSeat_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(this.lblMovieName.Text))
            {
                MessageBox.Show("您还没选择电影!", "提示");
                return;
            }
            ticket++;
            try
            {
                string seatNum      = ((Label)sender).Text.ToString();
                string customerName = this.txtCustomer.Text.ToString();
                int    discount     = 0;
                string type         = "";
                if (this.rdoStudent.Checked)
                {
                    type = "student";
                    if (this.cmbDisCount.Text == null)
                    {
                        MessageBox.Show("请输入折扣数!", "提示");
                        return;
                    }
                    else
                    {
                        discount = int.Parse(this.cmbDisCount.Text);
                    }
                }
                else if (this.rdoFree.Checked)
                {
                    if (String.IsNullOrEmpty(this.txtCustomer.Text))
                    {
                        MessageBox.Show("请输入赠票者姓名!", "提示");
                        return;
                    }
                    else
                    {
                        type = "free";
                    }
                }


                //调用工具类创建票
                Ticket newTicket = TicketUtil.CreateTicket(cinema.Schedule.Items[key], cinema.Seats[seatNum],
                                                           discount, customerName, type);
                if (cinema.Seats[seatNum].Color == Color.Yellow)
                {
                    string a = seatNum;
                    a = a.Replace("-", "");
                    char[] b      = a.ToCharArray();
                    string number = b[0].ToString();
                    if (number == "5")
                    {
                        DialogResult result;
                        result = MessageBox.Show("是否购买情侣座?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                        if (result == DialogResult.Yes)
                        {
                            cinema.Seats[seatNum].Color = Color.Red;
                            UpdateSeat();
                            newTicket.CalcPrice();
                            cinema.SoldTickets.Add(newTicket);
                            lblCalcPrice.Text = newTicket.Price.ToString();
                            newTicket.Print();
                        }
                        else if (result == DialogResult.No)
                        {
                            return;
                        }
                    }
                    //打印
                    else
                    {
                        DialogResult result;
                        result = MessageBox.Show("是否购买?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                        if (result == DialogResult.Yes)
                        {
                            cinema.Seats[seatNum].Color = Color.Red;
                            UpdateSeat();
                            newTicket.CalcPrice();
                            cinema.SoldTickets.Add(newTicket);
                            lblCalcPrice.Text = newTicket.Price.ToString();
                            newTicket.Print();
                        }
                        else if (result == DialogResult.No)
                        {
                            return;
                        }
                    }
                }
                else
                {
                    //显示当前售出票的信息
                    foreach (Ticket ticket0 in cinema.SoldTickets)
                    {
                        //判断是否为同场次、同电影、同座位号
                        if (ticket0.Seat.SeatNum == seatNum && ticket0.ScheduleItem.Time == tvMovies.SelectedNode.Text && ticket0.ScheduleItem.Movie.MovieName == tvMovies.SelectedNode.Parent.Text)
                        {
                            ticket0.Show();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }