public HttpResponseMessage DeleteTrack(int itemId, int codeCampId) { try { var sessions = SessionDataAccess.GetItemsByTrackId(itemId, codeCampId); if (sessions.Any()) { foreach (var session in sessions) { session.TrackId = null; session.LastUpdatedByDate = DateTime.Now; session.LastUpdatedByUserId = UserInfo.UserID; SessionDataAccess.UpdateItem(session); } } TrackDataAccess.DeleteItem(itemId, codeCampId); var response = new ServiceResponse <string> { Content = SUCCESS_MESSAGE }; return(Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson())); } catch (Exception ex) { Exceptions.LogException(ex); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE)); } }
public ActionResult SetTimeoutScreen() { SessionDataAccess sda = new SessionDataAccess(); ViewBag.Timeout = sda.GetLastTimeout(); return(View()); }
public HttpResponseMessage UnassignTimeSlotFromSession(int sessionId, int timeSlotId, int codeCampId) { try { var session = SessionDataAccess.GetItem(sessionId, codeCampId); if (session != null) { session.TimeSlotId = null; session.LastUpdatedByDate = DateTime.Now; session.LastUpdatedByUserId = UserInfo.UserID; SessionDataAccess.UpdateItem(session); } var response = new ServiceResponse <string> { Content = SUCCESS_MESSAGE }; if (session == null) { ServiceResponseHelper <string> .AddNoneFoundError("session", ref response); } return(Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson())); } catch (Exception ex) { Exceptions.LogException(ex); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE)); } }
public HttpResponseMessage GetSessionCountBySpeakerId(int codeCampId, int speakerId) { try { var allSessions = SessionDataAccess.GetItems(codeCampId); var sessionSpeakers = SessionSpeakerDataAccess.GetItemsBySpeakerId(speakerId).Select(s => s.SessionId); var sessions = allSessions.Where(s => sessionSpeakers.Contains(s.SessionId)); var response = new ServiceResponse <int> { Content = sessions.Any() ? sessions.Count() : 0 }; if (!sessions.Any()) { ServiceResponseHelper <int> .AddNoneFoundError("sessions", ref response); } return(Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson())); } catch (Exception ex) { Exceptions.LogException(ex); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE)); } }
public HttpResponseMessage AssignSessionToTrack(int sessionId, int trackId, int codeCampId) { try { var session = SessionDataAccess.GetItem(sessionId, codeCampId); session.TrackId = trackId; session.LastUpdatedByDate = DateTime.Now; session.LastUpdatedByUserId = UserInfo.UserID; SessionDataAccess.UpdateItem(session); var response = new ServiceResponse <string> { Content = SUCCESS_MESSAGE }; return(Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson())); } catch (Exception ex) { Exceptions.LogException(ex); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE)); } }
public ActionResult AddTimeout(int sessiontime) { bool flag = false; SessionDataAccess sda = new SessionDataAccess(); flag = sda.InsertSessionTimeout(sessiontime); Configuration config = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath); SystemWebSectionGroup syswebSection = (SystemWebSectionGroup)config.GetSectionGroup("system.web"); //you can change the value as you want syswebSection.SessionState.Timeout = new TimeSpan(0, sessiontime, 0); config.Save(); return(Json(new { result = flag, ErrorMessage = CustomMessages.Success }, JsonRequestBehavior.AllowGet)); }
public static void SetProperties() { SessionDataAccess sd = new SessionDataAccess(); while (true) { allSessions = sd.GetAllSessions(); activeSessionsPCIDs = new List<int>(); sessionsThatChangedStatus = new List<int>(); foreach (SessionObject session in allSessions) { if (session.status == 1) { //if session is active activeSessionsPCIDs.Add(session.pcid); } if (session.status != session.prevStat) { //if current status doesn't match the previous status sessionsThatChangedStatus.Add(session.pcid); } } Thread.Sleep(5000); } }
public DataAccess(UserDataAccess userData, SessionDataAccess sessionData, UsersRolesDataAccess usersRolesData, RoleDataAccess roleData, OrderDataAccess orderData, OrderRequestDataAccess orderRequestData, WorkSessionDataAccess workSessionData, WorkImageDataAccess workImageData, ImageTypeDataAccess imageTypeData, ExpensesDataAccess expenseData, ExpenseTypeDataAccess expenseTypeData) {//begin constructor UserData = userData; SessionData = sessionData; UsersRolesData = usersRolesData; RoleData = roleData; OrderRequestData = orderRequestData; OrderData = orderData; WorkSessionData = workSessionData; WorkImageData = workImageData; ImageTypeData = imageTypeData; ExpenseData = expenseData; ExpenseTypeData = expenseTypeData; } //end constructor
public HttpResponseMessage DeleteSession(int itemId, int codeCampId) { try { SessionDataAccess.DeleteItem(itemId, codeCampId); var response = new ServiceResponse <string> { Content = SUCCESS_MESSAGE }; return(Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson())); } catch (Exception ex) { Exceptions.LogException(ex); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE)); } }
public HttpResponseMessage UpdateSessionTimeSlotOrder(int sessionId, int codeCampId, int newPosition) { try { SessionDataAccess.UpdateItemSortOrder(sessionId, codeCampId, newPosition); var response = new ServiceResponse <string> { Content = SUCCESS_MESSAGE }; return(Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson())); } catch (Exception ex) { Exceptions.LogException(ex); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE)); } }
public HttpResponseMessage CreateSession(SessionInfo session) { try { var timeStamp = DateTime.Now; session.CreatedByDate = timeStamp; session.CreatedByUserId = UserInfo.UserID; session.LastUpdatedByDate = timeStamp; session.LastUpdatedByUserId = UserInfo.UserID; if (session.TrackId == 0) { session.TrackId = null; } if (session.TimeSlotId == 0) { session.TimeSlotId = null; } // adding a date/time placeholder because DAL doesn't know how to handle a null value session.ApprovedByDate = Globals.NULL_DATE; SessionDataAccess.CreateItem(session); var sessions = SessionDataAccess.GetItems(session.CodeCampId); var savedSession = sessions.OrderByDescending(s => s.CreatedByDate).FirstOrDefault(s => s.Title == session.Title); var response = new ServiceResponse <SessionInfo> { Content = savedSession }; return(Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson())); } catch (Exception ex) { Exceptions.LogException(ex); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE)); } }
public HttpResponseMessage GetSessionsUnassigned(int codeCampId) { try { var sessions = SessionDataAccess.GetItemsUnassigned(codeCampId); var response = new ServiceResponse <List <SessionInfo> > { Content = sessions.ToList() }; if (sessions == null) { ServiceResponseHelper <List <SessionInfo> > .AddNoneFoundError("sessions", ref response); } return(Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson())); } catch (Exception ex) { Exceptions.LogException(ex); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE)); } }
public HttpResponseMessage GetSession(int itemId) { try { var session = SessionDataAccess.GetItem(itemId, ActiveModule.ModuleID); var response = new ServiceResponse <SessionInfo> { Content = session }; if (session == null) { ServiceResponseHelper <SessionInfo> .AddNoneFoundError("session", ref response); } return(Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson())); } catch (Exception ex) { Exceptions.LogException(ex); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE)); } }
//When user Login this method will create Session for the user in Session Table . public Response CreateSessionObject(string userName, string password) { try { User user = new User(); if (userName != null && password != null) { user.userName = userName; user.password = password; SessionDataAccess sda = new SessionDataAccess(); Session sess = new Session(); sess.User_Id = user.userID; sess.Session_Code = CreateSessionCode(user); sess.Login_Time = DateTime.Now; if (sda.AddSession(sess).Result) { return(Response.Success); } else { return(Response.Faliur); } } else { return(Response.Faliur); } } catch (Exception e) { /* * In case of exception request/response will be logged. */ throw e; } }
public HttpResponseMessage UpdateSession(SessionInfo session) { try { var updatesToProcess = false; var originalSession = SessionDataAccess.GetItem(session.SessionId, session.CodeCampId); if (!string.Equals(session.Title, originalSession.Title)) { originalSession.Title = session.Title; updatesToProcess = true; } if (!string.Equals(session.Description, originalSession.Description)) { originalSession.Description = session.Description; updatesToProcess = true; } if (session.AudienceLevel != originalSession.AudienceLevel) { originalSession.AudienceLevel = session.AudienceLevel; updatesToProcess = true; } if (session.TrackId != originalSession.TrackId) { originalSession.TrackId = session.TrackId; updatesToProcess = true; } if (originalSession.CustomProperties != null) { // parse custom properties for updates foreach (var property in originalSession.CustomPropertiesObj) { if (session.CustomPropertiesObj.Any(p => p.Name == property.Name)) { // see if the existing property needs to be updated var prop = session.CustomPropertiesObj.FirstOrDefault(p => p.Name == property.Name); if (!string.Equals(prop.Value, property.Value)) { property.Value = prop.Value; updatesToProcess = true; } } else { // delete the property originalSession.CustomPropertiesObj.Remove(property); updatesToProcess = true; } } } if (session.CustomPropertiesObj != null) { // add any new properties if (originalSession.CustomProperties == null) { foreach (var property in session.CustomPropertiesObj) { originalSession.CustomPropertiesObj.Add(property); updatesToProcess = true; } } else { foreach (var property in session.CustomPropertiesObj.Where(property => !originalSession.CustomPropertiesObj.Contains(property))) { originalSession.CustomPropertiesObj.Add(property); updatesToProcess = true; } } } if (updatesToProcess) { originalSession.LastUpdatedByDate = DateTime.Now; originalSession.LastUpdatedByUserId = UserInfo.UserID; SessionDataAccess.UpdateItem(session); } var savedSession = SessionDataAccess.GetItem(session.SessionId, session.CodeCampId); var response = new ServiceResponse <SessionInfo> { Content = savedSession }; return(Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson())); } catch (Exception ex) { Exceptions.LogException(ex); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE)); } }
public HttpResponseMessage GetAgenda(int codeCampId) { try { var agenda = new AgendaInfo(); agenda.CodeCamp = CodeCampDataAccess.GetItem(codeCampId, ActiveModule.ModuleID); if (agenda.CodeCamp != null) { var slotsToOrder = TimeSlotDataAccess.GetItems(codeCampId); var timeSlots = TimeSlotInfoController.SortTimeSlots(slotsToOrder); var timeSlotCount = timeSlots.Count(); // determine how many days the event lasts for agenda.NumberOfDays = (int)(agenda.CodeCamp.EndDate - agenda.CodeCamp.BeginDate).TotalDays + 1; // iterate through each day agenda.EventDays = new List <EventDayInfo>(); var dayCount = 0; while (dayCount <= agenda.NumberOfDays - 1) { var eventDate = agenda.CodeCamp.BeginDate.AddDays(dayCount); var eventDay = new EventDayInfo() { Index = dayCount, Day = eventDate.Day, Month = eventDate.Month, Year = eventDate.Year, TimeStamp = eventDate }; eventDay.TimeSlots = new List <AgendaTimeSlotInfo>(); // iterate through each timeslot foreach (var timeSlot in timeSlots) { var slot = new AgendaTimeSlotInfo(timeSlot); if (!timeSlot.SpanAllTracks) { // iterate through each session slot.Sessions = SessionDataAccess.GetItemsByTimeSlotIdByPage(slot.TimeSlotId, codeCampId, dayCount + 1, timeSlotCount).ToList(); // iterate through each speaker foreach (var session in slot.Sessions) { session.Speakers = SpeakerDataAccess.GetSpeakersForCollection(session.SessionId, codeCampId); } } else { // add the full span session item // TODO: allow for items to be added to full span timeslots } eventDay.TimeSlots.Add(slot); } agenda.EventDays.Add(eventDay); dayCount++; } } var response = new ServiceResponse <AgendaInfo> { Content = agenda }; if (agenda.CodeCamp == null) { ServiceResponseHelper <AgendaInfo> .AddNoneFoundError("AgendaInfo", ref response); } return(Request.CreateResponse(HttpStatusCode.OK, response.ObjectToJson())); } catch (Exception ex) { Exceptions.LogException(ex); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ERROR_MESSAGE)); } }
public SessionService() { this.PasswordService = new PasswordService(); this.UserAccountService = new UserAccountService(); this.SessionDataAccess = new SessionDataAccess(); }