protected override void OnLoad(EventArgs e) { base.OnLoad(e); try { foreach (var item in Request.QueryString) { ValidateSecurity.ValidateString(Request.QueryString[item.ToString()], false); } if (UserController.GetCurrentUserInfo().UserID > 0) { if (UserController.GetCurrentUserInfo().IsInRole("Unverified Users")) { return; } if (!UserController.GetCurrentUserInfo().IsSuperUser) { UserPropertyComponent userPropertyComponent = new UserPropertyComponent(UserController.GetCurrentUserInfo().UserID); if (string.IsNullOrEmpty(userPropertyComponent.UserProperty.Agreement)) { RedirectToSing(); } } } } catch (Exception ee) { string ex = ee.ToString(); if (ee.Message == "Security Issue") { Response.Redirect("/Error/1000.html"); } } }
/// <summary> /// Update information of the file in the database /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnUpdate_Click(object sender, EventArgs e) { try { if (IsChallengeFiles) { challengeFileComponent = new ChallengeFileComponent(DocumentId); challengeFileComponent.ChallengeFile.Updated = DateTime.Now; challengeFileComponent.ChallengeFile.ObjectName = ValidateSecurity.ValidateString(txtTitle.Text, false); challengeFileComponent.ChallengeFile.ObjectType = ddCategory.SelectedItem.Text; try { string pathServer = Server.MapPath(ddCategory.SelectedValue); string sourceFile = System.IO.Path.Combine(Server.MapPath(challengeFileComponent.ChallengeFile.ObjectLocation)); string destFile = System.IO.Path.Combine(pathServer, ValidateSecurity.ValidateString(txtFileName.Text, false) + ValidateSecurity.ValidateString(lblExtension.Text, false)); if (!Directory.Exists(pathServer)) { Directory.CreateDirectory(pathServer); } if (System.IO.File.Exists(sourceFile)) { if (!System.IO.File.Exists(destFile)) { System.IO.File.Move(sourceFile, destFile); } else { System.IO.File.Delete(destFile); System.IO.File.Move(sourceFile, destFile); } } challengeFileComponent.ChallengeFile.ObjectLocation = ddCategory.SelectedValue + ValidateSecurity.ValidateString(txtFileName.Text, false) + ValidateSecurity.ValidateString(lblExtension.Text, false); challengeFileComponent.Save(); } catch { } } else { documentComponent = new DocumentComponent(DocumentId); documentComponent.Document.Updated = DateTime.Now; documentComponent.Document.UploadedBy = UserId; documentComponent.Document.Version++; documentComponent.Document.Title = ValidateSecurity.ValidateString(txtTitle.Text, false); documentComponent.Document.Name = ValidateSecurity.ValidateString(txtFileName.Text, false); documentComponent.Document.Description = ValidateSecurity.ValidateString(txtDescription.Text, false); documentComponent.Document.Scope = rdbScope.SelectedValue; documentComponent.Document.Category = ddCategory.SelectedValue; documentComponent.Save(); } FillDataRepeater(); Count = 0; WizardFile.ActiveStepIndex = 0; } catch (Exception exc) { Exceptions. ProcessModuleLoadException( this, exc); } }
/// <summary> /// Save the new user or update an exist user /// </summary> /// <param name="user"></param> /// <returns></returns> private int SaveProfile(UserProperty user) { try { user.FirstName = ValidateSecurity.ValidateString(txtFirstName.Text, false); user.LastName = ValidateSecurity.ValidateString(txtLastName.Text, false); user.Address = ValidateSecurity.ValidateString(CountryStateCityEditMode.SelectedAddress, false); user.City = CountryStateCityEditMode.SelectedCity; user.Region = CountryStateCityEditMode.SelectedState; user.Country = CountryStateCityEditMode.SelectedCountry; user.PostalCode = CountryStateCityEditMode.SelectedPostalCode; user.Longitude = CountryStateCityEditMode.SelectedLongitude; user.Latitude = CountryStateCityEditMode.SelectedLatitude; user.Telephone = ValidateSecurity.ValidateString(txtPhone.Text, false); user.SkypeName = ValidateSecurity.ValidateString(txtSkype.Text, false); user.Twitter = ValidateSecurity.ValidateString(txtTwitter.Text, false); user.FaceBook = ValidateSecurity.ValidateString(txtFacebook.Text, false); user.Google = ValidateSecurity.ValidateString(txtGoogle.Text, false); user.LinkedIn = ValidateSecurity.ValidateString(txtLinkedIn.Text, false); user.Agreement = "A001"; user.CustomerType = Convert.ToInt32(ddlWhoareYou.SelectedValue); user.NexsoEnrolment = Convert.ToInt32(ddlSource.SelectedValue); user.Language = Convert.ToInt32(ddlLanguage.SelectedValue); user.AllowNexsoNotifications = Convert.ToInt32(chkNotifications.Checked); } catch (Exception exc) //Module failed to load { Exceptions. ProcessModuleLoadException( this, exc); } return(0); }
/// <summary> /// Send message to the other user /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSendMessage_Click(object sender, EventArgs e) { try { Button button = (Button)sender; var txtMessage = (TextBox)button.Parent.FindControl("txtMessage"); if (!string.IsNullOrEmpty(txtMessage.Text)) { var ToUserId = button.CommandArgument; Repeater rpMessages = (Repeater)button.Parent.FindControl("rpMessages"); MessageComponent messageComponent = new MessageComponent(); // verify that the message doesn't have script and styles messageComponent.Message.Message1 = ValidateSecurity.ValidateString(txtMessage.Text, false); messageComponent.Message.DateCreated = DateTime.Now; messageComponent.Message.FromUserId = UserInfo.UserID; messageComponent.Message.ToUserId = Convert.ToInt32(ValidateSecurity.ValidateString(ToUserId, false)); //Save message in the database if (messageComponent.Save() > -1) { var list = FillMessages(GetListMessagesForUser(Convert.ToInt32(ValidateSecurity.ValidateString(ToUserId, false)))); rpMessages.DataSource = list; rpMessages.DataBind(); txtMessage.Text = string.Empty; UserPropertyComponent userPropertyComponent = new UserPropertyComponent(Convert.ToInt32(ToUserId)); UserInfo userTo = UserController.GetUserById(PortalId, userPropertyComponent.UserProperty.UserId); UserPropertyComponent userProperty = new UserPropertyComponent(UserInfo.UserID); //Send message try { CultureInfo language = new CultureInfo(getUserLanguage(userPropertyComponent.UserProperty.Language.GetValueOrDefault(1))); DotNetNuke.Services.Mail.Mail.SendEmail("*****@*****.**", userTo.Email, string.Format( Localization.GetString("MessageTitle", LocalResourceFile, language.Name), userProperty.UserProperty.FirstName + " " + userProperty.UserProperty.LastName ), Localization.GetString("MessageBody", LocalResourceFile, language.Name).Replace("{MESSAGE:Body}", messageComponent.Message.Message1).Replace("{MESSAGE:ViewLink}", NexsoHelper.GetCulturedUrlByTabName("MyMessages")) ); } catch (Exception ex) { Exceptions.ProcessModuleLoadException(this, ex); } } } } catch (Exception exc) { Exceptions. ProcessModuleLoadException( this, exc); } }
/// <summary> /// Load query string ReturnURL (load this page when the process) and returnParameter (load this page when the process) /// </summary> private void LoadParams() { if (UserController.GetCurrentUserInfo().IsInRole("Administrators") || UserController.GetCurrentUserInfo().IsInRole("NexsoSupport")) { } if (!string.IsNullOrEmpty(Request.QueryString["ret"])) { if (!string.IsNullOrEmpty(ValidateSecurity.ValidateString(Request.QueryString["ret"], false))) { try { returnParameter = Request.QueryString["ret"]; } catch (Exception e) { throw; } } else { throw new Exception(); } } if (!string.IsNullOrEmpty(Request.QueryString["returnurl"])) { if (!string.IsNullOrEmpty(ValidateSecurity.ValidateString(Request.QueryString["returnurl"], false))) { try { returnUrl = Request.QueryString["returnurl"]; } catch (Exception e) { throw; } } else { throw new Exception(); } } currentUser = UserController.GetCurrentUserInfo(); userId = currentUser.UserID; if (userId > 0) { userPropertyComponent = new UserPropertyComponent(userId); if (!IsPostBack) { userPropertyComponent.UserProperty.FirstName = UserInfo.FirstName; userPropertyComponent.UserProperty.LastName = UserInfo.LastName; userPropertyComponent.UserProperty.email = UserInfo.Email; userPropertyComponent.Save(); } } }
/// <summary> /// Adds information to the current user. Add the user the following roles: Registered Users and NexsoUser /// </summary> /// <param name="user"></param> /// <returns></returns> private int SaveProfile(UserProperty user) { try { user.FirstName = ValidateSecurity.ValidateString(txtFirstName.Text, false); user.LastName = ValidateSecurity.ValidateString(txtLastName.Text, false); user.Address = CountryStateCityEditMode.SelectedAddress; user.City = CountryStateCityEditMode.SelectedCity; user.Region = CountryStateCityEditMode.SelectedState; user.Country = CountryStateCityEditMode.SelectedCountry; user.PostalCode = CountryStateCityEditMode.SelectedPostalCode; user.Longitude = CountryStateCityEditMode.SelectedLongitude; user.Latitude = CountryStateCityEditMode.SelectedLatitude; user.email = ValidateSecurity.ValidateString(txtEmail.Text, false); //user.Telephone = txtPhone.Text; //user.SkypeName = txtSkype.Text; //user.Twitter = txtTwitter.Text; //user.FaceBook = txtFacebook.Text; //user.Google = txtGoogle.Text; //user.LinkedIn = txtLinkedIn.Text; user.Agreement = "A001"; //user.CustomerType = Convert.ToInt32(ddWhoareYou.SelectedValue); //user.NexsoEnrolment = Convert.ToInt32(ddSource.SelectedValue); //user.Language = Convert.ToInt32(ddLanguage.SelectedValue); //user.AllowNexsoNotifications = Convert.ToInt32(chkNotifications.Checked); if (currentUser != null) { UserInfo myDnnUser = currentUser; if (!myDnnUser.IsInRole("Registered Users")) { var oDnnRoleController = new RoleController(); RoleInfo oCurrentRole = oDnnRoleController.GetRoleByName(this.PortalId, "Registered Users"); oDnnRoleController.AddUserRole(this.PortalId, myDnnUser.UserID, oCurrentRole.RoleID, System.DateTime.Now.AddDays(-1), DotNetNuke.Common.Utilities.Null.NullDate); } if (!myDnnUser.IsInRole("NexsoUser")) { var oDnnRoleController = new RoleController(); RoleInfo oCurrentRole = oDnnRoleController.GetRoleByName(this.PortalId, "NexsoUser"); oDnnRoleController.AddUserRole(this.PortalId, myDnnUser.UserID, oCurrentRole.RoleID, System.DateTime.Now.AddDays(-1), DotNetNuke.Common.Utilities.Null.NullDate); } } } catch (Exception exc) //Module failed to load { Exceptions. ProcessModuleLoadException( this, exc); } return(0); }
public HttpResponseMessage CommentSolution(string txtComment, string scope, string solutionId) { try { var portalSettings = PortalController.GetCurrentPortalSettings(); var currentUser = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo(); if (currentUser.IsInRole("Registered Users")) { var solutionComponent = new SolutionComponent(new Guid(solutionId)); if (!string.IsNullOrEmpty(ValidateSecurity.ValidateString(txtComment, false)) && currentUser.UserID > 0 && solutionComponent.Solution.SolutionId != Guid.Empty) { SolutionCommentComponent solutionCommentComponent = new SolutionCommentComponent(); solutionCommentComponent.SolutionComment.Comment = txtComment; solutionCommentComponent.SolutionComment.CreatedDate = DateTime.Now; solutionCommentComponent.SolutionComment.Publish = true; solutionCommentComponent.SolutionComment.Scope = scope; solutionCommentComponent.SolutionComment.SolutionId = solutionComponent.Solution.SolutionId; solutionCommentComponent.SolutionComment.UserId = currentUser.UserID; if (solutionCommentComponent.Save() > 0) { // Notification var userToNotify = DotNetNuke.Entities.Users.UserController.GetUserById(portalSettings.PortalId, Convert.ToInt32(solutionComponent.Solution.CreatedUserId)); var currentUserProperty = new UserPropertyComponent(currentUser.UserID); if (currentUser.UserID != Convert.ToInt32(solutionComponent.Solution.CreatedUserId)) { if (Helper.HelperMethods.SetNotification("COMMENT", "SOLUTION", solutionComponent.Solution.SolutionId, userToNotify.UserID, currentUser.UserID, "") > 0) { Helper.HelperMethods.SendCommentNotificationEmails(solutionCommentComponent, portalSettings, currentUser); return(Request.CreateResponse(HttpStatusCode.OK, "Successful Operation")); } } } throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError)); } throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.BadRequest)); } throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.Unauthorized)); } catch (HttpResponseException e) { throw e; } catch (Exception ee) { DotNetNuke.Services.Exceptions.Exceptions.LogException(ee); throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError)); } }
public HttpResponseMessage SendMessage(string message, int userIdTo) { try { var portal = PortalController.GetCurrentPortalSettings(); var currentUser = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo(); UserInfo userTo = DotNetNuke.Entities.Users.UserController.GetUserById(portal.PortalId, userIdTo); if (currentUser.IsInRole("Registered Users") && userTo != null) { var fromUser = new UserPropertyComponent(currentUser.UserID); var toUser = new UserPropertyComponent(userIdTo); if (!string.IsNullOrEmpty(ValidateSecurity.ValidateString(message, false)) && toUser.UserProperty.UserId > 0 && currentUser.UserID > 0) { MessageComponent messageComponent = new MessageComponent(Guid.Empty); messageComponent.Message.Message1 = message; messageComponent.Message.ToUserId = userIdTo; messageComponent.Message.FromUserId = currentUser.UserID; messageComponent.Message.DateCreated = DateTime.Now; if (messageComponent.Save() > 0) { // Notification if (currentUser.UserID != Convert.ToInt32(userTo.UserID)) { if (Helper.HelperMethods.SetNotification("MESSAGE", "MESSAGE", messageComponent.Message.MessageId, toUser.UserProperty.UserId, currentUser.UserID, "") > 0) { CultureInfo culture = new CultureInfo(HelperMethods.GetUserLanguage(toUser.UserProperty.Language.GetValueOrDefault(1))); Helper.HelperMethods.SendEmailToUser("MessageTitleMessage", "MessageBodyMessage", userTo, culture, "", messageComponent.Message.Message1).ConfigureAwait(false); return(Request.CreateResponse(HttpStatusCode.OK, "Successful Operation")); } throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError)); } } else { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError)); } } throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.BadRequest)); } throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.Unauthorized)); } catch (HttpResponseException e) { throw e; } catch (Exception ee) { DotNetNuke.Services.Exceptions.Exceptions.LogException(ee); throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError)); } }
private void cmdChangePassword_Click(object sender, EventArgs e) { try { currentUser = UserController.GetCurrentUserInfo(); //1. Check New Password and Confirm are the same if (ValidateSecurity.ValidateString(txtPassword.Text, false) != ValidateSecurity.ValidateString(txtConfirmPassword.Text, false)) { resetMessages.Visible = true; var failed = Localization.GetString("PasswordMismatch", LocalResourceFile); LogFailure(failed); lblHelp.Text = failed; return; } try { // Fail: No match password if (UserController.ChangePassword(currentUser, txtOldPassword.Text, txtPassword.Text) == false) { resetMessages.Visible = true; var failed = Localization.GetString("FailedAttempt", LocalResourceFile); LogFailure(failed); lblHelp.Text = failed; } else { LogSuccess(); var loginStatus = UserLoginStatus.LOGIN_FAILURE; UserController.UserLogin(PortalSettings.PortalId, currentUser.Username, txtPassword.Text, "", "", "", ref loginStatus, false); pChangePassword.Visible = false; pMessage.Visible = true; } } catch { resetMessages.Visible = true; var failed = Localization.GetString("FailedAttempt", LocalResourceFile); LogFailure(failed); lblHelp.Text = failed; } } catch (Exception exc) { Exceptions. ProcessModuleLoadException( this, exc); } }
/// <summary> /// Load information of the current user or the user sent via querystring (ui) /// </summary> private void LoadParams() { if (UserController.GetCurrentUserInfo().IsInRole("Administrators") || UserController.GetCurrentUserInfo().IsInRole("NexsoSupport")) { if (!string.IsNullOrEmpty(Request.QueryString["ui"])) { if (!string.IsNullOrEmpty(ValidateSecurity.ValidateString(Request.QueryString["ui"], false))) { if (Request.QueryString["ui"] == "create") { userId = -1000; currentUser = new UserInfo(); return; } else { } } else { throw new Exception(); } } } try { if (!string.IsNullOrEmpty(Request.QueryString["ui"])) { if (!string.IsNullOrEmpty(ValidateSecurity.ValidateString(Request.QueryString["ui"], false))) { userId = Convert.ToInt32(Request.QueryString["ui"]); currentUser = UserController.GetUserById(PortalId, userId); return; } else { throw new Exception(); } } } catch { throw; } currentUser = UserController.GetCurrentUserInfo(); userId = currentUser.UserID; }
/// <summary> /// Verify that the entered text isn't a script or a stylesheet /// </summary> /// <param name="user"></param> private void SaveProfile(UserInfo user) { user.Profile.SetProfileProperty("FirstName", ValidateSecurity.ValidateString(txtFirstName.Text, false)); user.Profile.SetProfileProperty("LastName", ValidateSecurity.ValidateString(txtLastName.Text, false)); //user.Profile.SetProfileProperty("Street", txtAddress.Text); //user.Profile.SetProfileProperty("City", CountryStateCity1.SelectedCity); //user.Profile.SetProfileProperty("Region", CountryStateCity1.SelectedState); //user.Profile.SetProfileProperty("Country", CountryStateCity1.SelectedCountry); //user.Profile.SetProfileProperty("PostalCode", txtPostalCode.Text); //user.Profile.SetProfileProperty("Telephone", txtPhone.Text); //user.Profile.SetProfileProperty("SkypeName", txtSkype.Text); //user.Profile.SetProfileProperty("Twitter", txtTwitter.Text); //user.Profile.SetProfileProperty("FaceBook", txtFacebook.Text); //user.Profile.SetProfileProperty("Google", txtGoogle.Text); //user.Profile.SetProfileProperty("LinkedIn", txtLinkedIn.Text); //user.Profile.SetProfileProperty("Agreement", "A001"); }
//Continue Button Event protected void btnContinue_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(ResponseHTML.Value) && solutionComponent != null) { //The customDataLogComponent object is created and the user register is saved CustomDataLogComponent customDataLogComponent = new CustomDataLogComponent(); customDataLogComponent.CustomDataLog.CustomData = ValidateSecurity.ValidateString(ResponseHTML.Value, true); customDataLogComponent.CustomDataLog.SolutionId = solutionComponent.Solution.SolutionId; customDataLogComponent.CustomDataLog.Created = DateTime.Now; customDataLogComponent.CustomDataLog.Updated = customDataLogComponent.CustomDataLog.Created; customDataLogComponent.CustomDataLog.UserId = UserController.GetCurrentUserInfo().UserID; customDataLogComponent.CustomDataLog.CustomDataType = "eligibilityTemplate"; customDataLogComponent.CustomDataLog.CustomaDataSchema = challengeCustomDataComponent.ChallengeCustomData.EligibilityTemplate; customDataLogComponent.Save(); } //redirect according module configuration, "RedirectPage". And send id solution like parameter if (Settings.Contains("RedirectPage")) { Response.Redirect(Settings["RedirectPage"].ToString() + "/sl/" + solutionComponent.Solution.SolutionId); } }
/// <summary> /// Save document in the server /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { try { string pathServerTemp = Server.MapPath("Portals/0/Images/Temp/"); string pathServerThumbImages = Server.MapPath("Portals/0/ModIma/ThumbImages/"); if (IsChallengeFiles) { if (string.IsNullOrEmpty(ValidateSecurity.ValidateString(txtTitle.Text, false))) { rgvtxtTitle.IsValid = false; return; } //Information of the document challengeFileComponent = new ChallengeFileComponent(Guid.NewGuid()); challengeFileComponent.ChallengeFile.Created = DateTime.Now; challengeFileComponent.ChallengeFile.Updated = challengeFileComponent.ChallengeFile.Created; challengeFileComponent.ChallengeFile.ObjectName = txtFileName.Text; challengeFileComponent.ChallengeFile.ObjectType = ddCategory.SelectedItem.Text; challengeFileComponent.ChallengeFile.Size = FileSize; challengeFileComponent.ChallengeFile.ObjectExtension = ExtensionName; challengeFileComponent.ChallengeFile.Language = Language; challengeFileComponent.ChallengeFile.ChallengeReferenceId = ChallengeReference; try { string pathServer = Server.MapPath(ddCategory.SelectedValue); string sourceFile = System.IO.Path.Combine(pathServerTemp, FileName + ExtensionName); string destFile = System.IO.Path.Combine(pathServer, ValidateSecurity.ValidateString(txtFileName.Text, false) + ValidateSecurity.ValidateString(lblExtension.Text, false)); if (!Directory.Exists(pathServer)) { Directory.CreateDirectory(pathServer); } if (System.IO.File.Exists(sourceFile)) { if (!System.IO.File.Exists(destFile)) { System.IO.File.Move(sourceFile, destFile); } else { System.IO.File.Delete(destFile); System.IO.File.Move(sourceFile, destFile); } } //Save document information in the database challengeFileComponent.ChallengeFile.ObjectLocation = ddCategory.SelectedValue + ValidateSecurity.ValidateString(txtFileName.Text, false) + ValidateSecurity.ValidateString(lblExtension.Text, false); challengeFileComponent.Save(); } catch { } } else { documentComponent = new DocumentComponent(Guid.NewGuid()); UserPropertyComponent user = new UserPropertyComponent(UserId); documentComponent.Document.Created = DateTime.Now; documentComponent.Document.CreatedBy = UserId; documentComponent.Document.Updated = documentComponent.Document.Created; documentComponent.Document.Views = 0; documentComponent.Document.Version = 1; documentComponent.Document.UploadedBy = user.UserProperty.UserId; documentComponent.Document.Author = string.Empty;// user.UserProperty.FirstName + " " + user.UserProperty.LastName; documentComponent.Document.Name = ValidateSecurity.ValidateString(txtFileName.Text, false); documentComponent.Document.Title = ValidateSecurity.ValidateString(txtTitle.Text, false); documentComponent.Document.FileType = ExtensionName; documentComponent.Document.Deleted = false; documentComponent.Document.Description = ValidateSecurity.ValidateString(txtDescription.Text, false); documentComponent.Document.Size = FileSize; documentComponent.Document.Permission = "0"; documentComponent.Document.Scope = rdbScope.SelectedValue; documentComponent.Document.Status = "published"; documentComponent.Document.Category = ddCategory.SelectedValue; documentComponent.Document.DocumentObject = Bytes; documentComponent.Document.ExternalReference = SolutionId; documentComponent.Document.Folder = Folder; //Save information of the document if (documentComponent.Save() < 0) { throw new Exception(); } if (ExtensionName.ToUpper() == ".PDF") { GhostscriptWrapper.GeneratePageThumb(pathServerTemp + FileName + ExtensionName, pathServerThumbImages + "pdf-" + documentComponent.Document.DocumentId.ToString() + ".jpg", 1, 150, 150, 300, 300); } } FillDataRepeater(); WizardFile.ActiveStepIndex = 0; } catch (Exception exc) { Exceptions. ProcessModuleLoadException( this, exc); } }
/// <summary> /// Verify that the name and the last name not be written to the database as meta tags /// </summary> /// <param name="user"></param> private void SaveProfile(UserInfo user) { user.Profile.SetProfileProperty("FirstName", ValidateSecurity.ValidateString(txtFirstName.Text, false)); user.Profile.SetProfileProperty("LastName", ValidateSecurity.ValidateString(txtLastName.Text, false)); }
/// <summary> /// Registers the client script with the Page object using a key and a URL, which enables the script to be called from the client. /// </summary> private void RegisterScripts() { if (!IsPostBack) { string OrganizationName = string.Empty; string ProfileOrg = string.Empty; if (Organization != null) { ProfileOrg = NexsoHelper.GetCulturedUrlByTabName("insprofile") + "/in/" + Organization.OrganizationID; OrganizationName = Organization.Name; } Page.ClientScript.RegisterClientScriptInclude( this.GetType(), "countryStateCity", ControlPath + "resources/js/countryStateCity.js"); if (address.Value != string.Empty) { if (string.IsNullOrEmpty(ValidateSecurity.ValidateString(address.Value, false))) { lblMessage.ErrorMessage = Localization.GetString("InvalidFormat", LocalResourceFile); lblMessage.IsValid = false; return; } } string script = "<script>" + "var iconGenOrg" + this.ClientID + "='" + String.Format("{0}Images/organizationbldg.png", PortalSettings.HomeDirectory) + "';" + "var iconGenTestLocation" + this.ClientID + "='" + String.Format("{0}Images/testlocationcrc.png", PortalSettings.HomeDirectory) + "';" + "var profileOrg" + this.ClientID + "='" + ProfileOrg.ToString().ToLower() + "';" + "var orgName" + this.ClientID + "='" + OrganizationName.ToLower() + "';" + "var iconGenIni" + this.ClientID + "='" + String.Format("{0}Images/marker-yellow.png", PortalSettings.HomeDirectory) + "';" + //"var iconGenOrg" + this.ClientID + "='" + String.Format("{0}Images/marker-blue.png", PortalSettings.HomeDirectory) + "';" //+ "var multiSelectIni" + this.ClientID + "=" + MultiSelect.ToString().ToLower() + ";" + "var addressRequiredIni" + this.ClientID + "=" + AddressRequired.ToString().ToLower() + ";" + "var viewInEditModeIni" + this.ClientID + "=" + ViewInEditMode.ToString().ToLower() + ";" + "var addressPlaceHolderIni" + this.ClientID + "='" + GetLabelAddresPlaceHolder() + "';" + "var cscPlaceHolderIni" + this.ClientID + "='" + GetLabelCityStateCountryPlaceHolder() + "';" + "function load" + ClientID + "(){initializemap(document.getElementById('map_canvas" + ClientID + "'), document.getElementById('" + pac_input.ClientID + "'), document.getElementById('" + address.ClientID + "'),document.getElementById('btnGeocode" + ClientID + "'),document.getElementById('" + hdVal1.ClientID + "'),'" + this.ClientID + "');}" + "$(document).ready(function () {Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(load" + ClientID + ");Sys.WebForms.PageRequestManager.getInstance().add_endRequest(load" + ClientID + ");});" + "</script>"; Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "script" + ClientID, script); rfvAddress.Visible = LocationRequired; } }
/// <summary> /// Add new user to the data base /// </summary> /// <returns></returns> private int AddUser() { int totalUsers = 0; UserController.GetUsersByUserName(PortalId, txtEmail.Text, 1, 1, ref totalUsers); if (totalUsers == 0) { var objUser = new DotNetNuke.Entities.Users.UserInfo(); objUser.AffiliateID = Null.NullInteger; objUser.Email = ValidateSecurity.ValidateString(txtEmail.Text, false); objUser.FirstName = ValidateSecurity.ValidateString(txtFirstName.Text, false); objUser.IsSuperUser = false; objUser.LastName = ValidateSecurity.ValidateString(txtLastName.Text, false); objUser.PortalID = PortalController.GetCurrentPortalSettings().PortalId; objUser.Username = ValidateSecurity.ValidateString(txtEmail.Text, false); objUser.DisplayName = ValidateSecurity.ValidateString(txtFirstName.Text, false) + " " + ValidateSecurity.ValidateString(txtLastName.Text, false); objUser.Membership.Password = txtPassword.Text; objUser.Membership.Email = objUser.Email; objUser.Membership.Username = objUser.Username; objUser.Membership.UpdatePassword = false; objUser.Membership.LockedOut = true; if (userId == -1000) { objUser.Membership.Approved = true; //pero impersonation } else { objUser.Membership.Approved = true; //regular creation } DotNetNuke.Security.Membership.UserCreateStatus objCreateStatus = DotNetNuke.Entities.Users.UserController.CreateUser(ref objUser); if (objCreateStatus == DotNetNuke.Security.Membership.UserCreateStatus.Success) { CompleteUserCreation(DotNetNuke.Security.Membership.UserCreateStatus.Success, objUser, true, IsRegister); //objUser.Profile.InitialiseProfile(objUser.PortalID); //objUser.Profile.Country = CountryStateCity1.SelectedCountry; //objUser.Profile.Street = txtAddress.Text; //objUser.Profile.City = CountryStateCity1.SelectedCity; //objUser.Profile.Region = CountryStateCity1.SelectedState; //objUser.Profile.PostalCode = txtPostalCode.Text; //objUser.Profile.Telephone = txtPhone.Text; //objUser.Profile.FirstName = txtFirstName.Text; //objUser.Profile.LastName = txtLastName.Text; ////the agreement is sgned on //objUser.Profile.SetProfileProperty("Agreement", "A001"); //UserController.UpdateUser(objUser.PortalID, objUser); UserPropertyComponent userProperty = new UserPropertyComponent(objUser.UserID); SaveProfile(userProperty.UserProperty); userProperty.Save(); if (!objUser.IsInRole("Registered Users")) { var oDnnRoleController = new RoleController(); RoleInfo oCurrentRole = oDnnRoleController.GetRoleByName(this.PortalId, "Registered Users"); oDnnRoleController.AddUserRole(this.PortalId, objUser.UserID, oCurrentRole.RoleID, System.DateTime.Now.AddDays(-1), DotNetNuke.Common.Utilities.Null.NullDate); } return(objUser.UserID); } else { lblMessage.ErrorMessage = Localization.GetString("ExistingUser", LocalResourceFile); lblMessage.IsValid = false; } } else { lblMessage.ErrorMessage = Localization.GetString("ExistingUser", LocalResourceFile); lblMessage.IsValid = false; } return(-1); }
/// <summary> /// Save and update information of the organization /// </summary> /// <returns>status of save</returns> public bool SaveData() { try { NexsoProDAL.MIFNEXSOEntities mifnexsoEntities = new MIFNEXSOEntities(); mifnexsoEntities.Connection.Open(); var trans = mifnexsoEntities.Connection.BeginTransaction(); try { if (organizationComponent.Organization.OrganizationID == Guid.Empty) { organizationComponent.Organization.Created = DateTime.Now; organizationComponent.Organization.Updated = organizationComponent.Organization.Created.GetValueOrDefault(DateTime.Now); } else { organizationComponent.Organization.Updated = DateTime.Now; } organizationComponent.Organization.Name = ValidateSecurity.ValidateString(txtInstitutionName.Text, false); organizationComponent.Organization.Description = ValidateSecurity.ValidateString(txtDescription.Text, false); organizationComponent.Organization.ZipCode = CountryStateCityEditMode.SelectedPostalCode; organizationComponent.Organization.Phone = ValidateSecurity.ValidateString(txtPhone.Text, false); organizationComponent.Organization.Skype = ValidateSecurity.ValidateString(txtSkype.Text, false); organizationComponent.Organization.Twitter = ValidateSecurity.ValidateString(txtTwitter.Text, false); organizationComponent.Organization.Facebook = ValidateSecurity.ValidateString(txtFacebook.Text, false); organizationComponent.Organization.GooglePlus = ValidateSecurity.ValidateString(txtGoogle.Text, false); organizationComponent.Organization.LinkedIn = ValidateSecurity.ValidateString(txtLinkedIn.Text, false); organizationComponent.Organization.Address = ValidateSecurity.ValidateString(CountryStateCityEditMode.SelectedAddress, false); organizationComponent.Organization.Country = CountryStateCityEditMode.SelectedCountry; organizationComponent.Organization.Region = CountryStateCityEditMode.SelectedState; organizationComponent.Organization.City = CountryStateCityEditMode.SelectedCity; organizationComponent.Organization.Latitude = CountryStateCityEditMode.SelectedLatitude; organizationComponent.Organization.Longitude = CountryStateCityEditMode.SelectedLongitude; CountryStateCityViewMode.SelectedAddress = ValidateSecurity.ValidateString(CountryStateCityEditMode.SelectedAddress, false); CountryStateCityViewMode.SelectedCountry = CountryStateCityEditMode.SelectedCountry; CountryStateCityViewMode.SelectedState = CountryStateCityEditMode.SelectedState; CountryStateCityViewMode.SelectedCity = CountryStateCityEditMode.SelectedCity; CountryStateCityViewMode.SelectedLatitude = CountryStateCityEditMode.SelectedLatitude; CountryStateCityViewMode.SelectedLongitude = CountryStateCityEditMode.SelectedLongitude; CountryStateCityViewMode.SelectedPostalCode = CountryStateCityEditMode.SelectedPostalCode; CountryStateCityViewMode.UpdateMap(); organizationComponent.Organization.Email = txtEmail.Text; string newImg = Path.GetFileName(imgInstitution.ImageUrl); if (organizationComponent.Organization.Logo != newImg && newImg.ToUpper() != "NOIMAGE.PNG") { File.Move(Server.MapPath(PortalSettings.HomeDirectory + "ModIma/TempImages/" + newImg), Server.MapPath(PortalSettings.HomeDirectory + "ModIma/Images/" + newImg)); imgInstitution.ImageUrl = PortalSettings.HomeDirectory + "ModIma/Images/" + newImg; organizationComponent.Organization.Logo = newImg; } if (organizationComponent.Save() > 0) { if (organizationId == Guid.Empty) { UserInfo userInfo = UserController.Instance.GetCurrentUserInfo(); organizationId = organizationComponent.Organization.OrganizationID; UserOrganizationComponent userOrganizationComponent = new UserOrganizationComponent( userInfo.UserID, organizationId, 1); userOrganizationComponent.ChangeContext(ref mifnexsoEntities); if (userOrganizationComponent.Save() < 0) { throw new Exception(); } } } else { throw new Exception(); } mifnexsoEntities.AcceptAllChanges(); trans.Commit(); mifnexsoEntities.Dispose(); organizationId = organizationComponent.Organization.OrganizationID; return(true); } catch (Exception exc) { trans.Rollback(); mifnexsoEntities.Dispose(); Exceptions. ProcessModuleLoadException( this, exc); return(false); } } catch (Exception exc) { Exceptions. ProcessModuleLoadException( this, exc); return(false); } }
/// <summary> /// Add user to Nexso Database (userproperties), DotNetNuke Database(dnn_user) and roles to user /// </summary> /// <returns></returns> private int AddUser() { try { var eventlo = new DotNetNuke.Services.Log.EventLog.EventLogController(); int totalUsers = 0; UserController.GetUsersByUserName(PortalId, txtEmail.Text, 1, 1, ref totalUsers); if (totalUsers == 0) { var objUser = new DotNetNuke.Entities.Users.UserInfo(); objUser.AffiliateID = Null.NullInteger; objUser.Email = ValidateSecurity.ValidateString(txtEmail.Text, false); objUser.FirstName = ValidateSecurity.ValidateString(txtFirstName.Text, false); objUser.IsSuperUser = false; objUser.LastName = ValidateSecurity.ValidateString(txtLastName.Text, false); objUser.PortalID = PortalController.GetCurrentPortalSettings().PortalId; objUser.Username = ValidateSecurity.ValidateString(txtEmail.Text, false); objUser.DisplayName = ValidateSecurity.ValidateString(txtFirstName.Text, false) + " " + ValidateSecurity.ValidateString(txtLastName.Text, false); objUser.Membership.Password = txtPassword.Text; objUser.Membership.Email = objUser.Email; objUser.Membership.Username = objUser.Username; objUser.Membership.UpdatePassword = false; objUser.PortalID = PortalId; objUser.Membership.LockedOut = true; if (userId == -1000) { objUser.Membership.Approved = true; //pero impersonation } else { objUser.Membership.Approved = true; //regular creation } DotNetNuke.Security.Membership.UserCreateStatus objCreateStatus = DotNetNuke.Entities.Users.UserController.CreateUser(ref objUser); if (objCreateStatus == DotNetNuke.Security.Membership.UserCreateStatus.Success) { if (objUser != null) { CompleteUserCreation(DotNetNuke.Security.Membership.UserCreateStatus.Success, objUser, true, IsRegister); UserInfo myDnnUser = objUser; myDnnUser.Profile.InitialiseProfile(myDnnUser.PortalID); SaveProfile(myDnnUser); UserController.UpdateUser(myDnnUser.PortalID, myDnnUser); UserPropertyComponent userProperty = new UserPropertyComponent(objUser.UserID); if (userProperty.UserProperty != null) { currentUser = objUser; var ret = SaveProfile(userProperty.UserProperty); if (ret >= 0) { userProperty.Save(); } if (!objUser.IsInRole("Registered Users")) { var oDnnRoleController = new RoleController(); RoleInfo oCurrentRole = oDnnRoleController.GetRoleByName(this.PortalId, "Registered Users"); oDnnRoleController.AddUserRole(this.PortalId, objUser.UserID, oCurrentRole.RoleID, System.DateTime.Now.AddDays(-1), DotNetNuke.Common.Utilities.Null.NullDate); } if (!objUser.IsInRole("NexsoUser")) { var oDnnRoleController = new RoleController(); RoleInfo oCurrentRole = oDnnRoleController.GetRoleByName(this.PortalId, "NexsoUser"); oDnnRoleController.AddUserRole(this.PortalId, objUser.UserID, oCurrentRole.RoleID, System.DateTime.Now.AddDays(-1), DotNetNuke.Common.Utilities.Null.NullDate); } return(objUser.UserID); } else { eventlo.AddLog("NEXSO Object Null", "Trace NEXSO", PortalSettings, -1, DotNetNuke.Services.Log.EventLog.EventLogController.EventLogType.ADMIN_ALERT); } } else { eventlo.AddLog("Object null cration nexso", "Trace NEXSO", PortalSettings, -1, DotNetNuke.Services.Log.EventLog.EventLogController.EventLogType.ADMIN_ALERT); } } else { //lblMessage.ErrorMessage = Localization.GetString("ExistingUser", // LocalResourceFile); //lblMessage.IsValid = false; } } else { //lblMessage.ErrorMessage = Localization.GetString("ExistingUser", // LocalResourceFile); //lblMessage.IsValid = false; } } catch (Exception exc) //Module failed to load { Exceptions. ProcessModuleLoadException( this, exc); } return(-1); }