Пример #1
0
        public JsonResult Login(string userName, string password)
        {
            try
            {
                password = Utility.EncryptMd5(password.Trim());
                var ipl = SingletonIpl.GetInstance <IplAccount>();
                var ue  = new AccountEntity();
                var res = ipl.Login(userName, password.Trim(), ref ue);//Md5Util.Md5EnCrypt(password.Trim())

                if (res)
                {
                    var userSess = new UserSession
                    {
                        UserName    = ue.UserName,
                        UserType    = ue.Type,
                        Id          = int.Parse(ue.Id.ToString()),
                        DisplayName = ue.DisplayName,
                        Avatar      = ue.Avatar,
                        Email       = ue.Email
                    };
                    SessionUtility.SetUser(userSess);
                    Session["UserName"] = userName;
                }

                return(Json(new { status = res }, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                return(Json(new { status = false }, JsonRequestBehavior.AllowGet));
            }
        }
Пример #2
0
        public JsonResult UpdateLocaltionByAccountId(bool isAll, string userIdA, string userIdB, string[] listLocaltionId)
        {
            try
            {
                var ipl    = SingletonIpl.GetInstance <IplLocaltion>();
                var listId = string.Empty;
                if (listLocaltionId != null && listLocaltionId.Length > 0)
                {
                    listId = string.Join(",", listLocaltionId);
                }
                var idA = 0;
                if (!string.IsNullOrEmpty(userIdA))
                {
                    int.TryParse(userIdA, out idA);
                }
                var idB = 0;
                if (!string.IsNullOrEmpty(userIdB))
                {
                    int.TryParse(userIdB, out idB);
                }
                var res = ipl.UpdateLocaltionByAccountId(isAll, idA, idB, listId);

                return(Json(new { status = res, Data = res }, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                return(Json(new { status = false }, JsonRequestBehavior.AllowGet));
            }
        }
        // GET: Backend/Profile
        public ActionResult Index(int?id)
        {
            var iplDep = SingletonIpl.GetInstance <IplDepartment>();
            var allDep = iplDep.ListAll();

            ViewData["Department"] = allDep;
            var fullName   = string.Empty;
            var address    = string.Empty;
            var phone      = string.Empty;
            var avatarPath = string.Empty;
            var sess       = SessionSystem.GetUser();
            var emp        = new EmployeeEntity();

            id = id ?? sess.EmployeeId;
            if (sess != null)
            {
                emp = _iplEmployee.ViewDetail((int)id);

                fullName   = emp != null ? emp.FirstName + " " + emp.LastName : sess.Email;
                address    = emp != null ? emp.Address : string.Empty;
                phone      = emp != null ? emp.Phone : sess.Phone;
                avatarPath = !string.IsNullOrEmpty(emp.PicturePath) ? _imagePath + emp.PicturePath : "";
            }
            ViewBag.FullName = fullName;
            ViewBag.Address  = address;
            ViewBag.Phone    = phone;
            ViewBag.Avatar   = avatarPath;
            return(View("Index", emp));
        }
Пример #4
0
        private static IEnumerable <List <object> > GetExportDataAccountCheckin(int accountId, DateTime startDate, DateTime endDate)
        {
            var data = new List <List <object> >();

            try
            {
                var ipl = SingletonIpl.GetInstance <IplLocaltion>();
                var res = ipl.GetExportDataAccountCheckin(accountId, startDate, endDate);

                if (res != null && res.Count > 0)
                {
                    data.AddRange(res.Select(item => item.CheckDate != null ? new List <object>
                    {
                        item.Id,
                        item.UserName ?? "",
                        item.DistrictName ?? "",
                        item.Name ?? "",
                        item.ImageCheckin ?? "",
                        item.Phone ?? "",
                        item.Address ?? "",
                        item.CheckDate.Value.ToString("dd/MM/yyyy"),
                        item.Code ?? ""
                    } : null));
                }
                return(data);
            }
            catch (Exception ex)
            {
                return(data);
            }
        }
Пример #5
0
        private static IEnumerable <List <object> > GetExportDataStatistic(DateTime startDate, DateTime endDate)
        {
            var data = new List <List <object> >();

            try
            {
                var ipl = SingletonIpl.GetInstance <IplStatistic>();
                var res = ipl.GetExportData(startDate, endDate);

                if (res != null && res.Count > 0)
                {
                    data.AddRange(res.Select(item => new List <object>
                    {
                        item.Id,
                        item.UserName ?? "",
                        item.FullName ?? "",
                        item.SumAll,
                        item.SumCheckInMonth,
                        item.FullMinCheckInMonth
                    }));
                }
                return(data);
            }
            catch (Exception ex)
            {
                return(data);
            }
        }
Пример #6
0
        public JsonResult ListAllLocaltionByUserId(int userId)
        {
            try
            {
                var total = 0;
                var ipl   = SingletonIpl.GetInstance <IplLocaltion>();
                var res   = ipl.ListAllPagingByStatus(userId, 0, 0, "", 0, 1000, "", "", ref total);

                if (res != null && res.Count > 0)
                {
                    return(Json(new
                    {
                        data = res.Select(s => new {
                            key = s.Id,
                            label = s.Name
                        }).ToList()
                    }, JsonRequestBehavior.AllowGet));
                }

                return(Json(new
                {
                    data = res
                }, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                return(Json(new
                {
                    status = false,
                    totalCount = 0,
                    totalRow = 0
                }, JsonRequestBehavior.AllowGet));
            }
        }
Пример #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BaseIpl{T}" /> class.
 /// </summary>
 /// <param name="schema">The schema.</param>
 public BaseIpl(string schema = "dbo")
 {
     _schema     = schema;
     cache       = new MemcachedProvider(schema);
     cacheHelper = new CacheHelper(schema);
     unitOfWork  = (T)SingletonIpl.GetInstance <T>(schema);
 }
Пример #8
0
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            var results = new List <ValidationResult>();

            if (string.IsNullOrEmpty(UserName))
            {
                results.Add(new ValidationResult("The Username field is required.", new[] { "Username" }));
            }

            if (string.IsNullOrEmpty(Password))
            {
                results.Add(new ValidationResult("The Password field is required.", new[] { "Password" }));
            }


            // Check User does't exitst of User
            var ctx   = SingletonIpl.GetInstance <DataProvider>();
            var exist = ctx.IsAuthenticated(UserName, Password);

            if (!exist)
            {
                results.Add(new ValidationResult("The Username, Password is incorrect."));
            }

            return(results);
        }
Пример #9
0
        /// <summary>
        /// Check Restaurant code is Restaurant User
        /// </summary>
        /// <param name="resCode"></param>
        /// <returns></returns>
        public static bool IsExistRestaurantOfUser(string resCode)
        {
            var reval = false;
            var ctx   = SingletonIpl.GetInstance <DataProvider>();

            return(reval);
        }
Пример #10
0
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            var results = new List <ValidationResult>();

            if (string.IsNullOrEmpty(Email))
            {
                results.Add(new ValidationResult("The Email field is required.", new[] { "Email" }));
            }

            if (!Sum.HasValue)
            {
                results.Add(new ValidationResult("The Captcha field is required.", new[] { "Sum" }));
            }

            // Check Email & Restaurant does't exitst of User
            var ctx   = SingletonIpl.GetInstance <DataProvider>();
            var exist = ctx.IsExistEmailOfUser(Email);

            if (!exist)
            {
                results.Add(new ValidationResult("The email address does not exist in system.", new[] { "Email" }));
            }

            return(results);
        }
Пример #11
0
        public static List <EmployeeEntity> listEmployee(int Id)
        {
            var _iplEmployee = SingletonIpl.GetInstance <IplEmployee>();
            var list         = _iplEmployee.ListByIdDepart(Id);

            return(list);
        }
        // POST api/accountApi
        public AccountEntity Post(int id)
        {
            var ipl  = SingletonIpl.GetInstance <IplAccount>();
            var data = ipl.ViewDetail(id);

            return(data);
        }
        public JsonResult Add(FormCollection collection)
        {
            try
            {
                var id   = long.Parse(collection["hdProvinceId"]);
                var name = collection["txtName"];
                var type = collection["txtType"];

                var province = new ProvinceEntity
                {
                    Id   = id,
                    Name = name,
                    Type = type
                };
                var ipl = SingletonIpl.GetInstance <IplProvince>();

                if (id == 0)
                {
                    id = ipl.Insert(province);
                    return(Json(new { status = true, Data = id }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    var res = ipl.Update(province);
                    return(Json(new { status = res, Data = res }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                return(Json(new { status = false, message = "Lỗi không lưu được tài khoản." }, JsonRequestBehavior.AllowGet));
            }
        }
        public JsonResult ListAll()
        {
            try
            {
                var total = 0;
                var obj   = new ProvinceEntity();
                var ipl   = SingletonIpl.GetInstance <IplProvince>();
                var res   = ipl.ListAll();

                if (res != null && res.Count > 0)
                {
                    return(Json(new
                    {
                        status = true,
                        Data = res,
                        totalCount = res.Count
                    }, JsonRequestBehavior.AllowGet));
                }

                return(Json(new
                {
                    status = true,
                    Data = res,
                    totalCount = 0
                }, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                return(Json(new
                {
                    status = false
                }, JsonRequestBehavior.AllowGet));
            }
        }
Пример #15
0
        //[AuthorizeUser(ModuleName = "Roles", AccessLevel = Constants.Edit)]
        public JsonResult EditRoles(int userId, int ProjectId, string action, bool access)
        {
            var iplProject_Role = SingletonIpl.GetInstance <IplProject_Role>();
            var ret             = iplProject_Role.Update(userId, ProjectId, action, access);

            return(Json(new { status = ret }));
        }
        // GET api/accountApi
        public IEnumerable <AccountEntity> Get()
        {
            var ipl  = SingletonIpl.GetInstance <IplAccount>();
            var data = ipl.ListAll();

            return(data);
        }
Пример #17
0
        public ActionResult Change(ChangePasswordModel model)
        {
            var sess = SessionSystem.GetUser();

            if (ModelState.IsValid)
            {
                var    userInfo = SingletonIpl.GetInstance <IplUser>().Login(sess.UserName);
                string password = Framework.Security.Crypt.SHA.sha256_hash(model.OldPassword);
                if (userInfo.Password.Equals(password))
                {
                    var newPass = Framework.Security.Crypt.SHA.sha256_hash(model.NewPassword);
                    var flag    = SingletonIpl.GetInstance <IplUser>().ChangePass(sess.UserId, newPass);
                    if (flag)
                    {
                        Logs.logs("Thay đổi pass", "thay đổi pass thành công", "/ChangPassword/Change", sess.UserId);
                        SessionSystem.ClearSession();
                        return(Redirect("/Login"));
                    }
                }
                else
                {
                    ViewBag.MsgOldPass = ConstantMsg.OldPassInvalid;
                }
            }
            return(View("Index"));
        }
Пример #18
0
 public BookRoomsController()
 {
     _iplDepartment  = SingletonIpl.GetInstance <IplDepartment>();
     _iplEmployee    = SingletonIpl.GetInstance <IplEmployee>();
     _iplRoom        = SingletonIpl.GetInstance <IplRoom>();
     _iplBookMeeting = SingletonIpl.GetInstance <IplBookMeeting>();
 }
Пример #19
0
        /// <summary>
        /// Validation UserName, Password & restaurantCode
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="password"></param>
        /// <param name="resCode"></param>
        /// <returns></returns>
        public static bool IsAuthenticated(string userName, string password, string resCode)
        {
            var reval = false;
            var ctx   = SingletonIpl.GetInstance <DataProvider>();

            return(reval);
        }
Пример #20
0
 public ActionResult LogIn(LoginModel model)
 {
     if (ModelState.IsValid)
     {
         if (SecurityService.Login(model.UserName.Trim(), model.Password.Trim(), model.RememberMe))
         {
             var ctx        = SingletonIpl.GetInstance <DataProvider>();
             var userActive = ctx.GetUser(model.UserName.Trim(), model.Password.Trim());
             if (userActive.Active)
             {
                 return(RedirectToAction("Index", "Home"));
             }
             else
             {
                 // Logout for
                 SecurityService.Logout();
                 ModelState.AddModelError(string.Empty, string.Format("User Name or Email is inactive."));
                 return(View(model));
             }
         }
         else
         {
             ModelState.AddModelError(string.Empty, string.Format("The Username, Password is incorrect."));
             return(View(model));
         }
     }
     return(View(model));
 }
Пример #21
0
        public ActionResult ResetPassword(ChangePasswordModel model)
        {
            // Get user by forgot code
            var ctx       = SingletonIpl.GetInstance <DataProvider>();
            var userExist = ctx.GetUser(model.ForgotCode);

            // check if not exists user or forgot expired date
            if (userExist != null && userExist.ForgotExpired > DateTime.UtcNow)
            {
                ViewBag.Time_mail = userExist.ForgotExpired - DateTime.UtcNow;

                // check validation model
                if (ModelState.IsValid)
                {
                    // call reset password
                    ctx.ResetPassword(userExist.UserId, model.PassWord);

                    // call reset expired date
                    ctx.ResetExpireDate(userExist.UserId, null, null);

                    // return view reset result
                    return(View("ResetResult"));
                }
            }
            else
            {
                ModelState.AddModelError("ConfirmPassword", "Password change has expired.");
            }

            return(View(model));
        }
Пример #22
0
        public JsonResult Add(FormCollection collection)
        {
            try
            {
                var id   = long.Parse(collection["hdLocaltionStatusId"]);
                var name = collection["txtName"];

                var localtionStatus = new LocaltionStatusEntity
                {
                    Id   = id,
                    Name = name
                };
                var ipl = SingletonIpl.GetInstance <IplLocaltionStatus>();

                if (id == 0)
                {
                    id = ipl.Insert(localtionStatus);
                    return(Json(new { status = true, Data = id }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    var res = ipl.Update(localtionStatus);
                    return(Json(new { status = res, Data = res }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                return(Json(new { status = false, message = "Lỗi không lưu được trạng thái." }, JsonRequestBehavior.AllowGet));
            }
        }
Пример #23
0
        // GET api/LocaltionApi
        public IEnumerable <LocaltionEntity> Get()
        {
            var ipl  = SingletonIpl.GetInstance <IplLocaltion>();
            var data = ipl.ListAll();

            return(data);
        }
Пример #24
0
        public JsonResult Add(FormCollection collection)
        {
            try
            {
                var      id          = long.Parse(collection["hdAccountId"]);
                var      displayname = collection["txtDisplayName"];
                var      username    = collection["txtUserName"];
                var      password    = Utility.EncryptMd5(collection["txtPassword"]);
                var      email       = collection["txtEmail"];
                var      birthday    = collection["txtBirthDay"];
                DateTime dt          = DateTime.ParseExact(string.IsNullOrEmpty(birthday) ? DateTime.Now.ToString("dd/MM/yyyy") : birthday, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                var      address     = collection["txtAddress"];
                var      phone       = collection["txtPhone"];
                var      status      = (collection["cbxStatus"] ?? "").Equals("on", StringComparison.CurrentCultureIgnoreCase);
                var      type        = int.Parse(collection["sltType"]);
                var      parentId    = int.Parse(collection["sltParent"]);
                var      provinceId  = int.Parse(collection["sltProvince"]);
                var      account     = new AccountEntity
                {
                    Id          = id,
                    ParentId    = parentId,
                    ProvinceId  = provinceId,
                    Type        = type,
                    DisplayName = displayname,
                    UserName    = username,
                    Password    = password,
                    Email       = email,
                    BirthDay    = dt,
                    Address     = address,
                    Phone       = phone,
                    CreatedDate = DateTime.Now,
                    Status      = status
                };
                var ipl = SingletonIpl.GetInstance <IplAccount>();

                if (id == 0)
                {
                    var user = ipl.GetAccountByUserName(username);
                    if (user == null)
                    {
                        id = ipl.Insert(account);
                        return(Json(new { status = true, Data = id }, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        return(Json(new { status = false, message = "Tài khoản này đã tồn tại." }, JsonRequestBehavior.AllowGet));
                    }
                }
                else
                {
                    var res = ipl.Update(account);
                    return(Json(new { status = res, Data = res }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                return(Json(new { status = false, message = "Lỗi không lưu được tài khoản." }, JsonRequestBehavior.AllowGet));
            }
        }
Пример #25
0
        //protected string _schema;

        /// <summary>
        /// Initializes a new instance of the <see cref="BaseDal{T}" /> class.
        /// </summary>
        /// <param name="schema">The schema.</param>
        public BaseDal()
        {
            //_schema = schema;
            //cache = new MemcachedProvider(schema);
            //cacheHelper = new CacheHelper(schema);
            UnitOfWork = (T)SingletonIpl.GetInstance <T>();
            //unitOfWork.CacheHelper = cacheHelper;
        }
Пример #26
0
 public CountController()
 {
     _ipldispatchin     = SingletonIpl.GetInstance <IplDispatchIn>();
     _ipldispatchout    = SingletonIpl.GetInstance <IplDispatchOut>();
     _iplDepartment     = SingletonIpl.GetInstance <IplDepartment>();
     _ipldispatchtype   = SingletonIpl.GetInstance <IplDispatchType>();
     _ipldispatchstatus = SingletonIpl.GetInstance <IplDispatchStatus>();
 }
Пример #27
0
        //[AuthorizeUser(ModuleName = "Roles", AccessLevel = Constants.View)]
        public ActionResult Index(int id)
        {
            var iplProject  = SingletonIpl.GetInstance <IplProject>();
            var ProjectInfo = iplProject.ViewDetailWithCustomer(id);

            ViewData["ListRole"] = _iplProject_Roles.ListAllByProject(id);
            return(View(ProjectInfo));
        }
 public EmployeeController()
 {
     _iplDepartment       = SingletonIpl.GetInstance <IplDepartment>();
     _iplDispatchWork     = SingletonIpl.GetInstance <IplDispatchWork>();
     _iplEmployee         = SingletonIpl.GetInstance <IplEmployee>();
     _iplEmployee_History = SingletonIpl.GetInstance <IplEmployee_History>();
     _iplPosition         = SingletonIpl.GetInstance <IplPosition>();
     _iplUser             = SingletonIpl.GetInstance <IplUser>();
 }
 public ProjectCommentController()
 {
     _iplProject        = SingletonIpl.GetInstance <IplProject>();
     _iplProjectComment = SingletonIpl.GetInstance <IplProject_Comment>();
     _iplProject_Status = SingletonIpl.GetInstance <IplProject_Status>();
     _iplCustomer_Type  = SingletonIpl.GetInstance <IplCustomer_Type>();
     _iplCustomer       = SingletonIpl.GetInstance <IplCustomer>();
     _iplEmployee       = SingletonIpl.GetInstance <IplEmployee>();
     _iplProjectRole    = SingletonIpl.GetInstance <IplProject_Role>();
 }
 // GET: DispatchIn
 public DispatchInController()
 {
     _ipldispatchin       = SingletonIpl.GetInstance <IplDispatchIn>();
     _ipldepartment       = SingletonIpl.GetInstance <IplDepartment>();
     _ipldispatchtype     = SingletonIpl.GetInstance <IplDispatchType>();
     _ipldispatchstatus   = SingletonIpl.GetInstance <IplDispatchStatus>();
     _ipldispatchpriority = SingletonIpl.GetInstance <IplDispatchPriority>();
     _iplemployee         = SingletonIpl.GetInstance <IplEmployee>();
     _iplfile             = SingletonIpl.GetInstance <IplFile>();
 }