protected override bool AuthorizeCore(HttpContextBase httpContext) { bool authorize = false; Mugurtham.Core.Login.LoggedInUser objLoggedIn = new LoggedInUser(HttpContext.Current.User.Identity.Name); using (objLoggedIn as IDisposable) { foreach (var strRoleID in arrAuthourizedRoles) { if (strRoleID.ToString() == objLoggedIn.roleID) { authorize = true; } //if (strRoleID.ToString().ToLower() == strLoggedInUsersRoleID.ToLower()) //{ // authorize = true; //} //var user = context.AppUser.Where(m => m.UserID == GetUser.CurrentUser/* getting user form current context */ && m.strRoleID == strRoleID && //m.IsActive == true); // checking active users with allowed strArrRoles. //if (user.Count() > 0) //{ // authorize = true; /* return true if Entity has current user(active) with specific strRoleID */ //} } objLoggedIn.Dispose(); } objLoggedIn = null; return authorize; }
public bool StatusEmer(TaxiAppzDBContext context, long id, bool isStatus, LoggedInUser loggedInUser) { try { var tabSos = context.TabSos.Where(r => r.Sosid == id && r.IsDeleted == 0).FirstOrDefault(); if (tabSos != null) { tabSos.IsActive = isStatus == true ? 1 : 0; tabSos.UpdatedAt = DateTime.UtcNow; tabSos.UpdatedBy = loggedInUser.UserName; context.Update(tabSos); context.SaveChanges(); return(true); } return(false); } catch (Exception ex) { Extention.insertlog(ex.Message, "Admin", System.Reflection.MethodBase.GetCurrentMethod().Name, context); return(false); } }
public bool DisableUser(TaxiAppzDBContext context, long id, bool status, LoggedInUser loggedInUser) { try { var updatedate = context.TabUser.Where(u => u.Id == id && u.IsDelete == 0).FirstOrDefault(); if (updatedate != null) { updatedate.UpdatedAt = TimeZoneInfo.ConvertTimeToUtc(DateTime.Now); updatedate.UpdatedBy = "Admin"; updatedate.IsActive = status; context.Update(updatedate); context.SaveChanges(); return(true); } return(false); } catch (Exception ex) { Extention.insertlog(ex.Message, "Admin", "DisableUser", context); return(false); } }
string GenerateJSONWebToken(LoggedInUser userInfo) { var securityKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_config["Jwt:SecretKey"])); var credentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256); var claims = new[] { new Claim(JwtRegisteredClaimNames.Sub, userInfo.UserName), new Claim("userid", userInfo.UserID.ToString(CultureInfo.InvariantCulture)), new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()), }; var token = new JwtSecurityToken( issuer: _config["Jwt:Issuer"], audience: _config["Jwt:Audience"], claims: claims, expires: DateTime.Now.AddMinutes(5), signingCredentials: credentials ); return(new JwtSecurityTokenHandler().WriteToken(token)); }
public bool DeleteType(TaxiAppzDBContext context, long id, LoggedInUser loggedInUser) { try { var updatedate = context.TabTypes.Where(r => r.Typeid == id && r.IsDeleted == 0).FirstOrDefault(); if (updatedate != null) { updatedate.IsDeleted = 1; updatedate.DeletedAt = DateTime.UtcNow; updatedate.DeletedBy = loggedInUser.UserName; context.Update(updatedate); context.SaveChanges(); return(true); } return(false); } catch (Exception ex) { Extention.insertlog(ex.Message, "Admin", System.Reflection.MethodBase.GetCurrentMethod().Name, context); return(false); } }
public bool DeleteUser(TaxiAppzDBContext context, long id, LoggedInUser loggedInUser) { var roleExist = context.TabUserCancellation.FirstOrDefault(t => t.IsDelete == false && t.UserCancelId == id); if (roleExist == null) { throw new DataValidationException($"Tab user cancellation does not exists"); } var updatedate = context.TabUserCancellation.Where(u => u.UserCancelId == id && u.IsDelete == false).FirstOrDefault(); if (updatedate != null) { updatedate.DeletedAt = TimeZoneInfo.ConvertTimeToUtc(DateTime.Now); updatedate.DeletedBy = loggedInUser.Email; updatedate.IsDelete = true; context.Update(updatedate); context.SaveChanges(); return(true); } return(false); }
public bool StatusUser(TaxiAppzDBContext context, long id, bool isStatus, LoggedInUser loggedInUser) { var roleExist = context.TabUserCancellation.FirstOrDefault(t => t.IsDelete == false && t.UserCancelId == id); if (roleExist == null) { throw new DataValidationException($"Tab user cancellation does not exists"); } var updatedate = context.TabUserCancellation.Where(r => r.UserCancelId == id && r.IsDelete == false).FirstOrDefault(); if (updatedate != null) { updatedate.IsActive = isStatus == true; updatedate.UpdatedAt = DateTime.UtcNow; updatedate.UpdatedBy = loggedInUser.UserName; context.Update(updatedate); context.SaveChanges(); return(true); } return(false); }
public bool StatusEmail(TaxiAppzDBContext context, long id, bool isStatus, LoggedInUser loggedInUser) { var emailid = context.TabManageEmail.FirstOrDefault(t => t.ManageEmailid == id); if (emailid == null) { throw new DataValidationException($"Email does not already exists."); } var updatedate = context.TabManageEmail.Where(r => r.ManageEmailid == id).FirstOrDefault(); if (updatedate != null) { updatedate.IsActive = isStatus == true; updatedate.UpdatedAt = TimeZoneInfo.ConvertTimeToUtc(DateTime.Now);; updatedate.UpdatedBy = loggedInUser.UserName; context.Update(updatedate); context.SaveChanges(); return(true); } return(false); }
public bool StatusFAQ(TaxiAppzDBContext context, long id, bool isStatus, LoggedInUser loggedInUser) { var faq = context.TabFaq.FirstOrDefault(t => t.IsDelete == false && t.Faqid == id); if (faq == null) { throw new DataValidationException($"FAQ doest not exists."); } var updatedate = context.TabFaq.Where(t => t.Faqid == id && t.IsDelete == false).FirstOrDefault(); if (updatedate != null) { updatedate.IsActive = isStatus; updatedate.UpdatedAt = TimeZoneInfo.ConvertTimeToUtc(DateTime.Now); updatedate.UpdatedBy = loggedInUser.UserName; context.Update(updatedate); context.SaveChanges(); return(true); } return(false); }
/// <summary> /// Quitte la salle présentement dedans. /// </summary> /// <param name="player"></param> /// <param name="room"></param> /// <returns>True si succès, false autrement</returns> public bool LeaveRoom(Guid player, Guid room) { try { using (MilleBornesEntities tities = new MilleBornesEntities()) { LoggedInUser u = tities.LoggedInUser.First(p => p.Token == player); Room r = tities.Room.First(p => p.Token == room); // Si c'est le master, on DÉTRUIT LA ROOOOOOOOOOOOOOOOOOOOOOOOOM // Et tout les player state. // Et tous les messages. if (r.MasterUserId == u.UserId) { var lstPrs = tities.PlayerRoomState.Where(p => p.RoomId == r.RoomId).ToList(); tities.Message.RemoveRange(r.Message); tities.PlayerRoomState.RemoveRange(lstPrs); tities.Room.Remove(r); } else { // Sinon on quitte la salle, simplement. PlayerRoomState prsUser = tities.PlayerRoomState.First(p => p.UserId == u.UserId); tities.PlayerRoomState.Remove(prsUser); } tities.SaveChanges(); SendRoomMessage(Guid.ParseExact("00000000-0000-0000-0000-000000000000", "D"), room, "**Le joueur " + u.User.Name + " a quitté la partie ☹**"); } return(true); } catch { return(false); } }
public bool DeleteService(TaxiAppzDBContext context, long id, LoggedInUser loggedInUser) { var serviceExists = context.TabServicelocation.FirstOrDefault(t => t.IsDeleted == 0 && t.Servicelocid == id); if (serviceExists != null) { throw new DataValidationException($"Service with name '{serviceExists.Name}' already exists."); } var updatedate = context.TabServicelocation.Where(r => r.Servicelocid == id && r.IsDeleted == 0).FirstOrDefault(); if (updatedate != null) { updatedate.IsDeleted = 1; updatedate.DeletedAt = DateTime.UtcNow; updatedate.DeletedBy = loggedInUser.Email; context.Update(updatedate); context.SaveChanges(); return(true); } return(false); }
public async void DeviceTokken() { try { string type = "android"; if (Device.OS == TargetPlatform.iOS) { type = "ios"; } LoggedInUser objUser = App.Database.GetLoggedInUser(); string postData = "id=" + objUser.userId + "&deviceType=" + type + "&deviceToken=" + App.DeviceToken; var result = await CommonLib.UpdateToken(CommonLib.ws_MainUrl + "updateToken?" + postData); if (result.status == 1) { } } catch (Exception ex) { } }
//Click event handler for the Login/Logout button in the user menu protected void LoginMenu_Click(object sender, EventArgs e) { //Login if (!LoggedInUser.IsUserLoggedIn) { Response.Redirect("Login"); return; } //Logout LoggedInUser.SetUser(null); if (Settings.RequireLogin() && LoggedInUser.IsUserLoggedIn == false) { Response.Redirect("Login"); } DropDownSorting.SelectedIndex = 0; hidTABControl.Value = "#Tasks"; //page_load didn't setup the page(because this is a postback). so setup page Setup_Page(); }
public bool DeleteZone(long zoneid, TaxiAppzDBContext context, LoggedInUser loggedInUser) { TabZone tabZone = new TabZone(); var tabzone = context.TabZone.Include(t => t.TabZonepolygon).Where(z => z.Zoneid == zoneid).FirstOrDefault(); if (tabzone != null) { tabzone.IsDeleted = 1; tabzone.DeletedAt = DateTime.UtcNow; tabzone.DeletedBy = loggedInUser.UserName; context.TabZone.Update(tabzone); foreach (var tabpoly in tabzone.TabZonepolygon.ToList()) { tabpoly.IsDeleted = 1; tabpoly.DeletedAt = DateTime.UtcNow; tabpoly.DeletedBy = loggedInUser.UserName; context.TabZonepolygon.Update(tabpoly); } context.SaveChanges(); return(true); } return(false); }
public IEnumerator AcceptReceivedFriendRequest(Friendship existingToAccept) { Debug.Log("Accepting friend request"); Dictionary <string, string> data = new Dictionary <string, string>(); data ["fromUser"] = existingToAccept.GetOtherUser().GetUserId(); ServerCall waitFor = new ServerCall(INSTANCE.SendServerInformationRequest(ACCEPT_FRIEND_REQUEST, data)); yield return(StartCoroutine(waitFor.call())); string infoText = waitFor.Response; Debug.Log("Received " + infoText); Friendship accepted = JsonUtility.FromJson <Friendship> (infoText); LoggedInUser.GetLoggedInUser().friends.Remove(existingToAccept); LoggedInUser.GetLoggedInUser().friends.Add(accepted); yield return(accepted); }
public bool AddRole(TaxiAppzDBContext context, Roles roles, LoggedInUser loggedInUser) { var roleExist = context.TabRoles.FirstOrDefault(t => t.IsDelete == 0 && t.RoleName.ToLower() == roles.RoleName.ToLower()); if (roleExist != null) { throw new DataValidationException($"Role with name '{roles.RoleName}' already exists."); } TabRoles Insertdata = new TabRoles(); Insertdata.RoleName = roles.RoleName; Insertdata.DisplayName = roles.DisplayName; Insertdata.Description = roles.Description; Insertdata.IsActive = 1; Insertdata.AllRights = 1; Insertdata.Locked = 1; Insertdata.CreatedBy = loggedInUser.Email; context.TabRoles.Add(Insertdata); context.SaveChanges(); //need to add menu access while create the role return(true); }
/// <summary> /// Détermine si la connexion est toujours vivante. /// </summary> /// <param name="userToken"></param> /// <returns>True si c'est le cas, false autrement.</returns> /// <remarks>Tolérance d'un skip de heartbeat. /// Valeur par défaut 1 heartbeat == 2000ms</remarks> public bool Heartbeat(Guid userToken) { try { using (MilleBornesEntities context = new MilleBornesEntities()) { var lstLoggedUsers = context.LoggedInUser.Where(p => p.Token == userToken); LoggedInUser liu = lstLoggedUsers.First(); // Différence de temps. TimeSpan dt = DateTime.UtcNow - liu.LastHeartbeat; liu.LastHeartbeat = DateTime.UtcNow; context.SaveChanges(); return(dt.TotalMilliseconds <= DELAY_MS_HEARTBEAT * 10); } } catch { return(false); } }
private void reevaluateGlyphUniverseByLocation() { activeSpheres = enableOnlyCloseGlyphs(); // done by comparing glyph lat, long rather than sphere pos if (LoggedInUser.GetLoggedInUser() == null) { statusPanel.showStatus(NO_USER_LOGGED_IN_STATUS); } else if (activeSpheres.Count == 0) { statusPanel.showStatus(NO_CLOSE_GLYPHS_STATUS); } else { statusPanel.setStatusPanelVisible(false); } replotGlyphSpheres(); pushGlyphsThatAreTooCloseAway(); reevaluateGlyphUniverseByAngle(); }
private void populateGlyphList() { if (LoggedInUser.GetLoggedInUser() == null) { Debug.LogError("No user logged in"); return; } List <FoundGlyphEvent> foundGlyphs = LoggedInUser.GetLoggedInUser().foundGlyphs; foundGlyphs.Sort(); Glyph[] glyphs = new Glyph[foundGlyphs.Count]; int i = 0; foreach (FoundGlyphEvent found in foundGlyphs) { glyphs [i] = foundGlyphs [i].GetGlyph(); i++; } glyphList.setGlyphs(glyphs); }
public ActionResult validateLogin([System.Web.Http.FromBody] Mugurtham.Core.User.UserCoreEntity objUserCoreEntity) { int inLoginStatus = 0; bool boolLogin = false; ConnectionString objConnectionString = new ConnectionString(objUserCoreEntity.CommunityID); using (objConnectionString as IDisposable) { Mugurtham.Core.User.UserCore objUserCore = new Mugurtham.Core.User.UserCore(objConnectionString.AppKeyConnectionString); using (objUserCore as IDisposable) { inLoginStatus = objUserCore.validateLogin(ref objUserCoreEntity, out boolLogin); if (inLoginStatus == 1) { FormsAuthentication.SetAuthCookie(objUserCoreEntity.LoginID, false); Session.Timeout = 60; LoggedInUser objLoggedIn = new LoggedInUser(objUserCoreEntity.LoginID, objUserCoreEntity.CommunityID); objLoggedIn.CommunityID = objConnectionString.CommunityID; objLoggedIn.CommunityName = objConnectionString.CommunityName; objLoggedIn.ConnectionStringAppKey = objConnectionString.AppKeyConnectionString; objLoggedIn.ConnectionString = objConnectionString.AppConnectionString; Session["LoggedInUser"] = objLoggedIn; objUserCore.createSession(Helpers.primaryKey, objUserCoreEntity.LoginID, Request.ServerVariables["REMOTE_ADDR"].ToString(), objLoggedIn.ConnectionString); } else if (inLoginStatus == 6) // Connection Timed Out { objUserCoreEntity.LoginStatus = "6"; } } objUserCore = null; } objConnectionString = null; return(this.Json(objUserCoreEntity)); }
/// <summary> /// Obtient les nouveaux messages de name /// </summary> /// <param name="name">Utilisateur</param> /// <returns>Liste des nouveaux messages.</returns> public List <UserMessage> GetNewMessageFrom(Guid player, string name) { List <UserMessage> lstMessages = new List <UserMessage>(); try { using (MilleBornesEntities context = new MilleBornesEntities()) { // Récupère les ids... LoggedInUser receiver = context.LoggedInUser.First(p => p.Token == player); User sender = context.User.First(p => p.Name.Trim() == name.Trim()); IQueryable <PrivateMessage> lstNewMessages = context.PrivateMessage.Where(p => p.ReceiverUserId == receiver.UserId && p.SenderUserId == sender.UserId && p.Read == false); foreach (PrivateMessage pm in lstNewMessages) { UserMessage um = new UserMessage(); um.Content = pm.Message; um.Date = pm.SentTime; um.Username = name; lstMessages.Add(um); pm.Read = true; } context.SaveChanges(); } } catch { } return(lstMessages); }
public void OnBeforeSerialize() { if (fromUser == null) { fromUser = LoggedInUser.GetUserFromCache(fromUserId); } if (toUser == null) { toUser = LoggedInUser.GetUserFromCache(toUserId); } if (otherUser == null) { if (fromUser is LoggedInUser) { otherUser = toUser; } else if (toUser is LoggedInUser) { otherUser = fromUser; } } }
public bool SaveFAQ(TaxiAppzDBContext context, ManageFAQInfo manageFAQInfo, LoggedInUser loggedInUser) { var faq = context.TabServicelocation.FirstOrDefault(t => t.IsDeleted == 0 && t.Servicelocid == manageFAQInfo.Servicelocid); if (faq == null) { throw new DataValidationException($"Service location doest not exists."); } TabFaq tabFaq = new TabFaq(); tabFaq.ComplaintType = manageFAQInfo.Complaint_Type; tabFaq.FaqAnswer = manageFAQInfo.FAQ_Answer; tabFaq.FaqQuestion = manageFAQInfo.FAQ_Question; tabFaq.Servicelocid = manageFAQInfo.Servicelocid; tabFaq.CreatedAt = tabFaq.UpdatedAt = TimeZoneInfo.ConvertTimeToUtc(DateTime.Now); tabFaq.UpdatedBy = tabFaq.CreatedBy = loggedInUser.Email; context.TabFaq.Add(tabFaq); context.SaveChanges(); return(true); }
protected void AudioManagement_Table_RowDeleting(object sender, GridViewDeleteEventArgs e) { int ID; try { //Get the ID of the row that has fired the event ID = (int)AudioManagement_Table.DataKeys[e.RowIndex].Value; } catch (ArgumentOutOfRangeException arg) { return; } //Cathing the currentUser out of the Session and deleting the Audio LoggedInUser currentUser = (LoggedInUser)Session["loggedInUser"]; currentUser.deleteAudio(ID); //List<Audio> currentAudio = currentUser.getAudioFiles(); AudioManagement_Table.DataSource = currentUser.uploadedFiles; AudioManagement_Table.DataBind(); }
public bool AddService(TaxiAppzDBContext context, ServiceInfo serviceInfo, LoggedInUser loggedInUser) { var serviceExists = context.TabServicelocation.FirstOrDefault(t => t.IsDeleted == 0 && t.Name.ToLower() == serviceInfo.ServiceName.ToLower() && t.Servicelocid != serviceInfo.ServiceId); if (serviceExists != null) { throw new DataValidationException($"Service with name '{serviceExists.Name}' already exists."); } TabServicelocation tabServicelocation = new TabServicelocation(); tabServicelocation.Countryid = serviceInfo.CountryId; tabServicelocation.Timezoneid = serviceInfo.TimezoneId; tabServicelocation.Currencyid = serviceInfo.CurrencyId; tabServicelocation.Name = serviceInfo.ServiceName; tabServicelocation.CreatedAt = DateTime.UtcNow; tabServicelocation.UpdatedAt = DateTime.UtcNow; tabServicelocation.UpdatedBy = tabServicelocation.CreatedBy = loggedInUser.Email; context.TabServicelocation.Add(tabServicelocation); context.SaveChanges(); return(true); }
public IEnumerator MarkGlyphAsFound(Glyph glyph) { if (LoggedInUser.GetLoggedInUser().DidAlreadyFindGlyph(glyph)) { throw new Exception("User already found glyph"); } else { Dictionary <string, string> data = new Dictionary <string, string> (); data ["glyphid"] = "" + glyph.GetGlyphId(); ServerCall markGlyphAsFound = new ServerCall(INSTANCE.SendServerInformationRequest(MARK_AS_FOUND, data)); yield return(StartCoroutine(markGlyphAsFound.call())); string infoText = markGlyphAsFound.Response; Debug.Log("Received " + infoText); FoundGlyphEvent found = JsonUtility.FromJson <FoundGlyphEvent> (infoText); LoggedInUser.GetLoggedInUser().foundGlyphs.Add(found); yield return(found); } }
void onload() { Language langObj = App.Database.GetLanguage(); if (langObj != null) { App.Lng = langObj.LangKey; LoggedInUser objUser = App.Database.GetLoggedInUser(); if (objUser == null) { App.Current.MainPage = new NavigationPage(new MainPage()); } if (objUser != null) { if (objUser.userType == "2") { if (objUser.is_shop == "0") { App.Current.MainPage = new NavigationPage(new AddShopPage()); } else { App.Current.MainPage = new NavigationPage(new HomeMasterPage()); } } if (objUser.userType == "1") { App.Current.MainPage = new NavigationPage(new MainPage()); } } } else { App.Current.MainPage = new NavigationPage(new LanguagePage()); } }
public MenuList() { var masterPageItems = new List <MasterPageItem>(); masterPageItems.Add(new MasterPageItem { Title = AppResources.home, IconSource = "home.png", TargetType = typeof(HomePage), }); masterPageItems.Add(new MasterPageItem { Title = AppResources.profile, IconSource = "profile.png", TargetType = typeof(SellerProfilePage), }); masterPageItems.Add(new MasterPageItem { Title = AppResources.shop, IconSource = "add_on.png", TargetType = typeof(EditShopPage), }); masterPageItems.Add(new MasterPageItem { Title = AppResources.orders, IconSource = "products.png", TargetType = typeof(SellerOrderPage), }); masterPageItems.Add(new MasterPageItem { Title = AppResources.logout, IconSource = "logout.png", TargetType = typeof(LoginPage), }); listView = new ListView { ItemsSource = masterPageItems, ItemTemplate = new DataTemplate(typeof(CustomCell)), VerticalOptions = LayoutOptions.FillAndExpand, SeparatorVisibility = SeparatorVisibility.None, HasUnevenRows = true, BackgroundColor = Color.Transparent, }; Padding = new Thickness(0, 40, 0, 0); Icon = "hamburger.png"; Title = "Personal Organiser"; BackgroundImage = "drawer_bg.png"; BackgroundColor = Color.Transparent; LoggedInUser objUser = App.Database.GetLoggedInUser(); string name = ""; string email = ""; string image = ""; if (objUser != null) { name = objUser.fname + " " + objUser.lname; email = objUser.email; image = string.IsNullOrEmpty(objUser.image) ? "user_placeholder2.png" : objUser.image; } CachedImage img = new CachedImage() { Source = image, HorizontalOptions = LayoutOptions.Center, HeightRequest = 100, WidthRequest = 100, Aspect = Aspect.AspectFit, LoadingPlaceholder = "user_placeholder2.png", Transformations = new List <ITransformation>() { new FFImageLoading.Transformations.CircleTransformation() { BorderSize = 5, BorderHexColor = "#FE1F78" } }, }; Label namelbl = new Label() { Text = name, FontFamily = "CALIBRI", StyleId = "CALIBRI", TextColor = Color.FromHex("#FE1F78"), FontSize = 20, HorizontalTextAlignment = TextAlignment.Center }; Image lineimg = new Image() { Source = "line.png", }; StackLayout _imglinelayout = new StackLayout() { Orientation = StackOrientation.Vertical, BackgroundColor = Color.Transparent, Padding = new Thickness(0, 25, 0, 25), Children = { lineimg } }; StackLayout _layout = new StackLayout() { Orientation = StackOrientation.Vertical, VerticalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.Transparent, Spacing = 0, Children = { img, namelbl, listView } }; Content = new StackLayout { VerticalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.Transparent, Children = { _layout } }; }
public void SignInCustomIdentity(LoggedInUser userLoggedIn) { _accountService.SignInCustomIdentity(this, userLoggedIn); }
protected void Page_Load(object sender, EventArgs e) { if (Settings.RequireLogin() && LoggedInUser.IsUserLoggedIn == false) { Response.Redirect("Login.aspx"); } if (LoggedInUser.IsUserLoggedIn == false || RoleManager.UserHasPermission(LoggedInUser.GetUser(), RolesPermissions.ManageUsers) == false) { Response.Redirect("Index.aspx"); } if (IsPostBack) { return; } Page_LoadUser(); Page_Setup(); Page_Fill(); }
protected void SetupPage() { //setup the page in general if (Task.ID > 0) { //editting a task! txtReporter.Disabled = true; var userHash = LoggedInUser.GetUserHash(); var taskMngr = new TaskManager(); //check if its editable at all. if not, disable and grey out a few shits if (!taskMngr.TaskEditable(Task.ID, userHash) || !taskMngr.SetTaskOpened(Task.ID, userHash)) { ReadOnly = true; machineRow.Visible = false; selectTechnicians.Disabled = true; selectTechnicians.Style.Add("background-color", "#EBEBE4"); selectDepartments.Disabled = true; selectDepartments.Style.Add("background-color", "#EBEBE4"); selectLocations.Disabled = true; selectLocations.Style.Add("background-color", "#EBEBE4"); txtDescription.Disabled = true; NoteBox.Disabled = true; selectMachines.Disabled = true; selectMachines.Style.Add("background-color", "#EBEBE4"); selectTaskState.Disabled = true; selectTaskState.Style.Add("background-color", "#EBEBE4"); chkUrguent.Enabled = false; imagesList.Disabled = true; AddPhotoBtn.Disabled = true; AddPhotoInput.Disabled = true; AddNotesButton.Disabled = true; /* Add a warning/alert to the page saying we can't open the task */ JavascriptAlert.Show(ReadOnlyMsg); return; } } ReadOnly = false; //check user permissions if (LoggedInUser.IsUserLoggedIn) { txtReporter.Disabled = true; var roles = RoleManager.GetUserPermissions(LoggedInUser.GetUser()); if (!roles.Any(x => x == RolesPermissions.ManageMachines) && !roles.Any(x => x == RolesPermissions.Technician)) { machineRow.Visible = false; } if (!roles.Any(x => x == RolesPermissions.ManageTasks) && !roles.Any(x => x == RolesPermissions.Technician)) { selectTaskState.Disabled = true; selectTaskState.Style.Add("background-color", "#EBEBE4"); } } else { selectTechnicians.Disabled = true; selectTechnicians.Style.Add("background-color", "#EBEBE4"); machineRow.Visible = false; selectTaskState.Disabled = true; selectTaskState.Style.Add("background-color", "#EBEBE4"); } //fill the images in the ul foreach (var item in Task.Photos) { var li = new HtmlGenericControl("li"); li.Attributes.Add("style", "display:inline;max-height:inherit;"); var ancor = new HtmlGenericControl("a"); ancor.Attributes.Add("href", item.FileName); ancor.Attributes.Add("data-lightbox", "TaskImages"); ancor.Attributes.Add("style", "height:inherit;max-height:inherit;min-height:inherit;width:auto;margin-bottom:0;padding-right:5px;"); var image = new HtmlGenericControl("img"); image.Attributes.Add("src", item.FileName); image.Attributes.Add("style", "height:inherit;max-height:inherit;min-height:inherit;width:auto;margin-bottom:0;"); ancor.Controls.Add(image); li.Controls.Add(ancor); imagesList.Controls.Add(li); } }
private void attach_LoggedInUsers(LoggedInUser entity) { this.SendPropertyChanging(); entity.User = this; }
partial void InsertLoggedInUser(LoggedInUser instance);
partial void UpdateLoggedInUser(LoggedInUser instance);
partial void DeleteLoggedInUser(LoggedInUser instance);
//this method updates the user details. public static bool updateAccount(LoggedInUser user) { String database = System.Configuration.ConfigurationManager.ConnectionStrings["programaholics_anonymous_databaseConnectionString"].ConnectionString; using (OleDbConnection sqlConn = new OleDbConnection("PROVIDER=Microsoft.ACE.OLEDB.12.0;" + "Data Source=" + database)) { try { sqlConn.Open(); OleDbCommand cmd = sqlConn.CreateCommand(); OleDbTransaction transact = sqlConn.BeginTransaction(); //using a transaction incase something goes wrong... cmd.Transaction = transact; String update = "UPDATE [users] SET [city] = @city, [state] = @state, [favProgrammingLang] = @favProgLang, [leastFavProgrammingLang] = @leastFavProgLang, [lastProgramDate] = @dateLastProgrammed" + " WHERE [username] = @username"; cmd.CommandText = update; //update users table cmd.Parameters.Add("city", OleDbType.VarChar, 255).Value = user.getCity(); cmd.Parameters.Add("state", OleDbType.VarChar, 255).Value = user.getState(); cmd.Parameters.Add("favProgLang", OleDbType.VarChar, 255).Value = user.getFavProgLang(); cmd.Parameters.Add("leastFavProgLang", OleDbType.VarChar, 255).Value = user.getLeastFavProgLang(); cmd.Parameters.Add("dateLastProgrammed", OleDbType.Date).Value = user.getlastProgDate(); cmd.Parameters.Add("username", OleDbType.VarChar, 255).Value = user.getUsername(); cmd.Prepare(); int rows1 = cmd.ExecuteNonQuery(); if(rows1 == 1) { transact.Commit(); return true; } else { transact.Rollback(); return false; } } catch (OleDbException ex) { return false; } finally { sqlConn.Close(); } } }
//this method returns a LoggedInUser object populated with results of query. (only a single user) public static LoggedInUser getUserDetails(string username) { LoggedInUser user = null; String database = System.Configuration.ConfigurationManager.ConnectionStrings["programaholics_anonymous_databaseConnectionString"].ConnectionString; using (OleDbConnection sqlConn = new OleDbConnection("PROVIDER=Microsoft.ACE.OLEDB.12.0;" + "Data Source=" + database)) { try { sqlConn.Open(); OleDbCommand cmd = sqlConn.CreateCommand(); String select = "SELECT * FROM users WHERE [username] = @username"; cmd.CommandText = select; cmd.Parameters.Add("username", OleDbType.VarChar, 255).Value = username; OleDbDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { user = new LoggedInUser(); user.setUsername(reader["username"].ToString()); user.setCity(reader["city"].ToString()); user.setState(reader["state"].ToString()); user.setFavProgLang(reader["favProgrammingLang"].ToString()); user.setLeastFavProgLang(reader["leastFavProgrammingLang"].ToString()); user.setLastProgDate(DateTime.Parse(reader["lastProgramDate"].ToString())); } reader.Close(); } catch (OleDbException ex) { return user; } finally { sqlConn.Close(); } } return user; }
private void detach_LoggedInUsers(LoggedInUser entity) { this.SendPropertyChanging(); entity.Room = null; }
public ActionResult validateLogin([System.Web.Http.FromBody]Mugurtham.Core.User.UserCoreEntity objUserCoreEntity) { int inLoginStatus = 0; bool boolLogin = false; Mugurtham.Core.User.UserCore objUserCore = new Mugurtham.Core.User.UserCore(); using (objUserCore as IDisposable) { inLoginStatus = objUserCore.validateLogin(ref objUserCoreEntity, out boolLogin); if (inLoginStatus == 1) { objUserCore.createSession(Helpers.primaryKey, objUserCoreEntity.LoginID, Request.ServerVariables["REMOTE_ADDR"].ToString()); FormsAuthentication.SetAuthCookie(objUserCoreEntity.LoginID, false); Session.Timeout = 60; } } objUserCore = null; LoggedInUser objLoggedIn = new LoggedInUser(objUserCoreEntity.LoginID); Session["LoggedInUser"] = objLoggedIn; return this.Json(objUserCoreEntity); }
/// <summary> /// Logs a user in. Saves his userId so that it can be retrieved later by the IP. /// </summary> /// <param name="ip">The IP address of the client.</param> /// <param name="userId">The user id.</param> public void LogUserIn(IPAddress ip, int userId) { lock (_usersLoggedIn) { // Log out user (may be logged in here or elsewhere) LogUserOutNoLock(userId); if (_usersLoggedIn.ContainsKey(ip)) { // Log out old user using that machine LogUserOutNoLock(_usersLoggedIn[ip].userId); } _usersLoggedIn[ip] = new LoggedInUser(userId, DateTime.Now); } }