public ActionResult GetClockURL(int number) { try { UserInfo userInfo = new UserInfo(_context, HttpContext, User); bool isAdmin = userInfo.isAdmin(); if (isAdmin) //If user is admin, show admin panel to user by setting is admin property to true { ClockURL dto = new ClockURL(); dto.IsAdmin = isAdmin; return(Json(dto)); } else { //If user is not admin, try to find location of user from user info. string locationID = ""; var userDetails = userInfo.GetUserInfo(); CustomLogging.InfoLog("UserInfo details: empID=" + userDetails.empID + "; locationID=" + userDetails.locationID + "; jobCode=" + userDetails.jobCode + "; dept=" + userDetails.dept); locationID = userDetails.locationID; //IF location is not recieived from user info, try to find it from user agent string if (locationID == "0" || locationID == null) { var userAgent = Request.Headers["User-Agent"].ToString(); locationID = Util.GetStoreFromUserAgent(userAgent); } //If location is not present in user agent string, show dropdown to user by sending empty object if (locationID == "0" || String.IsNullOrEmpty(locationID)) { ClockURL dtObject = new ClockURL(); return(Json(dtObject)); } // Now if location is present, generate URL's ClockGenerator generatorObj = new ClockGenerator(_context); ClockURL clockDTO = generatorObj.GetClockURLObject(locationID); //setting Redirection Clock string redirectionType = dbService.GetConfigurationProperties("WebClockType"); if (redirectionType.ToUpper() == "WEB") { clockDTO.RedirectURL = clockDTO.SilverLighClockURL; } else if (redirectionType.ToUpper() == "HTML") { clockDTO.RedirectURL = clockDTO.HTMLClockURL; } var result = Json(clockDTO); return(result); } } catch (Exception ex) { CustomLogging.ErrorLog(ex); return(Json(false)); } }
public IActionResult Startup(string location) { string locationID = ""; ViewData["RedirectURL"] = ""; ViewData["LocationID"] = ""; ViewData["LocationType"] = ""; var userAgent = Request.Headers["User-Agent"].ToString(); CustomLogging.InfoLog("User-Agent String = " + userAgent); locationID = String.IsNullOrEmpty(location)? Util.GetStoreFromUserAgent(userAgent):location; if (!String.IsNullOrEmpty(locationID)) { // Now if location is present, generate URL's ClockGenerator generatorObj = new ClockGenerator(_context); ClockURL clockDTO = generatorObj.GetClockURLObject(locationID); //Check if clock is registered or not. if (clockDTO.StatusCode == "101") { ViewData["RedirectURL"] = clockDTO.StatusCode; ViewData["LocationID"] = locationID; } else { //setting Redirection Clock string redirectionType = dbService.GetConfigurationProperties("WebClockType"); if (redirectionType.ToUpper() == "WEB") { clockDTO.RedirectURL = clockDTO.SilverLighClockURL; } else if (redirectionType.ToUpper() == "HTML") { clockDTO.RedirectURL = clockDTO.HTMLClockURL; } ViewData["RedirectURL"] = clockDTO.RedirectURL; ViewData["LocationType"] = clockDTO.LocationType; } } return(View()); }