public override void OnActionExecuting(ActionExecutingContext filterContext) { base.OnActionExecuting(filterContext); if (!UserSessionHelper.ExistUserInSession()) { filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { controller = "Account", action = "Login" })); } }
public ResponseHelper Acceder(LoginViewModel model, bool includes) { var rm = new ResponseHelper(); try { using (var ctx = _dbContextScopeFactory.Create()) { //string rol = ""; model.Password = ExtensionsHelpers.Hash(model.Password); var usuario = _usuariosRepository.SingleOrDefault(x => x.Email.Equals(model.username) && x.Password.Equals(model.Password), x => x.Rol); if (includes) { if (usuario != null) { UserSessionHelper.AddUserToSession(usuario.Id.ToString()); UserSessionHelper.AddTipeUser( ExtensionsHelpers.Hash(usuario.Rol.Rol[0].ToString().ToUpper())); rm.SetResponse(true); rm.Result = usuario.Nombres; } else { rm.SetResponse(false, "Correo o contraseña incorrecta"); } } else { if (usuario != null) { rm.SetResponse(true); rm.Result = usuario.Nombres; } else { rm.SetResponse(false, "Correo o contraseña incorrecta"); } } } } catch (Exception) { throw; } return(rm); }
public void SlipPurchaseOrder(string reportName, Dictionary <string, string> parameters) { rptReport.LocalReport.ReportPath = String.Format(@"{0}/{1}", ConfigurationManager.AppSettings[ApplicationSettingKeys.ReportFolder], reportName + ".rdlc"); ReportService.ConnectionString = ManagementService.GetConnectionString(UserSessionHelper.GetCurrentCompanyCode()); var detail = ReportService.GetPurchaseOrderDetail(parameters["DocumentNo"]); var header = ReportService.GetPurchaseOrderHeader(parameters["DocumentNo"]); var rdsHeader = new ReportDataSource("Header", header); var rdsDetail = new ReportDataSource("Detail", detail); rptReport.LocalReport.DataSources.Add(rdsHeader); rptReport.LocalReport.DataSources.Add(rdsDetail); rptReport.LocalReport.Refresh(); }
// Returns the session which matches as closely as possible the requirements private UserSession GetUserSessionState(int sessionId) { UserInfo userInfo = new UserInfo(); List <WTS_SESSION_INFO> sessions = UserSessionHelper.GetUserSessions(); // Loop through the current user sessions to find the one with matching sessionId foreach (WTS_SESSION_INFO session in sessions) { if (session.SessionId == sessionId) { UserSession sessionStateValue = null; if (session.State == WTS_CONNECTSTATE_CLASS.WTSActive) { // A locked session also has its state as WTSActive. // Check specifically if it is locked. if (UserSessionHelper.IsLoginSession(sessionId)) { sessionStateValue = new UserSession(UserSessionType.Locked); } else { sessionStateValue = new UserSession(UserSessionType.Active); } } if (session.State == WTS_CONNECTSTATE_CLASS.WTSDisconnected) { sessionStateValue = new UserSession(UserSessionType.Disconnected); } // Grab the user info (username, domain, password) if (UserSessionHelper.GetUserSessionUserInfo(sessionId, out userInfo)) { sessionStateValue.UserLoginInfo = userInfo; return(sessionStateValue); } else { // For machines without auto logon, password retrieval fails. We would like to // throw an exception here to fail the test case. throw new InvalidOperationException("Auto logon is required to be enabled for this task to succeed"); } } } return(null); }
public void ListPurchaseOrder(string reportName, Dictionary <string, string> parameters) { rptReport.LocalReport.ReportPath = String.Format(@"{0}/{1}", ConfigurationManager.AppSettings[ApplicationSettingKeys.ReportFolder], reportName + ".rdlc"); ReportService.ConnectionString = ManagementService.GetConnectionString(UserSessionHelper.GetCurrentCompanyCode()); DateTime fromDate = Convert.ToDateTime(parameters["FromDate"]); DateTime toDate = Convert.ToDateTime(parameters["ToDate"]); var reportData = ReportService.ListPurchaseOrder(fromDate, toDate); var rds = new ReportDataSource("ListPurchaseOrder", reportData); var reportParameters = new List <ReportParameter>(); reportParameters.Add(new ReportParameter("FromDate", fromDate.ToString("dddd, dd MMMM yyyy"))); reportParameters.Add(new ReportParameter("ToDate", toDate.ToString("dddd, dd MMMM yyyy"))); rptReport.LocalReport.DataSources.Add(rds); rptReport.LocalReport.SetParameters(reportParameters); rptReport.LocalReport.Refresh(); }
/// <summary> /// Allows you to transition the session state based on a given action /// </summary> /// <param name="value"></param> /// <param name="action"></param> public override bool SetValue(UserSession value, Nullable <UserSessionAction> action) { if (value == null) { return(false); } switch (value.SessionType) { case UserSessionType.Active: return(UserSessionHelper.TryUserSessionConnect(sessionId, "Console")); case UserSessionType.Disconnected: return(UserSessionHelper.TryUserSessionDisconnect(sessionId)); case UserSessionType.Locked: // return(false); } return(false); }
private void MakeAudit() { var modifiedEntries = ChangeTracker.Entries().Where( x => x.Entity is AuditEntity && ( x.State == EntityState.Added || x.State == EntityState.Modified || x.State == EntityState.Deleted ) ); foreach (var entry in modifiedEntries) { var entity = entry.Entity as AuditEntity; if (entity != null) { var date = DateTime.Now; var userId = UserSessionHelper.GetUser() != 0 ? UserSessionHelper.GetUser() : 0; if (entry.State == EntityState.Added) { entity.CreatedAt = date; entity.CreatedBy = userId; } else if (entity is ISoftDeleted && ((ISoftDeleted)entity).Deleted) { entity.DeletedAt = date; entity.DeletedBy = userId; } Entry(entity).Property(x => x.CreatedAt).IsModified = false; Entry(entity).Property(x => x.CreatedBy).IsModified = false; entity.UpdatedAt = date; entity.UpdatedBy = userId; } } }
/// <summary> /// Load your modules or register your services here! /// </summary> /// <param name="kernel">The kernel.</param> private static void RegisterServices(IKernel kernel) { kernel.Bind <ManagementDataContext>() .ToConstructor( o => new ManagementDataContext( ConfigurationManager.ConnectionStrings["ManagementConnectionString"].ConnectionString)) .InRequestScope(); ////.WhenInjectedInto<string>() //.WithParameter(new ConstructorArgument("connection", // ConfigurationManager.ConnectionStrings["ManagementConnectionString"].ConnectionString // )); kernel.Bind <IPrincipal>().ToMethod(ctx => HttpContext.Current.User); kernel.Bind <ArtileriDataContext>() .ToMethod(ctx => new ArtileriDataContext(ctx.Kernel.Get <ManagementProvider>() .GetConnectionString(HttpContext.Current == null ? "" : UserSessionHelper.GetCurrentCompanyCode()))) .InRequestScope(); }
public EmployeeController(IAppUrlHelper appUrlHelper, UserSessionHelper userSessionHelper) { _appUrlHelper = appUrlHelper; _userSessionHelper = userSessionHelper; }
protected void btnProcessApprove_Click(object sender, EventArgs e) { try { PurchaseOrderService.ApprovedPurchaseOrder(txtDocumentNo.Text, EmployeeService.GetEmployee(UserSessionHelper.GetCurrentUserName()).ID, txtApproveReason.Text); LoadData(); WebFormHelper.SetLabelTextWithCssClass(lblStatusAddEdit, String.Format("Purchase Order {0} has been marked as APPROVED", txtDocumentNo.Text), LabelStyleNames.AlternateMessage); } catch (Exception ex) { WebFormHelper.SetLabelTextWithCssClass(lblStatusAddEdit, ex.Message, LabelStyleNames.ErrorMessage); } }
public SpeedController(IAppUrlHelper appUrlHelper, UserSessionHelper userSessionHelper) { _appUrlHelper = appUrlHelper; _userSessionHelper = userSessionHelper; }
public StorageDeviceController(IAppUrlHelper appUrlHelper, UserSessionHelper userSessionHelper) { _appUrlHelper = appUrlHelper; _userSessionHelper = userSessionHelper; }
public AccountController(UserSessionHelper userSessionHelper) { _userSessionHelper = userSessionHelper; }
public StudyScheduleController(IAppUrlHelper appUrlHelper, UserSessionHelper userSessionHelper) { _appUrlHelper = appUrlHelper; _userSessionHelper = userSessionHelper; }
public TeacherController(IAppUrlHelper appUrlHelper, UserSessionHelper userSessionHelper) { _appUrlHelper = appUrlHelper; _userSessionHelper = userSessionHelper; }
public StorageCapacityController(IAppUrlHelper appUrlHelper, UserSessionHelper userSessionHelper) { _appUrlHelper = appUrlHelper; _userSessionHelper = userSessionHelper; }
public ComputerRoomController(IAppUrlHelper appUrlHelper, UserSessionHelper userSessionHelper) { _appUrlHelper = appUrlHelper; _userSessionHelper = userSessionHelper; }
public HomeController(UserSessionHelper userSessionHelper) { _userSessionHelper = userSessionHelper; }
public OpticalDiscController(IAppUrlHelper appUrlHelper, UserSessionHelper userSessionHelper) { _appUrlHelper = appUrlHelper; _userSessionHelper = userSessionHelper; }
protected void Page_Load(object sender, EventArgs e) { //var userSession = ManagementService.GetUserSession(Page.User.Identity.Name); lblCurrentActiveCompany.Text = String.Format("{0}", UserSessionHelper.GetCurrentCompanyCode()); }
protected void Page_Load(object sender, EventArgs e) { sdsMaster.ConnectionString = ManagementService.GetConnectionString(UserSessionHelper.GetCurrentCompanyCode()); grdMaster.Columns[0].Visible = false; }
public ActionResult Logout() { UserSessionHelper.DestroyUserSession(); return(Redirect("~/")); }
public MonitorController(IAppUrlHelper appUrlHelper, UserSessionHelper userSessionHelper) { _appUrlHelper = appUrlHelper; _userSessionHelper = userSessionHelper; }
public ProvinceController(IAppUrlHelper appUrlHelper, UserSessionHelper userSessionHelper) { _appUrlHelper = appUrlHelper; _userSessionHelper = userSessionHelper; }