public async Task <ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var user = new ApplicationUser() { UserName = model.UserName }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { //await SignInAsync(user, isPersistent: false); //Link employee to user UserManagementHelper.AssignUserIdToEmpId(model.EmpId, user.Id); //return Json("true"); // return RedirectToAction("Index", "Home"); } else { AddErrors(result); } } // If we got this far, something failed, redisplay form ViewBag.EmpList = EmployeeHelper.GetEmpDic(); return(View(model)); }
public IHttpActionResult Login(Models.UserViewModel usr) { try { using (DatabaseContext dbctx = new DatabaseContext()) { String userRole = dbctx.UserAccounts.Where(usn => usn.Username.Equals(usr.Username)) .Where(usp => usp.Password.Equals(usr.Password)) .Select(column => column.UserRole).First(); if (userRole != null || userRole != String.Empty) { var permissions = UserManagementHelper.GetPermissionsDictionaryFor(userRole); LoggerHelper.UserAction(usr.Username, "Autentificare cu succes "); return(Ok(permissions)); } } } catch (Exception ex) { Console.WriteLine("Exception in AccountController/api/User/Login", ex.ToString()); LoggerHelper.UserAction(usr.Username, "Autentificare esuata "); return(NotFound()); } return(Ok()); }
public ActionResult AppendixItems_Read([DataSourceRequest] DataSourceRequest request, string bilDoc) { Contract serviceModel; try { serviceModel = WCFClientManager.SAPServiceClient.GetBillingsToPrintAppendix(UserManagementHelper.GetSessionId(), bilDoc) as Contract; } catch (Exception ex) { ErrorSignal.FromCurrentContext().Raise(ex); return(Json(JsonRequestBehavior.AllowGet)); } var viewModel = BillingReportingHelper.GenerateBillingItemsViewModel(serviceModel); var result = viewModel.AppendixTableViewModels.ToDataSourceResult(request); var json = Json(result, JsonRequestBehavior.AllowGet); json.MaxJsonLength = int.MaxValue; return(json); }
/// <summary> /// Initializes a new instance of the <see cref="ShareEventDialog"/> class. /// </summary> /// <param name="connectorClient">Connector client </param> /// <param name="eventHelper">EventHelper instance</param> /// <param name="userManagementHelper">UserManagementHelper instance</param> /// <param name="logProvider">Logging component</param> public ShareEventDialog(IConnectorClient connectorClient, EventHelper eventHelper, UserManagementHelper userManagementHelper, ILogProvider logProvider) { this.eventHelper = eventHelper; this.connectorClient = connectorClient; this.logProvider = logProvider; this.userManagementHelper = userManagementHelper; }
/// <summary> /// Initializes a new instance of the <see cref="MessagesController"/> class. /// </summary> /// <param name="scope">ILifetimeScope</param> /// <param name="logProvider">The instance of <see cref="ILogProvider"/></param> /// <param name="userManagementHelper">UserManagementHelper instance</param> /// <param name="eventHelper">EventHelper</param> public MessagesController(ILifetimeScope scope, ILogProvider logProvider, UserManagementHelper userManagementHelper, EventHelper eventHelper) { this.scope = scope; this.logProvider = logProvider; this.userManagementHelper = userManagementHelper; this.eventHelper = eventHelper; }
/// <summary> /// GET Run ProformaInvoice from DB /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult Run(int?id) { RunInvoiceHeaderDTO serviceModel; try { //this should trigger the WCF to prepare billing items after being invoked //the mechanism to call is EXACTLY SAME with the mechanism to call service from SAP (in the beginning) serviceModel = WCFClientManager.SAPServiceClient.QueryRunInvoiceHeaderFromDB( UserManagementHelper.GetSessionId(), id ?? 0); } catch (Exception ex) { ErrorSignal.FromCurrentContext().Raise(ex); return(RedirectToAction("Index", "Error")); } if (serviceModel == null) { ErrorSignal.FromCurrentContext().Raise(new Exception(ErrorResource.WCFNullObject)); return(RedirectToAction("Index", "Error", new { errorKey = "WCFNullObject" })); } PopulateCategories(); var viewModel = ProformaInvoiceHelper.GenerateRunProformaInvoiceViewModel(serviceModel); return(View(viewModel)); }
private Permissions GetPermissions(string userName) { if (string.IsNullOrEmpty(userName)) { // Username without auth var s = UserManagementSettings.GetSettings(); return((Permissions)UserManagementHelper.GetPermissions(s)); } var dbUser = UserRepository.GetUserByUsername(userName); if (dbUser != null) { var permissions = (Permissions)dbUser.Permissions; return(permissions); } var plexUser = PlexUsers.GetUserByUsername(userName); if (plexUser != null) { var permissions = (Permissions)plexUser.Permissions; return(permissions); } return(0); }
public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) { var requestForm = controllerContext.HttpContext.Request.Form; var model = new DataCollectionApprovalViewModelStep2(); model.ExtractForCodes <DataCollectionFieldOfResearch>(requestForm); model.ExtractSeoCodes <DataCollectionSocioEconomicObjective>(requestForm); int id; if (int.TryParse(requestForm["Id"], out id)) { var collection = DataCollectionRepository.Get(id); model.Manager = collection.Parties .Where(p => p.Party.UserId != null && p.Relationship == DataCollectionRelationshipType.Manager) .Single().Party; model.ProjectId = collection.ProjectId; } UserManagementHelper.DeserializeUrdmsUsers <DataCollectionRelationshipType>(model, requestForm); UserManagementHelper.DeserializeNonUrdmsUsers <DataCollectionRelationshipType>(model, requestForm); bindingContext.ModelMetadata.Model = model; return(base.BindModel(controllerContext, bindingContext)); }
public void Start() { JobRecord.SetRunning(true, JobNames.EmbyUserChecker); try { var settings = EmbySettings.GetSettings(); if (string.IsNullOrEmpty(settings.ApiKey) || !settings.Enable) { return; } var embyUsers = EmbyApi.GetUsers(settings.FullUri, settings.ApiKey); var userManagementSettings = UserManagementSettings.GetSettings(); var dbUsers = Repo.GetAll().ToList(); // Regular users foreach (var user in embyUsers) { var dbUser = dbUsers.FirstOrDefault(x => x.EmbyUserId == user.Id); if (dbUser != null) { // we already have a user continue; } // Looks like it's a new user! var m = new EmbyUsers { EmbyUserId = user.Id, Permissions = UserManagementHelper.GetPermissions(userManagementSettings), Features = UserManagementHelper.GetFeatures(userManagementSettings), UserAlias = string.Empty, Username = user.Name, LoginId = Guid.NewGuid().ToString() }; // If it's the admin, give them the admin permission if (user.Policy.IsAdministrator) { if (!((Permissions)m.Permissions).HasFlag(Permissions.Administrator)) { m.Permissions += (int)Permissions.Administrator; } } Repo.Insert(m); } } catch (Exception e) { Log.Error(e); } finally { JobRecord.SetRunning(false, JobNames.EmbyUserChecker); JobRecord.Record(JobNames.EmbyUserChecker); } }
public HomeController(ApplicationDbContext db, IHostingEnvironment environment, IFileManager manager, UserManager <ApplicationUser> userManager, RoleManager <IdentityRole> roleManager) { _db = db; hosting = environment; _imgHelper = new ImgUploadHelper(hosting, manager); _userManagementHelper = new UserManagementHelper(_db); _userManager = userManager; _roleManager = roleManager; }
public DashboardController(ApplicationDbContext db, IHostingEnvironment environment, UserManager <ApplicationUser> userManager, SignInManager <ApplicationUser> signInManager, RoleManager <IdentityRole> roleManager, UrlEncoder urlEncoder) { _db = db; hosting = environment; _userManager = userManager; _signInManager = signInManager; _roleManager = roleManager; _urlEncoder = urlEncoder; _userManagementHelper = new UserManagementHelper(_db); }
public ActionResult GetSecRights(int empId) { string userId = UserManagementHelper.GetUserIdByEmpId(empId); if (string.IsNullOrEmpty(userId)) { return(Content("<p>No user is found for this employee. Must Add user first.</p>")); } var moduleList = UserManagementHelper.GetModulesList(empId); return(PartialView("~/Areas/Admin/Views/Security/_SecRights.cshtml", moduleList)); }
public LoginModel(ApplicationDbContext db, IHostingEnvironment environment, UserManager <ApplicationUser> userManager, SignInManager <ApplicationUser> signInManager, RoleManager <IdentityRole> roleManager, UrlEncoder urlEncoder, ILogger <LoginModel> logger) { _db = db; hosting = environment; _userManager = userManager; _signInManager = signInManager; _roleManager = roleManager; _urlEncoder = urlEncoder; _logger = logger; _userManagementHelper = new UserManagementHelper(_db); }
public NominationController(ApplicationDbContext db, IHostingEnvironment environment, UserManager <ApplicationUser> userManager, SignInManager <ApplicationUser> signInManager, RoleManager <IdentityRole> roleManager, UrlEncoder urlEncoder, INotification notification) { _db = db; hosting = environment; _userManager = userManager; _signInManager = signInManager; _roleManager = roleManager; _urlEncoder = urlEncoder; _userManagementHelper = new UserManagementHelper(_db); _notificationService = notification; }
public ActionResult CheckIfEmpHasUser(int empId) { bool hasUser = false; string userId = UserManagementHelper.GetUserIdByEmpId(empId); if (!string.IsNullOrEmpty(userId)) { hasUser = true; } return(Json(hasUser)); }
public ActionResult Error404() { try { UserManagementHelper.GetSessionId(); } catch { return(View()); } return(View("Error404Inside")); }
public AccountController(ApplicationDbContext db, IHostingEnvironment environment, UserManager <ApplicationUser> userManager, SignInManager <ApplicationUser> signInManager, RoleManager <IdentityRole> roleManager, UrlEncoder urlEncoder, ILogger <AccountController> logger, IConfiguration config) { _db = db; hosting = environment; _userManager = userManager; _signInManager = signInManager; _roleManager = roleManager; _urlEncoder = urlEncoder; _logger = logger; _configuration = config; _userManagementHelper = new UserManagementHelper(_db); }
protected override bool AuthorizeCore(HttpContextBase httpContext) { try { UserManagementHelper.GetSessionId(); } catch (Exception ex) { return(false); } return(true); }
/// <summary> /// Search for Users /// </summary> /// <param name="clientSearchCriteria">Search criteria.</param> /// <param name="keyWord">Search key word.</param> public void SearchUser( DCU.Enums.UserInfoSearchCriteria clientSearchCriteria, string keyWord) { // 1.) Get Service IUserManagementServices userManagementServices = ComponentManager.GetComponent <IUserManagementServices>(); // 2.) Create Request DCO.Enums.UserInfoSearchCriteriaEnum coreSearchCriteria = UserAccountConverter.ConvertToCoreUserInfoSearchCriteria(clientSearchCriteria); UserManagementRequest request = UserManagementHelper.CreateUserManagementRequest( UserManagementActionType.SearchUsers, searchKeyWord: keyWord, userInfoSearchCriteria: coreSearchCriteria); // 3.) Send Request UserManagementResponse response = userManagementServices.UserManagementHandleRequest(request); // 4.) Handle Response List <DCO.Objects.UserAccount> coreUserAccounts = response.UserAccountsRetrieved; List <DCU.Objects.UserAccount> clientUserAccounts = new List <DCU.Objects.UserAccount>(); foreach (DCO.Objects.UserAccount coreUserAccount in coreUserAccounts) { clientUserAccounts.Add(UserAccountConverter.CovertToClientUserAccount(coreUserAccount)); } // Get the logged in user account that was used by the server // when handling the request. DCU.Objects.UserAccount clientUserAccountLoggedIn = UserAccountConverter.CovertToClientUserAccount(response.RequestorUserAccount); UserAccountEventArgs userAccountEventArgs = createUserAccountEventArgs( UserAccountActionType.SearchUsers, clientUserAccounts, clientUserAccountLoggedIn, response.ResponseErrorMessage); // Broadcast to UserAccountEventArgs that a search user was triggered. EventBus <UserAccountEventArgs> .Broadcast( this, userAccountEventArgs); }
public ProfilController(ApplicationDbContext db, IHostingEnvironment environment, IFileManager manager, UserManager <ApplicationUser> userManager, RoleManager <IdentityRole> roleManager, SignInManager <ApplicationUser> signInManager, UrlEncoder urlEncoder, ILogger <AccountController> logger) { _db = db; hosting = environment; _imgHelper = new ImgUploadHelper(hosting, manager); _userManagementHelper = new UserManagementHelper(_db); _userManager = userManager; _roleManager = roleManager; _userManager = userManager; _signInManager = signInManager; _roleManager = roleManager; _urlEncoder = urlEncoder; _logger = logger; }
/// <summary> /// Unlocks a User Account /// </summary> /// <param name="userAccount">User Account to be unlocked.</param> public void UnlockUser(DCU.Objects.UserAccount userAccount) { // 1.) Get Service IUserManagementServices userManagementServices = ComponentManager.GetComponent <IUserManagementServices>(); // 2.) Create Request UserManagementRequest request = UserManagementHelper.CreateUserManagementRequest( UserManagementActionType.UnlockUser, UserAccountConverter.CovertToCoreUserAccount(userAccount)); // 3.) Send Request UserManagementResponse response = userManagementServices.UserManagementHandleRequest(request); // 4.) Handle Response UserAccountActionType userAccountActionType; string message; if (response.IsRequestSuccessful) { userAccountActionType = UserAccountActionType.UnlockUser; message = response.ResponseMessage; } else { userAccountActionType = UserAccountActionType.UnlockUserFailed; message = response.ResponseErrorMessage; } // Get the logged in user account that was used by the server // when handling the request. DCU.Objects.UserAccount clientUserAccountLoggedIn = UserAccountConverter.CovertToClientUserAccount(response.RequestorUserAccount); UserAccountEventArgs userAccountEventArgs = createUserAccountEventArgs( userAccountActionType, null, clientUserAccountLoggedIn, message); // Broadcast to UserAccountEventARgs that an unlock user was triggered. EventBus <UserAccountEventArgs> .Broadcast( this, userAccountEventArgs); }
/// <summary> /// Performs a login request to UserManagementServices. /// </summary> /// <param name="userAccount">UserAccount to login.</param> public void Login(DCU.Objects.UserAccount userAccount) { // 1.) Get Service IUserManagementServices userManagementServices = ComponentManager.GetComponent <IUserManagementServices>(); // 2.) Populate and Create Request. DCO.Objects.UserAccount coreUserAccount = new DCO.Objects.UserAccount(); coreUserAccount.Username = userAccount.Username; coreUserAccount.Password = userAccount.Password; UserManagementRequest request = UserManagementHelper.CreateUserManagementRequest( DCO.Enums.UserManagementActionType.Login, coreUserAccount); // 3.) Send Request UserManagementResponse response = userManagementServices.UserManagementHandleRequest (request); // 4.) Handle Response DCU.Objects.UserAccount userAccountLoggedIn = new DCU.Objects.UserAccount(); if (response.UserAccountsRetrieved.Count > 0) { userAccountLoggedIn = UserAccountConverter.CovertToClientUserAccount(response.UserAccountsRetrieved[0]); } UserLoginEventArgs userLoginEventArg; if (response.IsRequestSuccessful) { ComponentManager.RegisterComponent <DCU.Objects.UserAccount>(userAccountLoggedIn); userLoginEventArg = createUserLoginEventArg( LoginResultType.Success, response.ResponseMessage); } else { userLoginEventArg = createUserLoginEventArg( LoginResultType.Failed, response.ResponseErrorMessage); } // 5.) Broadcast via the EventBus. EventBus <UserLoginEventArgs> .Broadcast(this, userLoginEventArg); }
public ActionResult PreviewAppendix(string bilDoc) { RunPrintBillingsDTO serviceModel; try { serviceModel = WCFClientManager.SAPServiceClient.GetBillingsToPrintAppendix(UserManagementHelper.GetSessionId(), bilDoc) as RunPrintBillingsDTO; } catch (Exception ex) { ErrorSignal.FromCurrentContext().Raise(ex); RedirectToAction("Index", "Error"); } return(View("Appendix")); }
/// <summary> /// Updates User Accounts /// </summary> /// <param name="actionType">Action Type</param> public void UpdateUsers( UserAccountActionType actionType = UserAccountActionType.UpdateUsers) { // 1.) Get Service IUserManagementServices userManagementServices = ComponentManager.GetComponent <IUserManagementServices>(); // 2.) Create Request UserManagementRequest request = UserManagementHelper.CreateUserManagementRequest( UserManagementActionType.GetUsers); // 3.) Send Request UserManagementResponse response = userManagementServices.UserManagementHandleRequest(request); // 4.) Handle Response List <DCO.Objects.UserAccount> coreUserAccounts = response.UserAccountsRetrieved; List <DCU.Objects.UserAccount> clientUserAccounts = new List <DCU.Objects.UserAccount>(); foreach (DCO.Objects.UserAccount coreUserAccount in coreUserAccounts) { clientUserAccounts.Add(UserAccountConverter.CovertToClientUserAccount(coreUserAccount)); } // Get the logged in user account that was used by the server // when handling the request. DCU.Objects.UserAccount clientUserAccountLoggedIn = UserAccountConverter.CovertToClientUserAccount(response.RequestorUserAccount); UserAccountEventArgs userAccountEventArgs = createUserAccountEventArgs( actionType, clientUserAccounts, clientUserAccountLoggedIn, response.ResponseErrorMessage); // Broadcast to UserAccountEventArgs that update users was triggered. EventBus <UserAccountEventArgs> .Broadcast( this, userAccountEventArgs); }
public ActionResult GenerateInvoice(string bilDoc) { RunPrintBillingsDTO serviceModel; try { serviceModel = WCFClientManager.SAPServiceClient.GetBillingsToPrintTotal(UserManagementHelper.GetSessionId(), bilDoc) as RunPrintBillingsDTO; } catch (Exception ex) { ErrorSignal.FromCurrentContext().Raise(ex); return(RedirectToAction("Index", "Error")); } ReportInvoiceViewModel invoiceViewModel = BillingReportingHelper.GenerateInvoiceViewModel(serviceModel); HeaderInvoice(bilDoc); return(GenerateInvoicePdf(invoiceViewModel, bilDoc)); }
/// <summary> /// Initially save to DB when all data have been loaded /// </summary> /// <returns></returns> public ActionResult SaveChanges() { try { WCFClientManager.SAPServiceClient.SaveInitialSAPData(UserManagementHelper.GetSessionId()); } catch (Exception ex) { ErrorSignal.FromCurrentContext().Raise(ex); return(Json(new { messageToShow = ErrorResource.WCFCannotSave }, JsonRequestBehavior.AllowGet)); } return(Json(new { messageToShow = string.Format(ProformaInvoiceResource.SaveAsDraftSuccessMessage) }, JsonRequestBehavior.AllowGet)); }
/// <summary> /// Edits a User Account /// </summary> /// <param name="userAccount">User Account to be edited.</param> public void EditUser(DCU.Objects.UserAccount userAccount) { // 1.) Get Service IUserManagementServices userManagementServices = ComponentManager.GetComponent <IUserManagementServices>(); // 2.) Create Request UserManagementRequest request = UserManagementHelper.CreateUserManagementRequest( UserManagementActionType.EditUser, UserAccountConverter.CovertToCoreUserAccount(userAccount)); // 3.) Send Request UserManagementResponse response = userManagementServices.UserManagementHandleRequest(request); // 4.) Handle Response if (response.IsRequestSuccessful) { // Broadcast to UserAccountEventArgs that add was successful. UpdateUsers(UserAccountActionType.EditUser); } else { // Get the logged in user account that was used by the server // when handling the request. DCU.Objects.UserAccount clientUserAccountLoggedIn = UserAccountConverter.CovertToClientUserAccount(response.RequestorUserAccount); UserAccountEventArgs userAccountEventArgs = createUserAccountEventArgs( UserAccountActionType.EditUserFailed, null, clientUserAccountLoggedIn, response.ResponseErrorMessage); // Broadcast to UserAccountEventArgs that add failed. EventBus <UserAccountEventArgs> .Broadcast( this, userAccountEventArgs); } }
public ActionResult BillingItems_Update([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")] IEnumerable <BillingItemViewModel> viewModel) { if (viewModel == null || !ModelState.IsValid) { return(Json(viewModel.ToDataSourceResult(request, ModelState))); } foreach (var model in viewModel) { try { WCFClientManager.SAPServiceClient.UpdateRunInvoiceBilling(UserManagementHelper.GetSessionId(), model.BillingItemId, model.ReasonForRejectionVM.CategoryName == SharedResource.SpaceChar || model.ReasonForRejectionVM.CategoryName == ProformaInvoiceResource.PleaseSelectReasonForRejection ? string.Empty : model.ReasonForRejectionVM.CategoryName, model.Remarks); } catch (Exception ex) { ErrorSignal.FromCurrentContext().Raise(ex); ModelState.AddModelError("Name", ex.Message); return(Json(ModelState.ToDataSourceResult())); } } try { var newId = WCFClientManager.SAPServiceClient.SaveRunInvoiceBillings(UserManagementHelper.GetSessionId()); System.Web.HttpContext.Current.Session["newBillingRunId"] = newId; } catch (Exception ex) { ErrorSignal.FromCurrentContext().Raise(ex); ModelState.AddModelError("Name", ex.Message); return(Json(ModelState.ToDataSourceResult())); } return(Json(viewModel.ToDataSourceResult(request, ModelState))); }
public JsonResult BillingDocument(MSTInvoiceBillingReportingViewModel iModel) { BillingNumberItemDTO[] billingNumber; try { var dateFrom = DictionaryHelper.KendoDatePickerDateStringToDateTime(iModel.DateFromValue); var dateTo = DictionaryHelper.KendoDatePickerDateStringToDateTime(iModel.DateToValue); billingNumber = WCFClientManager.SAPServiceClient.QueryBillingNumbers(UserManagementHelper.GetSessionId(), iModel.SoldToFromValue, dateFrom, dateTo); } catch (Exception) { return(Json(new { html = ErrorResource.WCFCannotGetObjectHTML })); } var viewModel = BillingReportingHelper.GeneratePopupBillingDocumentViewModel(billingNumber, iModel); var renderedHtml = ViewHelper.RenderPartialViewToString(this, "_PartialPopupBillingDocumentListBilling", viewModel); return(Json(new { html = renderedHtml })); }
/// <summary> /// GET SubmitToSAP triggered by Kendo Button. /// </summary> /// <returns></returns> public ActionResult SubmitToSAP() { var index = 0; // Save to DB First! try { WCFClientManager.SAPServiceClient.SaveRunInvoiceBillings(UserManagementHelper.GetSessionId()); } catch (Exception ex) { ErrorSignal.FromCurrentContext().Raise(ex); return(Json(new { messageToShow = ErrorResource.WCFCannotSave, urlToRedirect = "/Error?errorKey=WCFCannotSave" }, JsonRequestBehavior.AllowGet)); } // Submit to SAP try { index = WCFClientManager.SAPServiceClient.SubmitInvoiceProforma(UserManagementHelper.GetSessionId()) ?? 0; } catch (Exception ex) { ErrorSignal.FromCurrentContext().Raise(ex); return(Json(new { messageToShow = ErrorResource.WCFCannotSubmitToSAP, urlToRedirect = "/Error?errorKey=WCFCannotSubmitToSAP" }, JsonRequestBehavior.AllowGet)); } return(Json(new { messageToShow = string.Format(ProformaInvoiceResource.SubmitToSAPSucessMessage), urlToRedirect = string.Format("/ProformaInvoice/Run/{0}", index) }, JsonRequestBehavior.AllowGet)); }