示例#1
0
    /// <summary>
    ///
    /// </summary>
    private void BindAdminGridView()
    {
        DataTable dt = UserProfileDB.GetAllAdministrativeUsers();

        this.AdminGridView.DataSource = dt;
        this.AdminGridView.DataBind();
    }
示例#2
0
    /// <summary>
    ///
    /// </summary>
    /// <returns></returns>
    private UserProfile GetCurrentUserProfile()
    {
        UserProfile _userProfile = null;

        try
        {
            //check if admin
            if (Website.Security.IsAdministrator() && this.UserID > 0)
            {
                //get user profile by id
                _userProfile = UserProfileDB.GetUserProfileByUserID(this.UserID);
            }

            else
            {
                //get current users profile
                _userProfile = UserProfileDB.GetUserProfileByMembershipUserGUID(Membership.GetUser().ProviderUserKey.ToString());
            }
        }
        catch
        {
        }


        return(_userProfile);
    }
示例#3
0
 public LaunchRequest(SkillRequest skillRequest)
 {
     this.userProfile       = new UserProfileDB(skillRequest.Session.User.UserId, LOGGER.log);
     this.sessionAttributes = new SessionAttributes(LOGGER.log);
     this.productInventory  = new ProductInventory(skillRequest);
     AlexaResponse.SetSessionAttributeHandler(sessionAttributes);
 }
示例#4
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="pageIndex"></param>
    private void BindLockedOutUsersGridView(int pageIndex = 0)
    {
        DataTable dt = UserProfileDB.GetAllAspnetUsersLockedOutDataTable();

        this.LockedOutUsersGridView.DataSource = dt;
        LockedOutUsersGridView.PageIndex       = pageIndex;
        this.LockedOutUsersGridView.DataBind();
    }
示例#5
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="pageIndex"></param>
    private void BindNotApprovedUsersGridView(int pageIndex = 0)
    {
        DataTable dt = UserProfileDB.GetAllAspnetUsersNotApprovedDataTable();

        this.NotApprovedUsersGridView.DataSource = dt;
        NotApprovedUsersGridView.PageIndex       = pageIndex;
        this.NotApprovedUsersGridView.DataBind();
    }
示例#6
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="pageIndex"></param>
    private void BindUserProfiles(int pageIndex = 0)
    {
        DataTable dt = UserProfileDB.GetAllUserProfilesDataTable();

        this.UserProfilesGridView.DataSource = dt;
        UserProfilesGridView.PageIndex       = pageIndex;
        this.UserProfilesGridView.DataBind();
    }
示例#7
0
    private void UploadSponsorLogo(vwarDAL.IDataRepository dal, ContentObject co)
    {
        if (this.SponsorLogoRadioButtonList.SelectedItem != null)
        {
            switch (this.SponsorLogoRadioButtonList.SelectedValue.Trim())
            {
            case "0":     //use profile logo

                //use profile logo if use current and there's an empty file name otherwise don't change
                if (string.IsNullOrEmpty(co.SponsorLogoImageFileName))
                {
                    DataTable dt = UserProfileDB.GetUserProfileSponsorLogoByUserName(Context.User.Identity.Name);

                    if (dt != null && dt.Rows.Count > 0)
                    {
                        DataRow dr = dt.Rows[0];

                        if (dr["Logo"] != System.DBNull.Value && dr["LogoContentType"] != System.DBNull.Value && !string.IsNullOrEmpty(dr["LogoContentType"].ToString()))
                        {
                            var data = (byte[])dr["Logo"];
                            using (MemoryStream s = new MemoryStream())
                            {
                                s.Write(data, 0, data.Length);
                                s.Position = 0;

                                //filename
                                co.SponsorLogoImageFileName = "sponsor.jpg";


                                if (!string.IsNullOrEmpty(dr["FileName"].ToString()))
                                {
                                    co.SponsorLogoImageFileName = dr["FileName"].ToString();
                                }
                                FedoraContentObject.SponsorLogoImageFileNameId =
                                    dal.SetContentFile(s, co, co.SponsorLogoImageFileName);
                            }
                        }
                    }
                }



                break;

            case "1":     //Upload logo
                if (this.SponsorLogoFileUpload.FileContent.Length > 0 && !string.IsNullOrEmpty(this.SponsorLogoFileUpload.FileName))
                {
                    co.SponsorLogoImageFileName     = this.SponsorLogoFileUpload.FileName;
                    co.DeveloperLogoImageFileNameId = dal.SetContentFile(this.SponsorLogoFileUpload.FileContent, co, this.SponsorLogoFileUpload.FileName);
                }

                break;

            case "2":     //none
                break;
            }
        }
    }
示例#8
0
 public Intent(SkillRequest request)
 {
     this.skillRequest      = request;
     this.userProfile       = new UserProfileDB(skillRequest.Session.User.UserId, LOGGER.log);
     this.sessionAttributes = new SessionAttributes(LOGGER.log);
     this.sessionAttributes.UpdateSessionAttributes(skillRequest.Session.Attributes);
     AlexaResponse.SetSessionAttributeHandler(sessionAttributes);
     this.products = new ProductInventory(request);
 }
示例#9
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="userName"></param>
    private static void DelteUser(string userName)
    {
        bool success = UserProfileDB.DeleteUserProfileByUserName(userName);

        if (success)
        {
            //remove all the user's roles
            string[] usersRoles = Roles.GetRolesForUser(userName);
            foreach (string r in usersRoles)
            {
                Roles.RemoveUserFromRole(userName, r);
            }

            //delete the membership user
            Membership.DeleteUser(userName, true);
        }
    }
示例#10
0
    /// <summary>
    ///
    /// </summary>
    private void BindContactUs()
    {
        if (Context.User.Identity.IsAuthenticated)
        {
            UserProfile p = null;
            try
            {
                p = UserProfileDB.GetUserProfileByUserName(Context.User.Identity.Name.Trim());
            }

            catch
            {
            }

            if (p != null)
            {
                //bind to profile
                this.FirstNameTextBox.Text   = p.FirstName.Trim();
                this.LastNameTextBox.Text    = p.LastName.Trim();
                this.PhoneNumberTextBox.Text = p.Phone.Trim();
                this.EmailTextBox.Text       = p.Email.Trim();
            }
        }
    }
示例#11
0
    private void BindDeveloperLogo()
    {
        string logoImageURL = "";


        //check fedora
        if (!this.IsNew && this.FedoraContentObject != null && !string.IsNullOrEmpty(this.FedoraContentObject.DeveloperLogoImageFileName))
        {
            try
            {
                logoImageURL = String.Format("~/Public/Serve.ashx?pid={0}&mode=GetDeveloperLogo", this.FedoraContentObject.PID);
            }
            catch
            {
            }

            if (!string.IsNullOrEmpty(logoImageURL))
            {
                this.DeveloperLogoImage.ImageUrl = logoImageURL.Trim();
                return;
            }
        }
        //get from profile
        if (Context.User.Identity.IsAuthenticated)
        {
            UserProfile p = null;


            try
            {
                p = UserProfileDB.GetUserProfileByUserName(Context.User.Identity.Name);
            }
            catch
            {
            }

            //check profile if authenticated
            if (Context.User.Identity.IsAuthenticated && p != null)
            {
                if (p.DeveloperLogo != null && !string.IsNullOrEmpty(p.DeveloperLogoContentType))
                {
                    logoImageURL = Website.Pages.Types.FormatProfileImageHandler(p.UserID.ToString(), "Developer");

                    if (!string.IsNullOrEmpty(logoImageURL))
                    {
                        this.DeveloperLogoImage.ImageUrl = logoImageURL.Trim();
                        return;
                    }
                }
            }
        }


        //set selected
        //remove use current from radiobuttonlist, show file upload
        if (string.IsNullOrEmpty(logoImageURL))
        {
            //clear selection
            if (this.DeveloperLogoRadioButtonList.SelectedItem != null)
            {
                this.DeveloperLogoRadioButtonList.ClearSelection();
            }

            //remove
            this.DeveloperLogoRadioButtonList.Items.RemoveAt(0);

            //set upload new selected
            this.DeveloperLogoRadioButtonList.Items.FindByValue("1").Selected = true;
            this.DeveloperLogoImage.Visible           = false;
            this.DeveloperLogoFileUploadPanel.Visible = true;
        }
    }
示例#12
0
    protected void Step1NextButton_Click(object sender, EventArgs e)
    {
        //update
        if (IsModelUpload)
        {
            vwarDAL.IDataRepository dal = (new vwarDAL.DataAccessFactory()).CreateDataRepositorProxy();;


            if (this.IsNew)
            {
                //create new & add to session
                ContentObject co = new ContentObject(dal);
                co.Title          = this.TitleTextBox.Text.Trim();
                co.UploadedDate   = DateTime.Now;
                co.LastModified   = DateTime.Now;
                co.Views          = 0;
                co.SubmitterEmail = Context.User.Identity.Name.Trim();
                dal.InsertContentObject(co);
                FedoraContentObject  = co;
                this.ContentObjectID = co.PID;
            }
            else
            {
                FedoraContentObject.Title = TitleTextBox.Text.Trim();
            }


            if (this.FedoraContentObject != null)
            {
                //asset type
                this.FedoraContentObject.AssetType = "Model";
                string newFileName = TitleTextBox.Text.ToLower().Replace(' ', '_') + Path.GetExtension(this.ContentFileUpload.PostedFile.FileName);
                //model upload
                Utility_3D.ConvertedModel model = null;
                if (this.ContentFileUpload.HasFile)
                {
                    string newOriginalFileName = "original_" + newFileName;

                    if (IsNew)
                    {
                        using (MemoryStream stream = new MemoryStream())
                        {
                            stream.Write(this.ContentFileUpload.FileBytes, 0, this.ContentFileUpload.FileBytes.Length);
                            FedoraContentObject.OriginalFileId = dal.SetContentFile(stream, FedoraContentObject.PID, newOriginalFileName);
                        }
                    }
                    else
                    {
                        //Update the original file
                        dal.UpdateFile(this.ContentFileUpload.FileBytes, FedoraContentObject.PID, FedoraContentObject.OriginalFileName, newOriginalFileName);
                    }
                    FedoraContentObject.OriginalFileName = newOriginalFileName;

                    Utility_3D.Model_Packager pack = new Utility_3D.Model_Packager();
                    Utility_3D _3d = new Utility_3D();
                    Utility_3D.ConverterOptions cOptions = new Utility_3D.ConverterOptions();
                    cOptions.EnableTextureConversion(Utility_3D.ConverterOptions.PNG);
                    cOptions.EnableScaleTextures(Website.Config.MaxTextureDimension);
                    _3d.Initialize(Website.Config.ConversionLibarayLocation);

                    string UploadedFilename = newFileName;
                    if (Path.GetExtension(UploadedFilename) != ".zip")
                    {
                        UploadedFilename = Path.ChangeExtension(newFileName, ".zip");
                    }

                    try
                    {
                        model = pack.Convert(this.ContentFileUpload.PostedFile.InputStream, this.ContentFileUpload.PostedFile.FileName, cOptions);
                    }
                    catch
                    {
                        Response.Redirect(Page.ResolveClientUrl("~/Public/Model.aspx?ContentObjectID=" + this.ContentObjectID));
                    }


                    var    displayFilePath   = "";
                    string convertedFileName = newFileName.Replace(Path.GetExtension(newFileName).ToLower(), ".zip");
                    if (this.ContentFileUpload.HasFile)
                    {
                        using (Stream stream = new MemoryStream())
                        {
                            stream.Write(model.data, 0, model.data.Length);
                            stream.Seek(0, SeekOrigin.Begin);
                            FedoraContentObject.Location = UploadedFilename;
                            //FedoraContentObject.DisplayFileId =
                            dal.SetContentFile(stream, FedoraContentObject, UploadedFilename);
                        }
                    }
                    else
                    {
                        using (MemoryStream stream = new MemoryStream())
                        {
                            stream.Write(model.data, 0, model.data.Length);
                            stream.Seek(0, SeekOrigin.Begin);
                            dal.SetContentFile(stream, FedoraContentObject, UploadedFilename);
                            FedoraContentObject.Location = UploadedFilename;
                        }
                    }
                    FedoraContentObject.Location = convertedFileName;

                    if (model.type != "UNKNOWN")
                    {
                        string optionalPath   = (newFileName.LastIndexOf("o3d", StringComparison.CurrentCultureIgnoreCase) != -1) ? "viewerTemp/" : "converterTemp/";
                        string pathToTempFile = "~/App_Data/" + optionalPath;

                        string destPath = Path.Combine(Context.Server.MapPath(pathToTempFile), newFileName);

                        System.IO.FileStream savefile = new FileStream(destPath, FileMode.OpenOrCreate);
                        byte[] filedata = new Byte[model.data.Length];
                        model.data.CopyTo(filedata, 0);
                        savefile.Write(model.data, 0, (int)model.data.Length);
                        savefile.Close();

                        string outfilename       = Context.Server.MapPath("~/App_Data/viewerTemp/") + newFileName.Replace(".zip", ".o3d");
                        string convertedtempfile = ConvertFileToO3D(destPath, outfilename);



                        displayFilePath = FedoraContentObject.DisplayFile;
                        string o3dFileName = newFileName.Replace(Path.GetExtension(newFileName).ToLower(), ".o3d");
                        if (this.ContentFileUpload.HasFile)
                        {
                            using (FileStream stream = new FileStream(convertedtempfile, FileMode.Open))
                            {
                                FedoraContentObject.DisplayFileId = dal.SetContentFile(stream, FedoraContentObject, o3dFileName);
                            }
                        }
                        else
                        {
                            using (MemoryStream stream = new MemoryStream())
                            {
                                stream.Write(filedata, 0, filedata.Length);
                                stream.Seek(0, SeekOrigin.Begin);
                                dal.SetContentFile(stream, FedoraContentObject, UploadedFilename);
                                FedoraContentObject.DisplayFile = Path.GetFileName(FedoraContentObject.DisplayFile);
                            }
                        }
                        FedoraContentObject.DisplayFile = o3dFileName;
                    }
                    else
                    {
                        FedoraContentObject.DisplayFile = string.Empty;
                    }


                    FedoraContentObject.UnitScale   = model._ModelData.TransformProperties.UnitMeters.ToString();
                    FedoraContentObject.UpAxis      = model._ModelData.TransformProperties.UpAxis;
                    FedoraContentObject.NumPolygons = model._ModelData.VertexCount.Polys;
                    FedoraContentObject.NumTextures = model._ModelData.ReferencedTextures.Length;

                    PopulateValidationViewMetadata(FedoraContentObject);
                }

                //upload thumbnail
                if (this.ThumbnailFileUpload.HasFile)
                {
                    int length = (int)this.ThumbnailFileUpload.PostedFile.InputStream.Length;

                    if (IsNew || FedoraContentObject.ScreenShot == "")// order counts here have to set screenshot id after the update so we can find the correct dsid
                    {
                        this.FedoraContentObject.ScreenShot = "screenshot.png";
                    }

                    FedoraContentObject.ScreenShotId = dal.SetContentFile(this.ThumbnailFileUpload.PostedFile.InputStream, this.FedoraContentObject, FedoraContentObject.ScreenShot);

                    string ext = new FileInfo(ThumbnailFileUpload.PostedFile.FileName).Extension.ToLower();
                    System.Drawing.Imaging.ImageFormat format;

                    if (ext == ".png")
                    {
                        format = System.Drawing.Imaging.ImageFormat.Png;
                    }
                    else if (ext == ".jpg")
                    {
                        format = System.Drawing.Imaging.ImageFormat.Jpeg;
                    }
                    else if (ext == ".gif")
                    {
                        format = System.Drawing.Imaging.ImageFormat.Gif;
                    }
                    else
                    {
                        ScreenshotValidator.Visible = true;
                        ScreenshotValidator.Text    = "Nice job generating a POST request without the interface. Don't you feel special?";
                        return;
                    }

                    //Avoid wasting space by removing old thumbnails
                    //if (!String.IsNullOrEmpty(FedoraContentObject.ThumbnailId))
                    //   File.Delete("~/thumbnails/" + FedoraContentObject.ThumbnailId);

                    //Use the original file bytes to remain consistent with the new file upload ID creation for thumbnails
                    FedoraContentObject.ThumbnailId = Website.Common.GetFileSHA1AndSalt(ThumbnailFileUpload.PostedFile.InputStream) + ext;

                    //using (FileStream outFile = new FileStream(HttpContext.Current.Server.MapPath("~/thumbnails/" + FedoraContentObject.ThumbnailId), FileMode.Create))
                    //   Website.Common.GenerateThumbnail(ThumbnailFileUpload.PostedFile.InputStream, outFile, format);
                }

                //creative commons license url
                if (this.CCLicenseDropDownList.SelectedItem != null && this.CCLicenseDropDownList.SelectedValue != "None")
                {
                    this.FedoraContentObject.CreativeCommonsLicenseURL = this.CCLicenseDropDownList.SelectedValue.Trim();
                }

                //Require Resubmit Checkbox
                FedoraContentObject.RequireResubmit = this.RequireResubmitCheckbox.Checked;

                //developer logo
                this.UploadDeveloperLogo(dal, this.FedoraContentObject);

                //developer name
                if (!string.IsNullOrEmpty(this.DeveloperNameTextBox.Text))
                {
                    this.FedoraContentObject.DeveloperName = this.DeveloperNameTextBox.Text.Trim();
                }

                //sponsor logo
                this.UploadSponsorLogo(dal, this.FedoraContentObject);


                //sponsor name
                if (!string.IsNullOrEmpty(this.SponsorNameTextBox.Text))
                {
                    this.FedoraContentObject.SponsorName = this.SponsorNameTextBox.Text.Trim();
                }

                //artist name
                if (!string.IsNullOrEmpty(this.ArtistNameTextBox.Text))
                {
                    this.FedoraContentObject.ArtistName = this.ArtistNameTextBox.Text.Trim();
                }

                //format
                if (!string.IsNullOrEmpty(this.FormatTextBox.Text))
                {
                    this.FedoraContentObject.Format = this.FormatTextBox.Text.Trim();
                }


                //description
                if (!string.IsNullOrEmpty(this.DescriptionTextBox.Text))
                {
                    this.FedoraContentObject.Description = this.DescriptionTextBox.Text.Trim();
                }

                //more information url
                if (!string.IsNullOrEmpty(this.MoreInformationURLTextBox.Text))
                {
                    this.FedoraContentObject.MoreInformationURL = this.MoreInformationURLTextBox.Text.Trim();
                }

                //keywords
                string cleanTags = "";
                foreach (string s in KeywordsTextBox.Text.Split(','))
                {
                    cleanTags += s.Trim() + ",";
                }
                cleanTags = HttpContext.Current.Server.HtmlEncode(cleanTags.Trim(','));
                this.FedoraContentObject.Keywords = cleanTags;
            }

            dal.UpdateContentObject(FedoraContentObject);
            if (IsNew)
            {
                PermissionsManager perm = new PermissionsManager();
                perm.SetModelToGroupLevel(System.Configuration.ConfigurationManager.AppSettings["DefaultAdminName"], FedoraContentObject.PID, vwarDAL.DefaultGroups.AllUsers, ModelPermissionLevel.Fetchable);
                perm.SetModelToGroupLevel(System.Configuration.ConfigurationManager.AppSettings["DefaultAdminName"], FedoraContentObject.PID, vwarDAL.DefaultGroups.AnonymousUsers, ModelPermissionLevel.Searchable);
                perm.Dispose();
            }
            SetModelDisplay();
            this.PopulateValidationViewMetadata(FedoraContentObject);
            this.MultiView1.SetActiveView(this.ValidationView);
            var admins = UserProfileDB.GetAllAdministrativeUsers();
            foreach (DataRow row in admins.Rows)
            {
                var url = Request.Url.OriginalString.Replace(Request.Url.PathAndQuery, this.ResolveUrl(Website.Pages.Types.FormatModel(this.ContentObjectID)));
                Website.Mail.SendModelUploaded(FedoraContentObject);
            }
            dal.Dispose();
        }
    }
示例#13
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void CreateUserWizardStep1_CreatedUser(object sender, EventArgs e)
    {
        // Create an empty Profile for the newly created user
        //ProfileCommon p = (ProfileCommon)ProfileCommon.Create(CreateUserWizard1.UserName, true);

        // Populate some Profile properties off of the create user wizard
        //p.FirstName = ((TextBox)CreateUserWizard1.CreateUserStep.Controls[0].FindControl("FirstName")).Text;
        //p.LastName = ((TextBox)CreateUserWizard1.CreateUserStep.Controls[0].FindControl("LastName")).Text;


        //load new membership user and set 'Comment' property to {FirstName}|{LastName}

        MembershipUser mu = String.IsNullOrEmpty(CreateUserWizard1.UserName) ? Membership.GetUser(CreateOpenIDWizard.UserName) : Membership.GetUser(CreateUserWizard1.UserName.Trim());

        //approved = false by default

        if (mu != null)
        {
            //set approved
            mu.IsApproved = Website.Config.MembershipUserApprovedByDefault;
            string targetRole = "Users";
            if (!Roles.IsUserInRole(mu.UserName, targetRole))
            {
                Roles.AddUserToRole(mu.UserName, targetRole);
            }

            //create user profile

            UserProfile p = null;

            string memGUID = mu.ProviderUserKey.ToString().Trim();
            string fName   = ((TextBox)CreateUserWizard1.CreateUserStep.Controls[0].FindControl("FirstName")).Text;
            string lName   = ((TextBox)CreateUserWizard1.CreateUserStep.Controls[0].FindControl("LastName")).Text;
            string email   = ((TextBox)CreateUserWizard1.CreateUserStep.Controls[0].FindControl("Email")).Text;

            try
            {
                p          = UserProfileDB.InsertUserProfile(memGUID, fName, lName, email, email, email);
                mu.Comment = p.FirstName.Trim() + "|" + p.LastName.Trim();

                Membership.UpdateUser(mu);
                Database.ConnString = Website.Config.PostgreSQLConnectionString;
                Database.DBType     = "MySQL";
                Database.DBPrefix   = "DMG";
                email = Functions.RepairString(email);
                string             password = Functions.Encrypt(Functions.RepairString(CreateUserWizard1.Password));
                PermissionsManager mgr      = new PermissionsManager();
                mgr.AddUserToGroup(System.Configuration.ConfigurationManager.AppSettings["DefaultAdminName"], vwarDAL.DefaultGroups.AllUsers, mu.UserName);
                if (Website.Config.SendEmailForNewRegistrations)
                {
                    Website.Mail.SendNewRegistrationNotificationEmail(mu);
                }
                mgr.Dispose();
                //Database.Write("INSERT INTO " + Database.DBPrefix + "_MEMBERS (MEMBER_USERNAME, MEMBER_PASSWORD, MEMBER_LEVEL, MEMBER_EMAIL, MEMBER_LOCATION, MEMBER_HOMEPAGE, MEMBER_SIGNATURE, MEMBER_SIGNATURE_SHOW, MEMBER_IM_AOL, MEMBER_IM_ICQ, MEMBER_IM_MSN, MEMBER_IM_YAHOO, MEMBER_POSTS, MEMBER_DATE_JOINED, MEMBER_DATE_LASTVISIT, MEMBER_TITLE, MEMBER_TITLE_ALLOWCUSTOM, MEMBER_TITLE_USECUSTOM, MEMBER_EMAIL_SHOW, MEMBER_IP_LAST, MEMBER_IP_ORIGINAL, MEMBER_REALNAME, MEMBER_OCCUPATION, MEMBER_SEX, MEMBER_AGE, MEMBER_BIRTHDAY, MEMBER_NOTES, MEMBER_FAVORITESITE, MEMBER_PHOTO, MEMBER_AVATAR, MEMBER_AVATAR_SHOW, MEMBER_AVATAR_ALLOWCUSTOM, MEMBER_AVATAR_USECUSTOM, MEMBER_AVATAR_CUSTOMLOADED, MEMBER_AVATAR_CUSTOMTYPE, MEMBER_VALIDATED, MEMBER_VALIDATION_STRING, MEMBER_RANKING) VALUES ('" + email + "','" + password + "', " + 1 + ", '" + email + "', ' ', ' ', ' ', 0, '', '', '', '', 0, " + Database.GetTimeStamp() + ", " + Database.GetTimeStamp() + ", '', 0, 0, 0, '', '', '', '', '', '', '', '', '', '', 1, 0 , 0, 0, 0, 'jpg', 1, '', 0)");
            }
            catch
            {
            }
        }

        // Save profile - must be done since we explicitly created it
        // p.Save();

        if (Website.Config.MembershipUserApprovedByDefault == false)
        {
            //not approved
            FormsAuthentication.SignOut();
            MultiView1.SetActiveView(ConfirmationView);
        }
        else
        {
            //approved
            FormsAuthentication.RedirectFromLoginPage(CreateUserWizard1.UserName, false);
            Website.Mail.SendRegistrationApprovalEmail(mu.Email);
        }
    }
示例#14
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void CreateUserWizardStep1_CreatedUser(object sender, EventArgs e)
    {
        // Create an empty Profile for the newly created user
        //ProfileCommon p = (ProfileCommon)ProfileCommon.Create(CreateUserWizard1.UserName, true);

        // Populate some Profile properties off of the create user wizard
        //p.FirstName = ((TextBox)CreateUserWizard1.CreateUserStep.Controls[0].FindControl("FirstName")).Text;
        //p.LastName = ((TextBox)CreateUserWizard1.CreateUserStep.Controls[0].FindControl("LastName")).Text;


        //load new membership user and set 'Comment' property to {FirstName}|{LastName}

        MembershipUser mu = String.IsNullOrEmpty(CreateUserWizard1.UserName) ? Membership.GetUser(CreateOpenIDWizard.UserName) : Membership.GetUser(CreateUserWizard1.UserName.Trim());

        //approved = false by default

        if (mu != null)
        {
            //set approved
            mu.IsApproved = Website.Config.MembershipUserApprovedByDefault;
            string targetRole = "Users";
            if (!Roles.IsUserInRole(mu.UserName, targetRole))
            {
                Roles.AddUserToRole(mu.UserName, targetRole);
            }

            //create user profile

            UserProfile p = null;

            string memGUID = mu.ProviderUserKey.ToString().Trim();
            string fName   = ((TextBox)CreateUserWizard1.CreateUserStep.Controls[0].FindControl("FirstName")).Text;
            string lName   = ((TextBox)CreateUserWizard1.CreateUserStep.Controls[0].FindControl("LastName")).Text;
            string email   = ((TextBox)CreateUserWizard1.CreateUserStep.Controls[0].FindControl("Email")).Text;

            try
            {
                p          = UserProfileDB.InsertUserProfile(memGUID, fName, lName, email, email, email);
                mu.Comment = p.FirstName.Trim() + "|" + p.LastName.Trim();

                Membership.UpdateUser(mu);
                PermissionsManager mgr = new PermissionsManager();
                mgr.AddUserToGroup(System.Configuration.ConfigurationManager.AppSettings["DefaultAdminName"], vwarDAL.DefaultGroups.AllUsers, mu.UserName);
                if (Website.Config.SendEmailForNewRegistrations)
                {
                    Website.Mail.SendNewRegistrationNotificationEmail(mu);
                }
                mgr.Dispose();
            }
            catch
            {
            }
        }

        // Save profile - must be done since we explicitly created it
        // p.Save();

        if (Website.Config.MembershipUserApprovedByDefault == false)
        {
            //not approved
            FormsAuthentication.SignOut();
            MultiView1.SetActiveView(ConfirmationView);
        }
        else
        {
            //approved
            FormsAuthentication.RedirectFromLoginPage(CreateUserWizard1.UserName, false);
            Website.Mail.SendRegistrationApprovalEmail(mu.Email);
        }
    }
示例#15
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void SubmitButton_Click(object sender, EventArgs e)
    {
        //UserProfile p = UserProfileDB.GetUserProfileByMembershipUserGUID(memGuid);

        UserProfile p = this.GetCurrentUserProfile();

        bool isNew = (p == null);

        string fName     = this.FirstNameTextBox.Text;
        string lName     = this.LastNameTextBox.Text;
        string email     = this.EmailTextBox.Text;
        string website   = this.WebsiteURLTextBox.Text;
        string sponsName = this.SponsorNameTextBox.Text;
        string devName   = this.DeveloperNameTextBox.Text;
        string artName   = this.ArtistNameTextBox.Text;
        string phone     = this.PhoneTextBox.Text;

        byte[] sponsorLogoByteArray   = null;
        string sponsorLogoContentType = "";
        string sponsorLogoFileName    = "";

        //sponsor logo
        if (this.SponsorLogoFileUpload.PostedFile != null && !String.IsNullOrEmpty(this.SponsorLogoFileUpload.PostedFile.FileName))
        {
            sponsorLogoContentType = this.SponsorLogoFileUpload.PostedFile.ContentType.Trim();
            sponsorLogoFileName    = this.SponsorLogoFileUpload.FileName;

            //check valid content type
            if (Website.Common.IsValidLogoImageContentType(sponsorLogoContentType))
            {
                sponsorLogoByteArray = Website.Common.GetByteArrayFromFileUpload(this.SponsorLogoFileUpload);
            }
            else
            {
                //show error message
                this.EditProfileViewErrorMessageLabel.Text = "Invalid Sponsor Logo file type. Please upload a valid image file";
                MultiView1.SetActiveView(EditProfileView);
                return;
            }
        }
        else
        {
            //set to current
            if (!isNew)
            {
                if (p.SponsorLogo != null && !string.IsNullOrEmpty(p.SponsorLogoContentType))
                {
                    if (this.RemoveSponsorLogoCheckBox.Checked)
                    {
                        sponsorLogoByteArray   = null;
                        sponsorLogoContentType = string.Empty;
                        sponsorLogoFileName    = string.Empty;
                    }
                    else
                    {
                        //set to current
                        sponsorLogoByteArray   = p.SponsorLogo;
                        sponsorLogoContentType = p.SponsorLogoContentType;
                        sponsorLogoFileName    = p.SponsorLogoFileName;
                    }
                }
            }
        }

        byte[] developerLogoByteArray   = null;
        string developerLogoContentType = null;
        string developerLogoFileName    = "";

        //developer logo
        if (this.DeveloperLogoFileUpload.PostedFile != null && !string.IsNullOrEmpty(this.DeveloperLogoFileUpload.PostedFile.FileName))
        {
            developerLogoContentType = this.DeveloperLogoFileUpload.PostedFile.ContentType.Trim();
            developerLogoFileName    = this.DeveloperLogoFileUpload.FileName;

            //check valid content type
            if (Website.Common.IsValidLogoImageContentType(developerLogoContentType))
            {
                developerLogoByteArray = Website.Common.GetByteArrayFromFileUpload(this.DeveloperLogoFileUpload);
            }
            else
            {
                this.EditProfileViewErrorMessageLabel.Text = "Invalid Developer Logo file type. Please upload a valid image file";
                MultiView1.SetActiveView(EditProfileView);
                return;
            }
        }
        else
        {
            if (!isNew)
            {
                //set to current
                if (p.DeveloperLogo != null && !string.IsNullOrEmpty(p.DeveloperLogoContentType))
                {
                    if (this.RemoveDeveloperLogoCheckBox.Checked)
                    {
                        //set to null
                        developerLogoByteArray   = null;
                        developerLogoContentType = string.Empty;
                        developerLogoFileName    = string.Empty;
                    }
                    else
                    {
                        //set to current
                        developerLogoByteArray   = p.DeveloperLogo;
                        developerLogoContentType = p.DeveloperLogoContentType;
                        developerLogoFileName    = p.DeveloperLogoFileName;
                    }
                }
            }
        }

        //update
        if (p != null)
        {
            //update
            p.FirstName                = fName;
            p.LastName                 = lName;
            p.Email                    = email;
            p.WebsiteURL               = website;
            p.SponsorName              = sponsName;
            p.DeveloperName            = devName;
            p.ArtistName               = artName;
            p.Phone                    = phone;
            p.SponsorLogo              = sponsorLogoByteArray;
            p.SponsorLogoContentType   = sponsorLogoContentType;
            p.SponsorLogoFileName      = sponsorLogoFileName;
            p.DeveloperLogo            = developerLogoByteArray;
            p.DeveloperLogoContentType = developerLogoContentType;
            p.DeveloperLogoFileName    = developerLogoFileName;

            try
            {
                UserProfileDB.UpdateUserProfile(p, Context.User.Identity.Name);


                if (Website.Security.IsAdministrator())
                {
                    ConfirmationLabel.Text = p.FirstName + " " + p.LastName + " has been successfully updated.";
                }
                else
                {
                    ConfirmationLabel.Text = "Your profile has been successfully updated.";
                }
            }
            catch
            {
                this.EditProfileViewErrorMessageLabel.Text = "Unable to update your profile. Please try again or <a href=" + this.ResolveUrl(Website.Pages.Types.Contact) + " class='Hyperlink'>Contact Us</a> if you have any questions.";
                MultiView1.SetActiveView(EditProfileView);
                return;
            }
        }
        else
        {
            //insert
            if (!Website.Security.IsAdministrator())
            {
                try
                {
                    ////update profile
                    MembershipUser mu = Membership.GetUser(Context.User.Identity.Name.Trim());

                    ////user guid
                    string memGuid = mu.ProviderUserKey.ToString();

                    p = UserProfileDB.InsertUserProfile(memGuid, fName, lName, email, Context.User.Identity.Name, Context.User.Identity.Name, website, sponsName, devName, artName, phone, sponsorLogoByteArray, sponsorLogoContentType, sponsorLogoFileName, developerLogoByteArray, developerLogoContentType, developerLogoFileName);
                    ConfirmationLabel.Text = "Your profile has been successfully created.";
                }
                catch
                {
                    this.EditProfileViewErrorMessageLabel.Text = "Unable to create your profile. Please try again or <a href = Contact.aspx class='Hyperlink'>Contact Us</a> if you have any questions.";
                    MultiView1.SetActiveView(EditProfileView);
                    return;
                }
            }
        }

        MultiView1.SetActiveView(ConfirmationView);
    }
示例#16
0
        public UserProfile GetUserProfile(int id)
        {
            var profileList = new List <UserProfileDB>();
            var retModel    = new UserProfile();

            try
            {
                using (SqlConnection conn = new SqlConnection(connString))
                {
                    conn.Open();

                    SqlCommand cmd = conn.CreateCommand();
                    cmd.CommandText = "User_Profile";
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@UserId", id);

                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var user = new UserProfileDB
                            {
                                Id            = (int)reader["UserId"],
                                Name          = (string)reader["Name"],
                                Email         = (string)reader["Email"],
                                Password      = (string)reader["Password"],
                                DateCreated   = (DateTime)reader["DateCreated"],
                                DateModified  = (DateTime)reader["DateModified"],
                                EmailVerified = (bool)reader["EmailVerified"],
                                IsAdmin       = (bool)reader["IsAdmin"],
                                ImageUrl      = reader["ImageUrl"] == DBNull.Value ? "" : (string)reader["ImageUrl"],

                                LyricsId          = reader["LyricsId"] == DBNull.Value ? 0 : (int)reader["LyricsId"],
                                LyricsBeatId      = reader["LyricsBeatId"] == DBNull.Value ? 0 :  (int)reader["LyricsBeatId"],
                                LyricsTitle       = reader["LyricsTitle"] == DBNull.Value ? "" : (string)reader["LyricsTitle"],
                                LyricsProducer    = reader["LyricsProducer"] == DBNull.Value ? "" : (string)reader["LyricsProducer"],
                                LyricsDateCreated = reader["LyricsDateCreated"] == DBNull.Value ?  DateTime.MinValue :  (DateTime)reader["LyricsDateCreated"],

                                BeatId         = reader["BeatId"] == DBNull.Value ? 0 : (int)reader["BeatId"],
                                BeatTitle      = reader["BeatTitle"] == DBNull.Value ? "" : (string)reader["BeatTitle"],
                                BeatProducer   = reader["BeatProducer"] == DBNull.Value ? "" : (string)reader["BeatProducer"],
                                BeatUploadDate = reader["BeatUploadDate"] == DBNull.Value ? DateTime.MinValue : (DateTime)reader["BeatUploadDate"],
                            };
                            profileList.Add(user);
                        }
                    }
                    conn.Close();
                }
                //group by user
                //possible refectoring required because data points to single user; no grouping required
                if (profileList.Count != 0)
                {
                    var groupUser = profileList.GroupBy(x => new
                    {
                        x.Id,
                        x.Password,
                        x.Name,
                        x.Email,
                        x.DateCreated,
                        x.DateModified,
                        x.EmailVerified,
                        x.IsAdmin,
                        x.ImageUrl
                    }).Select(y => new UserProfile
                    {
                        Id            = y.Key.Id,
                        Password      = y.Key.Password,
                        Name          = y.Key.Name,
                        Email         = y.Key.Email,
                        DateCreated   = y.Key.DateCreated,
                        DateModified  = y.Key.DateModified,
                        EmailVerified = y.Key.EmailVerified,
                        IsAdmin       = y.Key.IsAdmin,
                        ImageUrl      = y.Key.ImageUrl
                    }).ToList();

                    retModel = groupUser.First();

                    //group by beats
                    retModel.UserBeatsList = profileList.Exists(x => x.BeatId == 0) ? new List <UserBeats>() :
                                             profileList.GroupBy(x => new
                    {
                        x.BeatId,
                        x.BeatTitle,
                        x.BeatProducer,
                        x.BeatUploadDate,
                    })
                                             .Select(y => new UserBeats
                    {
                        Id         = y.Key.BeatId,
                        Title      = y.Key.BeatTitle,
                        Producer   = y.Key.BeatProducer,
                        UploadDate = y.Key.BeatUploadDate
                    }).ToList();


                    //group by lyrics if list exists
                    retModel.UserLyricsList = profileList.Exists(x => x.LyricsId == 0) ? new List <UserLyrics>() :
                                              profileList.GroupBy(x => new
                    {
                        x.LyricsId,
                        x.LyricsBeatId,
                        x.LyricsTitle,
                        x.LyricsProducer,
                        x.LyricsDateCreated
                    })
                                              .Select(y => new UserLyrics
                    {
                        Id         = y.Key.LyricsId,
                        BeatId     = y.Key.LyricsBeatId,
                        Title      = y.Key.LyricsTitle,
                        Producer   = y.Key.LyricsProducer,
                        UploadDate = y.Key.LyricsDateCreated
                    }).ToList();
                }
            }
            catch (Exception e)
            {
                var check = e.InnerException.ToString();
            }

            return(retModel);
        }
示例#17
0
    public static JsonWrappers.UploadDetailDefaults Step2_Submit(string ScaleValue, string UpAxis)
    {
        HttpContext       context       = HttpContext.Current;
        HttpServerUtility server        = context.Server;
        FileStatus        currentStatus = (FileStatus)context.Session["fileStatus"];

        var             factory = new DataAccessFactory();
        IDataRepository dal     = factory.CreateDataRepositorProxy();
        ContentObject   tempCO  = (ContentObject)context.Session["contentObject"];

        tempCO.UpAxis    = server.HtmlEncode(UpAxis);
        tempCO.UnitScale = server.HtmlEncode(ScaleValue);
        //dal.UpdateContentObject(tempCO);
        context.Session["contentObject"] = tempCO;


        //Bind the
        JsonWrappers.UploadDetailDefaults jsReturnParams = new JsonWrappers.UploadDetailDefaults();
        if (HttpContext.Current.User.Identity.IsAuthenticated)
        {
            UserProfile p = null;
            try
            {
                p = UserProfileDB.GetUserProfileByUserName(context.User.Identity.Name);
            }
            catch { }

            if (p != null)
            {
                jsReturnParams.HasDefaults   = true;
                jsReturnParams.DeveloperName = p.DeveloperName;
                jsReturnParams.ArtistName    = p.ArtistName;
                jsReturnParams.DeveloperUrl  = p.WebsiteURL;
                jsReturnParams.SponsorName   = p.SponsorName;

                string tempImagePath = context.Server.MapPath("~/App_Data/imageTemp/");
                if (p.DeveloperLogo != null)
                {
                    string extension           = p.DeveloperLogoContentType.Substring(p.DeveloperLogoContentType.LastIndexOf("/") + 1);
                    string tempDevLogoFilename = "devlogo_" + currentStatus.hashname.Replace("zip", extension);
                    using (FileStream stream = new FileStream(tempImagePath + tempDevLogoFilename, FileMode.Create))
                    {
                        stream.Write(p.DeveloperLogo, 0, p.DeveloperLogo.Length);
                    }

                    jsReturnParams.DeveloperLogoFilename = tempDevLogoFilename;
                }

                if (p.SponsorLogo != null)
                {
                    string extension = p.SponsorLogoContentType.Substring(p.SponsorLogoContentType.LastIndexOf("/") + 1);
                    string tempSponsorLogoFilename = "sponsorlogo_" + currentStatus.hashname.Replace("zip", extension);
                    using (FileStream stream = new FileStream(tempImagePath + tempSponsorLogoFilename, FileMode.Create))
                    {
                        stream.Write(p.SponsorLogo, 0, p.SponsorLogo.Length);
                    }

                    jsReturnParams.SponsorLogoFilename = tempSponsorLogoFilename;
                }
            }
        }
        dal.Dispose();
        return(jsReturnParams);
    }
示例#18
0
 public Declined(SkillRequest skillRequest)
 {
     this.userProfile = new UserProfileDB(skillRequest.Session.User.UserId, LOGGER.log);
 }