var file = File.ReadAllBytes(file_path);
var printQueue = LocalPrintServer.GetDefaultPrintQueue();
using (var job = printQueue.AddJob())
using (var stream = job.JobStream)
{
stream.Write(file, 0, file.Length);
}
File.Copy("file_path", "\\myPrintServerName\myPrinterName")
К сожалению, в Angular 2+ не предусмотрено механизма наследования компонентов.
import { Component, Input, Output, EventEmitter } from '@angular/core';
import { Employee } from './interfaces';
@Component({
selector: 'app-employee',
template: ''
})
export class EmployeeComponent {
@Input() employees: Employee[] = [];
@Output() select = new EventEmitter();
heading = 'Employees';
selectEmployee(employee: Employee) {
this.select.emit(employee);
}
}
import { Component } from '@angular/core';
import { EmployeeComponent } from './employee.component';
@Component({
selector: 'app-employee-list',
template: `
<h1>{{heading}}</h1>
<ul>
<li *ngFor="let employee of employees">
{{employee.firstName}} {{employee.lastName}} <br>
{{employee.email}} <br>
<button (click)="selectEmployee(employee)">Select</button>
</li>
</ul>
`
})
export class EmployeeListComponent extends EmployeeComponent {
heading = 'Employee List';
}
import { Component } from '@angular/core';
import { EmployeeComponent } from './employee.component';
@Component({
selector: 'app-employee-table',
template: `
<h1>{{heading}}</h1>
<table>
<tr>
<td>First Name</td>
<td>Last Name</td>
<td>Email</td>
</tr>
<tr *ngFor="let employee of employees">
<td>{{employee.firstName}}</td>
<td>{{employee.lastName}}</td>
<td>{{employee.email}}</td>
<td><button (click)="selectEmployee(employee)">Select</button></td>
</tr>
</table>
`
})
export class EmployeeTableComponent extends EmployeeComponent { }
<app-employee-list
[employees]="employees"
(select)="selectEmployee($event)"></app-employee-list>
<app-employee-table
[employees]="employees"
(select)="selectEmployee($event)"></app-employee-table>
$routeConfig: [
{path: '/:lookup_slug/...', name: 'Tabs', component: 'TabsComponent'}
]
$routeConfig: [
{path: '/:record_id', name: 'Lookup', component: 'LookupComponent'}
]
createNewComponent (tmpl:string) {
@Component({
selector: 'dynamic-component',
template: tmpl,
})
class CustomDynamicComponent implements IHaveDynamicData {
@Input() public entity: any;
};
// компонент для пришедшего темплейта
return CustomDynamicComponent;
}
createComponentModule (componentType: any) {
@NgModule({
imports: [
PartsModule,
],
declarations: [
componentType
],
})
class RuntimeComponentModule
{
}
// Рантайм модуль на выходе для инъекции
return RuntimeComponentModule;
}
public createComponentFactory(template: string)
: Promise<ComponentFactory<IHaveDynamicData>> {
let factory = this._cacheOfFactories[template];
if (factory) {
console.log("Module and Type are returned from cache")
return new Promise((resolve) => {
resolve(factory);
});
}
// если неизвестный тип - создаем его
let type = this.createNewComponent(template);
let module = this.createComponentModule(type);
return new Promise((resolve) => {
this.compiler
.compileModuleAndAllComponentsAsync(module)
.then((moduleWithFactories) =>
{
factory = _.find(moduleWithFactories.componentFactories
, { componentType: type });
this._cacheOfFactories[template] = factory;
resolve(factory);
});
});
}
// Здесь мы получаем фабрику (просто забираем ее из кеша)
this.typeBuilder
.createComponentFactory(template)
.then((factory: ComponentFactory<IHaveDynamicData>) =>
{
// Создаем компонент и инъекцируем его (для получения ссылки на него)
this.componentRef = this
.dynamicComponentTarget
.createComponent(factory);
// инъекция @Inputs в инстанс компонента
let component = this.componentRef.instance;
component.entity = this.entity;
//...
});
export class CustomDataSource extends DataSource<T> {
resultsLength: number = 0;
isLoadingResults: boolean;
isRateLimitReached: boolean;
constructor(private _customService: CustomService,
private _sort: MdSort,
private _paginator: MdPaginator) {
super();
}
connect(): Observable<T[]> {
const displayDataChanges = [
this._sort.mdSortChange,
this._paginator.page,
];
this._sort.mdSortChange.subscribe(() => {
this._paginator.pageIndex = 0;
});
return Observable.merge(...displayDataChanges)
.startWith(null)
.switchMap(() => {
this.isLoadingResults = true;
return this._customService.getAllObjects(
this._sort.active, this._sort.direction, this._paginator.pageIndex);
})
.catch(() => {
this.isRateLimitReached = true;
return Observable.of(null);
})
.map(result => {
this.isLoadingResults = false;
return result;
})
.map(result => {
if (!result) { return []; }
this.isRateLimitReached = false;
this.resultsLength = result.json().total_count;
return result.json();
});
}
disconnect() {}
}
<div class="container">
<div class="custom-loader" *ngIf="dataSource.isLoadingResults || dataSource.isRateLimitReached">
<md-spinner *ngIf="dataSource.isLoadingResults"></md-spinner>
<div class="cstom-rate-limit-reached" *ngIf="dataSource.isRateLimitReached">
Превышено время ожидания ответа.
</div>
</div>
<md-table #table [dataSource]="dataSource" class="custom-table" mdSort mdSortActive="created" mdSortDisableClear mdSortDirection="asc">
<ng-container cdkColumnDef="number">
<md-header-cell *cdkHeaderCellDef> Number </md-header-cell>
<md-cell *cdkCellDef="let row"> {{row.number}} </md-cell>
</ng-container>
<!-- Генерим свои строки -->
<md-header-row *cdkHeaderRowDef="displayedColumns"></md-header-row>
<md-row *cdkRowDef="let row; columns: displayedColumns;"></md-row>
</md-table>
<md-paginator [length]="dataSource.resultsLength" [pageSize]="30">
</md-paginator>
</div>
Путь к файлу нужно прописать, начиная с +1 уровня от текущего положения.
../../src/images/arrow.png