- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在创建 MVC 应用程序 chatter 应用程序。我想在聊天中显示谁在线。我怎样才能显示它?
我有chatter Controller 代码:
public ActionResult ChatterList(int ProjectId)
{
ReadCookieValue cookie = new ReadCookieValue();
clientId = cookie.readuserinfo().ClientId;
userId = cookie.readuserinfo().Id;
roleId = cookie.readuserinfo().RoleId;
ChatterViewModel model = new ChatterViewModel();
model.chattersList = Task.Run(() => _project.GetChatterList(ProjectId)).Result;
foreach (var item in model.chattersList)
{
item.CurrentUserId = userId;
}
model.newChatter = new ChatterModel();
model.newChatter.ProjectId = ProjectId;
model.newChatter.UserId = userId;
model.newChatter.UserName = cookie.readuserinfo().UserName;
return View("ProjectChatter", model);
}
public async Task<ActionResult> AddChatter(ChatterViewModel model)
{
if (model != null)
{
var obj = await _project.AddChatterList(model);
if (model.newChatter.ProjectId == 3)
{
return RedirectToAction("EbitDaReports");
}
}
return RedirectToAction("Reports");
}
我使用项目 ID View 创建了聊天代码看起来像
<div class="col-lg-6">
<div class="ibox-content">
<div class="chat-discussion">
<div class="ibox float-e-margins">
<div class="chat-element right">
<div class="row m-t-lg">
@if (Model.ProjectId > 0)
{
@Html.Action("ChatterList", "Projects", new { @ProjectId = Model.ProjectId })
}
</div>
</div>
</div>
</div>
</div>
</div>
我正在尝试使用
<div class="row">
@if (HttpRuntime.Cache["ProjectId"] != null)
{
var loggedOnUsers = HttpRuntime.Cache["ProjectId"] as Dictionary<string, DateTime>;
if (loggedOnUsers != null)
{<div class="ProjectId">
}
<span> Online Users: </span>
</div>
}
}
</div>
我什么也没得到。我需要创建新的 Controller ?或者我可以覆盖现有的 Controller ?
最佳答案
您需要循环遍历字典项目并显示它。
<div class="row">
@if (HttpRuntime.Cache["ProjectId"] != null)
{
var loggedOnUsers = HttpRuntime.Cache["ProjectId"] as Dictionary<string, DateTime>;
<span> Online Users: </span>
if (loggedOnUsers != null)
{
foreach (var userItem in loggedOnUsers.Keys)
{
<p>@userItem <span>@loggedOnUsers[userItem]</span></p>
}
}
else
{
<p>No users!</p>
}
}
else
{
<h2>Could not find a HttpRuntime Cache entry with key "ProjectId"</h2>
}
</div>
这将列出用户及其时间,假设 HttpRuntime.Cache["ProjectId"]
存储在线用户的字符串和日期时间字典。
编辑: 显示示例代码如何将数据设置到缓存。
这就是将项目添加到缓存的方式,您需要在应用程序中的某个位置执行这样的代码(可能是当用户登录聊天时,添加新条目)。
var data = HttpRuntime.Cache["ProjectId"] as Dictionary<string, DateTime>;
if(data==null)
data=new Dictionary<string, DateTime>();
data.Add("Scott",DateTime.Now);
data.Add("Shyju", DateTime.Now);
data.Add("Kevin", DateTime.Now);
HttpRuntime.Cache["ProjectId"] = data;
关于javascript - 如何使用 Chatter 应用程序 MVC 显示用户在线?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38744444/
yaml 文件: - - Invalid Password - contact xyz@gmail.com 我正在使用 python Chatterbot 库,如果我询问密码无效,它会返回响应联系
我想从 javascript 发布到 chatter。我正在创建的应用程序是一个浏览器扩展,因此它不特定于特定域。单击按钮时,javascript 会执行 oAuth 舞蹈,然后发布到 chatter
我的flex源文件夹“src”具有以下文件: src/ chatters.as chatters.mxml main.as main.mxml 这是“chatters.mxml”的来源
我正在创建 MVC 应用程序 chatter 应用程序。我想在聊天中显示谁在线。我怎样才能显示它? 我有chatter Controller 代码: public ActionResult Chatt
我是 iOS 的新手,正在尝试将 salesforce chatter 功能集成到我的原生 ios 应用程序中。我已经尝试这样做很长时间了,但没有取得任何成功。如果有人可以指导,那将非常有帮助先生对此
我将 pdf 作为聊天文件存储在我们的 SF 组织中,该组织运行良好,但向用户显示这些 PDF 非常具有挑战性,尤其是在移动设备(例如 ipad)上我找到了一些优秀的 javascript PDF 查
我正在尝试从在本地主机上运行的 JavaScript 访问 Chatter API(最终将托管在某处)。如果我尝试正常的 AJAX GET 请求,我会收到 Access-Control-Allow-O
我最近将我的应用程序从 Laravel 5.1 更新到 5.3。 此后不久,我尝试安装 chatter。 我按照说明,在这里找到:https://github.com/thedevdojo/chatt
我正在创建一个浏览器扩展,它使用 rest api 发布到 salesforce chatter。一旦我从 OAuth 用户代理流获得 access_token,由于浏览器同源策略,我无法从 java
我想在 Odoo 10 中向“mail.Chatter”小部件(mail/static/src/js/chatter.js)添加一个新事件。因此我想扩展“mail.Chatter”小部件。 odoo.
是否有人对将 Chatter 数据迁移到 MS Dynamics CRM 2011(本地)中的 Activity 源的可行性/最佳方法有任何见解或经验?能够在整个 Feed 历史记录中重新关联附件将是
我是一名优秀的程序员,十分优秀!