在Windows机器上(win 7或Win server 2008 R2),我有一个批处理脚本,可以将一些.config文件复制到备份文件夹中.
我想编写另一个脚本来删除一周前创建的备份文件.
有很多关于如何使用的建议FORFILES(例如):
FORFILES /P "D:\Configs_Backup" /M *.config /D -7 /C "cmd /c del @file"
Run Code Online (Sandbox Code Playgroud)
但是这个命令使用"修改"的时间戳,而我需要使用创建日期.
无需安装任何第三方程序,是否可以通过命令控制台实现此目的?
在我们的应用程序中,我们有一些从BaseComponent.
基础组件实现OnDestroy接口并发出一个 Subject 以通知子级取消订阅最终打开的流。
这是一种可以接受的方法还是每个组件都应该有自己的ngOnDestroy实现?从这篇文章我读到生命周期钩子不是继承的。
基础组件
export abstract class ComponentBase implements OnDestroy {
protected destroy$ = new Subject<boolean>();
ngOnDestroy() {
this.destroy$.next(true);
}
}
Run Code Online (Sandbox Code Playgroud)
子组件
export class ChildComponent extends ComponentBase implements OnInit {
ngOnInit() {
this.service
.getById(userId)
.pipe(takeUntil(this.destroy$)) // this is emitted by the parent
.subscribe(user => { ...}
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个使用 Sentry.io 进行日志记录的 Angular 应用程序。我创建了一个自定义错误处理程序类,在其中初始化 Sentry,并且希望避免日志服务器错误(404 未找到或 500 服务器错误)。
我读到,如果 Angular 中的网络调用失败,异常会冒泡,并且不会在 ErrorHandler 中捕获(因此它不会触发handleError方法)。
然而,即使我使用该beforeSend()方法,按照建议面对这种非常特殊的情况,控制台日志也会被写入(例如SENTRY SKIPPING EVENT),但所有服务器错误都会记录在Sentry中。
export class MyhErrorHandler implements ErrorHandler {
if (environment.production) {
Sentry.init({
dsn: 'https://12314567@sentry.io/123456789',
environment: this.environmentData.env,
beforeSend(event) {
try {
if (this.isServerError(JSON.stringify(event))) {
console.log('------ SENTRY SKIPPING EVENT: ', {event});
return null;
}
} catch (e) {
console.log('------ SENTRY ERROR: ', {e});
}
return event;
}
});
}
handleError(err: any): void {
if (!this.isServerError(err)) {
const errorText = MyhErrorHandler.getError(err);
Sentry.captureException(errorText);
}
} …Run Code Online (Sandbox Code Playgroud) 我使用了不同的jQuery插件,在某些情况下,它们无法正常工作(或根本不工作),直到我将它们嵌入$(function({ ... })).
作为示例插件:
$('#DateTextBox').datetimepicker();
Run Code Online (Sandbox Code Playgroud)
不起作用,即使在插件网站中它使用完全相同的形式.将它放在$(function())中它会完美地运行:
$(function ()
{
$('#DateTextBox').datepicker();
});
Run Code Online (Sandbox Code Playgroud)
"$(function())"语句带来了什么?我试图在同一个jQuery网站上搜索,但我找不到答案.
$(function())jQuery中的语句是一个简写$(document).ready( ...
在脚本部分的开头只有一次并且根据需要保存所有脚本代码(例如在aspx页面中的标记内)是否有意义?
或者更确切地说,不止一次复制它并包含相关代码的每个集合逻辑?
例如:
<script>
$(function()
{
//script code for function 1
});
$(function()
{
//script code for function 2
});
</script>
Run Code Online (Sandbox Code Playgroud)
关于它是否有任何"最佳实践",或者两者都是相同的?
我们计划将Oracle 10g数据库迁移到SQL Server 2008 R2.
目前,目标数据库中没有实现任何内容,这将使我们有机会在迁移期间更改和改进现有模式.
不仅要导入数据,还要导入存储过程和视图.
我已经使用过SSIS,我找到了一款出色的数据操作产品.
一位同事提到SSMA进行迁移.然而,在对网络进行一些研究之后,它似乎主要适用于数据迁移和转换,而SSIS似乎提供了更广泛的功能(任务,自定义脚本等).
这两种产品的优势/哪种产品最适合这项任务?
我一直在关注本教程https://codelabs.developers.google.com/codelabs/offline/#7
到目前为止,我能够让我的服务工作人员缓存脱机页面并加载它,但我只想在没有互联网访问时显示此offline.html 页面。现在它的工作方式是,每次我刷新页面时,即使可以访问互联网,它也会显示它,除非我选中Bypass for network开发人员工具中 Chrome 的“应用程序”选项卡中的复选框。
self.addEventListener('fetch', function(event) {
console.log(event.request.url);
event.respondWith(
fetch('https://mysite/offline.html')
);;
});
Run Code Online (Sandbox Code Playgroud) javascript google-chrome-devtools service-worker progressive-web-apps
为了体验Entity Framework的新功能,我创建了一个新的MVC 4 Internet应用程序.
我将它连接到现有数据库并使用dbContext生成器生成Model类.
通过运行应用程序,我在编辑表单时遇到了一些验证错误.作为DateTime字段的示例,如果日期插入为"12/10/2012"而不是2012-10-12(如在SQ服务器表示法中),则系统会抱怨.
我试图在项目中找到验证代码,但我无法在生成的代码中找到它.
我的一个模型类如下:
public partial class Artist
{
public Artist()
{
}
public int Id { get; set; }
public string Name { get; set; }
public Nullable<System.DateTime> DateOfBirth { get; set; }
public virtual Countries Countries { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
如果使用数据库第一种方法,如何自定义验证错误?
如果我使用我的验证属性来装饰模型,那么一旦再次生成模型类,它们就会被删除.
此外,在一个"现实世界"项目中,必须使用现有数据库,那么开发模型类的最佳方法是什么?
通过添加具有相同名称的部分类来扩展自动生成的类?
编辑(介绍部分视图):
@using (Html.BeginForm()) {
@Html.ValidationSummary(false)
<fieldset>
<legend>Movie</legend>
<div class="editor-label">
@Html.LabelFor(model => model.Name)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Name)
@Html.ValidationMessageFor(model => model.Name)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.DateOfBirth)
</div>
<div …Run Code Online (Sandbox Code Playgroud) 我正在使用angular 1.6,typescript,webpack,karma和jasmine编写应用程序.我能够为角度服务创建单元测试,但现在我遇到了测试组件的麻烦.在SO (1)和(2)以及网上我发现了不同的例子(像这样),但没有一个明确的指南解释如何用上述技术集测试角1组件.
我的组件(HeaderComponent.ts):
import {IWeatherforecast} from '../models/weather-forecast';
import WeatherSearchService from '../search/weather-search.service';
import WeatherMapperService from '../common/mapping/weatherMapper.service';
export default class HeaderComponent implements ng.IComponentOptions {
public bindings: any;
public controller: any;
public controllerAs: string = 'vm';
public templateUrl: string;
public transclude: boolean = false;
constructor() {
this.bindings = {
};
this.controller = HeaderComponentController;
this.templateUrl = 'src/header/header.html';
}
}
export class HeaderComponentController {
public searchText:string
private weatherData : IWeatherforecast;
static $inject: Array<string> = ['weatherSearchService',
'$rootScope',
'weatherMapperService']; …Run Code Online (Sandbox Code Playgroud) angularjs typescript karma-jasmine webpack angular-components
我有一个反应式表单,cancel必须将初始表单值再次设置到formGroup中。
import { Map } from "immutable";
@Input() data: any;
public ngOnInit() {
if (this.data && this.data.controls) {
this.group = this.fb.group({
isActive: [this.data.isActive],
items: this.fb.array(this.buildFormArray(this.data.controlPerformers)),
});
// Deep copy of the formGroup with ImmutableJs
this.originalFormData = Map(this.group).toJS();
}
}
public buildFormArray(controllers: IControlPerformer[]) {
return controllers.map((ctlr) => {
return this.fb.group({
user: [ctrl.userData],
ctrlName: [ctlr.name, Validators.required],
date: [moment(ctlr.date).toDate(), Validators.required],
});
});
}
public cancel() {
const existingItems = this.group.get("items") as FormArray;
while (existingItems.length) {
existingItems.removeAt(0);
}
// Here the error …Run Code Online (Sandbox Code Playgroud) angular ×3
javascript ×2
jquery ×2
typescript ×2
angularjs ×1
asp.net-mvc ×1
batch-file ×1
c# ×1
inheritance ×1
logging ×1
oracle10g ×1
rxjs6 ×1
sentry ×1
ssis ×1
webpack ×1
windows ×1