我正在输出查询但需要指定结果的第一行.我正在使用QueryAddRow()添加行并使用QuerySetCell()设置值.我可以创建行,我可以将内容添加到该行.如果我从QuerySetCell()中删除行号的参数,那么它在输出时作为查询的最后结果都可以正常工作.但是,我需要它作为查询的第一行,但是当我尝试使用QuerySetCell设置row属性时,它只会覆盖我查询中的第一个返回的行(即我的QueryAddRow()替换了我的查询中的第一个记录).我目前所拥有的是从recordCount设置变量并安排输出,但必须有一个非常简单的方法来做到这一点,我只是没有得到.此代码将行值设置为1,但会覆盖查询中第一个返回的行.
<cfquery name="qxLookup" datasource="#application.datasource#">
SELECT xID, xName, execution
FROM table
</cfquery>
<cfset QueryAddRow(qxLookup)/>
<cfset QuerySetCell(qxLookup, "xID","0",1)/>
<cfset QuerySetCell(qxLookup, "xName","Delete",1)/>
<cfset QuerySetCell(qxLookup, "execution", "Select this to delete",1)/>
<cfoutput query="qxLookup">
<tr>
<td>
<a href="##" onclick="javascript:ColdFusion.navigate('xSelect/x.cfm?xNameVar=#url.xNameVar#&xID=#qxLookup.xID#&xName=#URLEncodedFormat(qxLookup.xName)#', '#xNameVar#');ColdFusion.Window.hide('#url.window#')">#qxLookup.xName#</a>
</td>
<td>#qxLookup.execution#</td>
</tr>
</cfoutput>
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助.
我做了一个家庭作业,这里是问题陈述:
您的程序应该如下工作:
使用程序员编写的方法计算风寒因子,并以下列形式显示结果:
对于t =来自file的温度和v =来自文件的风速Wind chill index =计算结果华氏度.
显示小数点后两位数的所有数字.(记住 - 没有神奇的数字!)
重复这些步骤,直到遇到文件结尾.
我已经完成了作业,我的代码在下面,我只是想知道是否有任何方法可以提高效率,或者如果有一些不同的创造性方法来解决这个问题,我已经把它转到了50/50 ,但我很好奇你们有些高级和熟练的程序员会如何解决这个问题.
using System;
using System.IO;
class Program
{
// declare constants to use in wind chill factor equation - no magic numbers
const double FIRST_EQUATION_NUMBER = 35.74;
const double SECOND_EQUATION_NUMBER = 0.6215;
const double THIRD_EQUATION_NUMBER = 35.75;
const double FOURTH_EQUATION_NUMBER = 0.4275;
const double EQUATION_EXPONENT = 0.16;
const int DEGREE_SYMBOL_NUMBER = 176;
static void Main()
{
// declare and initialize some variables
string …Run Code Online (Sandbox Code Playgroud) 我有一个设置为AutoSize的图片框,以便图像强制它增长到图像的完整大小.
图片框位于autoScroll = true的面板中,因此当图片大于面板时会出现滚动条.
当用户单击图像上的拖动时,如何以编程方式滚动面板,从而重新定位图像.
我尝试过使用MouseMove事件,捕获鼠标的最后X和Y位置,计算鼠标移动了多少,并调整了面板的垂直和水平滚动值.
确实可以移动图像,但它会在整个地方跳跃,并且无法预测地滚动.
我怎样才能做到这一点?
这是我在鼠标事件中所拥有的......
private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
if (dragging)
{
if (e.Button == MouseButtons.Left)
{
// move the image inverse to direction dragged
int horizontalChange = (e.X - startingX) * -1;
int newHorizontalPos = panel1.HorizontalScroll.Value + horizontalChange;
if (newHorizontalPos < panel1.HorizontalScroll.Minimum)
{
newHorizontalPos = panel1.HorizontalScroll.Minimum;
horizontalChange = 0;
}
if (newHorizontalPos > panel1.HorizontalScroll.Maximum)
{
newHorizontalPos = panel1.HorizontalScroll.Maximum;
horizontalChange = 0;
}
panel1.HorizontalScroll.Value = newHorizontalPos;
int verticalChange = (e.Y - startingY);
// …Run Code Online (Sandbox Code Playgroud) 我使用jquery发布到返回信息表的MVC控制器动作.页面的用户通过单击各种链接来触发此操作.
如果用户决定快速连续点击一堆这些链接,我想取消任何以前可能尚未完成的ajax请求.
我发现当我这样做时(尽管客户端的POV很好)我会在Web应用程序上遇到错误
"The parameters dictionary contains a null entry for parameter srtCol of non-nullable type 'System.Int32'"
现在ajax帖子确实传递了所有参数,如果我不尝试取消ajax请求它就可以了.
但是如果我通过在XMLHttpRequest对象上调用abort()来取消请求,ajax()在完成之前返回,我从ASP.Net MVC得到错误.
例:
//Cancel any pevious request
if (req)
{
req.abort();
req = null;
}
//Make new request
req = $.ajax({
type: 'POST',
url: "/Myapp/GetTbl",
data: {srtCol: srt, view: viewID},
success: OnSuccess,
error: OnError,
dataType: "html"
});
Run Code Online (Sandbox Code Playgroud)
我注意到这只发生在IE8上.在FF中似乎不是一个问题.
有谁知道如何在IE8中取消ajax请求而不会导致MVC错误?
谢谢你的帮助.
我有一个使用Express框架和http-auth模块设计的node.js应用程序,如下所示:
var auth = require('http-auth');
var express = require('express');
// ...
var mywebapp = express();
// ...
if (usebasicauth) {
var basic = auth.basic({realm:"MyRealm", file:"/srv/config/passwd"});
mywebapp.use(auth.connect(basic));
}
mywebapp.use('/js', express.static(__dirname + '/files/js'));
mywebapp.use('/css', express.static(__dirname + '/files/css'));
// ...
Run Code Online (Sandbox Code Playgroud)
但是,我不想保护/js和/css目录下可用的资产.这是我尝试做的:
if (usebasicauth) {
var basic = auth.basic({realm:"MyRealm", file:"/srv/config/passwd"});
mywebapp.use(function(req, res, next) {
if (/^\/(css|js)/.test(req.url)) {
next();
}
else {
auth.connect(basic);
}
});
}
Run Code Online (Sandbox Code Playgroud)
试图访问的URL下/css,并/js达到预期效果; 但是,其他URL永远不会加载.
如何让其他网址按预期工作?
对不起,我不太明白秘密密钥在koa中是如何工作的.在koa中,对象keys上有一个字段app,将使用如下:
const app = new Koa();
app.keys = ['some secret', 'another secret', 'or more ...']; // it's an
// array right?
Run Code Online (Sandbox Code Playgroud)
然后,在使用koa-csrf中间件时,默认情况下内置程序csrf.middleware不使用提供的密钥app.keys.如果我使用默认中间件,我需要创建另一个在会话上设置密钥的中间件.
app.use(session()); // koa-generic-session
app.use(async (ctx, next) => { // without this custom middleware
ctx.session.secret = 'yet another secret'; // POST /protected-route
await next(); // will give 403
}); // missing secret
csrf(app);
app.use(csrf.middleware);
Run Code Online (Sandbox Code Playgroud)
当我使用Flask时,我只需要提供一个由string非设置的密钥array.为什么需要多个密钥?只使用一个整个应用程序还不够?
出于某种原因,我的路由忽略了任何访问我的MVC页面的尝试,只是给了我404.我有一个WebForms应用程序设置如下:
虚拟目录:事情
所以我经常这样访问我的网站:
我的ASP.NET WebForms应用程序的原始结构镜像文件系统,所以我有完整的.aspx文件夹,我需要能够像这样使用它们.出于某种原因,当我尝试使用MVC路由访问页面时,例如:
我刚收到404错误.我已经使用了ASP.NET MVC,我知道即使我没有正确设置我的文件夹,我也不会得到404.我会得到无法找到页面的原因并提示文件应该在哪里.以下是我的路由信息.我哪里错了?
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("{resource}.aspx/{*pathInfo}");
routes.MapRoute(
"Default",
// Route name
"{controller}/{action}/{id}",
// URL with parameters
new { controller = "Home", action = "Index", id = "" }
// Parameter defaults
);
}
protected void Application_Start()
{
RegisterRoutes(RouteTable.Routes);
}
Run Code Online (Sandbox Code Playgroud) 我正在玩C#中的垃圾收集器(或者更确切地说是CLR?)试图更好地理解C#中的内存管理.
我制作了一个小样本程序,将三个较大的文件读入byte[]缓冲区.我想看看,如果
byte[]在当前迭代结束后将其设置为null 时,它会产生任何影响GC.Collect()免责声明:我使用Windows任务管理器测量内存消耗并将其四舍五入.我尝试了好几次,但总的来说还是差不多.
这是我的简单示例程序:
static void Main(string[] args)
{
Loop();
}
private static void Loop()
{
var list = new List<string>
{
@"C:\Users\Public\Music\Sample Music\Amanda.wma", // Size: 4.75 MB
@"C:\Users\Public\Music\Sample Music\Despertar.wma", // Size: 5.92 MB
@"C:\Users\Public\Music\Sample Music\Distance.wma", // Size: 6.31 MB
};
Console.WriteLine("before loop");
Console.ReadLine();
foreach (string pathname in list)
{
// ... code here ...
Console.WriteLine("in loop");
Console.ReadLine();
}
Console.WriteLine(GC.CollectionCount(1));
Console.WriteLine("end loop");
Console.ReadLine();
}
Run Code Online (Sandbox Code Playgroud)
对于每个测试,我只更改了foreach循环的内容.然后我运行程序,每次Console.ReadLine()停止并检查Windows任务管理器中进程的内存使用情况.我记下了已用过的内存,然后继续程序返回(我知道断点;)).在循环结束后,我写信GC.CollectionCount(1)给控制台,以便了解GC的频率是多少.
我search widget在我navigation drawer的应用程序中实现了Android .我已将其设置为打开键盘并editText在单击搜索图标时对焦.我想设置后退按钮(向上按钮)来隐藏键盘.我在网上搜索了R.id向上按钮,发现了这个android.R.id.home.所以我把它设置为:
@Override
public boolean onOptionsItemSelected(MenuItem item) {
...
case android.R.id.home:
hideKeyboard();
break;
...
}
Run Code Online (Sandbox Code Playgroud)
我调试了代码并注意到点击navigation bar图标会激活android.R.id.home,但点击搜索小部件的向上按钮甚至都不会进入该onOptionsItemSelected(MenuItem item)功能.我也试过这个:
searchView.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (!hasFocus) {
hideKeyboard();
}
}
});
Run Code Online (Sandbox Code Playgroud)
但没有奏效.
按下后(向上)按钮时如何隐藏键盘?
设置搜索视图:
private void setSearchView(Menu menu) {
// Get the SearchView and set the searchable configuration
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
searchView = (SearchView) menu.findItem(R.id.search).getActionView(); …Run Code Online (Sandbox Code Playgroud) 我有两个实体,用户和员工.所以我想在不同的端点都使用CRUD,但是它们都将安装在"api"下,所以我可以定义api_v1,api_v2等等.端点将是这样的:
get api/users
put api/users/12
delete api/users/12
get api/employees
....
Run Code Online (Sandbox Code Playgroud)
我的两条路线都无法获得"api"前缀.无法使用koa-mount.
我的文件:
server.js
// Dependencies
import Koa from 'koa'
import mongoose from 'mongoose'
import logger from 'koa-logger'
// import parser from 'koa-bodyparser';
import convert from 'koa-convert'
import serve from 'koa-static'
import Router from 'koa-router'
import session from 'koa-generic-session'
import mount from 'koa-mount'
// A seperate file with my routes.
import routingUsers from './users'
import routingEmployees from './employees'
// config
const config = require("./config/config")
// connect to the database
mongoose.connect(config.mongo.url)
mongoose.connection.on('error', …Run Code Online (Sandbox Code Playgroud) c# ×3
asp.net-mvc ×2
koa ×2
koa2 ×2
ajax ×1
android ×1
asp.net ×1
coldfusion ×1
coldfusion-8 ×1
express ×1
file-io ×1
http-auth ×1
iis ×1
java ×1
jquery ×1
koa-router ×1
node.js ×1
panel ×1
performance ×1
picturebox ×1
searchview ×1
secret-key ×1
winforms ×1