我在app/Lib文件夹中创建了一些文件,并希望从库类中访问我的一个模型:
<?php
App::uses('CrawlerBase','Lib');
App::uses('Deal', 'Model');
class SampleCrawler extends CrawlerBase {
public $uses = array('Deal');
function __construct(){
$this->Deal->create();
Run Code Online (Sandbox Code Playgroud)
然而,蛋糕似乎找不到Deal模型,我在模型创建行中的非对象上调用成员函数create().
感谢帮助.
如何在控制器方法中执行异步方法并返回HttpStatusCodeResult(200),而async委托不会过早地终止其执行?
我正在开发一个asp.net应用程序,我的一个动作是我的家庭控制器需要很长时间才能运行(10-30秒).我想返回一个HttpStatusCodeResult(200)并继续运行我的函数.functoin不需要返回任何东西,但它仍然不是真正的火灾和遗忘,因为我立即返回对服务器的响应HttpStatusCodeResult.
我尝试使用委托,但似乎一旦我从动作返回状态代码,委托就会停止执行.另一个选择是创建一个Windows服务,但这就像使用火箭筒杀死一只苍蝇.我得到的请求很少,所以资源和性能在我的情况下不是问题.我听说ThreadPool.QueueUserWorkItem是一个选项,但哪个最适合我的情况?
我正在处理的应用程序需要三个环境,一个开发环境,其中最新版本的代码是(在每次提交时构建)和测试发生(我们合并开发和测试环境以提高效率)。我们有一个临时环境,这个环境用于产品演示和演示,以及带有实时数据和客户的生产环境。
现在这将如何映射到 Azure 云服务,我在许多博客中读到我不应该为此使用内置的暂存/生产槽。我应该使用三个单独的链接数据库创建三个单独的云服务,这是最佳实践吗?
我正在尝试将数据库中的值传递给asp.net mvc中的视图,非常简单
public ActionResult SettingsList() {
using (podio_doc_db db = new podio_doc_db() ) {
string app_id = db.Configs.Where(r => r.Key == "app.id").Select(r => r.Value).First();
ViewBag["app_id"] = app_id;
}
return View();
}
Run Code Online (Sandbox Code Playgroud)
但是我一直收到这个错误
Cannot apply indexing with [] to an expression of type 'System.Dynamic.DynamicObject'
Run Code Online (Sandbox Code Playgroud) 我有以下json文件
{"fields":[
{
"status":"active",
"external_id":"title",
"config":{},
"field_id":11848871,
"label":"Title",
"values":[
{
"value":"Test Deliverable"
}
],
"type":"text"
},{
"status":"active",
"external_id":"client-name",
"config":{},
"field_id":12144855,
"label":"Client Name",
"values":[
{
"value":"Chcuk Norris"
}
],
"type":"text"
}}
Run Code Online (Sandbox Code Playgroud)
我想选择具有external_id ="title"的字段的值,例如,我正在使用Json.Net并且已经解析了该对象.我如何在Json对象上使用lambda或linq这样做,我想这样的事情
JObject o = JObject.Parse(json);
Title = o["fields"].Select(q => q["extenral_id"].Values[0] == "title");
Run Code Online (Sandbox Code Playgroud)
这在语法方面不是事件正确的.我不太熟悉Lambda或Linq认为它已经存在了一段时间.感谢帮助
谢谢
叶海亚
我正在尝试使用我的模块中提供的新模块覆盖Mage_Catalog_Block_Product_Price_Template块和模板,通过设置配置覆盖块是正常的:
<global>
<blocks>
<catalog>
<rewrite>
<product_price>ABC_PriceX_Block_Price</product_price>
</rewrite>
</catalog>
</blocks>
</global>
Run Code Online (Sandbox Code Playgroud)
然后调用新块
<?php
class ABC_PriceX_Block_Price extends Mage_Catalog_Block_Product_Price_Template {
protected function _construct() {
parent::_construct();
Mage::log('I am in ABC block');
$this->setTemplate('pricex/price.phtml');
Mage::log('Template file is '. $this->getTemplateFile() );
}
}
Run Code Online (Sandbox Code Playgroud)
但是我得到了一个非常奇怪的行为,价格块在前端不再显示,而我在日志文件中得到的只是
2012-09-07T18:05:38+00:00 DEBUG (7): I am in ABC block
2012-09-07T18:05:38+00:00 DEBUG (7): Template file is
Run Code Online (Sandbox Code Playgroud)
并且不呈现模板:
<p>
<?php Mage::log('I am in ABC template'); ?>
</p>
Run Code Online (Sandbox Code Playgroud)
我错过了什么吗?
我正在使用Identity 2.1来处理我的asp.net应用程序中的用户角色.到目前为止,我创建了从IdentityDBContext扩展的新上下文,扩展了IdentityUser和IdentityRole以添加几个新字段.但是,每当我尝试使用UserManager即可将用户添加到特定角色时The entity type IdentityRole is not part of the model for the current context..所以用户 - 角色关系似乎有问题,到目前为止这是我的代码供参考:
用户
public class User : IdentityUser{
public string Name { get; set; }
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<User> manager, string authenticationType) {
// Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
var userIdentity = await manager.CreateIdentityAsync(this, authenticationType);
// Add custom user claims here
return userIdentity;
}
}
Run Code Online (Sandbox Code Playgroud)
角色
public partial class Role : IdentityRole
{
public string Description { get; …Run Code Online (Sandbox Code Playgroud) 我理解异步如何工作以及它与javascript承诺的比较,但我不确定如下所示的行如何能有任何好处
IdentityResult result = await UserManager.CreateAsync(user, model.password);
Run Code Online (Sandbox Code Playgroud)
因为我们正在创建一个异步调用并立即在线程上等待,所以在异步调用调用完成之前,不会执行后面的行.
我有一个如下组件,其中有一个select_property单击时调用的按钮。问题是我不确定在$livevisitors每次点击重新分配之前是否需要以任何方式取消订阅,不确定$livevisitors | async在组件模板中这是否对我有用。
export class LiveComponent{
livevisitors$: Observable<LiveVisitor[]>;
selected_property_id: number = 0;
constructor(
private store: Store<AppState>
) {
this.livevisitors$ = this.store.select(selectAllLiveVisitors);
}
select_property(id){
this.selected_property_id = id;
if (id == 0){
this.livevisitors$ = this.store.select(selectAllLiveVisitors);
} else {
this.livevisitors$ = this.store.select(selectLiveVisitorsByPropertyId, {property_id: id});
}
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试将身份表重命名为 Roles、Users、UserRoles、UserLogins 和 UserClaims。我部分成功地执行并使用命令 Update-Table 更新了我的数据库。
但是我似乎无法摆脱 AspNetUsers 表,它总是只生成一列,即 Id 列,尽管我得到了另一个带有完整列列表的 Users 表和另一个 Id 列。
Update-Database 生成的脚本
Applying automatic migration: 201501190035078_AutomaticMigration.
CREATE TABLE [dbo].[Roles] (
[Id] [nvarchar](128) NOT NULL,
[Name] [nvarchar](256) NOT NULL,
CONSTRAINT [PK_dbo.Roles] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[UserRoles] (
[UserId] [nvarchar](128) NOT NULL,
[RoleId] [nvarchar](128) NOT NULL,
[IdentityUser_Id] [nvarchar](128),
CONSTRAINT [PK_dbo.UserRoles] PRIMARY KEY ([UserId], [RoleId])
)
CREATE TABLE [dbo].[Users] (
[Id] [nvarchar](128) NOT NULL,
[Email] [nvarchar](max),
[EmailConfirmed] [bit] NOT NULL,
[PasswordHash] [nvarchar](max),
[SecurityStamp] [nvarchar](max),
[PhoneNumber] [nvarchar](max), …Run Code Online (Sandbox Code Playgroud) asp.net ×3
asp.net-mvc ×3
c# ×2
angular ×1
async-await ×1
azure ×1
c#-3.0 ×1
cakephp ×1
json.net ×1
magento ×1
ngrx ×1
ngrx-store ×1
php ×1
threadpool ×1
viewbag ×1