Пример #1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            lblMsg.Text = "";
            UserDA objUserDA = new UserDA();

            UserBE objUBE1 = new UserBE();
            objUBE1.isEmailWeeklyUpdate = chkEmailUpdate.Checked;
            objUBE1.TimeZoneID = Convert.ToInt32(rcmbTimeZone.SelectedValue);
            objUBE1.isAutoDLSave = chkDaylight.Checked;
            objUBE1.UserID = Convert.ToInt32(Session["UserID"]);

            objUserDA.UpdateUserAcccountSetting(objUBE1);

            lblMsg.ForeColor = System.Drawing.Color.Green;
            lblMsg.Text = objErr.getMessage("AM0006");
        }
Пример #2
0
        public int AddUserAccountDA(UserBE objUserBE)
        {
            int userID = 0;
            // SQL: Client record
            string sql1 = DBQuery.sqlUserInsert;
            try
            {
                using (MySqlConnection sqlCon = new MySqlConnection(Constant.EBirdConnectionString))
                {
                    MySqlCommand sqlCmd = new MySqlCommand("spAddNewUser", sqlCon);

                    sqlCmd.Parameters.Add(new MySqlParameter("pEmailID", objUserBE.EmailID));
                    sqlCmd.Parameters.Add(new MySqlParameter("pUserPassword", objUserBE.Password));
                    sqlCmd.Parameters.Add(new MySqlParameter("pFirstName", objUserBE.FirstName));
                    sqlCmd.Parameters.Add(new MySqlParameter("pLastName", objUserBE.LastName));
                    sqlCmd.Parameters.Add(new MySqlParameter("pAddress1", objUserBE.Address));
                    sqlCmd.Parameters.Add(new MySqlParameter("pTelephone", objUserBE.Telephone));
                    sqlCmd.Parameters.Add(new MySqlParameter("pRole", objUserBE.Role));
                    sqlCmd.Parameters.Add(new MySqlParameter("pClientID", objUserBE.ClientID));
                    sqlCmd.Parameters.Add(new MySqlParameter("pDepartment", objUserBE.Department));
                    sqlCmd.Parameters.Add(new MySqlParameter("pUserStatus", "Active"));
                    sqlCmd.Parameters.Add(new MySqlParameter("pIsPrimary", (objUserBE.isPrimary ? 1 : 0)));
                    sqlCmd.Parameters.Add(new MySqlParameter("pCreatedBy", (objUserBE.CreatedBy)));

                    sqlCon.Open();
                    sqlCmd.CommandType = CommandType.StoredProcedure;
                    MySqlDataReader reader = sqlCmd.ExecuteReader();
                    if (reader.HasRows)
                    {
                        reader.Read();
                        userID = Convert.ToInt32(reader.GetValue(0));
                    }

                    reader.Close();
                    reader = null;
                    sqlCon.Close();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return userID;
        }
Пример #3
0
        private static UserBE RenameUser(UserBE user, string newUserName, string newFullName)
        {
            //Renaming requires admin rights.
            PermissionsBL.CheckUserAllowed(DekiContext.Current.User, Permissions.ADMIN);

            if (!ServiceBL.IsLocalAuthService(user.ServiceId))
            {
                //TODO MaxM: allow renaming of external users
                throw new ExternalUserRenameNotImplementedExceptionException();
            }

            //Check for already existing user with same name
            UserBE existingUser = DbUtils.CurrentSession.Users_GetByName(newUserName);

            if (existingUser != null)
            {
                throw new UserWithIdExistsConflictException(existingUser.Name, existingUser.ID);
            }

            PageBE existingTargetUserHomePage = PageBL.GetPageByTitle(Title.FromUIUsername(newUserName));

            if (existingTargetUserHomePage != null && existingTargetUserHomePage.ID != 0 && !existingTargetUserHomePage.IsRedirect)
            {
                throw new UserHomepageRenameConflictException();
            }

            //Try to move the homepage.
            PageBE userHomePage = GetHomePage(user);

            if (userHomePage != null && userHomePage.ID != 0)
            {
                Title newTitle = Title.FromUIUsername(newUserName);

                // new user homepage displayname is the user's full name or rebuilt from the username
                newTitle.DisplayName = !string.IsNullOrEmpty(newFullName) ? newFullName : newTitle.AsUserFriendlyDisplayName();
                PageBL.MovePage(userHomePage, newTitle, true);
            }

            //Rename the user
            user.Name = newUserName;
            UserBL.UpdateUser(user);
            return(user);
        }
Пример #4
0
        public async Task <IActionResult> Registration(UserRegisterViewModel userviewmodel, CancellationToken token)
        {
            if (ModelState.IsValid)
            {
                UserBE userExistence = await _userBL.GetUserByUserNameAndEmailBL(userviewmodel.UserName, userviewmodel.Email, token);

                UserBE userToAdd = new UserBE();

                if (userExistence == null)
                {
                    userToAdd.UserName           = userviewmodel.UserName;
                    userToAdd.Email              = userviewmodel.Email;
                    userToAdd.NormalizedUserName = userviewmodel.UserName.ToUpper();
                    userToAdd.NormalizedEmail    = userviewmodel.Email.ToUpper();

                    var resultRegistration = await _userManager.CreateAsync(userToAdd, userviewmodel.Password);

                    if (resultRegistration.Succeeded)
                    {
                        var userAfterAdd = await _userManager.FindByEmailAsync(userviewmodel.Email);

                        await _signManager.SignInAsync(userAfterAdd, false);

                        return(RedirectToAction("UserFlights", "Flight"));
                    }
                    else
                    {
                        foreach (var error in resultRegistration.Errors)
                        {
                            ModelState.AddModelError("", error.Description);
                        }
                    }
                }

                ModelState.AddModelError("Login", "Vous avez deja un compte");
                ModelState.AddModelError("Email", "Vous avez deja un compte");

                return(View(userviewmodel));
            }

            return(View(userviewmodel));
        }
Пример #5
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            string RealPass = txtPass.Text;

            if (ValidData())
            {
                return;
            }

            UserBE    LoggedInUser = new UserBE();
            CommonBAL combal       = new CommonBAL();
            UserBAL   userBAL      = new UserBAL();
            DataTable dt           = new DataTable();

            // Using screen inputs create UserBE;
            LoggedInUser.UserName = txtName.Text;
            LoggedInUser.EncPass  = combal.Encrypt(txtPass.Text, false);
            if (userBAL.Validate(ref LoggedInUser))
            {
                Session["LoggedInUser"] = LoggedInUser;
                if (Session["LoggedInUser"] != null)
                {
                    LoggedInUser.UserId = ((UserBE)Session["LoggedInUser"]).UserId;
                    if (userBAL.UserAccessRight(LoggedInUser, ref dt))
                    {
                        Session["UserAccessRights"] = dt;
                        Response.Redirect(@"~\UserMaint\LoggedInHome.aspx");
                    }
                    //General master = (General)this.Master;
                    //master.ShowMessage("You are not authorised to access this page. Please contact system administrator.", false); //?? Message through Query String
                    ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "CallJS", "alert('You are not authorised to access this page. Please contact system administrator.');", true);
                    return;
                }
            }
            else
            {
                //General master = (General)this.Master;
                //master.ShowMessage("Incorrect Email or Password.", false);
                ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "CallJS", "alert('Incorrect Email or Password.');", true);
                return;
            }
        }
Пример #6
0
 private void PageChanged(DateTime eventTime, PageBE page, UserBE user, XDoc extra, params string[] path)
 {
     try {
         XUri     channel  = _channel.At(PAGES).At(path);
         XUri     resource = PageBL.GetUriCanonical(page).WithHost(_wikiid);
         string[] origin   = new string[] { PageBL.GetUriCanonical(page).AsServerUri().ToString(), XUri.Localhost + "/" + page.Title.AsUiUriPath() };
         XDoc     doc      = new XDoc("deki-event")
                             .Elem("channel", channel)
                             // BUGBUGBUG: This will generally generate a Uri based on the request that caused the event,
                             //            which may not really be canonical
                             .Elem("uri", PageBL.GetUriCanonical(page).AsPublicUri().ToString())
                             .Elem("pageid", page.ID)
                             .Start("user")
                             .Attr("id", user.ID)
                             .Attr("anonymous", UserBL.IsAnonymous(user))
                             .Elem("uri", UserBL.GetUri(user))
                             .End()
                             .Start("content.uri")
                             .Attr("type", "application/xml")
                             .Value(PageBL.GetUriContentsCanonical(page).With("format", "xhtml").AsServerUri().ToString())
                             .End()
                             .Elem("revision.uri", PageBL.GetUriRevisionCanonical(page).AsServerUri().ToString())
                             .Elem("tags.uri", PageBL.GetUriCanonical(page).At("tags").AsServerUri().ToString())
                             .Elem("comments.uri", PageBL.GetUriCanonical(page).At("comments").AsServerUri().ToString())
                             .Elem("path", page.Title.AsUiUriPath());
         if (extra != null)
         {
             doc.Add(extra);
         }
         Queue(eventTime, channel, resource, origin, doc);
         if (page.Title.IsTalk)
         {
             PageBE front = PageBL.GetPageByTitle(page.Title.AsFront());
             if ((front != null) && (front.ID > 0))
             {
                 PageChanged(eventTime, front, user, extra, ArrayUtil.Concat(new string[] { DEPENDENTS_CHANGED, TALK }, path));
             }
         }
     } catch (Exception e) {
         _log.WarnExceptionMethodCall(e, "PageChanged", "event couldn't be created");
     }
 }
Пример #7
0
        public IList <BinnacleBE> GetBinnacleWithFilters(DateTime?DateTo, DateTime?DateFrom, string UserName)
        {
            var dbContext  = new DBContext();
            var parameters = Array.Empty <SqlParameter>();

            parameters = new SqlParameter[3];

            parameters[0] = dbContext.CreateParameters("@DateFrom", DateFrom.HasValue ? DateFrom.Value : default(DateTime?));
            parameters[1] = dbContext.CreateParameters("@DateTo", DateTo.HasValue ? DateTo.Value : default(DateTime?));
            parameters[2] = dbContext.CreateParameters("@UserName", string.IsNullOrEmpty(UserName) ? null : UserName);


            var binnacleList = new List <BinnacleBE>();
            var dataTable    = dbContext.Read("GetBinnacle", parameters);

            UserBE user = null;

            foreach (DataRow row in dataTable.Tables[0].Rows)
            {
                var register = new BinnacleBE
                {
                    Id          = Guid.Parse(row["BinnacleID"].ToString()),
                    Description = row["Description"].ToString(),
                    Date        = DateTime.Parse(row["Date"].ToString())
                };

                if (row["UserID"] != null)
                {
                    user = new UserBE
                    {
                        Id       = Guid.Parse(row["UserID"].ToString()),
                        UserName = row["UserName"].ToString(),
                    };
                }

                register.User = user;

                binnacleList.Add(register);
            }

            return(binnacleList);
        }
Пример #8
0
        public async Task <IList <string> > GetRolesAsync(UserBE user, CancellationToken token)
        {
            if (user == null)
            {
                throw new ArgumentNullException("user");
            }

            try
            {
                IList <string> result = new List <string>();
                result.Add("Admin");
                result.Add("User");
                return(result);
            }
            catch (Exception ex)
            {
                _logError.Log(ex);
                return(null);
            }
        }
Пример #9
0
        public static UserBE SetPassword(UserBE user, string password, bool altPassword)
        {
            string pwhash = Logic.AuthBL.EncryptPassword(user, password);

            if (altPassword)
            {
                //Set the alternate password only while keeping the main password untouched.
                user.NewPassword = pwhash;
            }
            else
            {
                //Set the main password and clear the alternate password.
                user.Password    = pwhash;
                user.NewPassword = string.Empty;
            }

            user.Touched = DateTime.UtcNow;
            DbUtils.CurrentSession.Users_Update(user);
            return(user);
        }
Пример #10
0
        public static string NormalizeExternalNameToWikiUsername(string externalUserName)
        {
            uint   suffix = 0;
            UserBE userWithMatchingName = null;
            string newUserName;

            do
            {
                newUserName = Title.FromUIUsername(externalUserName).Path;
                if (suffix > 0)
                {
                    newUserName = newUserName + suffix.ToString();
                }

                userWithMatchingName = DbUtils.CurrentSession.Users_GetByName(newUserName);
                suffix++;
            } while(userWithMatchingName != null);

            return(newUserName);
        }
Пример #11
0
        public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
        {
            try
            {
                UserBLL        userBLL        = new UserBLL();
                PermissionsBLL permissionsBLL = new PermissionsBLL();
                UserBE         userToFind     = new UserBE()
                {
                    UserName = context.UserName,
                    Password = context.Password
                };
                var user = await Task.Run(() => userBLL.CheckUserName(userToFind));

                user.Permissions = permissionsBLL.GetUserPermission(user);
                if (user != null)
                {
                    var identity = new ClaimsIdentity(context.Options.AuthenticationType);
                    identity.AddClaim(new Claim("Username", user.UserName));

                    string userObj = JsonConvert.SerializeObject(user);
                    identity.AddClaim(new Claim("userObject", userObj));
                    identity.AddClaim(new Claim("LoggedOn", DateTime.Now.ToString()));
                    identity = ListPermissions(user.Permissions, identity);
                    //var additionalData = new AuthenticationProperties(new Dictionary<string, string>{
                    //   {
                    //        "role", Newtonsoft.Json.JsonConvert.SerializeObject(identity.userRoles)
                    //    }
                    //});
                    //var token = new AuthenticationTicket(identity,new AuthenticationProperties() { });
                    context.Validated(identity);
                }
                else
                {
                    return;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #12
0
        public void Users_Update(UserBE user)
        {
            if (user == null || user.ID == 0)
            {
                return;
            }

            Catalog.NewQuery(@" /* Users_Update */
UPDATE users 
SET user_role_id = ?ROLEID,
user_name = ?USERNAME,
user_password = ?USERPASSWORD,
user_newpassword = ?NEWPASSWORD,
user_touched = ?TOUCHED,
user_email = ?EMAIL,
user_service_id = ?SERVICEID,
user_active = ?ACTIVE,
user_real_name = ?REALNAME,
user_external_name = ?EXTERNALNAME,
user_create_timestamp = ?USER_CREATE_TIMESTAMP,
user_timezone = ?USER_TIMEZONE,
user_language = ?USER_LANGUAGE,
user_seat = ?USER_SEAT
WHERE user_id = ?USERID;")
            .With("USERPASSWORD", user._Password)
            .With("NEWPASSWORD", user._NewPassword)
            .With("ROLEID", user.RoleId)
            .With("USERNAME", user.Name)
            .With("TOUCHED", user._Touched)
            .With("EMAIL", user.Email)
            .With("SERVICEID", user.ServiceId)
            .With("ACTIVE", user.UserActive)
            .With("REALNAME", user.RealName)
            .With("USERID", user.ID)
            .With("EXTERNALNAME", user.ExternalName)
            .With("USER_CREATE_TIMESTAMP", user.CreateTimestamp)
            .With("USER_TIMEZONE", user.Timezone)
            .With("USER_LANGUAGE", user.Language)
            .With("USER_SEAT", user.LicenseSeat)
            .Execute();
        }
Пример #13
0
        protected void btnDeleteYes_Click(object sender, EventArgs e)
        {
            if (!commonBAL.isUserAuthorisedForPageFunc(LoggedInUser.UserId, thisPageName, "delete"))
            {
                LoggedIn master = (LoggedIn)this.Master;
                master.ShowMessage("You are not authorised to perform this function. Please contact system administrator.", false);
                return;
            }
            UserBE  user    = new UserBE();
            UserBAL userBAL = new UserBAL();

            user.UserId = Convert.ToInt32(hdnUserId.Value);

            if (userBAL.Delete(user))
            {
                if (lvUserList.Items.Count == 1)
                {
                    UserDataPager.SetPageProperties(UserDataPager.TotalRowCount - UserDataPager.PageSize - 1,
                                                    UserDataPager.PageSize, true);
                    bindLVUser();
                    recalcNoOfPages();
                    LoggedIn master = (LoggedIn)this.Master;
                    master.ShowMessage("User successfully deleted.", true);
                }
                else
                {
                    lvUserList.EditIndex = -1;
                    bindLVUser();
                    recalcNoOfPages();
                    LoggedIn master = (LoggedIn)this.Master;
                    master.ShowMessage("User successfully deleted.", true);
                }
            }
            else
            {
                LoggedIn master = (LoggedIn)this.Master;
                master.ShowMessage("Sorry You cannot delete this User because it is already in use", false);
            }
            // Hide the ModalPopup.
            //this.mpe_DeleteUser.Hide();
        }
Пример #14
0
        private UserBE Users_Populate(IDataReader dr)
        {
            UserBE user = new UserBE();

            user._NewPassword    = dr.Read <byte[]>("user_newpassword");
            user._Password       = dr.Read <byte[]>("user_password");
            user._Touched        = dr.Read <string>("user_touched");
            user.CreateTimestamp = dr.Read <DateTime>("user_create_timestamp");
            user.Email           = dr.Read <string>("user_email");
            user.ExternalName    = dr.Read <string>("user_external_name");
            user.ID          = dr.Read <uint>("user_id");
            user.Language    = dr.Read <string>("user_language");
            user.Name        = dr.Read <string>("user_name");
            user.RealName    = dr.Read <string>("user_real_name");
            user.RoleId      = dr.Read <uint>("user_role_id");
            user.ServiceId   = dr.Read <uint>("user_service_id");
            user.Timezone    = dr.Read <string>("user_timezone");
            user.UserActive  = dr.Read <bool>("user_active");
            user.LicenseSeat = dr.Read <bool>("user_seat");
            return(user);
        }
Пример #15
0
        public async Task <IdentityResult> DeleteAsync(UserBE user, CancellationToken token)
        {
            try
            {
                if (string.IsNullOrEmpty(user.Id))
                {
                    throw new ArgumentException();
                }

                await _data.DeleteUser(user, token);

                return(IdentityResult.Success);
            }
            catch (Exception ex)
            {
                _logError.Log(ex);
                return(IdentityResult.Failed(new IdentityError {
                    Description = ex.ToString()
                }));
            }
        }
Пример #16
0
        public static UserBE CreateOrUpdateUser(UserBE user, string newPassword)
        {
            if (user.ID > 0)
            {
                UpdateUser(user);
            }
            else
            {
                //TODO consider logic here to confirm that the user does not yet exist.

                user = CreateNewUser(user);
            }

            if (!string.IsNullOrEmpty(newPassword) && ServiceBL.IsLocalAuthService(user.ServiceId))
            {
                user = UserBL.SetPassword(user, newPassword, false);
                DekiContext.Current.Instance.EventSink.UserChangePassword(DekiContext.Current.Now, user);
            }

            return(user);
        }
Пример #17
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            UserBE objUserBE = new UserBE();
            objUserBE.FirstName = txtFName.Text.Trim();
            objUserBE.LastName = txtLName.Text.Trim();
            objUserBE.Telephone = txtTelephone.Text.Trim();
            objUserBE.Department = txtDepartment.Text.Trim();
            objUserBE.JobTitle = txtJobTitle.Text.Trim();
            objUserBE.UserID = Convert.ToInt32(Session["UserID"]);
            objUserDA.UpdateUserProfileRecord(objUserBE);

            PresenterBE objPreBE = new PresenterBE();
            txtPresenterName.Text = txtFName.Text.Trim() + " " + txtLName.Text.Trim();
            txtPresenterTitle.Text = txtJobTitle.Text.Trim();
            objPreBE.PresenterName = txtPresenterName.Text.Trim();
            objPreBE.Title =  txtPresenterTitle.Text.Trim();
            objPreBE.Organization = txtPreOrgName.Text.Trim();
            objPreBE.Bio = redtBio.Text;
            objPreBE.UserID = Convert.ToInt32(Session["UserID"]);
            objWebinarDA.UpdatePresenterDetail(objPreBE);
        }
Пример #18
0
        public UserBE Users_GetByName(string userName)
        {
            if (string.IsNullOrEmpty(userName))
            {
                return(null);
            }
            UserBE user = null;

            Catalog.NewQuery(@" /* Users_GetByName */
SELECT  *
FROM    users
WHERE   user_name = ?USERNAME")
            .With("USERNAME", userName)
            .Execute(delegate(IDataReader dr) {
                if (dr.Read())
                {
                    user = Users_Populate(dr);
                }
            });
            return(user);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            LoggedInUser = (UserBE)Session["LoggedInUser"];

            if (LoggedInUser == null)
            {
                if (Session["QuestId"] == null) //cv?org
                {
                    // return to login page because user has not loggedin or session has timedout...
                    Response.Redirect("~/Login.aspx");
                }
                else
                {
                    //coming from QA_SearchQuestionWOLogin.aspx page - i.e. search w/o login - Quick Search click
                }
            }

            if (!IsPostBack)
            {
                if (Session["QuestId"] != null)                                                                                            //CV?org
                {
                    hdnQuestId.Value = Session["QuestId"].ToString();                                                                      //cv?org

                    CommonBAL commBAL = new CommonBAL();                                                                                   //am??

                    bool blnTemp = commBAL.QueriesTotalViewCountrIncrement(Convert.ToInt16(Session["QuestId"]), (int)LoggedInUser.UserId); //am???



                    //Session["QuestIdWOLogin"] = Session["QuestId"].ToString(); //cv?org
                    Session["QuestId"] = null; //CV??org
                    ShowQuestion();
                    GetAnswers();
                }
                else
                {
                    Response.Redirect("~/UserMaint/LoggedInHome.aspx");
                }
            }
        }
Пример #20
0
        public AnswerResponseBE UpdateUser(UserBE UPUS)
        {
            AnswerResponseBE     AR   = new AnswerResponseBE();
            MasterProductContext BDMP = new MasterProductContext();

            try
            {
                User user = new User();
                user = BDMP.User.Where(x => x.IdUser == UPUS.IdUser).FirstOrDefault();
                if (user != null)
                {
                    user.IdUser   = UPUS.IdUser;
                    user.NameUser = UPUS.NameUser;
                    user.Photo    = UPUS.Photo;


                    BDMP.SaveChanges();

                    AR.CodeError        = 0;
                    AR.DescriptionError = "Se ha actualizado el usuario correctamente";
                }
                else
                {
                    AR.CodeError        = 2;
                    AR.DescriptionError = "El registro no existe, por favor verifique la información";
                }
            }
            catch (Exception EX)
            {
                AR.CodeError        = 1;
                AR.DescriptionError = "Hubo un error";
            }
            finally
            {
                BDMP.Dispose();
            }


            return(AR);
        }
Пример #21
0
        public AnswerResponseBE InsertUser(UserBE IUS)
        {
            AnswerResponseBE     AR   = new AnswerResponseBE();
            MasterProductContext BDMP = new MasterProductContext();

            try
            {
                int CountUser = 0;
                CountUser = BDMP.User.Where(x => x.IdUser == IUS.IdUser).ToList().Count();
                if (CountUser == 0)
                {
                    User USER = new User();
                    USER.IdUser   = IUS.IdUser;
                    USER.NameUser = IUS.NameUser;
                    USER.Photo    = IUS.Photo;

                    BDMP.User.Add(USER);
                    BDMP.SaveChanges();

                    AR.CodeError        = 0;
                    AR.DescriptionError = "Se ha insertado el usuario correctamente";
                }
                else
                {
                    AR.CodeError        = 2;
                    AR.DescriptionError = "El usuario ya existe, por favor verifique la información";
                }
            }
            catch (Exception EX)
            {
                AR.CodeError        = 1;
                AR.DescriptionError = "Hubo un error";
            }
            finally
            {
                BDMP.Dispose();
            }

            return(AR);
        }
Пример #22
0
 //--- Cosntructors ---
 public IndexRebuilder(
     IDekiChangeSink eventSink,
     UserBE currentUser,
     ISearchBL searchBL,
     IPageBL pageBL,
     ICommentBL commentBL,
     IAttachmentBL attachmentBL,
     IUserBL userBL,
     NS[] indexNameSpaceWhitelist,
     DateTime now
     )
 {
     _eventSink               = eventSink;
     _currentUser             = currentUser;
     _searchBL                = searchBL;
     _pageBL                  = pageBL;
     _commentBL               = commentBL;
     _attachmentBL            = attachmentBL;
     _userBL                  = userBL;
     _indexNameSpaceWhitelist = indexNameSpaceWhitelist;
     _now = now;
 }
Пример #23
0
        protected void btnAddRole_Click(object sender, EventArgs e)
        {
            if (!commonBAL.isUserAuthorisedForPageFunc(LoggedInUser.UserId, thisPageName, "add"))
            {
                LoggedIn master = (LoggedIn)this.Master;
                master.ShowMessage("You are not authorised to Perform any operation on this page. Please contact system administrator.", false);
                //   Server.Transfer("UM_BlankPage.aspx"); //?? send Message through Query String to the BlankPage
                //  string cat = Request.QueryString["Message"];
                //  Response.Redirect("UM_BlankPage.aspx?Message=You are not authorised to Perform any operation on this page. Please contact system administrator.");
                return;
            }
            if (ValidData())
            {
            }
            else
            {
                UserBE  user       = (UserBE)Session["LoggedInUser"];
                RoleBE  addRoleBE  = new RoleBE();
                RoleDAL addRoleDal = new RoleDAL();
                RoleBAL addRoleBal = new RoleBAL();

                addRoleBE.RoleShortDesc  = txtRoleShortDesc.Text;
                addRoleBE.RoleLongDesc   = txtRoleLongDesc.Text;
                addRoleBE.LastModifiedBy = user.UserId;

                if (addRoleBal.AddRole(addRoleBE))
                {
                    txtRoleShortDesc.Text = "";
                    txtRoleLongDesc.Text  = "";
                    LoggedIn master = (LoggedIn)this.Master;
                    master.ShowMessage("Record Inserted Successfully.", true);
                }
                else
                {
                    LoggedIn master = (LoggedIn)this.Master;
                    master.ShowMessage("Unsuccessful.", false);
                }
            }
        }
        //
        // GET: /OrdenCompra/
        public ActionResult Index()
        {
            var    daoOrden          = new OrdenCompraWS();
            UserBE usuario           = ((UserBE)Session["Usuario"]);
            int    IdEstablecimiento = 0;

            if (usuario.Rol.RolId == (int)ConstantesBE.Rol.Establecimiento)
            {
                IdEstablecimiento = usuario.EmpleadoId;
            }
            var firstDayOfMonth = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
            var lastDayOfMonth  = firstDayOfMonth.AddMonths(1);
            var lista           = daoOrden.Listar("", 0, firstDayOfMonth, lastDayOfMonth, IdEstablecimiento);

            var daoParametro = new ParametroWS();

            ViewBag.ListaEstado = daoParametro.Listar((int)ConstantesBE.Dominio.EstadoOrdenCompra);



            return(View(lista));
        }
Пример #25
0
        public ActionResult Index(UserBE UserBE)
        {
            var db        = new UserWS();
            var UsuarioBe = db.ObtenerUsuario(UserBE.UserLogin);

            if (UsuarioBe == null)
            {
                ModelState.AddModelError("", "El Usuario no Existe");
                return(View(UserBE));
            }
            else if (UsuarioBe.UserPassword.Equals(UserBE.UserPassword))
            {
                FormsAuthentication.SetAuthCookie(UserBE.UserLogin, true);
                Session["Usuario"] = UsuarioBe;
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                ModelState.AddModelError("", "Usuario o Contraseña Incorrectos");
                return(View(UserBE));
            }
        }
Пример #26
0
        protected void btnGuardar_Click(object sender, EventArgs e)
        {
            UsersBR       oSecurityClient   = new UsersBR();
            UserBE        Respuesta         = new UserBE();
            ReglasBE      Reglas            = new ReglasBE();
            string        sMensaje          = string.Empty;
            StringBuilder sMensajeRespuesta = new StringBuilder(string.Empty);
            bool          res;

            Respuesta    = GetWUCs();
            Reglas.IDAPP = long.Parse(ResIEL.IdApp);



            res = oSecurityClient.updateUsuario(Reglas, Respuesta.USUARIOS, Respuesta.DOMICILIOS, Respuesta.CONTACTOS,
                                                Respuesta.DATOSUSUARIO.RolesXUsuario, long.Parse(ResIEL.IdApp));


            sMensajeRespuesta.Append("alert('");
            if (res)
            {
                sMensaje = "El Usuario se actualizó correctamente.";
                sMensajeRespuesta.Append(sMensaje);
            }
            else
            {
                sMensaje = "Existió un error al dar de alta al cliente.";
                sMensajeRespuesta.Append(sMensaje);
            }


            sMensajeRespuesta.Append("');");

            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.Append(@"<script type='text/javascript'>");
            sb.Append(sMensajeRespuesta.ToString());
            sb.Append(@"</script>");
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ShowAlertUpdateScript", sb.ToString(), false);
        }
Пример #27
0
        protected void grdUsuarios_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int               index       = Convert.ToInt32(e.CommandArgument);
            StringBuilder     sMensajelbl = new StringBuilder(string.Empty);
            List <UsuariosBE> lstUsaurios = (List <UsuariosBE>)ViewState["lstUsuarios"];
            UsuariosBE        item        = new UsuariosBE();
            GridViewRow       gvrow       = grdUsuarios.Rows[index];
            UserBE            Usuario     = new UserBE();

            string sIdUsuario = grdUsuarios.DataKeys[index].Value.ToString();

            UsersBR  oUserSecurityServiceClient = new UsersBR();
            ReglasBE Reglas = new ReglasBE();

            Reglas.USUARIO      = sIdUsuario;
            Reglas.TIPOBUSQUEDA = 1;

            Usuario.DATOSUSUARIO = oUserSecurityServiceClient.getUsuarioFull(Reglas, long.Parse(ResIEL.IdApp));

            if (e.CommandName.Equals("EditUsuario"))
            {
                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                sb.Append(@"<script type='text/javascript'>");
                sb.Append("$('#mdlUser').modal('show');");
                sb.Append(@"</script>");
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "mdlEditUserScript", sb.ToString(), false);

                sMensajelbl.Append(" EDITAR USUARIO ");
                //sMensajelbl.Append(item.psNOMBRECATALOGO);

                lblModalUser.Text = sMensajelbl.ToString();

                UserFullWUC.ClearWUCs();
                UserFullWUC.SetWUCs(Usuario);
                UserFullWUC.RegisterWUCsScripts();
            }

            RegisterGridpaging(grdUsuarios);
        }
Пример #28
0
        public bool SetUserPermission(UserBE entity, DBContext dbCon)
        {
            try
            {
                var  dataSet    = new DataSet();
                var  parameters = Array.Empty <SqlParameter>();
                bool result     = false;


                //probar bien esto
                try
                {
                    foreach (var userper in entity.Permissions)
                    {
                        parameters = new SqlParameter[3];

                        parameters[1] = dbCon.CreateParameters("@userID", entity.Id);
                        parameters[0] = dbCon.CreateParameters("@permissionID", userper.Id);
                        parameters[2] = dbCon.CreateParameters("@userpermissionID", Guid.NewGuid());

                        result = (dbCon.Write("SetUserPermission", parameters) > 0) ? true : false;
                    }
                    return(result);
                }
                catch (Exception ex)
                {
                    throw ex;
                }



                return(result);
            }
            catch (Exception ex)
            {
                throw new Exception(Messages.Generic_Error);
            }
        }
Пример #29
0
        public AnswerResponseBE InsertUser(UserBE IUSER)
        {
            AnswerResponseBE  AR   = new AnswerResponseBE();
            EmploActiEntities BDEA = new EmploActiEntities();

            try
            {
                int CountUser = 0;
                CountUser = BDEA.User.Where(x => x.IdUser == IUSER.IdUser).ToList().Count();
                if (CountUser == 0)
                {
                    User US = new User();
                    US.NameUser = IUSER.NameUser;
                    US.Password = IUSER.Password;

                    BDEA.User.Add(US);
                    BDEA.SaveChanges();

                    AR.CodeError        = 0;
                    AR.DescriptionError = "Se ha insertado el usuario correctamente";
                }
                else
                {
                    AR.CodeError        = 2;
                    AR.DescriptionError = "El registro ya existe, por favor verifique la información";
                }
            }
            catch (Exception EX)
            {
                AR.CodeError        = 1;
                AR.DescriptionError = "Hubo un error";
            }
            finally
            {
                BDEA.Dispose();
            }
            return(AR);
        }
Пример #30
0
        private void SetGrid(bool bCargaInicial)
        {
            UsersBR           oUserSecurity = new UsersBR();
            ReglasBE          Reglas        = new ReglasBE();
            UserBE            Usuario       = new UserBE();
            UsuariosBE        item          = new UsuariosBE();
            List <UsuariosBE> lstUsuarios   = new List <UsuariosBE>();

            // item.IDAPLICACION = ddlSistema.SelectedIndex;
            item.IDUSUARIOAPP = txtUsuario.Text;
            item.NOMBRE       = txtNombre.Text;
            item.APATERNO     = txtAPaterno.Text;
            item.AMATERNO     = txtAMaterno.Text;

            if (bCargaInicial)
            {
                lstUsuarios = oUserSecurity.GetUsuarios(item, long.Parse(ResIEL.IdApp));
                ViewState["lstUsuarios"] = lstUsuarios;
            }
            lstUsuarios            = (List <UsuariosBE>)ViewState["lstUsuarios"];
            grdUsuarios.DataSource = lstUsuarios;
            grdUsuarios.DataBind();
        }
Пример #31
0
        public UserBE Users_GetByExternalName(string externalUserName, uint serviceId)
        {
            if (string.IsNullOrEmpty(externalUserName))
            {
                return(null);
            }
            UserBE user = null;

            Catalog.NewQuery(@" /* Users_GetByExternalName */
select  *
from    users 
where   user_external_name = ?EXTERNAL_NAME
AND     user_service_id = ?SERVICE_ID;")
            .With("EXTERNAL_NAME", externalUserName)
            .With("SERVICE_ID", serviceId)
            .Execute(delegate(IDataReader dr) {
                if (dr.Read())
                {
                    user = Users_Populate(dr);
                }
            });
            return(user);
        }
Пример #32
0
        public static XDoc GetArchivePageXml(uint pageid)
        {
            XDoc      ret  = XDoc.Empty;
            ArchiveBE page = DbUtils.CurrentSession.Archive_GetPageHeadById(pageid);

            if (page == null)
            {
                throw new PageArchiveLogicNotFoundException(pageid);
            }

            //Retrieve metadata about the deletion to populate page info
            TransactionBE t         = DbUtils.CurrentSession.Transactions_GetById(page.TransactionId);
            DateTime      deleteTs  = DateTime.MinValue;
            UserBE        deletedBy = null;

            if (t != null)
            {
                deletedBy = UserBL.GetUserById(t.UserId);
                deleteTs  = t.TimeStamp;
            }

            return(GetArchivePageXml(ret, page, deletedBy, deleteTs));
        }
Пример #33
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // string PageName = Request.QueryString["Page"];
            LoggedIn lgdIn = (LoggedIn)this.Page.Master;

            LoggedInUser = (UserBE)Session["LoggedInUser"];

            if (LoggedInUser == null)
            {
                // return to login page because user has not loggedin or session has timedout...
                Response.Redirect("~/Login.aspx");
            }



            if (Session["HomePageId"] != null)
            {
                if (!IsPostBack)
                {
                    hdnHomePageId.Value = Session["HomePageId"].ToString();
                    btnUpdate.Visible   = true;
                    btnSave.Visible     = false;
                    btnBack.Visible     = true;
                    retreiveDATA();
                    Session["HomePageId"] = null;
                }
            }
            else
            {
                if (!IsPostBack)
                {
                    btnUpdate.Visible = false;
                    btnSave.Visible   = true;
                    btnBack.Visible   = false;
                }
            }
        }
Пример #34
0
        private void saveUserRec()
        {
            UserBE objUsr = new UserBE();
            objUsr.EmailID = txtUserEmail.Text;
            objUsr.FirstName = txtUserFName.Text;
            objUsr.LastName = txtUserLName.Text;
            objUsr.Address = "";
            objUsr.Telephone = txtUserPhone.Text.Trim();
            objUsr.Role = (chkAdmin.Checked ? "Admin" : "User");
            objUsr.ClientID = Convert.ToInt32(Session["ClientID"]);
            objUsr.Department = txtUserDept.Text;
            objUsr.UserStatus = hUserStatus.Value;
            objUsr.isPrimary = false;
            objUsr.CreatedBy = Convert.ToInt32(Session["UserID"]);
            objUsr.UserID = Convert.ToInt32(hUserID.Value);
            if (objUsr.ClientID == 0)
            {
                objUsr.Role = "AEAdmin";
            }
            if (hAction.Value == "A")
            {
                string rndPasswd = RandomPassword.Generate();
                objUsr.Password = EBirdUtility.Encrypt(rndPasswd);
                if (objUserDA.AddUserAccountDA(objUsr) > 0)
                {
                    popUsers();
                    // Emailing the account details to user
                    int reqID = SaveToEmailJob(txtUserEmail.Text, rndPasswd);
                    if (reqID > 0)
                    {
                        EmailApp objEmailing = new EmailApp();
                        objEmailing.SendEmail(reqID);
                    }
                    lbtnBack_Click(null, null);
                }
                else
                {
                    dvMsg.Visible = true;
                    lblmsg.Text = objError.getMessage("AM0002");
                }
            }
            if (hAction.Value == "E")
            {
                int PrimaryAdmin = objUsr.UserID;

                if (lblPrimary.Visible)
                {
                    if (chkAdmin.Checked)
                        objUsr.isPrimary = true;
                    else
                        PrimaryAdmin = Convert.ToInt32(rcmbAdmin.SelectedValue);
                }
                if (objUserDA.UpdateUserRecord(objUsr, PrimaryAdmin))
                {
                    popUsers();
                    lbtnBack_Click(null, null);
                }
                else
                {
                    dvMsg.Visible = true;
                    lblmsg.Text = objError.getMessage("AM0012");
                }
            }
        }
Пример #35
0
 public void UpdateUserAcccountSetting(UserBE objUserBE)
 {
     try
     {
         using (MySqlConnection sqlCon = new MySqlConnection(Constant.EBirdConnectionString))
         {
             MySqlCommand sqlCmd = new MySqlCommand(DBQuery.sqlUserAcctSettingUpdate, sqlCon);
             sqlCmd.Parameters.Add(new MySqlParameter("@isEmailWeekly", objUserBE.isEmailWeeklyUpdate));
             sqlCmd.Parameters.Add(new MySqlParameter("@TimeZoneID", objUserBE.TimeZoneID));
             sqlCmd.Parameters.Add(new MySqlParameter("@isAutoDLSave", objUserBE.isAutoDLSave));
             sqlCmd.Parameters.Add(new MySqlParameter("@userID", objUserBE.UserID));
             sqlCon.Open();
             sqlCmd.CommandType = CommandType.Text;
             sqlCmd.ExecuteNonQuery();
         }
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Пример #36
0
        public uint Users_Insert(UserBE newUser) {
            uint userId = Catalog.NewQuery(@" /* Users_Insert */
insert into users
	(user_role_id,user_name,user_password,user_newpassword,user_touched,user_email,user_service_id,user_active,user_real_name,user_external_name,user_create_timestamp,user_language,user_timezone,user_seat)
values
	(?ROLEID, ?USERNAME, ?USERPASSWORD, ?NEWPASSWORD, ?TOUCHED, ?EMAIL, ?SERVICEID, ?ACTIVE, ?REALNAME, ?EXTERNALNAME, ?USER_CREATE_TIMESTAMP, ?USER_LANGUAGE, ?USER_TIMEZONE, ?USER_SEAT);
select LAST_INSERT_ID();")
                .With("USERPASSWORD", newUser._Password)
                .With("NEWPASSWORD", newUser._NewPassword)
                .With("ROLEID", newUser.RoleId)
                .With("USERNAME", newUser.Name)
                .With("TOUCHED", newUser._Touched)
                .With("EMAIL", newUser.Email)
                .With("SERVICEID", newUser.ServiceId)
                .With("ACTIVE", newUser.UserActive)
                .With("REALNAME", newUser.RealName)
                .With("EXTERNALNAME", newUser.ExternalName)
                .With("USER_CREATE_TIMESTAMP", newUser.CreateTimestamp)
                .With("USER_TIMEZONE", newUser.Timezone)
                .With("USER_LANGUAGE", newUser.Language)
                .With("USER_SEAT", newUser.LicenseSeat ? 1 : 0)
                .ReadAsUInt() ?? 0;

            return userId;
        }
Пример #37
0
        public bool UpdateUserRecord(UserBE objUserBE, int priAdminID)
        {
            bool rtnVal = false;
            try
            {
                using (MySqlConnection sqlCon = new MySqlConnection(Constant.EBirdConnectionString))
                {
                    MySqlCommand sqlCmd = new MySqlCommand("spUpdateUserInfo", sqlCon);

                    sqlCmd.Parameters.Add(new MySqlParameter("pEmailID", objUserBE.EmailID));
                    sqlCmd.Parameters.Add(new MySqlParameter("pFirstName", objUserBE.FirstName));
                    sqlCmd.Parameters.Add(new MySqlParameter("pLastName", objUserBE.LastName));
                    sqlCmd.Parameters.Add(new MySqlParameter("pAddress1", objUserBE.Address));
                    sqlCmd.Parameters.Add(new MySqlParameter("pTelephone", objUserBE.Telephone));
                    sqlCmd.Parameters.Add(new MySqlParameter("pRole", objUserBE.Role));
                    sqlCmd.Parameters.Add(new MySqlParameter("pClientID", objUserBE.ClientID));
                    sqlCmd.Parameters.Add(new MySqlParameter("pDepartment", objUserBE.Department));
                    sqlCmd.Parameters.Add(new MySqlParameter("pUserStatus", objUserBE.UserStatus));
                    sqlCmd.Parameters.Add(new MySqlParameter("pIsPrimary", (objUserBE.isPrimary ? 1 : 0)));
                    sqlCmd.Parameters.Add(new MySqlParameter("pPrimaryAdminID", priAdminID));
                    sqlCmd.Parameters.Add(new MySqlParameter("pUserID", objUserBE.UserID));

                    sqlCon.Open();
                    sqlCmd.CommandType = CommandType.StoredProcedure;
                    MySqlDataReader reader = sqlCmd.ExecuteReader();
                    if (reader.HasRows)
                    {
                        reader.Read();
                        if (Convert.ToInt32(reader.GetValue(0)) == 0)
                            rtnVal = true;
                    }
                    reader.Close();
                    reader = null;
                    sqlCon.Close();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return rtnVal;
        }
Пример #38
0
        public void UpdateUserProfileRecord(UserBE objUserBE)
        {
            try
            {
                using (MySqlConnection sqlCon = new MySqlConnection(Constant.EBirdConnectionString))
                {
                    MySqlCommand sqlCmd = new MySqlCommand(DBQuery.sqlUserProfileUpdate, sqlCon);

                    sqlCmd.Parameters.Add(new MySqlParameter("@FirstName", objUserBE.FirstName));
                    sqlCmd.Parameters.Add(new MySqlParameter("@LastName", objUserBE.LastName));
                    sqlCmd.Parameters.Add(new MySqlParameter("@Telephone", objUserBE.Telephone));
                    sqlCmd.Parameters.Add(new MySqlParameter("@Department", objUserBE.Department));
                    sqlCmd.Parameters.Add(new MySqlParameter("@jobTitle", objUserBE.JobTitle));
                    sqlCmd.Parameters.Add(new MySqlParameter("@userID", objUserBE.UserID));

                    sqlCon.Open();
                    sqlCmd.CommandType = CommandType.Text;
                    sqlCmd.ExecuteNonQuery();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Пример #39
0
        public void Users_Update(UserBE user) {
            if(user == null || user.ID == 0)
                return;

            Catalog.NewQuery(@" /* Users_Update */
UPDATE users 
SET user_role_id = ?ROLEID,
user_name = ?USERNAME,
user_password = ?USERPASSWORD,
user_newpassword = ?NEWPASSWORD,
user_touched = ?TOUCHED,
user_email = ?EMAIL,
user_service_id = ?SERVICEID,
user_active = ?ACTIVE,
user_real_name = ?REALNAME,
user_external_name = ?EXTERNALNAME,
user_create_timestamp = ?USER_CREATE_TIMESTAMP,
user_timezone = ?USER_TIMEZONE,
user_language = ?USER_LANGUAGE,
user_seat = ?USER_SEAT
WHERE user_id = ?USERID;")
               .With("USERPASSWORD", user._Password)
               .With("NEWPASSWORD", user._NewPassword)
               .With("ROLEID", user.RoleId)
               .With("USERNAME", user.Name)
               .With("TOUCHED", user._Touched)
               .With("EMAIL", user.Email)
               .With("SERVICEID", user.ServiceId)
               .With("ACTIVE", user.UserActive)
               .With("REALNAME", user.RealName)
               .With("USERID", user.ID)
               .With("EXTERNALNAME", user.ExternalName)
               .With("USER_CREATE_TIMESTAMP", user.CreateTimestamp)
               .With("USER_TIMEZONE", user.Timezone)
               .With("USER_LANGUAGE", user.Language)
               .With("USER_SEAT", user.LicenseSeat)
               .Execute();
        }
Пример #40
0
        public void RecentChanges_Insert(DateTime timestamp, PageBE page, UserBE user, string comment, ulong lastoldid, RC type, uint movedToNS, string movedToTitle, bool isMinorChange, uint transactionId) {
            string dbtimestamp = DbUtils.ToString(timestamp);
            string pageTitle = String.Empty;
            NS pageNamespace = NS.MAIN;
            ulong pageID = 0;
            uint userID = 0;
            if (page != null) {
                pageTitle = page.Title.AsUnprefixedDbPath() ;
                pageNamespace = page.Title.Namespace;
                pageID = page.ID;
            }

            if (user != null) {
                userID = user.ID;
            }

            string q = "/* RecentChanges_Insert */";
            if(lastoldid > 0) {
                q += @"
UPDATE recentchanges SET rc_this_oldid = ?LASTOLDID 
WHERE rc_namespace = ?NS 
AND rc_title = ?TITLE 
AND rc_this_oldid=0;";
            }
             q += @"
INSERT INTO recentchanges
(rc_timestamp, rc_cur_time, rc_user, rc_namespace, rc_title, rc_comment, rc_cur_id, rc_this_oldid, rc_last_oldid, rc_type, rc_moved_to_ns, rc_moved_to_title, rc_minor, rc_transaction_id)
VALUES
(?TS, ?TS, ?USER, ?NS, ?TITLE, ?COMMENT, ?CURID, 0, ?LASTOLDID, ?TYPE, ?MOVEDTONS, ?MOVEDTOTITLE, ?MINOR, ?TRANID);
";

            if(!string.IsNullOrEmpty(comment) && comment.Length > MAXCOMMENTLENGTH) {
                string segment1 = comment.Substring(0, MAXCOMMENTLENGTH / 2);
                string segment2 = comment.Substring(comment.Length - MAXCOMMENTLENGTH / 2 + 3);
                comment = string.Format("{0}...{1}", segment1, segment2);
            }
            
            Catalog.NewQuery(q)
                .With("TS", dbtimestamp)
                .With("USER", userID)
                .With("NS", pageNamespace)
                .With("TITLE", pageTitle)
                .With("COMMENT", comment)
                .With("CURID", pageID)
                .With("LASTOLDID", lastoldid)
                .With("TYPE", (uint) type)
                .With("MOVEDTONS", movedToNS)
                .With("MOVEDTOTITLE", movedToTitle)
                .With("MINOR", isMinorChange ? 1 : 0)
                .With("TRANID", transactionId)
                .Execute();
        }
Пример #41
0
 private UserBE Users_Populate(IDataReader dr) {
     UserBE user = new UserBE();
     user._NewPassword = dr.Read<byte[]>("user_newpassword");
     user._Password = dr.Read<byte[]>("user_password");
     user._Touched = dr.Read<string>("user_touched");
     user.CreateTimestamp = dr.Read<DateTime>("user_create_timestamp");
     user.Email = dr.Read<string>("user_email");
     user.ExternalName = dr.Read<string>("user_external_name");
     user.ID = dr.Read<uint>("user_id");
     user.Language = dr.Read<string>("user_language");
     user.Name = dr.Read<string>("user_name");
     user.RealName = dr.Read<string>("user_real_name");
     user.RoleId = dr.Read<uint>("user_role_id");
     user.ServiceId = dr.Read<uint>("user_service_id");
     user.Timezone = dr.Read<string>("user_timezone");
     user.UserActive = dr.Read<bool>("user_active");
     user.LicenseSeat = dr.Read<bool>("user_seat");
     return user;
 }
Пример #42
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            int ID = Convert.ToInt32(hClientID.Value);
            if (ID != 0 && (hCurrStatus.Value != rcmbStatus.SelectedValue))
            {
                objClientDA.UpdateClientStatusDA(ID, rcmbStatus.SelectedValue, Convert.ToInt32(Session["UserID"]));
                popClients();
                lbtnBack_Click(null, null);
            }
            else
            {
                // Business rule check
                if ((ID != 0) && (Convert.ToInt32(txtNoUsers.Text) < Convert.ToInt32(hActiveUserCnt.Value)))
                {
                    dvValidationMsg.Visible = true;
                    lblValidationMsg.Text = objError.getMessage("SS0003");
                }
                else if (ID != 0)
                {
                    if (objUserDA.isUserExistDA(txtAdminEmail.Text.Trim(), Convert.ToInt32(hAdminID.Value)))
                    {
                        dvValidationMsg.Visible = true;
                        lblValidationMsg.Text = objError.getMessage("AM0012");
                    }
                }
                else if (ID == 0)
                {
                    if (objUserDA.isUserExistDA(txtAdminEmail.Text.Trim()))
                    {
                        dvValidationMsg.Visible = true;
                        lblValidationMsg.Text = objError.getMessage("AM0002");
                    }
                }

                if (dvValidationMsg.Visible == false)
                {
                    #region add/update client profile

                    objClientBE.ClientID = ID;
                    objClientBE.ClientName = txtClientName.Text;
                    objClientBE.Address1 = txtAddress.Text;
                    objClientBE.City = txtCity.Text;
                    objClientBE.State = txtState.Text;
                    objClientBE.CountryID = Convert.ToInt32(rcmbCountry.SelectedValue);
                    objClientBE.PostCode = txtPostcode.Text;
                    objClientBE.Phone = txtPhone.Text;
                    objClientBE.Website = txtWebsite.Text;
                    objClientBE.IndustryID = Convert.ToInt32(rcmbIndustry.SelectedValue);
                    objClientBE.AnnualRevID = Convert.ToInt32(rcmbRevenue.SelectedValue);
                    objClientBE.NoOfUsers = Convert.ToInt32(txtNoUsers.Text);
                    objClientBE.CurrentPkgSubscribed = chkPackage.SelectedValue;
                    objClientBE.ClientStatus = rcmbStatus.SelectedValue; // "Active";
                    objClientBE.CreatedBy = Convert.ToInt32(Session["UserID"]);
                    ID = objClientDA.SaveClientProfileDA(objClientBE);
                    #endregion

                    #region Creating required folder structure for client
                    if (hClientID.Value == "0" && ID != 0)
                    {
                        DocAccess objDocAccess = new DocAccess();
                        if (!objDocAccess.InitClientFolders(ID))
                            lblFilterError.Text = objError.getMessage("AM0010");
                    }
                    #endregion

                    #region Updating primary contact and administrator
                    if (ID != 0)
                    {
                        lblClientError.Text = "";
                        //Saving Contact
                        ContactBE objContact = new ContactBE();
                        objContact.ClientID = ID;
                        objContact.ContactID = Convert.ToInt32(hContactID.Value);
                        objContact.Contactname = txtContactName.Text;
                        objContact.Phone = txtContactPhone.Text;
                        objContact.Email = txtContactEmail.Text;
                        objContact.Department = txtContactDepart.Text;
                        objContact.JobTitle = txtJobTitle.Text;
                        objClientDA.SaveClientContactDA(objContact);

                        //Saving Primary administrator

                        UserBE objUserBE = new UserBE();

                        objUserBE.UserID = Convert.ToInt32(hAdminID.Value);
                        objUserBE.EmailID = txtAdminEmail.Text;
                        objUserBE.FirstName = txtAdminFName.Text;
                        objUserBE.LastName = txtAdminLName.Text;
                        objUserBE.Address = "";
                        objUserBE.Telephone = txtAdminPhone.Text;
                        objUserBE.Role = "Admin";
                        objUserBE.ClientID = ID;
                        objUserBE.Department = txtAdminDept.Text;
                        objUserBE.UserStatus = "Active";
                        objUserBE.isPrimary = true;
                        objUserBE.CreatedBy = Convert.ToInt32(Session["UserID"]);

                        if (Convert.ToInt32(hAdminID.Value) != 0)
                        {
                            if (!objUserDA.UpdateUserRecord(objUserBE, objUserBE.UserID))
                                lblClientError.Text = objError.getMessage("AM0012");
                        }
                        else
                        {
                            string rndPasswd = RandomPassword.Generate();
                            objUserBE.Password = rndPasswd;

                            if (objUserDA.AddUserAccountDA(objUserBE) > 0)
                            {
                                // Emailing the account details to user
                                int reqID = SaveToEmailJob(txtAdminEmail.Text, rndPasswd);
                                if (reqID > 0)
                                {
                                    EmailApp objEmailing = new EmailApp();
                                    objEmailing.SendEmail(reqID);
                                }
                            }
                        }
                        // Following commented on 2/20/13 - J, as these logics ar moved inside the sp for add/edit client profile
                        //if (hClientID.Value == "0")
                        //    objClientDA.InitClientConfigDA(ID, chkPackage.SelectedValue, false);
                        //else if (hCurrPkg.Value != chkPackage.SelectedValue)
                        //    objClientDA.InitClientConfigDA(ID, chkPackage.SelectedValue, true);

                        //Session["clientID"] = ID.ToString();
                        //Response.Redirect("ClientConfig/");
                        popClients();
                        if (lblClientError.Text == "")
                            lbtnBack_Click(null, null);
                    }
                    #endregion
                    if (lblClientError.Text == "")
                        clearAll();
                }
            }
        }