示例#1
0
        private static CBE.UserCBE CreateObjectFromDataRow(DataRow dr)
        {
            VaaaN.MLFF.Libraries.CommonLibrary.CBE.UserCBE user = new VaaaN.MLFF.Libraries.CommonLibrary.CBE.UserCBE();

            if (dr["USER_ID"] != DBNull.Value)
            {
                user.UserId = Convert.ToInt32(dr["USER_ID"]);
            }

            //if (dr["organization_id"] != DBNull.Value)
            //    user.OrganizationId = Convert.ToInt32(dr["organization_id"]);

            if (dr["login_name"] != DBNull.Value)
            {
                user.LoginName = Convert.ToString(dr["login_name"]);
            }

            if (dr["first_name"] != DBNull.Value)
            {
                user.FirstName = Convert.ToString(dr["first_name"]);
            }

            if (dr["last_name"] != DBNull.Value)
            {
                user.LastName = Convert.ToString(dr["last_name"]);
            }
            if (dr["role_name"] != DBNull.Value)
            {
                user.RoleName = Convert.ToString(dr["role_name"]);
            }

            return(user);
        }
示例#2
0
        private DataTable CreateCommonDataTable(string reportName)
        {
            CommonDataSet.CommonDataTable dt = new CommonDataSet.CommonDataTable();
            DataRow dr = dt.NewRow();

            VaaaN.MLFF.Libraries.CommonLibrary.CBE.UserCBE usr = new VaaaN.MLFF.Libraries.CommonLibrary.CBE.UserCBE();
            usr.UserId = Convert.ToInt32(Session["LoggedUserId"]);
            VaaaN.MLFF.Libraries.CommonLibrary.CBE.UserCBE user = VaaaN.MLFF.Libraries.CommonLibrary.BLL.UserBLL.GetUserById(usr);
            dr["footer_detail"] = reportName + " Generated at " + DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss tt") + " By " + user.LoginName;
            dr["report_name"]   = reportName;
            dr["company_name"]  = "Bali Tower";
            dr["project_name"]  = "MLFF";

            try
            {
                Image img = Image.FromFile(@"C:\MLFF\Config\logo.jpg");
                using (MemoryStream mStream = new MemoryStream())
                {
                    img.Save(mStream, img.RawFormat);
                    dr["logo_1"] = mStream.ToArray();
                }

                img = Image.FromFile(@"C:\MLFF\Config\smarterplogo.jpg");
                using (MemoryStream mStream = new MemoryStream())
                {
                    img.Save(mStream, img.RawFormat);
                    dr["logo_2"] = mStream.ToArray();
                }
            }
            catch (Exception ex)
            {
                LogMessage("Report logo not found." + ex.Message);
            }

            dt.Rows.Add(dr);

            return(dt);
        }
示例#3
0
        /// <summary>
        /// Check login status based on username and password provided
        /// </summary>
        /// <param name="username">user login name</param>
        /// <param name="password">user password</param>
        /// <returns>return values defined in Constants.LoginResult. </returns>
        public static VaaaN.MLFF.Libraries.CommonLibrary.Constants.LoginResult ValidateUser(string loginName, string password, ref VaaaN.MLFF.Libraries.CommonLibrary.CBE.UserCBE currentUser)
        {
            VaaaN.MLFF.Libraries.CommonLibrary.Constants.LoginResult result = VaaaN.MLFF.Libraries.CommonLibrary.Constants.LoginResult.InvalidUser;
            CBE.UserCollection users = new CBE.UserCollection();

            try
            {
                users = VaaaN.MLFF.Libraries.CommonLibrary.DAL.LoginDAL.GetUserByLoginName(loginName);

                if (users.Count == 0)
                {
                    result = VaaaN.MLFF.Libraries.CommonLibrary.Constants.LoginResult.InvalidUser;
                }
                else
                {
                    foreach (CBE.UserCBE user in users)
                    {
                        if (user.LoginName.ToLower() == loginName.ToLower() && user.Password == VaaaN.MLFF.Libraries.CommonLibrary.Cryptography.Encryption.ComputeHash(password))
                        {
                            result      = VaaaN.MLFF.Libraries.CommonLibrary.Constants.LoginResult.Successful;
                            currentUser = user;

                            //Check Account expiry
                            if (currentUser.AccountExpiryDate < System.DateTime.Now)
                            {
                                result = VaaaN.MLFF.Libraries.CommonLibrary.Constants.LoginResult.AccountExpired;
                            }


                            break;
                        }
                        else
                        {
                            result = VaaaN.MLFF.Libraries.CommonLibrary.Constants.LoginResult.InvalidUser;
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                result = VaaaN.MLFF.Libraries.CommonLibrary.Constants.LoginResult.DatabaseError;
                VaaaN.MLFF.Libraries.CommonLibrary.Logger.Log.Write("Failed to validate user. " + ex.ToString(), VaaaN.MLFF.Libraries.CommonLibrary.Logger.Log.ErrorLogModule.LoginModule);

                throw ex;
            }
            return(result);
        }
示例#4
0
 public static void Delete(VaaaN.MLFF.Libraries.CommonLibrary.CBE.UserCBE user)
 {
     VaaaN.MLFF.Libraries.CommonLibrary.DAL.UserDAL.Delete(user);
 }
示例#5
0
 public static void UpdateWithPassword(VaaaN.MLFF.Libraries.CommonLibrary.CBE.UserCBE newObject, VaaaN.MLFF.Libraries.CommonLibrary.CBE.UserCBE oldObject)
 {
     newObject.Password = VaaaN.MLFF.Libraries.CommonLibrary.Cryptography.Encryption.ComputeHash(newObject.Password);
     //Update user record
     VaaaN.MLFF.Libraries.CommonLibrary.DAL.UserDAL.UpdateWithPassword(newObject);
 }
示例#6
0
 public static void Update(VaaaN.MLFF.Libraries.CommonLibrary.CBE.UserCBE newObject, VaaaN.MLFF.Libraries.CommonLibrary.CBE.UserCBE oldObject)
 {
     //Update user record
     VaaaN.MLFF.Libraries.CommonLibrary.DAL.UserDAL.Update(newObject);
 }
示例#7
0
 public static int Insert(VaaaN.MLFF.Libraries.CommonLibrary.CBE.UserCBE user)
 {
     user.Password = VaaaN.MLFF.Libraries.CommonLibrary.Cryptography.Encryption.ComputeHash(user.Password);
     return(VaaaN.MLFF.Libraries.CommonLibrary.DAL.UserDAL.Insert(user));
 }
示例#8
0
 public static VaaaN.MLFF.Libraries.CommonLibrary.CBE.UserCBE GetUserById(VaaaN.MLFF.Libraries.CommonLibrary.CBE.UserCBE user)
 {
     return(VaaaN.MLFF.Libraries.CommonLibrary.DAL.UserDAL.GetUserById(user));
 }