我使用Web API的MVC4 Web应用程序.我想创建一个动作过滤器,我想知道哪个用户(登录用户)做了动作.我该怎么做?
public class ModelActionLog : ActionFilterAttribute
{
public override void OnActionExecuting(SHttpActionContext actionContext)
{
string username = ??
}
public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
{
??
}
}
Run Code Online (Sandbox Code Playgroud) 我正在使用SWI-Prolog并且我正在尝试打印列表,但如果列表中有超过9个项目 - 它看起来像那样 -
[1, 15, 8, 22, 5, 19, 12, 25, 3|...]
Run Code Online (Sandbox Code Playgroud)
有没有办法显示整个列表?
我构建了一个Android应用程序.我有一个EditText.我想在用户更改文本后自动保存更改(或其他任何内容).现在我用
editText.addTextChangedListener(textWatcher);
Run Code Online (Sandbox Code Playgroud)
和
TextWatcher textWatcher = new TextWatcher() {
public void afterTextChanged(Editable s) {
...
}
Run Code Online (Sandbox Code Playgroud)
但是它会在每次微小的更改后保存更改(添加\删除一个字母),我希望它只在用户完成后才能保存(关闭键盘,点击不同的编辑文本等).我怎样才能做到这一点?
我想在配置文件中保存一些设置以备将来使用.我正在尝试使用我在所有教程中看到的常规代码 -
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.AppSettings.Settings["username"].Value = m_strUserName;
// I also tried -
//config.AppSettings.Settings.Remove("username");
//config.AppSettings.Settings.Add("username", m_strUserName);
config.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection("appSettings");
Run Code Online (Sandbox Code Playgroud)
现在 - 我可以看到在运行时 - "Debug"文件夹中的文件"... vshost.exe.config"发生了变化,当我关闭我的应用程序时,它会被删除 - 所有更改都将被删除.我能做什么?
我有一个Web应用程序,我安装在客户的计算机上供内部使用.我使用C#MVC5和代码优先实体框架.我使用自动migration = true但我停下来并将其设置为false.我在生产环境(发布)上安装了它 - 使用deploy-package(没有Visual Studio).
我与应用客户-第1版.现在,我想升级到第2版.我希望能够提升应用程序的DB(在生产文件,从包CMD安装),但有这种可能性降级的数据库是否存在任何问题 - 但不删除现有行.
例如 - 如果我有一个表"Items"和Items有Key, Name, Location
.在升级时,我添加了一个新列:Email
.降级时 - 新列将被删除.我在Visual Studio上创建了迁移,我得到了这个代码(这只是为了示例 - 我有更多的迁移):
public partial class AddEmail : DbMigration
{
public override void Up()
{
AddColumn("dbo.Items", "Email", c => c.String());
}
public override void Down()
{
DropColumn("dbo.Items", "Email");
}
}
Run Code Online (Sandbox Code Playgroud)
现在,我在现有版本上安装了应用程序的新版本,并且工作正常 - 添加了新列并使用了新代码.我添加了一些项目(行).
现在,如何重新安装旧版本以删除新列?实际上我想回滚新的迁移 - 但我不想丢失新行,只想丢失新列.
在我的应用中,用户可以将特殊事件添加到他们的Google日历中.我希望在没有任何警报/提醒/通知的情况下添加事件.某些用户的日历具有提醒的默认设置,如"活动前一天,即9:00".
我如何添加事件,以便尽管有默认设置,它们根本不会有任何警报?
ContentValues eventValues = new ContentValues();
eventValues.put("calendar_id", calendarId);
eventValues.put("title",title);
eventValues.put("allDay", 1);
eventValues.put("dtstart", dtstart);
eventValues.put("dtend", dtend );
eventValues.put("hasAlarm", 1); // I tried both 0 and 1, none of them solved the problem!
eventValues.put("hasAttendeeData", 1);
eventValues.put("availability",1);
Run Code Online (Sandbox Code Playgroud)
编辑:似乎只有在事件与Google的服务同步后才会添加提醒,几分钟后,而不是立即.我该怎样预防呢?
我使用VisualStudio构建一个C#-MVC3网站,效果很好.
我需要在另一台计算机上安装该网站进行检查.这台电脑有IIS7.
我试图安装(我的第一次......我真的不知道IIS),当我浏览网站(localhost/mySite)时,我可以看到所有目录(控制器,视图...)但我不能看到网站本身.
我可以看到一个特定的文件(如localhost/mySite/Content/img.jpg)但我看不到带控制器的站点(localhost/mySite或localhost/mySite/Home)
该怎么办?
我是wix的新手.需要创建本地网站的快捷方式.
它工作正常并创建了shorcuts,但它没有在开始菜单和桌面上显示任何图标...该网站有favicon文件,当我打开网站时,我可以完美地看到它 - 我只是看不到它捷径.我试图谷歌它但我没有找到一个很好的答案的util:InternetShortcut ..
我的代码是:
<DirectoryRef Id="ApplicationProgramsFolder">
<Component Id="ApplicationShortcutBBBApp" Guid="---">
<util:InternetShortcut Id="ApplicationStartMenuShortcutBBBApp"
Name="BBB"
Target="http://localhost/BBB"/>
<util:InternetShortcut Id="ApplicationDesktopShortcutBBBApp"
Name="BBB"
Directory="DesktopFolder"
Target="http://localhost/BBB"/>
<RegistryValue Root="HKCU" Key="Software\Microsoft\BBB" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
</Component>
</DirectoryRef>
Run Code Online (Sandbox Code Playgroud) 我首先使用EF代码并自动迁移.我想在我的模型中添加一个新列 - 一个布尔列,用于显示"active"(true)或"inactive"(false).如何添加此列并为数据库中已有的行设置默认值("true") - 具有自动迁移功能?
c# entity-framework ef-code-first ef-migrations automatic-migration
我正在构建一个Android应用程序,该应用程序使用户可以将事件插入到Google日历和外部日历(如Exchange帐户).
问题在于,如果用户想要在2038年之后添加事件,则会在过去创建事件(例如 - 2038年1月变为1901年12月,2038年7月4日变为1902年5月28日).我做了一些研究,发现问题是" 2038年问题 ".
2038年问题是计算和数据存储情况的问题,其中时间值存储或计算为带符号的32位整数,并且此数字被解释为1970年1月1日00:00:00 UTC以来的秒数这种实现无法在2038年1月19日03:14:07 UTC之后编码.
可以用Unix签名的32位整数时间格式表示的最新时间是2038年1月19日星期二03:14:07 UTC(1970年1月1日之后的2,147,483,647秒).超出该时间的时间将"环绕"并在内部存储为负数,这些系统将解释为1901年12月13日而不是2038年1月19日.这是由整数溢出引起的.
似乎我的Java代码工作正常,我得到的毫秒是好的,但是当我将值发送到Google API insert
函数时 - 我认为它不知道如何处理它然后它在错误的日期插入事件( 1901年及以上).有办法处理吗?
这是我的代码:
private void InsertEvent(MyEvent myEvent) {
Uri EVENTS_URI = Uri.parse(getCalendarUriBase() + "events");
ContentValues eventValues = new ContentValues();
eventValues.put("eventTimezone", TimeZone.getDefault().getID());
eventValues.put("calendar_id", myEvent.calId);
eventValues.put("title",myEvent.title);
eventValues.put("allDay", 1);
long dateStart = myEvent.startDate.getTime(); // returns milliseconds - 2160248400000 for date 06/16/2038
eventValues.put("dtstart", dateStart );
long dateEnd = myEvent.endDate.getTime();
eventValues.put("dtend", dateEnd );
// At this point, in debug mode, I can see that the millisecond of …
Run Code Online (Sandbox Code Playgroud) c# ×4
android ×3
app-config ×1
asp.net-mvc ×1
calendar ×1
downgrade ×1
favicon ×1
iis-7 ×1
milliseconds ×1
prolog ×1
reminders ×1
shortcut ×1
swi-prolog ×1
textwatcher ×1
wix ×1
year2038 ×1