public SigmaResultType AddSigmaUser(TypeSigmaUser objSigmaUser) { TypeUserInfo userinfo = AuthMgr.GetUserInfo(); objSigmaUser.CreatedBy = userinfo.SigmaUserId; TransactionScope scope = null; SigmaResultType result = new SigmaResultType(); // Get connection string string connStr = ConnStrHelper.getDbConnString(); string pwd = RandumPassword(); List<SqlParameter> paramList = new List<SqlParameter>(); paramList.Add(new SqlParameter("@SigmaUserId", objSigmaUser.SigmaUserId)); paramList.Add(new SqlParameter("@CompanyId", objSigmaUser.CompanyId)); paramList.Add(new SqlParameter("@EmployeeId", objSigmaUser.EmployeeId)); paramList.Add(new SqlParameter("@FirstName", objSigmaUser.FirstName)); paramList.Add(new SqlParameter("@LastName", objSigmaUser.LastName)); paramList.Add(new SqlParameter("@PhoneNo", objSigmaUser.PhoneNo)); paramList.Add(new SqlParameter("@Email", objSigmaUser.Email)); paramList.Add(new SqlParameter("@PhotoUrl", objSigmaUser.PhotoUrl)); paramList.Add(new SqlParameter("@Password", GetMD5Hash(RandumPassword()))); paramList.Add(new SqlParameter("@CreatedBy", objSigmaUser.CreatedBy)); using (scope = new TransactionScope(TransactionScopeOption.Required)) { result.AffectedRow = SqlHelper.ExecuteNonQuery(connStr, CommandType.StoredProcedure, "usp_AddSigmaUser", paramList.ToArray()); objSigmaUser.Password = pwd; MailMgr mailMgr = new MailMgr(); mailMgr.SendMail(objSigmaUser); result.IsSuccessful = true; scope.Complete(); } return result; }
public SigmaResultType AddSigmaUserTemplate(TypeSigmaUser objSigmaUser) { TypeUserInfo userinfo = AuthMgr.GetUserInfo(); objSigmaUser.CreatedBy = userinfo.SigmaUserId; TransactionScope scope = null; SigmaResultType result = new SigmaResultType(); // Get connection string string connStr = ConnStrHelper.getDbConnString(); string pwd = RandumPassword(); List<SqlParameter> paramList = new List<SqlParameter>(); paramList.Add(new SqlParameter("@SigmaUserId", objSigmaUser.SigmaUserId)); paramList.Add(new SqlParameter("@CompanyName", objSigmaUser.CompanyName)); paramList.Add(new SqlParameter("@EmployeeId", objSigmaUser.EmployeeId)); paramList.Add(new SqlParameter("@FirstName", objSigmaUser.FirstName)); paramList.Add(new SqlParameter("@LastName", objSigmaUser.LastName)); paramList.Add(new SqlParameter("@PhoneNo", objSigmaUser.PhoneNo)); paramList.Add(new SqlParameter("@Email", objSigmaUser.Email)); paramList.Add(new SqlParameter("@PhotoUrl", objSigmaUser.PhotoUrl)); paramList.Add(new SqlParameter("@Password", GetMD5Hash(RandumPassword()))); paramList.Add(new SqlParameter("@CreatedBy", objSigmaUser.CreatedBy)); SqlParameter outParam = new SqlParameter("@ExMessage", SqlDbType.NVarChar, 100); outParam.Direction = ParameterDirection.Output; paramList.Add(outParam); using (scope = new TransactionScope(TransactionScopeOption.Required)) { result.AffectedRow = SqlHelper.ExecuteNonQuery(connStr, CommandType.StoredProcedure, "usp_AddSigmaUserByTemplate", paramList.ToArray()); result.IsSuccessful = true; if (!string.IsNullOrEmpty(outParam.Value.ToString())) result.ErrorMessage = outParam.Value.ToString(); else { objSigmaUser.Password = pwd; MailMgr mailMgr = new MailMgr(); mailMgr.SendMail(objSigmaUser); } scope.Complete(); } return result; }