コード例 #1
0
        protected void ButtonRegister_Click(object sender, EventArgs e)
        {
            string email     = TextBoxEmail.Text;
            string password1 = TextBoxPassword1.Text;
            string password2 = TextBoxPassword2.Text;
            int    inviteId  = Convert.ToInt32(HiddenFieldInvite.Value);

            Classes.UserProfileSet   ups    = new Classes.UserProfileSet();
            Tuple <int, string, int> result = ups.register(email, password1, password2, inviteId);

            if (result.Item1 == -1)
            {
                LabelError.Visible = true;
                LabelError.Text    = result.Item2;
            }
            else if (result.Item1 == 1)
            {
                Classes.UserInfo ui = new Classes.UserInfo();
                int userId          = ui.getUserIdByEmail(email);
                Session["UserId"] = userId.ToString();

                int    Hours            = Convert.ToInt32(ConfigurationManager.AppSettings["LoginHoursShort"].ToString());
                string VerificationCode = Convert.ToString(Guid.NewGuid());

                // set login information
                Classes.LoginSession ls = new Classes.LoginSession();
                ls.setLoginSession(userId, VerificationCode, Hours);

                // create the cookies
                HttpCookie _userInfoCookies = new HttpCookie("VC");
                _userInfoCookies["VC"]   = VerificationCode;
                _userInfoCookies.Expires = DateTime.Now.AddHours(Hours);
                Response.Cookies.Add(_userInfoCookies);

                //check if user got invited
                int invitorId = 0;

                try
                {
                    invitorId = Convert.ToInt32(Page.RouteData.Values["UserId"]);
                }
                catch (Exception ex)
                {
                }
                finally
                {
                }

                if (invitorId != 0)
                {
                    Classes.Notifications n = new Classes.Notifications();
                    n.notificationAdd(invitorId, 5, userId);
                }

                // redirect the user
                Response.Redirect("~/Completion");
            }
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //check login
            int UserId = 0;

            if (Request.Cookies["VC"] != null)
            {
                string VC = Request.Cookies["VC"].Values["VC"];
                Classes.LoginSession ls = new Classes.LoginSession();
                UserId = ls.getUserId(VC);
                if (UserId == 0) //if user not logged in redirect to login
                {
                    Response.Redirect("~/Login/Notifications");
                }
                else
                {
                    Session["UserId"] = UserId.ToString();
                }
            }
            else
            {
                Response.Redirect("~/Login/Notifications");
            }

            //all read
            Classes.Notifications n = new Classes.Notifications();
            n.allRead(UserId);

            //get botifications
            DataTable dt = n.notifications(UserId);

            if (dt.Rows.Count == 0)
            {
                //LabelNoRecord.Visible = true;
            }
            else
            {
                RepeaterNotifications.DataSource = dt;
                RepeaterNotifications.DataBind();
            }
        }
コード例 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //check login
            int UserId = 0;

            if (Request.Cookies["VC"] != null)
            {
                string VC = Request.Cookies["VC"].Values["VC"];
                Classes.LoginSession ls = new Classes.LoginSession();
                UserId = ls.getUserId(VC);
                if (UserId == 0) //if user not logged in redirect to login
                {
                    Response.Redirect("~/Login/Notifications");
                }
                else
                {
                    Session["UserId"] = UserId.ToString();
                }
            }
            else
            {
                Response.Redirect("~/Login/Notifications");
            }

            //all read
            Classes.Notifications n = new Classes.Notifications();
            n.allRead(UserId);

            //get botifications
            DataTable dt = n.notifications(UserId);
            
            if (dt.Rows.Count == 0)
            {
                //LabelNoRecord.Visible = true;
            }
            else
            {
                RepeaterNotifications.DataSource = dt;
                RepeaterNotifications.DataBind();
            }
        }
コード例 #4
0
ファイル: ChatHub.cs プロジェクト: m3hrad/CityCrowd
 public bool deleteNotification(int userId, int notificationId)
 {
     Classes.Notifications n = new Classes.Notifications();
     n.notificationDelete(userId, notificationId);
     return(true);
 }
コード例 #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //check login
            int UserId = 0;
            if (Session["UserId"] != null)
            {
                UserId = Convert.ToInt32(Session["UserId"]);
            }
            else
            {
                if (Request.Cookies["VC"] != null)
                {
                    string VC = Request.Cookies["VC"].Values["VC"];
                    Classes.LoginSession ls = new Classes.LoginSession();
                    UserId = ls.getUserId(VC);
                    if (UserId == 0) //if user not logged in redirect to login
                    {
                        Response.Redirect("~/Login/Notifications");
                    }
                    else
                    {
                        Session["UserId"] = UserId.ToString();
                    }
                }
                else
                {
                    Response.Redirect("~/Login/Notifications");
                }
            }

            //check user status
            string completionValue = Session["DoneCompletion"] as string; if (String.IsNullOrEmpty(completionValue))
            {
                Classes.UserInfo ui = new Classes.UserInfo();
                int userStatus = ui.getUserStatus(UserId);
                switch (userStatus)
                {
                    case 1:
                        Session["DoneCompletion"] = "1";
                        break;
                    case 0:
                    case 4:
                        Response.Redirect("~/Completion");
                        break;
                    case 2:
                        Response.Redirect("~/Error/UserDisabled");
                        break;
                    case 3:
                        Response.Redirect("~/Error/UserDeactivated");
                        break;
                }
            }

            //all read
            Classes.Notifications n = new Classes.Notifications();
            n.allRead(UserId);

            //get notifications
            DataTable dt = n.notifications(UserId);
            
            if (dt.Rows.Count == 0)
            {
                HiddenFieldStatus.Value = "0";
            }
            else
            {
                RepeaterNotifications.DataSource = dt;
                RepeaterNotifications.DataBind();
                HiddenFieldStatus.Value = "1";
            }
        }
コード例 #6
0
ファイル: Register.aspx.cs プロジェクト: m3hrad/CityCrowd
        protected void ButtonRegister_Click(object sender, EventArgs e)
        {
            string email = TextBoxEmail.Text;
            string password1 = TextBoxPassword1.Text;
            string password2 = TextBoxPassword2.Text;
            int inviteId = Convert.ToInt32(HiddenFieldInvite.Value);

            Classes.UserProfileSet ups = new Classes.UserProfileSet();
            Tuple<int, string, int> result = ups.register(email, password1, password2, inviteId);

            if (result.Item1 == -1)
            {
                LabelError.Visible = true;
                LabelError.Text = result.Item2;
            }
            else if (result.Item1 == 1)
            {
                Classes.UserInfo ui = new Classes.UserInfo();
                int userId = ui.getUserIdByEmail(email);
                Session["UserId"] = userId.ToString();

                int Hours = Convert.ToInt32(ConfigurationManager.AppSettings["LoginHoursShort"].ToString());
                string VerificationCode = Convert.ToString(Guid.NewGuid());

                // set login information
                Classes.LoginSession ls = new Classes.LoginSession();
                ls.setLoginSession(userId, VerificationCode, Hours);

                // create the cookies
                HttpCookie _userInfoCookies = new HttpCookie("VC");
                _userInfoCookies["VC"] = VerificationCode;
                _userInfoCookies.Expires = DateTime.Now.AddHours(Hours);
                Response.Cookies.Add(_userInfoCookies);

                //check if user got invited
                int invitorId = 0;

                try
                {
                    invitorId = Convert.ToInt32(Page.RouteData.Values["UserId"]);
                }
                catch (Exception ex)
                {

                }
                finally
                {
                    
                }

                if (invitorId != 0)
                {
                    Classes.Notifications n = new Classes.Notifications();
                    n.notificationAdd(invitorId, 5, userId);
                }

                // redirect the user
                Response.Redirect("~/Completion");
            }
        }
コード例 #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //check login
            int UserId = 0;

            if (Session["UserId"] != null)
            {
                UserId = Convert.ToInt32(Session["UserId"]);
            }
            else
            {
                if (Request.Cookies["VC"] != null)
                {
                    string VC = Request.Cookies["VC"].Values["VC"];
                    Classes.LoginSession ls = new Classes.LoginSession();
                    UserId = ls.getUserId(VC);
                    if (UserId == 0) //if user not logged in redirect to login
                    {
                        Response.Redirect("~/Login/Notifications");
                    }
                    else
                    {
                        Session["UserId"] = UserId.ToString();
                    }
                }
                else
                {
                    Response.Redirect("~/Login/Notifications");
                }
            }

            //check user status
            string completionValue = Session["DoneCompletion"] as string; if (String.IsNullOrEmpty(completionValue))

            {
                Classes.UserInfo ui = new Classes.UserInfo();
                int userStatus      = ui.getUserStatus(UserId);
                switch (userStatus)
                {
                case 1:
                    Session["DoneCompletion"] = "1";
                    break;

                case 0:
                case 4:
                    Response.Redirect("~/Completion");
                    break;

                case 2:
                    Response.Redirect("~/Error/UserDisabled");
                    break;

                case 3:
                    Response.Redirect("~/Error/UserDeactivated");
                    break;
                }
            }

            //all read
            Classes.Notifications n = new Classes.Notifications();
            n.allRead(UserId);

            //get notifications
            DataTable dt = n.notifications(UserId);

            if (dt.Rows.Count == 0)
            {
                HiddenFieldStatus.Value = "0";
            }
            else
            {
                RepeaterNotifications.DataSource = dt;
                RepeaterNotifications.DataBind();
                HiddenFieldStatus.Value = "1";
            }
        }