/// <summary> /// Calls when user logged out/ disconnected from the system. /// Calls the web api using RestSharp to update database /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult Logout() { var username = ((UserViewModel)Session["User"]).UserName; var action = "home/logout/"; var result = RestHelper.ExecuteGetRequest <UserViewModel>(action, username); ViewBag.UserName = ""; return(RedirectToAction("Index")); }
/// <summary> /// Calls when user logged in into the system. Calls the web api using RestSharp. /// On successful login user is redirected to chat page /// </summary> /// <returns></returns> public ActionResult Login() { var username = Request.Form["username"]; var action = "home/login/"; var result = RestHelper.ExecuteGetRequest <UserViewModel>(action, username); ViewBag.UserName = result.UserName; Session["User"] = result; return(RedirectToAction("Chat")); }
/// <summary> /// Displays the top 15 chats of various users /// </summary> /// <param name="username"></param> /// <returns></returns> public ActionResult Chat() { if (Session["User"] == null) { return(View("Index")); } var action = "home/GetMessages/"; var result = RestHelper.ExecuteGetRequest <List <UserChatViewModel> >(action); ViewBag.UserName = ((UserViewModel)Session["User"]).UserName; ViewBag.Messages = result; return(View()); }
/// <summary> /// Fires when any client get disconnected and /// removes the user from the list of online/active users and inform the other clients. /// </summary> /// <param name="stop"></param> /// <returns>Call the client side function leftRoom to update the online users list</returns> public override Task OnDisconnected(bool stop) { var userTobeDisconnected = _connectedUsers.Where(o => o.ConnectionId == Context.ConnectionId).FirstOrDefault(); _connectedUsers.Remove(userTobeDisconnected); if (userTobeDisconnected != null) { var action = "home/Logout/"; RestHelper.ExecuteGetRequest <UserViewModel>(action, userTobeDisconnected.UserName); return(Clients.All.leftRoom(_connectedUsers, userTobeDisconnected.UserName)); } return(Clients.All.leftRoom(_connectedUsers, null)); }
protected override void ExecuteCmdlet() { string output = string.Empty; switch (Scope) { case SearchConfigurationScope.Web: { if (PromotedResultsToBookmarkCSV.IsPresent) { output = RestHelper.ExecuteGetRequest(ClientContext, "searchsetting/getpromotedresultqueryrules"); } else { output = CurrentWeb.GetSearchConfiguration(); } break; } case SearchConfigurationScope.Site: { if (PromotedResultsToBookmarkCSV.IsPresent) { output = RestHelper.ExecuteGetRequest(ClientContext, "searchsetting/getpromotedresultqueryrules?sitecollectionlevel=true"); } else { output = ClientContext.Site.GetSearchConfiguration(); } break; } case SearchConfigurationScope.Subscription: { if (!ClientContext.Url.ToLower().Contains("-admin")) { throw new InvalidOperationException(Resources.CurrentSiteIsNoTenantAdminSite); } if (PromotedResultsToBookmarkCSV.IsPresent) { output = RestHelper.ExecuteGetRequest(ClientContext, "searchsetting/getpromotedresultqueryrules"); } else { SearchObjectOwner owningScope = new SearchObjectOwner(ClientContext, SearchObjectLevel.SPSiteSubscription); var config = new SearchConfigurationPortability(ClientContext); ClientResult <string> configuration = config.ExportSearchConfiguration(owningScope); ClientContext.ExecuteQueryRetry(); output = configuration.Value; } } break; } if (PromotedResultsToBookmarkCSV.IsPresent) { output = ConvertToCSV(output); } if (Path != null) { if (!System.IO.Path.IsPathRooted(Path)) { Path = System.IO.Path.Combine(SessionState.Path.CurrentFileSystemLocation.Path, Path); } System.IO.File.WriteAllText(Path, output); } else { if (OutputFormat == OutputFormat.CompleteXml) { WriteObject(output); } else if (OutputFormat == OutputFormat.ManagedPropertyMappings) { StringReader sr = new StringReader(output); var doc = XDocument.Load(sr); var mps = GetCustomManagedProperties(doc); foreach (var mp in mps) { mp.Aliases = new List <string>(); mp.Mappings = new List <string>(); var mappings = GetCpMappingsFromPid(doc, mp.Pid); mp.Mappings = mappings; var aliases = GetAliasesFromPid(doc, mp.Pid); mp.Aliases = aliases; } WriteObject(mps); } } }