我们正在探索是否可以慢慢地将旧的 WinForms 应用程序迁移为 blazor Web 应用程序。
在迁移整个应用程序之前,我们将一次将每个表单功能公开为一个 blazor 页面。如果 Web 应用程序缺少(尚未实现)功能,用户可以打开完整的 WinFroms 应用程序来完成他们需要的操作。
为了完成这项工作,我希望有一个页面具有不同的布局,具体取决于访问该页面的 UI 客户端。因此,如果您通过网络访问,它应该显示导航菜单、页眉页脚等...如果它是作为 Winforms 应用程序中的嵌入式 WebControl2 视图访问的(我不想在两个平台上重复代码)那么所有导航栏/页眉/页脚内容都应该消失,因为 Winforms 应用程序假定该功能。
我最初的想法是有 2 个 URL 转到同一页面,并让页面应用不同的布局,具体取决于是否使用 Web 应用程序(navLinks 将使用“员工”url)或 Winforms 应用程序是否正在访问它(winforms 应用程序将加载“/winforms/employees”url),如下所示:
@page "/employees"
@page "/winforms/employees"
@inject NavigationManager MyNavigationManager
@if (MyNavigationManager.Uri.Contains("winforms"))
{
@layout AppHostLayout
}
else
{
@layout MainLayout
}
Run Code Online (Sandbox Code Playgroud)
然而,这不起作用,因为每页只能有一个布局指令。
是否有更好的和/或特定于 blazor 的方法来实现我期望的结果?
我没办法.我是powershell的新手,我已经尝试过我在网上找到的所有内容.我想要做的是将数组的哈希表打印到文件中,而不会在每个数组值的末尾出现愚蠢的省略号.以下是我最好的尝试.
# Update output buffer size to prevent clipping in output window.
if( $Host -and $Host.UI -and $Host.UI.RawUI )
{
$rawUI = $Host.UI.RawUI
$oldSize = $rawUI.BufferSize
$typeName = $oldSize.GetType( ).FullName
$newSize = New-Object $typeName (1000, $oldSize.Height)
$rawUI.BufferSize = $newSize
}
# Suposedly to allow enumeration in formatting to be unlimited
$formatenumerationlimit = -1
$Dir = get-childitem c:\SomeFolderWithFiles -recurse
$List = $Dir | where {$_.extension -eq ".hash"} | where-object {$_ -ne $null}
$lookupTable = @{}
Foreach ($element in $List)
{
#Get …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Dapper orm以下简单查询:
var sqlString = new StringBuilder();
sqlString.Append("select a.acct AccountNumber,");
sqlString.Append(" b.first_name FirstName,");
sqlString.Append(" b.last_name LastName,");
sqlString.Append(" a.rr RrNumber,");
sqlString.Append(" c.addr1 AddressLine1,");
sqlString.Append(" c.addr2 AddressLine2,");
sqlString.Append(" c.addr3 AddressLine3,");
sqlString.Append(" c.addr4 AddressLine4,");
sqlString.Append(" c.addr5 AddressLine5,");
sqlString.Append(" c.addr6 AddressLine6,");
sqlString.Append(" c.addr7 AddressLine7,");
sqlString.Append(" c.addr8 AddressLine8 ");
sqlString.Append("from (pub.mfclac as a left join pub.mfcl as b on a.client=b.client) ");
sqlString.Append("left join pub.mfclad as c on a.client=c.client ");
sqlString.Append("where a.acct = '@ZYX'");
var connection = new OdbcConnection(_connectionString);
var result = connection.Query(sqlString.ToString(),
new
{
ZYX …Run Code Online (Sandbox Code Playgroud) 因此,我研究了所有建议的导入.dmp文件的方式,但似乎没有一个能回答这个问题:导入后数据将流向何处?
上下文:我像这样创建了一个用户:
SQL> create user IMPORTER identified by "12345";
SQL> grant connect, unlimited tablespace, resource to IMPORTER;
Run Code Online (Sandbox Code Playgroud)
然后,我运行“ imp”命令,如下所示:
C:\>imp system/password FROMUSER=OVIEDOE TOUSER=IMPORTER file=c:\database1.dmp
Run Code Online (Sandbox Code Playgroud)
现在有9个.dmp文件,每个文件之后都要求我提供下一个文件,然后我收到消息“导入成功终止并显示警告”。
警告是:
Warning: the objects were exported by OVIEDOE, not by you
import done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set
export client uses WE8ISO8859P1 character set (possible charset conversion)
IMP-00046: using FILESIZE value from export file of 2147483648
Run Code Online (Sandbox Code Playgroud)
现在它说成功终止了,所以我的假设(我是oracle的新手,所以这可能是错误的)是数据已加载。但是,当我使用SQL Developer连接到数据库并查看IMPORTER用户下的“ tables”节点下时,那里什么也没有。到底是怎么回事?数据加载了吗?如果是这样,我在哪里可以找到它?
我在设置TARGETDIR路径时遇到问题.我曾经dark.exe对一个正在运行的MSI文件进行逆向工程并阅读我在这个主题上可以找到的任何帖子,但我似乎无法将TARGETDIR设置为指向路径ProgramFiles\Manufacturer\Product.下面是我的WXS文件的提取,导致我的应用程序由于某种原因安装到我的D驱动器的根目录:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*"
Name="FBL - Some App"
Language="1033"
Version="1.0.0.0"
Manufacturer="Foo & Bar Limited"
UpgradeCode="780286c6-e064-4402-80d8-dd2c68b56c04">
<Package InstallerVersion="200"
Compressed="yes"
InstallScope="perMachine"
Comments="Performs some operation that is important" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<Media Id="1" Cabinet="App.1.0.0.cab" EmbedCab="yes" />
<CustomAction Id="setTARGETDIR"
Property="TARGETDIR"
Value="[ProgramFilesFolder][Manufacturer]\[ProductName]"
Execute="firstSequence"
Return="check" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Component Id="C__App.exe"
Guid="{074586E9-A675-2734-A4CD-1CE520922A41}">
<File Id="F__App.exe"
Name="App.exe"
KeyPath="yes"
Assembly=".net"
AssemblyManifest="F__App.exe"
AssemblyApplication="F__App.exe"
DiskId="1"
Source="D:\SomePath\bin\Debug\App.exe" />
</Component>
</Directory>
<Feature Id="DefaultFeature" ConfigurableDirectory="TARGETDIR" Level="1">
<ComponentRef Id="C__App.exe" …Run Code Online (Sandbox Code Playgroud) 所以我尝试了所有我能找到的东西来让这两个一起玩.
我已经安装了nuget包Common.Logging.NLog20,
我的配置看起来像:
<configSections>
<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
</sectionGroup>
<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog20" />
</configSections>
<common>
<logging>
<factoryAdapter type="Common.Logging.NLog.NLogLoggerFactoryAdapter, Common.Logging.NLog20">
<arg key="configType" value="INLINE" />
</factoryAdapter>
</logging>
</common>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="NLog" publicKeyToken="5120e14c03d0593c" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.1.0.0" newVersion="2.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Common.Logging" publicKeyToken="af08829b84f0328e" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
Run Code Online (Sandbox Code Playgroud)
我正在使用nuget NLog.Configuration包,所以我的nlog配置在一个名为NLog.config的单独文件中:
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
internalLogFile="nlog.ERRORS.txt" internalLogLevel="Error" >
<!--
See http://nlog-project.org/wiki/Configuration_file
for information on customizing logging rules and outputs. …Run Code Online (Sandbox Code Playgroud) 我试图让Singleton实例使用Autofac.我正在使用Winforms做一个准mvvm类型的东西,只是一个实验,所以不要挂在那上面.但我正在尝试让我的模型成为一个带有命令引用的单个实例(ICommand这里不是WPF变种):
我有一个容器的以下设置:
var cb = new ContainerBuilder();
cb.RegisterType<CalculateCommissionCommand>().As<ICommand<TradeEntry>>().SingleInstance();
cb.RegisterType<CalculationsModel>().As<ICalculationsModel>().SingleInstance();
cb.Register(c => new CalculationsView() { Model = c.Resolve<ICalculationsModel>() }).SingleInstance();
cb.Build();
Run Code Online (Sandbox Code Playgroud)
现在,Command将ICalculationsModel作为构造函数参数.但是,当我在传递给Command的Model中设置一个值时,该值不会出现在已使用CalculationsView设置的模型中.尽管调用了"singleInstance"方法,但似乎命令和视图正在传递CalculationsModel的不同实例.我错过了什么吗?为什么会这样?
所以我看到了一堆这个问题的答案。似乎没有一个能解决我的问题。我正在使用 servicestack 作为自托管 web 服务运行该项目。
尽管如此,我仍然收到错误消息:
无法加载文件或程序集“EntityFramework”或其依赖项之一。访问被拒绝。":"EntityFramework"
=== Pre-bind state information ===
LOG: DisplayName = EntityFramework
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: EntityFramework | Domain ID: 1
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended …Run Code Online (Sandbox Code Playgroud) 我正在使用WPF和MVVM。我的模型中有一个可以为空的Datetime(Datime?)属性。
我的Xaml看起来像:
<CheckBox Grid.Row="0" Grid.Column="2" x:Name="ChkBoxFromDate"
Margin="10,0,0,5" FontWeight="Bold">
Orders with Trades After Date:
</CheckBox>
<DatePicker Grid.Row="1" Grid.Column="2" Margin="10,0,0,0"
SelectedDate="{Binding FromDate}" HorizontalContentAlignment="Stretch">
<DatePicker.Style>
<Style TargetType="{x:Type DatePicker}">
<Setter Property="SelectedDate" Value="{Binding Path=FromDate, Mode=TwoWay}" />
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=ChkBoxFromDate, Path=IsChecked}" Value="false">
<Setter Property="SelectedDate" Value="{x:Null}" />
<Setter Property="IsEnabled" Value="false" />
</DataTrigger>
</Style.Triggers>
</Style>
</DatePicker.Style>
</DatePicker>
Run Code Online (Sandbox Code Playgroud)
我有通过文本框和cobmobox上的复选框禁用和清除的相同模式,并且工作正常。使用Datepicker,selecteddate的Null设置不起作用。UI和模型都不会更新。IsEnabled被设置并且控件灰显,但是datepicker中的值仍然保留。我想念什么?
更新资料
因此,显然这是一个比我最初想象的更深的问题。我认为在文本框和组合框上运行的内容在实际运行时不起作用(UI只是使外观看起来如此)。上面的代码发生的事情实际上是您通过将绑定设置为Null来清除绑定。我希望它将设置绑定的值,但事实并非如此。实际上,当您使用setter时,您实际上是在清除绑定并将属性设置为null,这就是为什么不会更新模型的原因。那么,下面的代码为什么起作用,为什么文本框和组合框“出现”以清除自身,而日期选择器却不起作用?据我所知,日期选择器“文本框”没有直接连接到SelectedDate属性。这样,当它显示时,它会显示“选择日期” s null或为空,否则显示日期。换句话说,在设置SelectedDate和在文本框中显示文本之间发生了一些魔术。这就是使“ hack”在下面的xaml中起作用的原因。通过设置文本(而不是SelectedDate),我没有清除SelectedDate上的绑定,而是行使了控件为使Text属性与SelectedDate属性同步所做的魔力。您可以对Combobox执行相同的技巧。但是,对于文本框,要绑定的属性是text属性,似乎没有办法解决此问题。我为此控件所进行的工作最终是将一个命令添加到复选框,该命令将Modelbox的文本框绑定值设置为null,并绑定到IsChecked属性。如果有人有更好的主意,
这可能是一个愚蠢的问题,但他们在VS2010中埋葬报告参数的位置是什么?
2005/2008年这很容易.转到报告菜单,然后选择报告参数.现在我不能为我的生活找到它!
谢谢.
我有以下格式的时间戳:
20110316 11:03:22.276919 -0400s
Run Code Online (Sandbox Code Playgroud)
顺便说一句,有人知道这个日期时间的末尾是什么吗?
我试图将此转换为它最初来自的时区中的datetime对象。但是执行以下转换:
DateTime.ParseExact(source, "yyyyMMdd HH:mm:ss.FFFFFF zzzz\\s", CultureInfo.CurrentCulture)
Run Code Online (Sandbox Code Playgroud)
自动将其转换为我的本地时区。
我期望的日期时间是我的日期时间上午11:03,但是由于我所在的时区比该时间戳晚2小时,因此转换返回的时间是上午9:03。除了执行字符串截断以忽略时区之外,还有什么方法可以解析日期,同时将其保留在其所在的时区中?
我有一个启动确认对话框的视图,但不是等待对话框返回结果,而是直接跳转到承诺的“then”部分。见下面的代码:
ConfirmDialog.ts
import { inject } from 'aurelia-framework';
import { DialogController } from 'aurelia-dialog';
@inject(DialogController)
export class ConfirmDialog {
private message: string;
private controller: DialogController;
constructor(controller: DialogController) {
this.controller = controller;
}
public activate(message: string) {
this.message = message;
}
}
Run Code Online (Sandbox Code Playgroud)
确认对话框.html
<template>
<div tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" click.trigger="controller.cancel()" class="close" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">Confirmation</h4>
</div>
<div class="modal-body">
${message}?
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" click.trigger="controller.cancel()">No!</button>
<button type="button" class="btn btn-danger" click.trigger="controller.ok()">Yes</button>
</div>
</div><!-- /.modal-content …Run Code Online (Sandbox Code Playgroud) 我有一个基类,它有一个方法将文件移动到适当的文件夹.有许多不同的文件有许多不同的命名方案.每个文件的移动和文件夹创建都是相同的,但由于文件名不同,确定日期也不同.我想这样做:
public class FileBase
{
protected FileInfo _source;
protected string GetMonth()
{
// 2/3 Files have the Month in this location
// So I want this to be used unless a derived class
// redefines this method.
return _source.Name.Substring(Source.Name.Length - 15, 2);
}
public void MoveFileToProcessedFolder()
{
MoveFileToFolder(Properties.Settings.Default.processedFolder + GetMonth);
}
private void MoveFileToFolder(string destination)
{
....
}
}
public class FooFile : FileBase
{
protected new string GetMonth()
{
return _source.Name.Substring(Source.Name.Length - 9, 2);
}
}
public class Program …Run Code Online (Sandbox Code Playgroud)