我想对我的所有文本区域执行某些操作,但是不选择所有这些区域$("textarea").这是我在伪代码中尝试做的事情:
for each textarea do
alert(textarea.val)
Run Code Online (Sandbox Code Playgroud)
在我的情况下,我需要在我的所有textareas中进行Word替换,所以我认为使用迭代进行这样做会更加清晰,但是我无法弄清楚如何去做.
这是我目前所做的,这非常乏味:
var txtcode = $("#txt_banner1").text().replace("AFFURL",producturl);
$("#txt_banner1").text(txtcode);
var txtcode = $("#txt_banner2").text().replace("AFFURL",producturl);
$("#txt_banner2").text(txtcode);
Run Code Online (Sandbox Code Playgroud)
......等等......
谢谢!
我现在已经把头发拉了大约两天,因为每当我向现有实体添加多对多实体时,我根本无法获得EF来保存更改.
我的结构很简单:
我有一个名为的表Person,它有一个ID(主要,身份)和一些其他字符串字段
一个名为KeywordID(主,身份)和一个名为的字符串字段的表Value
和a PersonKeywordRelation,有a PersonId和a KeywordId字段
当我(第一数据库)生成我的实体,我得到的一类Person,有ICollection<Keyword>-所有的好,按预期工作.
当我尝试Person使用修改后的关键字列表保存现有内容时,会出现问题.只保存标量属性(字符串),而不是我的关键字!
我很确定我不是唯一一个遇到这个问题的人,(事实上我完全确定,因为我已经在这里看过几个问题,在同一个主题上,但我找不到合适的答案. ..),主要是针对旧版本的EF,这是另一个很好的理由,为什么我开始了另一个问题:没有任何改变可以解决这个问题?
这是我的代码,用于更新(和创建)人员.您会注意到我尝试相应地进行EF保存更改.
public void SavePersons(IList<Person> persons)
{
// Create a EF Context
using (var ctx = new MyDbEntities())
{
foreach (var person in persons)
{
// Attach
ctx.Persons.Attach(person);
// Insert or update?
ctx.Entry(person).State = person.Id == 0 ? EntityState.Added : EntityState.Modified;
// Get current keywords before clearing from entity
var keywords = …Run Code Online (Sandbox Code Playgroud) 我正在使用Go语言迈出第一步,我正在尝试在Debian Squeeze中安装它.我按照下载源代码的步骤,然后,我在我的终端上做了这个:
cd $GOROOT/src
./all.bash
Run Code Online (Sandbox Code Playgroud)
最后,它说:
# Checking API compatibility.
Go version is "go1.1.1", ignoring -next /root/go/api/next.txt
~pkg net, func ListenUnixgram(string, *UnixAddr) (*UDPConn, error)
~pkg syscall (darwin-386), func Fchflags(string, int) error
~pkg syscall (darwin-386-cgo), func Fchflags(string, int) error
~pkg syscall (darwin-amd64), func Fchflags(string, int) error
~pkg syscall (darwin-amd64-cgo), func Fchflags(string, int) error
~pkg syscall (freebsd-386), func Fchflags(string, int) error
~pkg syscall (freebsd-amd64), func Fchflags(string, int) error
~pkg text/template/parse, type DotNode bool
~pkg text/template/parse, type Node interface { Copy, String, Type …Run Code Online (Sandbox Code Playgroud) 我正在开发一个文件上传经常发生的应用程序,并且可能非常大.
这些文件正在上传到Web API,然后Web API将从请求中获取流,并将其传递给我的存储服务,然后将其上载到Azure Blob存储.
我需要确保:
我看过这篇文章,它描述了如何禁用输入流缓冲,但是许多不同用户的文件上传同时发生,重要的是它实际上完成了它在锡上所说的内容.
这就是我目前控制器中的内容:
if (this.Request.Content.IsMimeMultipartContent())
{
var provider = new MultipartMemoryStreamProvider();
await this.Request.Content.ReadAsMultipartAsync(provider);
var fileContent = provider.Contents.SingleOrDefault();
if (fileContent == null)
{
throw new ArgumentException("No filename.");
}
var fileName = fileContent.Headers.ContentDisposition.FileName.Replace("\"", string.Empty);
// I need to make sure this stream is ready to be processed by
// the Azure client lib, but not buffered fully, to prevent OoM.
var stream = await fileContent.ReadAsStreamAsync();
}
Run Code Online (Sandbox Code Playgroud)
我不知道如何可靠地测试这个.
编辑:我忘了提到直接上传到Blob存储(绕过我的API)将无法正常工作,因为我正在进行一些大小检查(例如,这个用户可以上传500mb吗?这个用户是否使用了他的配额?).
我正在尝试使用VirtualStringTree而不是Listview来构建我的项目,因为速度差异巨大.事情是,即使在通过演示看之后,我也无法弄清楚我将如何将其用作ListView.比如,添加,删除,基本上只是使用ListView项目是如此简单,但是当我看到VT时,它变得非常复杂.
我正在寻找的是一个看起来像ListView的VT,子项目等.
以下是使用ListView的一些例程,我想与VT一起使用(这只是一个伪示例:
procedure Add;
begin
with ListView.Items.Add do
Begin
Caption := EditCaption.Text;
SubItems.Add(EditSubItem.Text):
End;
end;
Procedure ReadItem(I : Integer);
begin
ShowMessage(ListView.Items[I].Caption);
ShowMessage(ListView.Items[I].SubItems[0]);
end;
Run Code Online (Sandbox Code Playgroud)
当然,也是删除功能,但由于那就像1行,我没有打扰:P
任何人都可以将上面的例子翻译成使用ListView风格的VT吗?
谢谢!
我刚刚意识到我的异常没有在我的线程中向用户显示!
起初我在我的线程中使用它来引发异常,这不起作用:
except on E:Exception do
begin
raise Exception.Create('Error: ' + E.Message);
end;
Run Code Online (Sandbox Code Playgroud)
IDE向我显示了异常,但我的应用程序没有!
我四处寻找解决方案,这就是我发现的:
http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_22039681.html
这些都不适合我.
这是我的Thread单元:
unit uCheckForUpdateThread;
interface
uses
Windows, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
IdHTTP, GlobalFuncs, Classes, HtmlExtractor, SysUtils, Forms;
type
TUpdaterThread = class(TThread)
private
FileGrabber : THtmlExtractor;
HTTP : TIdHttp;
AppMajor,
AppMinor,
AppRelease : Integer;
UpdateText : string;
VersionStr : string;
ExceptionText : string;
FException: Exception;
procedure DoHandleException;
procedure SyncUpdateLbl;
procedure SyncFinalize;
public
constructor Create;
protected
procedure HandleException; virtual;
procedure Execute; override;
end;
implementation
uses …Run Code Online (Sandbox Code Playgroud) 我一直在修改,调试,修改,调试(你知道演练),我只是无法弄清楚导致这些访问冲突的原因!
最典型的一个是在Skype4COM.dll中使用" 读取地址80000000 ",但我不怀疑它是导致它的代码.
我的第一个怀疑是我向Skype API发送了太多命令(通过Skype4COM),但在添加一些暂停逻辑后,为了确保Skype和COM对象能够跟上,我意识到这不是它 - 它仍然是发生的历史!
我正在使用Threads来执行此操作,即使不使用Threads,它仍然会引发AV.(我一次只使用一个线程)
这是我的Thread Execute方法:
procedure TMyThread.Execute;
Var
I : Integer;
User : PUser;
ReceiverName : String;
FullMessage : String;
PauseEvent : TEvent;
TimesToPause : Integer;
iPause : Integer;
J : Integer;
FExit : Boolean;
begin
inherited;
if Terminated then
Exit;
FreeOnTerminate := True;
CoInitialize(Nil);
FExit := True;
UserList := TList.Create;
SkypeThr := TSkype.Create(Nil);
PauseEvent := TEvent.Create(True);
Try
try
SkypeThr.Attach(10,False);
Synchronize(SyncBegin);
iMax := UserList.Count;
Synchronize(SyncSetMax);
LogID := 'N/A';
TimesToPause := Round(UserList.Count / 300);
// …Run Code Online (Sandbox Code Playgroud) 用Firemonkey查看新的Delphi XE2.考虑到它为Windows,Mac OSX和iOS编译,VCL组件在FireMonkey应用程序中是无用的.
我的问题是:是否会有Indy Firemonkey版?因为我非常需要IdHTTP.Post();.如果没有,有没有办法在FireMonkey中执行此操作?
我现在谷歌搜索了很长一段时间,没有找到任何东西.:S
请考虑以下(常见)方案.我将首先尝试使用OAuth指定我对(漂亮的)Web API的理解.如果我有任何错误的流程,请纠正我.
我的API:关注的焦点,所有客户都使用它.
我的Web应用程序:就像任何其他客户端一样使用API.
我的移动应用程序:也使用API,与Web应用程序完全相同.用户应该能够在不打开浏览器的情况下进行身份验证.
第三方Web App:也使用API - 但是,用户/资源所有者必须授予应用程序执行某些操作的权限.他们通过重定向到我的站点(或打开一个弹出窗口),在必要时记录用户,并提示用户进行访问来完成此操作.
第三方移动应用程序:与第三方Web应用程序相同的要求.
这是我理解的,并且到目前为止都会这样做.这是我真正需要帮助的地方 - 正确完成这项工作.
官方网络应用
- Client attempts to `GET /api/tasks/".
- API says "who are you? (HTTP 401)
- Official web app redirects to login form.
> Bob enters his credentials.
- .. now what? Get an authentication token? Cookie?
Run Code Online (Sandbox Code Playgroud)
我主要使用.NET(C#),但我喜欢一种适用于基于Node JS的API的方法.
你会怎么做?特别是客户流程对我来说是一个问题.我问的原因是,我已经知道除非绝对必要,否则你不应该推出自己的安全解决方案,所以如果有任何标准的准则,请告诉我.:)
我在OpenShift的免费套餐上部署了我的第一个Node.js应用程序,它运行良好.
OpenShift会在崩溃时自动重启我的Node应用程序,还是我必须设置Forever.js?我尝试设置它,它不会工作.运行后node_modules/forever/bin/forever start app.js(工作目录是app-root/repo本地副本forever)我得到了这个输出:
warn: --minUptime not set. Defaulting to: 1000ms
warn: --spinSleepTime not set. Your script will exit if it does not stay up for at least 1000ms
info: Forever processing file: app.js
fs.js:240
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: ENOENT, no such file or directory '/var/lib/openshift/5397416f5004466c0b000080/.forever/VQMF.log'
at Object.openSync (fs.js:240:18)
at Object.startDaemon (/var/lib/openshift/5397416f5004466c0b000080/app-root/runtime/repo/node_modules/forever/lib/forever.js:406:14)
at /var/lib/openshift/5397416f5004466c0b000080/app-root/runtime/repo/node_modules/forever/lib/forever/cli.js:258:13
at /var/lib/openshift/5397416f5004466c0b000080/app-root/runtime/repo/node_modules/forever/lib/forever/cli.js:145:5
at Object.oncomplete (/var/lib/openshift/5397416f5004466c0b000080/app-root/runtime/repo/node_modules/forever/lib/forever.js:358:11)
Run Code Online (Sandbox Code Playgroud)
那么,OpenShift是否为我管理我的应用程序的运行状况,或者我需要让Forever工作吗?如果是的话,对我得到的错误有任何想法吗?
delphi ×4
c# ×2
.net ×1
asp.net ×1
azure ×1
database ×1
debian ×1
delphi-xe2 ×1
exception ×1
firemonkey ×1
forever ×1
go ×1
html ×1
http ×1
indy ×1
iteration ×1
javascript ×1
jquery ×1
listview ×1
node.js ×1
oauth ×1
openshift ×1
raise ×1
rest ×1
security ×1
skype ×1
sql-server ×1
textarea ×1
tthread ×1