protected void btnDelete0_Click(object sender, EventArgs e)
    {
        try
        {
            if (txtUserName0.Text.Trim().Length < 1)
            {
                lblMsg0.Text = "Please get one user first!";
            }
            else
            {
                //delete from login
                if (Membership.DeleteUser(txtUserName0.Text.Trim()))
                {
                    //delete from table
                    string[] strParas = new string[1];
                    strParas[0] = txtUserName0.Text.Trim();

                    clsStoreProcedureAccess clsDelete = new clsStoreProcedureAccess("DeleteUserAccount", strSQLConn);
                    clsDelete.fnExecuteSP(strParas);

                    lblMsg0.Text = "Delete successfully!";

                    //refresh - to be done
                    //fnLoadUserNames();
                    fnReset();
                }
            }
        }
        catch (Exception ex)
        {
            lblMsg0.Text = ex.Message;
        }
    }
    protected void btnSave0_Click(object sender, EventArgs e)
    {
        try
        {
            //change access level
            string username    = ddlUserName0.SelectedItem.Value;
            string strUserRole = Roles.GetRolesForUser(username)[0].ToString();
            Roles.RemoveUserFromRole(username, strUserRole);
            //add a specified role
            Roles.AddUserToRole(username, ddlAccessLevel0.SelectedItem.Value);

            //update other info
            string[] strParas = new string[9];
            strParas[0] = ddlUserName0.SelectedItem.Value;
            strParas[1] = txtFirstName0.Text.Trim();
            strParas[2] = txtLastName0.Text.Trim();
            strParas[3] = txtPhoneNum0.Text.Trim();
            strParas[4] = txtEmail0.Text.Trim();
            strParas[5] = txtOrganization0.Text.Trim();
            strParas[6] = ddlAccessLevel0.SelectedItem.Value;
            strParas[7] = ddlApprovalStatus0.SelectedItem.Value;
            strParas[8] = ddlExportData0.SelectedItem.Value;

            clsStoreProcedureAccess clsUpdate = new clsStoreProcedureAccess("UpdateUserAccountInfo", strSQLConn);
            clsUpdate.fnExecuteSP(strParas);

            lblMsg0.Text = "Done!";
        }
        catch (Exception ex)
        {
            lblMsg0.Text = ex.Message;
        }
    }
Example #3
0
    protected void RegisterUser_CreatedUser(object sender, EventArgs e)
    {
        string strSQLConn = System.Configuration.ConfigurationManager.AppSettings["SQLConString"].Trim();

        try
        {
            //FormsAuthentication.SetAuthCookie(RegisterUser.UserName, false /* createPersistentCookie */);

            //string continueUrl = RegisterUser.ContinueDestinationPageUrl;
            //if (String.IsNullOrEmpty(continueUrl))
            //{
            //    continueUrl = "~/";
            //}
            //Response.Redirect(continueUrl);

            Roles.AddUserToRole(RegisterUser.UserName, "pending");//role

            TextBox txtFirstName    = (TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("FirstName");
            TextBox txtLastName     = (TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("LastName");
            TextBox txtPhoneNum     = (TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("PhoneNum");
            TextBox txtEmailAddress = (TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("Email");
            TextBox txtOrganization = (TextBox)this.RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("Organization");
            TextBox txtUserName     = (TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("UserName");

            string[] strParas = new string[10];
            for (int i = 0; i < strParas.Length; i++)
            {
                strParas[i] = "";
            }

            strParas[0] = txtUserName.Text.Trim();
            strParas[1] = txtFirstName.Text.Trim();
            strParas[2] = txtLastName.Text.Trim();
            strParas[3] = txtPhoneNum.Text.Trim();
            strParas[4] = txtEmailAddress.Text.Trim();
            strParas[5] = txtOrganization.Text.Trim();
            strParas[6] = "pending";
            strParas[7] = "Yes";
            strParas[8] = "No";
            strParas[9] = DateTime.Today.ToShortDateString();


            clsStoreProcedureAccess clsNewAccount = new clsStoreProcedureAccess("InsertNewAccount", strSQLConn);
            clsNewAccount.fnExecuteSP(strParas);
        }
        catch (Exception ex)//lblSysMsg
        {
            Label lblMsg = (Label)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("lblSysMsg");
            lblMsg.Text = "Error: " + ex.Message;
        }
    }
Example #4
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        try
        {
            //update other info
            string[] strParas = new string[3];
            strParas[0] = txtUserName.Text.Trim();
            strParas[1] = ddlApprovalStatus.SelectedItem.Value;
            strParas[2] = ddlExportData.SelectedItem.Value;

            clsStoreProcedureAccess clsUpdate = new clsStoreProcedureAccess("UpdateUserAccountInfoSpec", strSQLConn);
            clsUpdate.fnExecuteSP(strParas);

            lblMsg.Text = "Successfully Done!";
        }
        catch (Exception ex)
        {
            lblMsg.Text = ex.Message;
        }
    }
Example #5
0
    protected void Login1_LoggedIn(object sender, EventArgs e)
    {
        AgolToken ar = null;
        RestToken rt = null;


        Session["username"] = Login1.UserName;
        String[] roles = Roles.GetRolesForUser(Login1.UserName);

        MembershipUser mu = Membership.GetUser(Login1.UserName);

        if (roles.Length > 0)
        {
            //shufan added codes 08082014======
            try
            {
                string strSQLConn = System.Configuration.ConfigurationManager.AppSettings["SQLConString"].Trim();

                //insert log information
                string[] strParas = new string[2];
                strParas[0] = Login1.UserName;
                strParas[1] = DateTime.Now.ToString("MM-dd-yyyy HH:mm:ss");

                clsStoreProcedureAccess clsInsertLog = new clsStoreProcedureAccess("InsertLogRec", strSQLConn);
                clsInsertLog.fnExecuteSP(strParas);
            }
            catch (Exception ex)
            {
                throw ex;
            }//Shufan added codes end

            if (Roles.GetRolesForUser(mu.UserName).Contains("pending") == false)
            {
                string url = "https://www.arcgis.com/sharing/oauth2/token?" +
                             "client_id=" + ConfigurationManager.AppSettings["client_id"] +
                             "&client_secret=" + ConfigurationManager.AppSettings["client_secret"] +
                             "&grant_type=client_credentials";


                ar = MakeRequest(url);

                if (ar != null)
                {
                    Session["agol_token"] = ar.access_token;
                }

                //url = "https://www.arcgis.com/sharing/generateToken?f=json&" +
                //                  "&token=" + ar.access_token +
                //                  "&serverUrl=http://analysis.arcgis.com";


                url = "https://www.arcgis.com/sharing/generateToken?f=json&" +
                      "&username="******"agol_user"] +
                      "&password="******"agol_password"] +
                      "&referer=https://www.scarchsite.org";

                rt = MakeRequest2(url);

                if (rt != null)
                {
                    Session["agol_analysis_token"] = rt.token;
                }

                Session["rolename"]    = roles[0];
                Session["DISPLAYNAME"] = "";
                Session["AFFILIATION"] = "";

                SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString);

                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = "[dbo].[aspnet_GetUserInfo]";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Connection  = conn;

                cmd.Parameters.Add("@username", SqlDbType.NVarChar, 256).Value = Login1.UserName;

                SqlCommand iCmd = new SqlCommand();
                iCmd.CommandText = "[dbo].[aspnet_InsertUserToken]";
                iCmd.CommandType = CommandType.StoredProcedure;
                iCmd.Connection  = conn;

                iCmd.Parameters.Add("@username", SqlDbType.NVarChar, 256).Value = Login1.UserName;
                iCmd.Parameters.Add("@token", SqlDbType.NVarChar, 256).Value    = ar.access_token;
                System.TimeSpan duration = new System.TimeSpan(0, 0, 0, ar.expires_in);
                iCmd.Parameters.Add("@expired", SqlDbType.DateTime).Value = DateTime.Now.Add(duration);

                conn.Open();

                using (SqlDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        String name = "";
                        if (!(reader["FIRSTNAME"] is System.DBNull))
                        {
                            name += reader["FIRSTNAME"].ToString();
                        }
                        if (!(reader["LASTNAME"] is System.DBNull))
                        {
                            name += " " + reader["LASTNAME"].ToString();
                        }

                        Session["DISPLAYNAME"] = name;

                        String affil = "";
                        if (!(reader["AFFILIATION"] is System.DBNull))
                        {
                            affil = reader["AFFILIATION"].ToString();
                        }

                        Session["AFFILIATION"] = affil;
                    }
                }

                //Insert the token
                iCmd.ExecuteNonQuery();

                conn.Close();
            }
        }

        if (mu.Comment == "cp")
        {
            Response.Redirect("ChangePassword.aspx");
        }
        else if (Roles.GetRolesForUser(mu.UserName)[0].Equals("admin"))
        {
            Response.Redirect("~/ManagementTool.aspx");
        }
        else if (Roles.GetRolesForUser(mu.UserName).Contains("pending") == false)
        {
            Response.Redirect("~/Map/Map.aspx");
        }
        else
        {
            Response.Redirect("~/PublicView.aspx");
        }
    }