我正在尝试实现一个简单的CQRS应用程序示例.
这是我的"命令"部分的结构:
public interface ICommand
{
}
//base interface for command handlers
interface ICommandHandler<in TCommand> where TCommand: ICommand
{
void Execute(TCommand command);
}
// example of the command
public class SimpleCommand: ICommand
{
//some properties
}
// example of the SimpleCommand command handler
public class SimpleCommandHandler: ICommandHandler<SimpleCommand>
{
public void Execute(SimpleCommand command)
{
//some logic
}
}
Run Code Online (Sandbox Code Playgroud)
这是界面ICommandDipatcher.它将命令分派给其处理程序.
public interface ICommandDispatcher
{
void Dispatch<TCommand>(TCommand command) where TCommand : ICommand;
}
Run Code Online (Sandbox Code Playgroud)
这是默认实现,ICommandDispatcher主要问题是通过命令的类型获取必要的命令处理程序Autofac.
public class DefaultCommandDispatcher …Run Code Online (Sandbox Code Playgroud) 我们在Azure上使用免费的BizSpark订阅,并将我们的应用程序托管为Azure网站.我们经常会遇到意外的站点关闭,因为它有很多后台进程,所以我们的应用程序非常痛苦.
"Always on"设置可以解决此问题,但遗憾的是,在当前订阅中我们无法使用它.
您可能知道IIS有两个基于以下设置的回收:
我想知道如果我们打开" Always on "设置,我们能否确保它可以帮助我们防止上述两种应用程序回收类型.
顺便说一下,我发现了这个问题: "Always On"设置会阻止BOTH idleTimeout和periodicRestart吗?有类似的话题.它说这个设置应该有所帮助.
但我想确定,这是真的.因为在我们的案例中,实时后台进程的中断是绝对不可接受的.
感谢任何答案.
我在VS解决方案中有一个项目,在VS2015中正确加载,但在VS2017(RC2)中似乎已损坏.
在解决方案资源管理器中,它显示其"加载失败",当我尝试重新加载它时,我收到一条错误弹出窗口,其中显示消息"对象引用未设置为对象的实例".
我认为可能是因为VS2017会根据.csproj需要自动更改文件,但在与VS2015解决方案中的版本进行比较后,我发现它们并没有什么不同.
有没有人经历过这样的事情?它怎么可能修复?
谢谢.
我是AngularJS的新手并且遇到过这个问题.
我可以在所有控制器上重新注入我的工厂单例对象吗?
例如:
.factory('medicalCenterService', function(MedicalCenterResource) {
var medicalCenterService = {};
medicalCenterService.currentMedCenter = MedicalCenterResource.get();
medicalCenterService.reloadMedCenter = function() {
medicalCenterService.currentMedCenter = MedicalCenterResource.get();
return medicalCenterService.currentMedCenter;
};
medicalCenterService.updateMedicalCenter = function(medicalCenter) {
MedicalCenterResource.updateMedicalCenter(medicalCenter);
medicalCenterService.currentMedCenter = medicalCenter;
};
return medicalCenterService;
})
Run Code Online (Sandbox Code Playgroud)
在MedicalCenterController中,我在应用程序启动时获得带医疗中心的单例对象:
function MedicalCenterController($scope, medicalCenterService) {
$scope.currentMedCenter = medicalCenterService.currentMedCenter;
}
Run Code Online (Sandbox Code Playgroud)
但后来我尝试在AccountProfileController中编辑医疗中心字段(名称,地址等)
function AccountProfileController($scope, medicalCenterService) {
$scope.currentMedCenter = medicalCenterService.currentMedCenter;
$scope.applyMedCenterChanges = function (currentMedCenter) {
medicalCenterService.updateMedicalCenter(currentMedCenter);
};
}
Run Code Online (Sandbox Code Playgroud)
而我期望拥有的是具有更新字段的对象.如何返回我的单身人士的新实例?
我在我的范围内有一个对象列表,并希望迭代它们,以有序的属性方式显示它们的一些属性并更改它们.
ng-repeat用于显示绑定到列表中每个对象的文本框,以及使用"position"作为参数的orderby过滤器.
再次,位置也是可编辑的!
现在我们改变某个对象的位置一次(角度按预期重新排列列表),然后改变两次.Angular不会重新排序列表.
任何人都可以解释如何修复这种仅重新排序的情况以及这种行为的原因是什么?
这是小提琴:JSFiddle
HTML
<div ng-controller="MyCtrl">
<p>List of activities:</p>
<div ng-repeat="activity in model.activities | orderBy: 'position'">
<textarea type="text" ng-model="activity.name">
</textarea>
{{activity.name}}
<input type="text" ng-model="activity.position">
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
JS
var myApp = angular.module('myApp',[]);
function MyCtrl($scope) {
$scope.model = {
activities: [
{name: "activity 1", position: 1},
{name: "activity 2", position: 2},
{name: "activity 3", position: 3},
{name: "activity 4", position: 4},
{name: "activity 5", position: 5}
]
};
}
Run Code Online (Sandbox Code Playgroud) 在过去的一天里,我一直坚持找到使用angular来控制带有子菜单的菜单列表的最佳方法.
使用jQuery,您可以在特定类型的元素(例如a)上单击事件后进行侦听,<li>并在其子元素中添加一个类以打开菜单.
我正在尝试使用Angular 这个页面上的菜单http://geedmo.com/themeforest/wintermin/dashboard.html做同样的事情.但无法通过使用我自己的指令或现有的指令(如ng-hide和ng-show)找到正确的方法.
如果有人有一个示例og指南如何以最好的方式做到这一点,我的日子将被保存.:)
我也很有新意,所以每天都要学习新东西.
我将我的ASP.NET MVC应用程序托管为Azure云服务.
在新部署后,我在删除用户上传的图片时遇到问题.
上传的图片将保存到自定义特殊文件夹中 WebProject/UserFiles/MedicalCenterImages
下面我提供了我的项目文件夹结构.

我发现并调查了几个与我相关的问题
并且弄清楚,我应该在.csproj文件上添加一个SkipDelete规则.
<Target Name="AddCustomSkipRules">
<Message Text="Adding Custom Skip Rules" />
<ItemGroup>
<MsDeploySkipRules Include="SkipUserFilesFolder">
<SkipAction>Delete</SkipAction>
<ObjectName>filePath</ObjectName>
<AbsolutePath>UserFiles</AbsolutePath>
</MsDeploySkipRules>
</ItemGroup>
</Target>
Run Code Online (Sandbox Code Playgroud)
但我不完全明白我应该编辑哪个文件?(MaxPatient.Web.csproj或MaxPatientCloudService.ccproj或任何其他文件)
我总是发布我的MaxPatientCloudService项目.
我将不胜感激任何帮助.
谢谢 :)
任何人都可以解释一下,为什么我不能重用WebClient对象来发送另一个HTTP POST请求?
此代码不起作用:
var client = new WebClient();
client.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
string buySmsNumberResult = client.UploadString(ApiBuyUrl, apiBuyParams); //it works fine
//but when I try to send another HTTP POST with the existing WebClient object
string updateSmsNumberResult = client.UploadString(ApiUpdateNumberUrl, apiUpdateParams);
//it throws the exception
Run Code Online (Sandbox Code Playgroud)
例外情况是:
远程服务器返回错误:(400)错误请求.
但是如果我在第二次HTTP POST之前重新创建WebClient对象,它的工作没有任何问题.
这段代码有效.
var client = new WebClient();
client.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
string buySmsNumberResult = client.UploadString(ApiBuyUrl, apiBuyParams);
//recreating of the WebCLient object
client = new WebClient();
client.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
string updateSmsNumberResult= client.UploadString(ApiUpdateNumberUrl, apiUpdateParams); …Run Code Online (Sandbox Code Playgroud) 对于大多数项目,我从内部服务器中提取软件包,因此它是通过以下方式添加的:
yarn config set registry http://custom-packages-server.com
但是现在在新项目中,我想使用其他(默认)项目,而仅在特定项目中使用它。据我了解,如果我在新项目的目录中运行以下命令
yarn config set registry https://registry.yarnpkg.com
它将同时更新所有其他项目的全局注册表值,因此他们还将在新位置查找软件包。
那么,纱中是否有可能仅覆盖特定项目的全局注册表记录?
我是AngularJS的新手,遇到了一个问题.
需要创建消息历史记录树,该树在父项上提供展开/折叠功能.
我创建了视图:
<div class="tree">
<ul>
<li ng-repeat="appt in apptsToFilter() | filter: groupByAppt" ng-click="showChilds()">
<span>{{appt.startTime}} - Appt. Id: {{appt.appointmentId}} </span>
<ul>
<li ng-repeat="item in appts | filter: {appointmentId: appt.appointmentId}" ng-show="active">
<span>{{item.message}}</span>
</li>
</ul>
</li>
</ul>
</div>
Run Code Online (Sandbox Code Playgroud)
这是我对此观点的控制者:
function MessageHistoryController($scope, $routeParams, MessageHistoryResource) {
......//some code
$scope.active = false;
$scope.showChilds = function() {
if ($scope.active == false) {
$scope.active = true;
} else {
$scope.active = false;
}
};
}
Run Code Online (Sandbox Code Playgroud)
当我扩展第一个父项时,这就是我得到的:
ParentItem2:
- Child1
- Child2
- Child3
ParentItem2
- Child1
- …Run Code Online (Sandbox Code Playgroud) 我想为我的工作创建 cron 表达式,但我不知道如何从表达式中排除一周中的特定日期。
triggerBuilder
.ForJob(jobKey)
.WithSchedule(CronScheduleBuilder.CronSchedule("????")).InTimeZone(TimeZoneInfo.Utc))
.StartNow()
.WithIdentity(triggerKey)
.Build();
Run Code Online (Sandbox Code Playgroud)
例如:除了星期一之外,我每天都想解雇我的工作。
我找到了一种方法,我们可以将工作时间间隔设置为每天中午(12 点)解雇:
0 0 0 ? * MON-FRI或者0 0 0 ? * 1-5
但是从这个间隔中排除特定的一天怎么样,例如“星期四”。
感谢您的帮助:)
我将列表添加到sessionStorage,如:
var item = new cartItem(product.id, product.name, product.price, qty);
orderItem.push(item);
sessionStorage.setItem('addedProductsList', JSON.stringify(orderItem));
var retrieveArray= JSON.parse(sessionStorage.addedProductsList);
Run Code Online (Sandbox Code Playgroud)
它的工作正常,现在我想通过productId从这个列表中删除一个对象.
当我尝试使用CsvHelper将非常多的数据(具有30万行及更多行的列表)写入内存流时,它将引发异常“ System.IO.IOException:流太长”。。
数据类相当大,具有约30个属性,因此文件中的每个记录将具有约30列。
这是实际的写代码,其中的异常抛出(这段代码是基于这样说 CsvHelper LIB的作者的回答):
using (var memoryStream = new MemoryStream())
{
using (var streamWriter = new StreamWriter(memoryStream, encoding ?? Encoding.ASCII))
{
var csvWriter = new CsvWriter(streamWriter, GetConfiguration(delimiter, mappingClassType, mappingActions));
csvWriter.WriteRecords(data); //data is IEnumerable<T> and has more than 300k records
streamWriter.Flush();
return memoryStream.ToArray();
}
}
Run Code Online (Sandbox Code Playgroud)
然后,将结果字节数组保存到文件中。
File.WriteAllBytes(filePath, resultedBytesArray);
Run Code Online (Sandbox Code Playgroud)
请注意,当我向文件写入100 000条记录时,相同的代码会很好地工作(在这种情况下,文件的大小约为1GB)。顺便说一句,我的目标是写出60万条数据记录。
这是与此问题相关的堆栈跟踪的相关部分。
Stream was too long.|System.IO.IOException: Stream was too long.
at System.IO.MemoryStream.Write(Byte[] buffer, Int32 offset, Int32 count)
at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean …Run Code Online (Sandbox Code Playgroud)