Ejemplo n.º 1
0
    /// <summary>
    /// Get from database all conversation related of the user
    /// </summary>
    private void BindData()
    {
        var listMessagesFrom       = MessageComponent.GetMessagesFrom(UserInfo.UserID).ToList();
        var usersTo                = (from s in listMessagesFrom select s.ToUserId).Distinct();
        var listMessagesTo         = MessageComponent.GetMessagesTo(UserInfo.UserID).ToList();
        var usersFrom              = (from s in listMessagesTo select s.FromUserId).Distinct();
        var ListUsersConversations = usersFrom.Concat(usersTo).Distinct();
        List <UserProperty> list   = new List <UserProperty>();

        foreach (int id in ListUsersConversations)
        {
            UserPropertyComponent userProperty = new UserPropertyComponent(id);
            list.Add(userProperty.UserProperty);
        }
        if (list.Count <= 0)
        {
            noMessageContainer.Visible = true;
        }
        else
        {
            noMessageContainer.Visible = false;
        }

        rpConversations.DataSource = list;
        rpConversations.DataBind();
    }
Ejemplo n.º 2
0
        public static List <UserProfileModel> ParseUserProfile(List <UserNotificationConnection> userNotificationConnection)
        {
            List <UserProfileModel> listUserProfileModel = new List <UserProfileModel>();

            if (userNotificationConnection != null)
            {
                foreach (var item in userNotificationConnection)
                {
                    UserPropertyComponent user_ = new UserPropertyComponent(item.UserId);


                    listUserProfileModel.Add(new UserProfileModel()
                    {
                        UserId           = user_.UserProperty.UserId,
                        LastName         = user_.UserProperty.LastName,
                        FirstName        = user_.UserProperty.FirstName,
                        Bio              = user_.UserProperty.Bio,
                        ProfilePicture   = user_.UserProperty.ProfilePicture.GetValueOrDefault(Guid.Empty),
                        BannerPicture    = user_.UserProperty.BannerPicture.GetValueOrDefault(Guid.Empty),
                        NotificationRole = item.Rol,
                        NotificationTag  = item.Tag
                    });
                }
            }
            return(listUserProfileModel);
        }
Ejemplo n.º 3
0
        public string GetStatistics(string ChallengeReferences = "")
        {
            List <string> challengeReferences = new List <string>();

            if (!string.IsNullOrEmpty(ChallengeReferences))
            {
                string references = Regex.Replace(ChallengeReferences, @"\s+", "");
                references = !string.IsNullOrEmpty(references) ? references : "";
                if (references.Contains(","))
                {
                    challengeReferences = references.Split(',').ToList();
                }
                else
                {
                    challengeReferences.Add(references);
                }
            }
            else
            {
                challengeReferences.Add("");
            }

            Dictionary <string, string> result = new Dictionary <string, string>();
            var users                 = UserPropertyComponent.GetUsersStatistics();
            var totalUsers            = users.Count();
            var getSolutionStatistics = SolutionComponent.GetSolutionStatistics();
            var totalSolutions        = getSolutionStatistics.Count();
            var startupsSolutions     = getSolutionStatistics.Where(x => x.ChallengeReference == "DEMAND_SOLUTIONS2015" || x.ChallengeReference == "EconomiaNaranja").Count();

            result.Add("Users", totalUsers.ToString());
            result.Add("Solutions", totalSolutions.ToString());
            result.Add("Startups", startupsSolutions.ToString());
            return(JsonConvert.SerializeObject(result));
        }
Ejemplo n.º 4
0
        public HttpResponseMessage RemoveBannerImage(Guid organizationId)
        {
            try
            {
                var portal       = PortalController.GetCurrentPortalSettings();
                var user         = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo();
                var userProperty = new UserPropertyComponent(user.UserID);

                var organization = new OrganizationComponent(organizationId);
                if (user.IsInRole("Administrators") || organization.Organization.CreatedBy == user.UserID)
                {
                    Helper.HelperMethods.DeleteFiles(portal.HomeDirectoryMapPath + "OrgImages\\HeaderImages", "*" + organization.Organization.OrganizationID.ToString() + "*");
                    return(Request.CreateResponse(HttpStatusCode.Accepted, "Successful Delete"));
                }
                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));
            }
        }
Ejemplo n.º 5
0
        public HttpResponseMessage RemoveBannerImage()
        {
            try
            {
                var portal       = PortalController.GetCurrentPortalSettings();
                var user         = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo();
                var userProperty = new UserPropertyComponent(user.UserID);
                if (userProperty.UserProperty.BannerPicture != null)
                {
                    Helper.HelperMethods.DeleteFiles(portal.HomeDirectoryMapPath + "ModIma\\UserHeaderImages", "*" + userProperty.UserProperty.BannerPicture.ToString() + ".png");

                    userProperty.UserProperty.BannerPicture = null;
                    if (userProperty.Save() > 0)
                    {
                        return(Request.CreateResponse(HttpStatusCode.Accepted, "Successful Delete"));
                    }
                    throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError));
                }
                return(Request.CreateResponse(HttpStatusCode.NotModified, "Nothing to Delete"));
            }
            catch (HttpResponseException e)
            {
                throw e;
            }
            catch (Exception ee)
            {
                DotNetNuke.Services.Exceptions.Exceptions.LogException(ee);
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError));
            }
        }
Ejemplo n.º 6
0
    /// <summary>
    /// Load Judge and solutions per judge
    /// </summary>
    public void DataBind()
    {
        var list = ChallengeJudgeComponent.GetChallengeJudges(challenge);

        List <JudgeChallenge> listJudgesChallenge = new List <JudgeChallenge>();

        foreach (var item in list)
        {
            var userProfile = new UserPropertyComponent(item.UserId);

            listJudgesChallenge.Add(new JudgeChallenge
            {
                ChallengeJudgeId  = item.ChallengeJudgeId,
                UserId            = Convert.ToInt32(userProfile.UserProperty.UserId),
                FirstName         = userProfile.UserProperty.FirstName + " " + userProfile.UserProperty.LastName,
                Email             = userProfile.UserProperty.email,
                PermisionLevel    = item.PermisionLevel,
                FromDate          = Convert.ToDateTime(item.FromDate),
                ToDate            = Convert.ToDateTime(item.ToDate),
                AssignedSolutions = GetAssignedSolutions(item.JudgesAssignations.OrderBy(x => x.Solution.Title).ToList())
            });
        }
        if (listJudgesChallenge.Count() == 0)
        {
            btnExport.Visible = false;
        }

        grdManageJudge.DataSource = listJudgesChallenge;
    }
Ejemplo n.º 7
0
        public UserProfileModel GetProfile(int?userId = null, string language = "en-US")
        {
            try
            {
                var currentUser = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo();
                if (currentUser.IsInRole("Registered Users"))
                {
                    CultureInfo culture = new CultureInfo(language);

                    int userIdValid = userId.GetValueOrDefault(currentUser.UserID);
                    if (userIdValid == -1)
                    {
                        return(new UserProfileModel());
                    }
                    var portal = PortalController.GetCurrentPortalSettings();
                    UserPropertyComponent userPropertyComponent = new UserPropertyComponent(userIdValid);

                    if (currentUser.IsInRole("Administrators") || currentUser.UserID == userIdValid)
                    {
                        return(Helper.HelperMethods.ParseUserProfile(userPropertyComponent.UserProperty, "Owner", culture));
                    }
                    return(Helper.HelperMethods.ParseUserProfile(userPropertyComponent.UserProperty, "", culture));
                }
                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));
            }
        }
Ejemplo n.º 8
0
    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");
            }
        }
    }
Ejemplo n.º 9
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);
        }
    }
Ejemplo n.º 10
0
        public List <SolutionCommentsModel> GetList(Guid solutionId, int rows = 10, int page = 0)
        {
            try
            {
                var portal      = PortalController.GetCurrentPortalSettings();
                var currentUser = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo();


                var result     = SolutionCommentComponent.GetCommentsPerSolution(solutionId).OrderByDescending(p => p.CreatedDate).ToList();
                var totalCount = result.Count();
                var totalPages = (int)Math.Ceiling((double)totalCount / rows);


                var prevLink = page > 0 ? string.Format("/Comment/getlist?rows={0}&page={1}", rows, page - 1) : "";
                var nextLink = page < totalPages - 1 ? string.Format("/Comment/getlist?rows={0}&page={1}", rows, page + 1) : "";
                List <SolutionCommentsModel> SolutionCommentsModel = new List <SolutionCommentsModel>();

                foreach (var resultTmp in result.Skip(rows * page).Take(rows).ToList())
                {
                    var user = new UserPropertyComponent(resultTmp.UserId.GetValueOrDefault(-1));
                    SolutionCommentsModel.Add(new SolutionCommentsModel()
                    {
                        CommentId   = resultTmp.Comment_Id,
                        SolutionId  = (Guid)resultTmp.SolutionId,
                        UserId      = Convert.ToInt32(resultTmp.UserId),
                        FirstName   = user.UserProperty.FirstName,
                        LastName    = user.UserProperty.LastName,
                        Comment     = resultTmp.Comment,
                        CreatedDate = Convert.ToDateTime(resultTmp.CreatedDate),
                        Publish     = Convert.ToBoolean(resultTmp.Publish),
                        Scope       = resultTmp.Scope
                    });
                }

                var paginationHeader = new
                {
                    TotalCount   = totalCount,
                    TotalPages   = totalPages,
                    PrevPageLink = prevLink,
                    NextPageLink = nextLink
                };

                System.Web.HttpContext.Current.Response.Headers.Add("X-Pagination",
                                                                    Newtonsoft.Json.JsonConvert.SerializeObject(paginationHeader));

                return(SolutionCommentsModel);
            }
            catch (HttpResponseException e)
            {
                throw e;
            }
            catch (Exception ee)
            {
                DotNetNuke.Services.Exceptions.Exceptions.LogException(ee);
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError));
            }
        }
Ejemplo n.º 11
0
    /// <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();
            }
        }
    }
Ejemplo n.º 12
0
        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));
            }
        }
Ejemplo n.º 13
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));
            }
        }
Ejemplo n.º 14
0
        public static void SendCommentNotificationEmails(SolutionCommentComponent solutionCommentComponent, PortalSettings portalSettings, UserInfo currentUser)
        {
            ResourceManager Localization = new ResourceManager("NexsoServices.App_LocalResources.Resource",
                                                               Assembly.GetExecutingAssembly());
            List <int> userIds = new List <int>();

            foreach (SolutionComment solutionComment in solutionCommentComponent.SolutionComment.Solution.SolutionComments)
            {
                if (!userIds.Contains(solutionComment.UserId.GetValueOrDefault(-1)))
                {
                    userIds.Add(solutionComment.UserId.GetValueOrDefault(-1));
                }
            }
            if (solutionCommentComponent.SolutionComment.Solution.CreatedUserId.GetValueOrDefault(-1) != -1)
            {
                userIds.Add(solutionCommentComponent.SolutionComment.Solution.CreatedUserId.GetValueOrDefault(-1));
            }
            foreach (int userids in userIds)
            {
                UserInfo user = DotNetNuke.Entities.Users.UserController.GetUserById(portalSettings.PortalId, userids);
                UserPropertyComponent property = new UserPropertyComponent(userids);
                if (currentUser.UserID != user.UserID)
                {
                    CultureInfo language = new CultureInfo(HelperMethods.GetUserLanguage(property.UserProperty.Language.GetValueOrDefault(1)));
                    DotNetNuke.Services.Mail.Mail.SendEmail("*****@*****.**",
                                                            user.Email,
                                                            string.Format(
                                                                Localization.GetString("MessageTitleComment", language),
                                                                currentUser.FirstName + " " + currentUser.LastName,
                                                                solutionCommentComponent.SolutionComment.Solution.Title),
                                                            Localization.GetString("MessageBodyComment", language).Replace(
                                                                "{COMMENT:Body}", solutionCommentComponent.SolutionComment.Comment).Replace(
                                                                "{SOLUTION:Title}", solutionCommentComponent.SolutionComment.Solution.Title).Replace(
                                                                "{SOLUTION:PageLink}", NexsoHelper.GetCulturedUrlByTabName("solprofile", 7, language.Name) +
                                                                "/sl/" + solutionCommentComponent.SolutionComment.Solution.SolutionId.ToString())
                                                            );
                }
            }
            CultureInfo langua = new CultureInfo("en-US");

            DotNetNuke.Services.Mail.Mail.SendEmail("*****@*****.**",
                                                    "[email protected],[email protected], [email protected],[email protected],[email protected]", "NOTIFICATION: " +
                                                    string.Format(
                                                        Localization.GetString("MessageTitleComment", langua),
                                                        currentUser.FirstName + " " + currentUser.LastName, solutionCommentComponent.SolutionComment
                                                        .Solution.Title),
                                                    Localization.GetString("MessageBodyComment", langua).Replace(
                                                        "{COMMENT:Body}", solutionCommentComponent.SolutionComment.Comment).Replace(
                                                        "{SOLUTION:Title}", solutionCommentComponent.SolutionComment.Solution.Title).Replace(
                                                        "{SOLUTION:PageLink}", NexsoHelper.GetCulturedUrlByTabName("solprofile", 7, langua.Name) +
                                                        "/sl/" + solutionCommentComponent.SolutionComment.Solution.SolutionId.ToString())
                                                    );
        }
Ejemplo n.º 15
0
        public async Task <FileResultModel> UploadUserImage( )
        {
            try
            {
                var portal      = PortalController.GetCurrentPortalSettings();
                var currentUser = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo();
                var tempId      = Helper.HelperMethods.GenerateHash(currentUser.UserID).ToString();
                if (currentUser.IsInRole("Registered Users"))
                {
                    string ServerUploadFolder    = portal.HomeDirectoryMapPath + "ModIma\\TempUserImages";
                    var    streamProvider        = new MultipartFormDataStreamProvider(ServerUploadFolder);
                    string ImageProcessingFolfer = "";
                    await Request.Content.ReadAsMultipartAsync(streamProvider);

                    string userId = streamProvider.FormData["userId"];
                    var    user   = new UserPropertyComponent(Convert.ToInt32(userId));
                    if (currentUser.IsInRole("Administrators") || user.UserProperty.UserId == currentUser.UserID)
                    {
                        Helper.HelperMethods.DeleteFiles(portal.HomeDirectoryMapPath + "ModIma\\TempUserImages", tempId + "*");
                        var      file              = streamProvider.FileData.First();
                        string   originalFileName  = file.Headers.ContentDisposition.FileName.Replace("\"", "");
                        string   originalExtension = Path.GetExtension(originalFileName);
                        FileInfo fi = new FileInfo(file.LocalFileName);
                        ImageProcessingFolfer = Path.Combine(portal.HomeDirectoryMapPath + "ModIma\\TempUserImages", tempId + originalExtension);
                        var size = fi.Length;
                        fi.CopyTo(ImageProcessingFolfer, true);
                        fi.Delete();
                        return(new FileResultModel()
                        {
                            Extension = originalExtension,
                            Filename = tempId,
                            Size = size,
                            Link = "/ModIma/TempUserImages/" + tempId + originalExtension
                        });
                    }
                    throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.Unauthorized));
                }
                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));
            }
        }
Ejemplo n.º 16
0
    /// <summary>
    /// Show message with all data to  the user
    /// </summary>
    /// <param name="list"></param>
    /// <returns></returns>
    private List <MessageUser> FillMessages(List <Message> list)
    {
        List <MessageUser> ListMessageUser = new List <MessageUser>();

        foreach (var item in list)
        {
            UserPropertyComponent userPropertyComponent = new UserPropertyComponent(Convert.ToInt32(item.FromUserId));
            ListMessageUser.Add(new MessageUser
            {
                IdUser      = userPropertyComponent.UserProperty.UserId,
                MessageId   = (Guid)(item.MessageId),
                FirstName   = userPropertyComponent.UserProperty.FirstName,
                Message1    = item.Message1,
                DateCreated = Convert.ToDateTime(item.DateCreated),
                DateRead    = Convert.ToDateTime(item.DateRead)
            });
        }
        return(ListMessageUser);
    }
Ejemplo n.º 17
0
        public static async Task SendEmailToUser(string subjectTemplate, string bodyTemplate, UserInfo userTo, CultureInfo culture, string messageSubject, string messageBody)
        {
            await Task.Run(() =>
            {
                ResourceManager Localization = new ResourceManager("NexsoServices.App_LocalResources.Resource",
                                                                   Assembly.GetExecutingAssembly());

                UserPropertyComponent currentUser = new UserPropertyComponent(userTo.UserID);
                DotNetNuke.Services.Mail.Mail.SendEmail("*****@*****.**",
                                                        userTo.Email,
                                                        string.Format(
                                                            Localization.GetString(subjectTemplate, culture),
                                                            currentUser.UserProperty.FirstName + " " + currentUser.UserProperty.LastName
                                                            ),
                                                        Localization.GetString("MessageBodyMessage", culture).Replace(
                                                            "{MESSAGE:Body}", messageBody).Replace(
                                                            "{MESSAGE:ViewLink}", NexsoHelper.GetCulturedUrlByTabName("MyMessages", 7, culture.Name))

                                                        );
            }
                           );
        }
Ejemplo n.º 18
0
    /// <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);
    }
Ejemplo n.º 19
0
    /// <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);
        }
    }
Ejemplo n.º 20
0
        public List <FileResultModel> CropSaveProfile([FromBody] CropImage body)
        {
            try
            {
                var filename      = body.Filename;
                var yCropPosition = body.yCrop;
                var portal        = PortalController.GetCurrentPortalSettings();
                var user          = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo();
                var userProperty  = new UserPropertyComponent(user.UserID);
                if (user.IsInRole("Registered Users"))
                {
                    if (userProperty.UserProperty.ProfilePicture.GetValueOrDefault(Guid.Empty) == Guid.Empty)
                    {
                        userProperty.UserProperty.ProfilePicture = Guid.NewGuid();
                        if (userProperty.Save() <= 0)
                        {
                            throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError));
                        }
                    }

                    var fileResultModelList = new List <FileResultModel>();
                    yCropPosition = yCropPosition * -1;
                    string       extension             = ".png";//Path.GetExtension(filename);
                    string       fileRootName          = userProperty.UserProperty.ProfilePicture.ToString();
                    MemoryStream outStream             = new MemoryStream();
                    long         tmpSize               = 0;
                    string       ImageProcessingFolfer = Path.Combine(portal.HomeDirectoryMapPath + "ModIma\\TempUserImages", filename);

                    ImageFactory imageFactory = new ImageFactory(preserveExifData: true);
                    imageFactory.Load(ImageProcessingFolfer);
                    imageFactory.Save(outStream);// ();
                    tmpSize = outStream.Length;
                    Helper.HelperMethods.SaveImage(ref outStream, Path.Combine(portal.HomeDirectoryMapPath + "ModIma\\UserProfileImages", fileRootName + extension));
                    fileResultModelList.Add(new FileResultModel()
                    {
                        Extension   = extension,
                        Filename    = fileRootName,
                        Link        = portal.HomeDirectory + "ModIma/UserProfileImages/" + fileRootName + extension,
                        Description = "Original Image",
                        Size        = tmpSize
                    });
                    var   image           = imageFactory.Image;
                    var   originalHeight  = image.Size.Height;
                    var   originalWidth   = image.Size.Width;
                    float referenceHeight = 512;
                    float referenceWidth  = 512;
                    float WidthFactor     = 1;
                    WidthFactor = referenceWidth / originalWidth;
                    float HeightFactor = 1;
                    HeightFactor = referenceHeight / originalHeight;
                    float standardHeight = 0;
                    standardHeight = originalHeight * WidthFactor;
                    float     cutTop        = Convert.ToSingle(yCropPosition) / WidthFactor;
                    float     cutBotom      = (standardHeight - referenceHeight - cutTop) / WidthFactor;
                    Size      sizeCrop      = new Size(Convert.ToInt32(referenceWidth / WidthFactor), Convert.ToInt32(referenceHeight / WidthFactor));
                    Point     pointCrop     = new Point(0, Convert.ToInt32(cutTop));
                    Rectangle rectangleCrop = new Rectangle(pointCrop, sizeCrop);
                    imageFactory.Crop(rectangleCrop);
                    System.Drawing.Size sizeBig = new System.Drawing.Size(Convert.ToInt32(referenceWidth), Convert.ToInt32(referenceHeight));
                    imageFactory.Resize(sizeBig);
                    outStream = new MemoryStream();
                    imageFactory.Save(outStream);
                    tmpSize = outStream.Length;
                    Helper.HelperMethods.SaveImage(ref outStream, Path.Combine(portal.HomeDirectoryMapPath + "ModIma\\UserProfileImages", "cropBig" + fileRootName + extension));
                    fileResultModelList.Add(new FileResultModel()
                    {
                        Extension   = extension,
                        Filename    = "cropBig" + fileRootName,
                        Link        = portal.HomeDirectory + "ModIma/UserProfileImages/" + "cropBig" + fileRootName + extension,
                        Description = "Crop Big",
                        Size        = tmpSize
                    });
                    System.Drawing.Size sizeSmall = new System.Drawing.Size(Convert.ToInt32(300), Convert.ToInt32(300));
                    imageFactory.Resize(sizeSmall);
                    outStream = new MemoryStream();
                    imageFactory.Save(outStream);
                    tmpSize = outStream.Length;
                    Helper.HelperMethods.SaveImage(ref outStream, Path.Combine(portal.HomeDirectoryMapPath + "ModIma\\UserProfileImages", "cropThumb" + fileRootName + extension));
                    fileResultModelList.Add(new FileResultModel()
                    {
                        Extension   = extension,
                        Filename    = "cropThumb" + fileRootName,
                        Link        = portal.HomeDirectory + "ModIma/UserProfileImages/" + "cropThumb" + fileRootName + extension,
                        Description = "Crop Thumbnail",
                        Size        = tmpSize
                    });
                    Helper.HelperMethods.DeleteFiles(portal.HomeDirectoryMapPath + "ModIma\\TempUserImages", filename);
                    return(fileResultModelList);
                }
                else
                {
                    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));
            }
        }
Ejemplo n.º 21
0
    /// <summary>
    /// Load Location and social networks of the user
    /// </summary>
    /// <param name="userId"></param>
    public void MapPropToPage(int userId)
    {
        UserPropertyComponent userPropertyComponent = new UserPropertyComponent(userId);

        if (!string.IsNullOrEmpty(userPropertyComponent.UserProperty.Agreement))
        {
            chkTerms.Checked = true;
        }
        else
        {
            chkTerms.Checked = false;
        }
        CountryStateCityEditMode.SelectedCountry   = userPropertyComponent.UserProperty.Country;
        CountryStateCityEditMode.SelectedState     = userPropertyComponent.UserProperty.Region;
        CountryStateCityEditMode.SelectedCity      = userPropertyComponent.UserProperty.City;
        CountryStateCityEditMode.SelectedLatitude  = userPropertyComponent.UserProperty.Latitude.GetValueOrDefault(0);
        CountryStateCityEditMode.SelectedLongitude = userPropertyComponent.UserProperty.Longitude.GetValueOrDefault(0);
        CountryStateCityEditMode.SelectedAddress   = userPropertyComponent.UserProperty.Address;
        CountryStateCityViewMode.SelectedCountry   = userPropertyComponent.UserProperty.Country;
        CountryStateCityViewMode.SelectedState     = userPropertyComponent.UserProperty.Region;
        CountryStateCityViewMode.SelectedCity      = userPropertyComponent.UserProperty.City;
        CountryStateCityViewMode.SelectedLatitude  = userPropertyComponent.UserProperty.Latitude.GetValueOrDefault(0);
        CountryStateCityViewMode.SelectedLongitude = userPropertyComponent.UserProperty.Longitude.GetValueOrDefault(0);
        CountryStateCityViewMode.SelectedAddress   = userPropertyComponent.UserProperty.Address;
        txtPhone.Text              = userPropertyComponent.UserProperty.Telephone;
        lblPhoneTxt.Text           = userPropertyComponent.UserProperty.Telephone;
        txtSkype.Text              = userPropertyComponent.UserProperty.SkypeName;
        lblSkype.Text              = userPropertyComponent.UserProperty.SkypeName;
        txtTwitter.Text            = userPropertyComponent.UserProperty.Twitter;
        lblAddress.Text            = userPropertyComponent.UserProperty.Address;
        lblCity.Text               = CountryStateCityEditMode.SelectedCityName;
        lblState.Text              = CountryStateCityEditMode.SelectedStateName;
        lblCountry.Text            = CountryStateCityEditMode.SelectedCountryName;
        ddlLanguage.SelectedValue  = userPropertyComponent.UserProperty.Language.GetValueOrDefault(0).ToString();
        ddlWhoareYou.SelectedValue = userPropertyComponent.UserProperty.CustomerType.GetValueOrDefault(0).ToString();
        ddlSource.SelectedValue    = userPropertyComponent.UserProperty.NexsoEnrolment.GetValueOrDefault(0).ToString();
        chkNotifications.Checked   =
            Convert.ToBoolean(userPropertyComponent.UserProperty.AllowNexsoNotifications.GetValueOrDefault(0));
        SetChkControl("Theme", chkTheme);
        SetChkControl("Beneficiaries", chkBeneficiaries);
        SetChkControl("Sector", chkSector);

        if (userPropertyComponent.UserProperty.Twitter != string.Empty)
        {
            hlTwitter.NavigateUrl = @"http://www.twitter.com/" + userPropertyComponent.UserProperty.Twitter;
            hlTwitter.ToolTip     = userPropertyComponent.UserProperty.Twitter;
            hlTwitter.Visible     = true;
        }
        else
        {
            hlTwitter.Visible = false;
        }
        //lblTwitter.Text = value;

        if (userPropertyComponent.UserProperty.FaceBook != string.Empty)
        {
            hlFacebook.NavigateUrl = @"http://www.facebook.com/" + userPropertyComponent.UserProperty.FaceBook;
            hlFacebook.ToolTip     = userPropertyComponent.UserProperty.FaceBook;
            hlFacebook.Visible     = true;
        }
        else
        {
            hlFacebook.Visible = false;
        }
        //lblFacebook.Text = value;
        if (userPropertyComponent.UserProperty.Google != string.Empty)
        {
            hlGoogle.NavigateUrl = @"http://plus.google.com/" + userPropertyComponent.UserProperty.Google;
            hlGoogle.ToolTip     = userPropertyComponent.UserProperty.Google;
            hlGoogle.Visible     = true;
        }
        else
        {
            hlGoogle.Visible = false;
        }
        //lblGoogle.Text = value;

        if (userPropertyComponent.UserProperty.LinkedIn != string.Empty)
        {
            hlLinkedin.NavigateUrl = @"http://www.linkedin.com/" + userPropertyComponent.UserProperty.LinkedIn;
            hlLinkedin.ToolTip     = userPropertyComponent.UserProperty.LinkedIn;
            hlLinkedin.Visible     = true;
        }
        else
        {
            hlLinkedin.Visible = false;
        }
    }
Ejemplo n.º 22
0
    /// <summary>
    /// Changes the view to edit mode
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnEditProfile_Click1(object sender, EventArgs e)
    {
        if (btnEditProfile.CommandArgument == "EDIT")
        {
            PopulateControls();
            setControl("EDIT");
        }
        else if (btnEditProfile.CommandArgument == "CREATE")
        {
            int userIdTmp = AddUser();

            if (userId == -1000)
            {
                userId = userIdTmp;
                SaveChkControl("Theme", chkTheme);
                Response.Redirect(NexsoHelper.GetCulturedUrlByTabName("My Nexso") + "/ui/" + userId,
                                  false);
            }
            else if (userIdTmp >= 0)
            {
                userId = userIdTmp;
                SaveChkControl("Theme", chkTheme);
                Response.Redirect(NexsoHelper.GetCulturedUrlByTabName("Discover solutions"),
                                  false);
            }
        }
        else if (btnEditProfile.CommandArgument == "EDITING")
        {
            btnEditProfile.CommandArgument = "EDIT";
            btnEditProfile.Text            = Localization.GetString("EditProfile",
                                                                    LocalResourceFile);
            UserPropertyComponent userProperty = new UserPropertyComponent(userId);
            UserInfo myDnnUser = currentUser;
            myDnnUser.Profile.InitialiseProfile(myDnnUser.PortalID);
            SaveProfile(myDnnUser);
            UserController.UpdateUser(myDnnUser.PortalID, myDnnUser);
            var sw = SaveProfile(userProperty.UserProperty);
            CountryStateCityViewMode.SelectedAddress    = CountryStateCityEditMode.SelectedAddress;
            CountryStateCityViewMode.SelectedCity       = CountryStateCityEditMode.SelectedCity;
            CountryStateCityViewMode.SelectedState      = CountryStateCityEditMode.SelectedState;
            CountryStateCityViewMode.SelectedCountry    = CountryStateCityEditMode.SelectedCountry;
            CountryStateCityViewMode.SelectedPostalCode = CountryStateCityEditMode.SelectedPostalCode;
            CountryStateCityViewMode.SelectedLongitude  = CountryStateCityEditMode.SelectedLongitude;
            CountryStateCityViewMode.SelectedLatitude   = CountryStateCityEditMode.SelectedLatitude;
            CountryStateCityViewMode.UpdateMap();
            if (sw >= 0)
            {
                userProperty.Save();
            }
            else
            {
                return;
            }
            SaveChkControl("Theme", chkTheme);
            SaveChkControl("Beneficiaries", chkBeneficiaries);
            SaveChkControl("Sector", chkSector);

            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);
            }

            PopulateControls();
            setControl("VIEW");
        }
    }
Ejemplo n.º 23
0
    /// <summary>
    /// Load information to the grid. This method allows you to filter and sort the grid by various parameters (fisrtname, email, permissions, todate, fromdate).
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {
        if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
        {
            GridEditFormItem edititem = (GridEditFormItem)e.Item;

            RadComboBox rdEmail = (RadComboBox)edititem.FindControl("rdEmail");

            MIFNEXSOEntities nx = new MIFNEXSOEntities();

            rdEmail.EmptyMessage = Localization.GetString("SelectItem", this.LocalResourceFile);
            rdEmail.DataSource   = nx.UserProperties.ToList();
            rdEmail.DataBind();


            RadComboBox rdPermisionLevel = (RadComboBox)edititem.FindControl("rdPermisionLevel");
            var         list             = ListComponent.GetListPerCategory("PermisionLevel", Thread.CurrentThread.CurrentCulture.Name).ToList();
            rdPermisionLevel.EmptyMessage = Localization.GetString("SelectItem", this.LocalResourceFile);
            rdPermisionLevel.DataSource   = list;
            rdPermisionLevel.DataBind();


            CheckBoxList cblSolutions = (CheckBoxList)edititem.FindControl("cblSolutions");

            var            listSolutionsAux = SolutionComponent.GetPublishSolutionPerChallenge(challenge).Where(x => x.Deleted == false || x.Deleted == null).OrderBy(x => x.Title);
            List <Generic> listGeneric      = new List <Generic>();

            int count = 1;
            foreach (var item in listSolutionsAux)
            {
                var text = "<span style=\"margin-right:1em;\"><b>" + count.ToString() + ".</b></span><a href='" + NexsoHelper.GetCulturedUrlByTabName("solprofile") + "/sl/" + item.SolutionId + "' Target=\"_blank\" style=\"color:#3786bd;\">" + item.Title + "<a> - " + item.Language;


                listGeneric.Add(new Generic {
                    Id = item.SolutionId, Text = text
                });
                count++;
            }

            cblSolutions.DataSource = listGeneric;
            cblSolutions.DataBind();


            if (!(e.Item is GridEditFormInsertItem))
            {
                try
                {
                    int UserId = Convert.ToInt32(DataBinder.Eval(e.Item.DataItem, "UserId"));

                    var userProfile = new UserPropertyComponent(UserId);

                    string challengeJudgeId = DataBinder.Eval(e.Item.DataItem, "ChallengeJudgeId").ToString();
                    challengeJudgeComponent = new ChallengeJudgeComponent(new Guid(challengeJudgeId));

                    TextBox txtEmail = (TextBox)edititem.FindControl("txtEmail");
                    txtEmail.Text    = userProfile.UserProperty.email;
                    txtEmail.Enabled = false;
                    txtEmail.Visible = true;
                    rdEmail.Visible  = false;
                    RequiredFieldValidator rfvrdEmail = (RequiredFieldValidator)edititem.FindControl("rfvrdEmail");
                    rfvrdEmail.Visible         = false;
                    rfvrdEmail.ValidationGroup = string.Empty;
                    var itemm = (RadComboBoxItem)rdPermisionLevel.Items.FindItemByValue(challengeJudgeComponent.ChallengeJudge.PermisionLevel);
                    if (itemm != null)
                    {
                        itemm.Selected = true;
                        itemm.Checked  = true;
                    }



                    var itemmaux = (RadComboBoxItem)rdEmail.Items.FindItemByValue(userProfile.UserProperty.UserId.ToString());
                    if (itemmaux != null)
                    {
                        itemmaux.Selected = true;
                        itemmaux.Checked  = true;
                    }


                    RadDatePicker dtFromDate = (RadDatePicker)edititem.FindControl("dtFromDate");
                    dtFromDate.SelectedDate = Convert.ToDateTime(challengeJudgeComponent.ChallengeJudge.FromDate);

                    RadDatePicker dtToDate = (RadDatePicker)edititem.FindControl("dtToDate");
                    dtToDate.SelectedDate = Convert.ToDateTime(challengeJudgeComponent.ChallengeJudge.ToDate);


                    var listJudgesAssignations = challengeJudgeComponent.ChallengeJudge.JudgesAssignations.ToList();



                    SetChkControl(listJudgesAssignations, cblSolutions);
                }
                catch
                {
                }
            }
        }
    }
Ejemplo n.º 24
0
    /// <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);
    }
Ejemplo n.º 25
0
        public List <OrganizationsModel> GetOrganization(Guid organization, int?userId = -1, string language = "en-US")
        {
            try
            {
                var currentUser = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo();

                //lists
                List <OrganizationsModel> ListOrganization = new List <OrganizationsModel>();

                List <string> ListLogo = new List <string>();

                List <ReferencesModel> ListReference = new List <ReferencesModel>();

                List <AccreditationsModel> ListAccreditation = new List <AccreditationsModel>();

                List <AttributesModel> ListAttributes = new List <AttributesModel>();

                List <UserProfileModel> ListuserInfo = new List <UserProfileModel>();

                //get attributes
                var attributes = AttributesComponent.GetAttributesList(organization).ToList();

                foreach (var item in attributes)
                {
                    ListAttributes.Add(new AttributesModel()
                    {
                        AttributeID    = item.AttributeID,
                        OrganizationID = item.OrganizationID,
                        Type           = item.Type,
                        Value          = item.Value,
                        ValueType      = item.ValueType,
                        Description    = item.Description,
                        Label          = item.Label
                    });
                }

                //get number of solution
                var solutionsNumber = SolutionComponent.GetSolutionPerOrganization(organization).ToList().Count();

                //get partners
                var partnersLogo = PartnershipsComponent.GetPartnershipListLogo(organization).ToList();

                //get organizations by Id
                var List = OrganizationComponent.GetOrganizationPerId(organization).ToList();

                //get organization references by Id
                var resultReferences = ReferencesComponent.GetReferences(organization).ToList();

                //get user info
                var users = List.First().UserOrganizations.Where(a => a.Role == 1);

                //know if current user is owner
                bool owner = false;
                if (currentUser.UserID == users.First().UserID || currentUser.IsInRole("Administrators") || currentUser.IsSuperUser)
                {
                    owner = true;
                }


                var userProfile = new UserPropertyComponent(users.First().UserID);

                // UserProfileModel userProfile = user.GetProfile(Convert.ToInt32(List.First().CreatedBy));

                string finalExt = "";
                if (System.IO.File.Exists(System.Web.HttpContext.Current.Server.MapPath("~\\Portals\\0\\ModIma\\UserProfileImages\\" + userProfile.UserProperty.ProfilePicture + ".png")))
                {
                    finalExt = "\\Portals\\0\\ModIma\\UserProfileImages\\" + userProfile.UserProperty.ProfilePicture + ".png";
                }
                else if (System.IO.File.Exists(System.Web.HttpContext.Current.Server.MapPath("~\\Portals\\0\\ModIma\\UserProfileImages\\" + userProfile.UserProperty.ProfilePicture + ".jpg")))
                {
                    finalExt = "\\Portals\\0\\ModIma\\UserProfileImages\\" + userProfile.UserProperty.ProfilePicture + ".jpg";
                }
                else
                {
                    finalExt = "\\Portals\\0\\ModIma\\UserProfileImages\\defaultImage.png";
                }


                if (resultReferences.Count() > 0)
                {
                    foreach (var item in resultReferences)
                    {
                        var userProfileReferences = new UserPropertyComponent(item.UserId);

                        ListReference.Add(new ReferencesModel()
                        {
                            ReferenceId    = (Guid)item.ReferenceId,
                            OrganizationId = (Guid)item.OrganizationId,
                            UserId         = item.UserId,
                            Type           = item.Type,
                            Comment        = item.Comment,
                            Created        = item.Created.ToString(),
                            Updated        = item.Updated.ToString(),
                            Deleted        = item.Deleted,
                            fullName       = userProfileReferences.UserProperty.FirstName + " " + userProfileReferences.UserProperty.LastName
                        });
                    }
                }

                //Get organization accreditations
                var resultAccreditations = AccreditationsComponent.GetAccreditationId(organization).ToList();

                if (resultAccreditations.Count() > 0)
                {
                    foreach (var item in resultAccreditations)
                    {
                        DocumentComponent doc = new DocumentComponent((Guid)item.DocumentId);

                        ListAccreditation.Add(new AccreditationsModel()
                        {
                            AccreditationId   = (Guid)item.AccreditationId,
                            OrganizationId    = (Guid)item.OrganizationId,
                            Content           = item.Content,
                            Description       = item.Description,
                            DocumentId        = (Guid)item.DocumentId,
                            Name              = item.Name,
                            Type              = item.Type,
                            yearAccreditation = item.Year,
                            docName           = doc.Document.Name,
                            docUrl            = ""
                        });
                    }
                }

                foreach (var item in List)
                {
                    ListOrganization.Add(new OrganizationsModel()
                    {
                        OrganizationID = (Guid)item.OrganizationID,
                        Code           = item.Code,
                        Name           = item.Name,
                        //Address = currentUser.IsInRole("NexsoUser") ? item.Address : "",
                        Address = item.Address,
                        //Phone = currentUser.IsInRole("NexsoUser") ? item.Phone  : "",
                        Phone = item.Phone,
                        //Email = currentUser.IsInRole("NexsoUser") ? item.Email : "",
                        Email = item.Email,
                        //ContactEmail = currentUser.IsInRole("NexsoUser") ? item.ContactEmail : "",
                        ContactEmail = item.ContactEmail,
                        Website      = item.Website,
                        Twitter      = item.Twitter,
                        //Skype = currentUser.IsInRole("NexsoUser") ? item.Skype : "",
                        Skype = item.Skype,
                        //Facebook = currentUser.IsInRole("NexsoUser") ? item.Facebook : "",
                        Facebook           = item.Facebook,
                        GooglePlus         = item.GooglePlus,
                        LinkedIn           = item.LinkedIn,
                        Description        = item.Description,
                        Logo               = item.Logo,
                        Country            = item.Country,
                        Region             = item.Region,
                        City               = item.City,
                        ZipCode            = item.ZipCode,
                        Created            = Convert.ToDateTime(item.Created),
                        Updated            = Convert.ToDateTime(item.Updated),
                        Latitude           = Convert.ToDecimal(item.Latitude),
                        Longitude          = Convert.ToDecimal(item.Longitude),
                        GoogleLocation     = item.GoogleLocation,
                        Language           = item.Language,
                        Year               = Convert.ToInt32(item.Year),
                        Staff              = Convert.ToInt32(item.Staff),
                        Budget             = Convert.ToDecimal(item.Budget),
                        CheckedBy          = item.CheckedBy,
                        CreatedOn          = Convert.ToDateTime(item.Created),
                        UpdatedOn          = Convert.ToDateTime(item.Updated),
                        CreatedBy          = Convert.ToInt32(item.CreatedBy),
                        Deleted            = Convert.ToBoolean(item.Deleted),
                        accreditations     = ListAccreditation,
                        references         = ListReference,
                        solutionNumber     = Convert.ToInt32(solutionsNumber),
                        partnershipsLogo   = partnersLogo,
                        attributes         = ListAttributes,
                        userFirstName      = userProfile.UserProperty.FirstName,
                        userLastName       = userProfile.UserProperty.LastName,
                        userEmail          = userProfile.UserProperty.email,
                        userLinkedIn       = userProfile.UserProperty.LinkedIn,
                        userFacebook       = userProfile.UserProperty.FaceBook,
                        userTwitter        = userProfile.UserProperty.Twitter,
                        userAddress        = userProfile.UserProperty.Address,
                        userCity           = userProfile.UserProperty.City,
                        userCountry        = userProfile.UserProperty.Country,
                        userProfilePicture = finalExt,
                        userID             = currentUser.UserID.ToString(),
                        ownerSolution      = owner
                    });
                }
                return(ListOrganization);
            }
            catch (HttpResponseException e)
            {
                throw e;
            }
            catch (Exception ee)
            {
                DotNetNuke.Services.Exceptions.Exceptions.LogException(ee);
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError));
            }
        }
Ejemplo n.º 26
0
    /// <summary>
    /// Update information of the user (if user is administrator is not possible change the password)
    /// This Method also update the user information in DNN
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void RadGrid1_UpdateCommand(object sender, GridCommandEventArgs e)
    {
        if (e.CommandName == RadGrid.UpdateCommandName)
        {
            if (e.Item is GridEditableItem)
            {
                GridEditableItem editItem  = (GridEditableItem)e.Item;
                TextBox          txtUserId = (TextBox)editItem.FindControl("txtUserId");
                int userId;
                if (txtUserId.Text == string.Empty)
                {
                    userId = 0;
                }
                else
                {
                    userId = Convert.ToInt32(txtUserId.Text);
                }

                // Get controls
                RadTextBox  txtEmail              = (RadTextBox)editItem.FindControl("txtEmail");
                RadTextBox  txtFirstName          = (RadTextBox)editItem.FindControl("txtFirstName");
                RadTextBox  txtLastName           = (RadTextBox)editItem.FindControl("txtLastName");
                RadTextBox  txtPhone              = (RadTextBox)editItem.FindControl("txtTelephone");
                RadTextBox  txtAddress            = (RadTextBox)editItem.FindControl("txtAddress");
                RadTextBox  txtLinkedIn           = (RadTextBox)editItem.FindControl("txtLinkedIn");
                RadTextBox  txtGoogle             = (RadTextBox)editItem.FindControl("txtGoogle");
                RadTextBox  txtTwitter            = (RadTextBox)editItem.FindControl("txtTwitter");
                RadTextBox  txtFacebook           = (RadTextBox)editItem.FindControl("txtFacebook");
                RadTextBox  txtSkype              = (RadTextBox)editItem.FindControl("txtSkypeName");
                RadComboBox ddLanguage            = (RadComboBox)editItem.FindControl("ddLanguage");
                RadComboBox ddCustomerType        = (RadComboBox)editItem.FindControl("ddCustomerType");
                RadComboBox ddNexsoEnrolment      = (RadComboBox)editItem.FindControl("ddNexsoEnrolment");
                RadComboBox ddUserTheme           = (RadComboBox)editItem.FindControl("ddUserTheme");
                RadComboBox ddUserBeneficiaries   = (RadComboBox)editItem.FindControl("ddUserBeneficiaries");
                RadComboBox ddUserSector          = (RadComboBox)editItem.FindControl("ddUserSector");
                RadTextBox  txtOtherSocialNetwork = (RadTextBox)editItem.FindControl("txtOtherSocialNetwork");
                CheckBox    chkNotifications      = (CheckBox)editItem.FindControl("chkNotifications");
                RadTextBox  txtPassword           = (RadTextBox)editItem.FindControl("txtPassword");
                if (userId == 0)
                {
                    if (txtEmail.Text != string.Empty)
                    {
                        int totalUsers = 0;
                        UserController.GetUsersByUserName(PortalId, txtEmail.Text, 1, 1, ref totalUsers);
                        if (totalUsers == 0)
                        {
                            //Update DNN Information
                            var objUser = new DotNetNuke.Entities.Users.UserInfo();
                            objUser.AffiliateID               = Null.NullInteger;
                            objUser.Email                     = txtEmail.Text;
                            objUser.FirstName                 = txtFirstName.Text;
                            objUser.IsSuperUser               = false;
                            objUser.LastName                  = txtLastName.Text;
                            objUser.PortalID                  = PortalController.GetCurrentPortalSettings().PortalId;
                            objUser.Username                  = txtEmail.Text;
                            objUser.DisplayName               = txtFirstName.Text + " " + txtLastName.Text;
                            objUser.Membership.LockedOut      = false;
                            objUser.Membership.Password       = txtPassword.Text;
                            objUser.Membership.Email          = objUser.Email;
                            objUser.Membership.Username       = objUser.Username;
                            objUser.Membership.UpdatePassword = false;
                            objUser.Membership.LockedOut      = false;
                            objUser.Membership.Approved       = true;
                            DotNetNuke.Security.Membership.UserCreateStatus objCreateStatus =
                                DotNetNuke.Entities.Users.UserController.CreateUser(ref objUser);
                            if (objCreateStatus == DotNetNuke.Security.Membership.UserCreateStatus.Success)
                            {
                                UserInfo myDnnUser = objUser;
                                myDnnUser.Profile.InitialiseProfile(myDnnUser.PortalID);
                                myDnnUser.Profile.SetProfileProperty("FirstName", txtFirstName.Text);
                                myDnnUser.Profile.SetProfileProperty("LastName", txtLastName.Text);
                                UserController.UpdateUser(myDnnUser.PortalID, myDnnUser);
                                //Update Nexso information
                                userPropertyComponent = new UserPropertyComponent(objUser.UserID);
                                //Update DNN roles
                                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);
                                }
                                ExistEmail = false;
                            }
                            else
                            {
                                ExistEmail = true;
                                return;
                            }
                        }
                        else
                        {
                            ExistEmail = true;
                            return;
                        }
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    userPropertyComponent = new UserPropertyComponent(userId);
                    if (txtEmail.Text != string.Empty)
                    {
                        UserInfo myDnnUser = DotNetNuke.Entities.Users.UserController.GetUser(PortalSettings.PortalId, userId, true);
                        myDnnUser.Profile.InitialiseProfile(myDnnUser.PortalID);
                        myDnnUser.Profile.SetProfileProperty("FirstName", txtFirstName.Text);
                        myDnnUser.Profile.SetProfileProperty("LastName", txtLastName.Text);

                        if (!myDnnUser.IsInRole("Administrators"))
                        {
                            if (txtPassword.Text != string.Empty)
                            {
                                MembershipUser usr = Membership.GetUser(myDnnUser.Username, false);
                                if (usr.IsLockedOut == true)
                                {
                                    usr.UnlockUser();
                                }
                                string resetPassword = usr.ResetPassword();
                                bool   sw            = usr.ChangePassword(resetPassword, txtPassword.Text);
                            }
                        }
                        // myDnnUser.Profile.SetProfileProperty("Password", txtPassword.Text);
                        UserController.UpdateUser(myDnnUser.PortalID, myDnnUser);
                        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);
                        }
                    }
                }
                userPropertyComponent.UserProperty.FirstName = txtFirstName.Text;
                userPropertyComponent.UserProperty.LastName  = txtLastName.Text;
                userPropertyComponent.UserProperty.Telephone = txtPhone.Text;
                userPropertyComponent.UserProperty.email     = txtEmail.Text;
                userPropertyComponent.UserProperty.SkypeName = txtSkype.Text;
                userPropertyComponent.UserProperty.Twitter   = txtTwitter.Text;
                userPropertyComponent.UserProperty.FaceBook  = txtFacebook.Text;
                userPropertyComponent.UserProperty.Google    = txtGoogle.Text;
                userPropertyComponent.UserProperty.LinkedIn  = txtLinkedIn.Text;
                userPropertyComponent.UserProperty.Address   = txtAddress.Text;
                userPropertyComponent.UserProperty.Agreement = "A001";
                userPropertyComponent.UserProperty.AllowNexsoNotifications = Convert.ToInt32(chkNotifications.Checked);

                if (ddCustomerType.SelectedValue != string.Empty)
                {
                    userPropertyComponent.UserProperty.CustomerType = Convert.ToInt32(ddCustomerType.SelectedValue);
                }
                if (ddNexsoEnrolment.SelectedValue != string.Empty)
                {
                    userPropertyComponent.UserProperty.NexsoEnrolment = Convert.ToInt32(ddNexsoEnrolment.SelectedValue);
                }
                if (ddLanguage.SelectedValue != string.Empty)
                {
                    userPropertyComponent.UserProperty.Language = Convert.ToInt32(ddLanguage.SelectedValue);
                }

                if (userPropertyComponent.Save() > 0)
                {
                    SaveChkControl("Theme", ddUserTheme, userPropertyComponent.UserProperty.UserId);
                    SaveChkControl("Beneficiaries", ddUserBeneficiaries, userPropertyComponent.UserProperty.UserId);
                    SaveChkControl("Sector", ddUserSector, userPropertyComponent.UserProperty.UserId);
                }
                if (editItem.ItemIndex != -1)
                {
                    this.grdManageUsers.MasterTableView.Items[editItem.ItemIndex].Edit = false;
                }
                else
                {
                    e.Item.OwnerTableView.IsItemInserted = false;
                }

                this.grdManageUsers.MasterTableView.Rebind();
            }
        }
    }