public int UpdateLogUserDashboard(EntityUserTimeModel model) { int output = 0; try { Dictionary <string, object> dicParas = new Dictionary <string, object>(); Dictionary <string, object> dicParaOuts = new Dictionary <string, object>(); dicParas.Add("UserId", model.UserId); dicParas.Add("PKID", model.PKID); dicParas.Add("UserName", model.UserName); dicParas.Add("Dashboard", model.Dashboard); dicParas.Add("TimeLogin", model.TimeLogin); dicParas.Add("Date", model.Date); output = DBConnection.ExecSPNonQuery("SP_USER_LOG_DASHBOARD", dicParas, ref dicParaOuts, true); if (DBConnection.ERROR != null) { throw new Exception(DBConnection.ERROR); } } catch (Exception ex) { this.ERROR = ex.ToString(); output = -1; } finally { this.DBConnection.CloseDBConnect(); } return(output); }
public int UpdateLogUserLogout(EntityUserTimeModel model) { int output = 0; try { DBConnection.OpenDBConnect(); Dictionary <string, object> dicParas = new Dictionary <string, object>(); Dictionary <string, object> dicParaOuts = new Dictionary <string, object>(); dicParas.Add("PKID", model.PKID); output = DBConnection.ExecSPNonQuery("SP_USER_LOG_UPDATE", dicParas, ref dicParaOuts, true); if (DBConnection.ERROR != null) { throw new Exception(DBConnection.ERROR); } } catch (Exception ex) { this.ERROR = ex.ToString(); output = -1; } finally { this.DBConnection.CloseDBConnect(); } return(output); }
public ActionResult Logout() { //var session = Session[this.SESSION_NAME_USER_NAME].ToString(); EntityUserTimeModel logger = (EntityUserTimeModel)Session["Logger"]; if (logger != null) { this.SetConnectionDB(); UserServices userServices = new UserServices(this.DBConnection); var insertlog = userServices.UpdateLogUserLogout(logger); } System.Web.Security.FormsAuthentication.SignOut(); Session.Clear(); Logging.WriteToLog("[Info] " + Session["UserName"] + " logged out.", LogType.Access); return(RedirectToAction("Login")); }
public ActionResult Login(LoginModel loginModel) { Char charRange = '/'; //STEP1: GOI HAM LOGIN TOI CSDL ***************************************************** this.SetConnectionDB(); BI_Project.Services.User.UserServices userServices = new UserServices(this.DBConnection); BI_Project.Services.Departments.DepartmentServices departmentServices = new DepartmentServices(this.DBConnection); Session["HDSD"] = loginModel.Department; EntityUserModel entityUser = userServices.CheckLogin(loginModel); EntityUserTimeModel logger = new EntityUserTimeModel(); EntityDepartmentModel entityDepartment = departmentServices.GetEntityById(entityUser.DeptId); SetDefaultPageService setDefault = new SetDefaultPageService(DBConnection); if (entityUser.UserName != null) { logger.UserId = entityUser.UserId; logger.PKID = Guid.NewGuid(); logger.TimeLogin = DateTime.Now; logger.Date = DateTime.Now.Date; logger.UserName = entityUser.UserName; Session["Logger"] = logger; var insertlog = userServices.UpdateLogUserLogin(logger); Session["UserName"] = entityUser.UserName; Session["FullName"] = entityUser.FullName; Session[this.SESSION_NAME_USER_NAME] = entityUser.UserName; Session[this.SESSION_NAME_USERID] = entityUser.UserId; Session["DepartIdUserLogin"] = entityUser.DeptId; Session["IsAdmin"] = entityUser.IsAdmin; Session["IsSuperAdmin"] = entityUser.IsSuperAdmin; Session["CodeIsAdmin"] = entityDepartment.Code; Session["Filter01IsAdmin"] = entityDepartment.Filter01; Session["ListAllowedMenuPath"] = entityUser.LstMenus.Select(x => x.Path).ToList(); List <EntityUserMenuModel> entityUserMenuModel = setDefault.GetListDefaultPage(entityUser.UserId); foreach (EntityUserMenuModel item in entityUserMenuModel) { if (item.IsDefaultPage == true) { var _path = item.Path; string _controller = _path.Split(charRange)[0]; string _action = _path.Split(charRange)[1]; int _menuId = item.MenuId; return(RedirectToAction(_action + "/" + _menuId, _controller)); } } return(RedirectToAction("Index")); } if (userServices.ERROR != null) { Session["msgcode"] = MessageType.ServerError; FileHelper.SaveFile(userServices.ERROR, this.LOG_FOLDER + "/ERROR_" + this.GetType().ToString() + BI_Project.Helpers.Utility.APIStringHelper.GenerateFileId() + ".txt"); } else { Session["msgcode"] = MessageType.BusinessError; } this.GetLanguage(); ViewData["VIEWDATA_LANGUAGE"] = this.LANGUAGE_OBJECT; return(View("~/" + this.THEME_FOLDER + "/" + this.THEME_ACTIVE + "/login.cshtml", loginModel)); //STEP2: NEU DANG NHAP KHONG THANH CONG }
public ActionResult Index(int id) { //lay url tu menu voi id ViewData["pagename"] = "Embed_Tableau"; ViewData["action_block"] = "Tableau/TableauView"; SetCommonData(); GetLanguage(); SetConnectionDB(); BI_Project.Models.UI.PageModel pageModel = new Models.UI.PageModel("Embed_Tableau"); // BI_Project.Models.UI.BlockModel blockModel = new BlockModel("TableauView"); pageModel.SetLanguage(this.LANGUAGE_OBJECT); //pageModel.H1Title = pageModel.GetElementByPath("page_excel.menu" + id + ".h1"); pageModel.Title = pageModel.GetElementByPath("title"); ViewData["page_model"] = pageModel; TableauModel param = new TableauModel(); ViewData["BlockData"] = param; MenuServices _menuServices = new MenuServices(DBConnection); EntityMenuModel _entityMenuModel = _menuServices.GetMenuModel(id.ToString()); EntityUserTimeModel logger = (EntityUserTimeModel)Session["Logger"]; logger.Dashboard = _entityMenuModel.Name; if (logger != null) { this.SetConnectionDB(); UserServices userServices = new UserServices(this.DBConnection); var insertlog = userServices.UpdateLogUserDashboard(logger); } UserServices _userServices = new UserServices(DBConnection); DepartmentServices _departmentServices = new DepartmentServices(DBConnection); EntityDepartmentModel _entityDepartmentModel = new EntityDepartmentModel(); //param.Site_Root = _entityMenuModel.Site_Root; param.Ticket = BI_Core.Helpers.TableauHelper.GetTicket(""); param.TableauUrl = _entityMenuModel.TableauUrl; param.Hidden = 1; param.username = Session["UserName"].ToString(); ViewBag.Id = id; var listFilter01 = _departmentServices.GetList().Select(x => x.Filter01).ToArray(); StringBuilder builderOrganization = new StringBuilder(); foreach (var _list in listFilter01) { builderOrganization.Append(_list).Append(','); } string _resultListOrganization = builderOrganization.ToString().TrimEnd(','); ViewBag.ListDepartment = _resultListOrganization; if (Session["IsAdmin"] is false && (Session["Filter01IsAdmin"].ToString() != "PE" || Session["Filter01IsAdmin"].ToString() != "PA" || Session["Filter01IsAdmin"].ToString() != "PB" || Session["Filter01IsAdmin"].ToString() != "PC" || Session["Filter01IsAdmin"].ToString() != "PD")) { param.GetFilter(id); } Random rd = new Random(); int item = rd.Next(100, 999); string log = DateTime.Now.ToString("yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture) + "_" + item; if (_menuServices.ERROR != null) { FileHelper.SaveFile(new { ERROR = _menuServices.ERROR }, this.LOG_FOLDER + "/ERROR_" + this.GetType().ToString() + APIStringHelper.GenerateFileId() + ".txt"); } FileHelper.SaveFile(_entityMenuModel, this.LOG_FOLDER + "/MenuModel_" + log + ".txt"); FileHelper.SaveFile(param.Ticket, this.LOG_FOLDER + "/Ticket_" + log + ".txt"); return(View("~/" + this.THEME_FOLDER + "/" + this.THEME_ACTIVE + "/index.cshtml")); }