这是一个后续问题
如果我向xml数据添加命名空间,则不会再返回任何内容.
DECLARE @xVar XML
SET @xVar =
'<ReportData ObjectId="123" xmlns="http://ait.com/reportdata">
<ReportId>AAAA-BBBB-CCCCC-DDDDD</ReportId>
<DocId>100</DocId>
<ReportName>Drag Scraper Troubleshooting</ReportName>
<DocType>Name</DocType>
<StatusId>1</StatusId>
<AuthorId>1</AuthorId>
</ReportData>'
SELECT [ReportId]= reportdata.item.value('.', 'varchar(40)')
FROM @xVar.nodes('/ReportData/ReportId[1]') AS reportdata(item)
Run Code Online (Sandbox Code Playgroud)
以上查询什么都不返回.其次,如何在单个选择中选择所有元素并返回包含所有元素作为字段的行?
我想返回一个构造如下的记录:
ReportId | DocId | ReportName |
AAAA-BBBB-CCCCC-DDDDD | 100 | AAAA-BBBB-CCCCC-DDDDD |
Run Code Online (Sandbox Code Playgroud) 试图在WPF表单中呈现一个长文本,并且完全像FlowDocument公开的可能性.我的问题是它会自动显示一个工具栏.任何人都知道如何删除它或建议一些其他控件来显示页面上复杂的流动文本
当使用MVVM和Prism时,我发现自己进行了大量的转换,因为大多数参数都是接口
防爆
public void AddCrSubSystemsToPlant(IPlantItem plantItm, CRArticleItem crItm)
{
OSiteSubSystem itm = (OSiteSubSystem)crItm;
itm.PartData.Order = ((OSiteEquipment)plantItm).SubSystems.Count() + 1;
((OSiteEquipment)plantItm).SubSystems.Add(itm);
}
Run Code Online (Sandbox Code Playgroud)
要么
public void DeletePart(IPlantItem plantItem)
{
IEnumerable<IPlantItem> itmParent = GetParentPartByObjectId(_siteDocument, plantItem);
if (plantItem is OSiteEquipment)
((ObservableCollection<OSiteEquipment>)itmParent).Remove((OSiteEquipment)plantItem);
if (plantItem is OSiteSubSystem)
((ObservableCollection<OSiteSubSystem>)itmParent).Remove((OSiteSubSystem)plantItem);
if (plantItem is OSiteComponent)
((ObservableCollection<OSiteComponent>)itmParent).Remove((OSiteComponent)plantItem);
}
Run Code Online (Sandbox Code Playgroud)
我的问题是,涉及的费用是多少.如果避免,这些操作是否会耗费大量内存或CPU.
任何意见?
我需要一个由三个应用程序共享的公共配置文件
我通过添加appSettings中的文件解决了这个问题
<appSettings file="ait.config">
<!--<add key="Culture" value="zh-CN" />-->
<add key="Culture" value=""/>
<add key="ClientSettingsProvider.ServiceUri" value=""/>
</appSettings>
Run Code Online (Sandbox Code Playgroud)
在ait.config中我存储了一些常见的值,比如
<?xml version="1.0" encoding="utf-8" ?>
<appSettings>
<add key="Username" value="Klabberius" />
</appSettings>
Run Code Online (Sandbox Code Playgroud)
如果我试着读它就好
string stvalue = ConfigurationManager.AppSettings["Username"];
Run Code Online (Sandbox Code Playgroud)
它工作正常,但如果我尝试写一个像这样的值
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.AppSettings.Settings["Username"].Value = userName;
config.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection("appSettings");
Run Code Online (Sandbox Code Playgroud)
它不是写入公共文件ait.config,而是将密钥用户名添加到每个单独应用程序中的标准app.config,任何人都知道如何解决这个问题.
我试图在我的应用程序中显示一个标准的MessageBox作为模态窗口,但它最终是非模态的.在第一个调用中,在下面的代码中,我显示了一个标准的MessageBox,它显示为模态,应该如此.在第二次调用中,即使我抓住主窗口调度程序,它也不会显示为模态.
Dispatcher disp = Application.Current.MainWindow.Dispatcher;
//First call, shown MODAL
if (this.messageService.ShowYesNo("Do you want to update the Word document, this will regenerate inspectiondata for document", "") == MessageBoxResult.Yes)
{
using (new WaitCursor())
{
_eventAggregator.GetEvent<ProgressBarRequestShow>().Publish("");
worker = new BackgroundWorker();
worker.DoWork += delegate(object s, DoWorkEventArgs args)
{
AITUpdateProgressDelegate update = new AITUpdateProgressDelegate(UpdateProgress);
this.docService.UpdateWorddocument(this.docService.GetCurrentDocumentFilePath, update);
};
worker.RunWorkerCompleted += delegate(object s, RunWorkerCompletedEventArgs args)
{
try
{
// Second call NOT MODAL
disp.Invoke((Action)delegate()
{
this.messageService.ShowInformation("Document generated, choose Open in Word in main toolbar to show document", …Run Code Online (Sandbox Code Playgroud) 试图在C#中打开图像进行编辑
我可以打开文件
System.Diagnostics.Process.Start(fileItem.Path);
Run Code Online (Sandbox Code Playgroud)
这似乎发出了默认的打开命令,在我的情况下,对于jpg文件是标准预览,有没有办法使用Process打开带有相关"编辑"命令的文件.
我使用Prism进行应用,需要一个登录对话框.对于要验证的登录,我需要初始化一些由Prism/MEF加载的应用程序数据,所以我不能把它放在App.xmal.cs OnStartUp中,所以我将登录对话框放在bootstrappers InitializeShell中这样
protected override void InitializeShell()
{
Application.Current.ShutdownMode = ShutdownMode.OnExplicitShutdown;
//// Authenticate the current user and set the default principal
LoginDialog auth = new LoginDialog();
auth.WindowStartupLocation = WindowStartupLocation.CenterScreen;
bool? dialogResult = auth.ShowDialog();
// deal with the results
if (dialogResult.HasValue && dialogResult.Value)
{
base.InitializeShell();
Application.Current.ShutdownMode = ShutdownMode.OnMainWindowClose;
}
else
{
Application.Current.Shutdown(-1);
}
#if SILVERLIGHT
Application.Current.RootVisual = (Shell)this.Shell;
#else
Application.Current.MainWindow = (Shell)this.Shell;
Application.Current.MainWindow.Show();
#endif
}
Run Code Online (Sandbox Code Playgroud)
我很难评估是否有任何陷阱或缺点,任何人都有评论
什么是在try部分和catch部分中使用变量的不同之处
string curNamespace;
try
{
curNamespace = "name"; // Works fine
}
catch (Exception e)
{
// Shows use of unassigned local variable
throw new Exception("Error reading " + curNamespace, e);
}
Run Code Online (Sandbox Code Playgroud)
如果我在try部分中使用变量,它编译得很好,在catch部分我得到"使用未分配的变量"
试图找出状态和参与者等工作流信息存储在Sharepoint数据库中的位置.有一个名为工作流的表,但我似乎无法找到文档和worflow数据中的数据之间的连接.任何人?
我有一个填充usercontrols的列表框.当我填充列表框时,我会得到一个垂直滚动条,但我也会在列表框中获得一个不受欢迎的水平滚动条.我试图为listboxitem创建一个转换器,但从不调用转换器.
<ListBox.Resources>
<local:ControlWidthConverter x:Key="widthConverter" />
</ListBox.Resources>
<ListBox.ItemTemplate>
<DataTemplate>
<!--Manages click on child controls so listitem is selected-->
<Controls:ComponentEditItem HorizontalAlignment="Left"
Width="{Binding RelativeSource={RelativeSource AncestorType={x:Type ListBox}},
Path=ActualWidth, Converter={StaticResource widthConverter}}">
<Controls:ComponentEditItem.Triggers>
<EventTrigger RoutedEvent="GotFocus">
<BeginStoryboard>
<Storyboard>
<BooleanAnimationUsingKeyFrames Duration="00:00:00" Storyboard.Target="{Binding Path=., RelativeSource={RelativeSource FindAncestor, AncestorType=ListBoxItem}}" Storyboard.TargetProperty="IsSelected">
<DiscreteBooleanKeyFrame Value="True" />
</BooleanAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Controls:ComponentEditItem.Triggers>
</Controls:ComponentEditItem>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
Run Code Online (Sandbox Code Playgroud)
转换器
public class ControlWidthConverter : IValueConverter
{
#region IValueConverter Members
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
double result …Run Code Online (Sandbox Code Playgroud) 在我的基础架构中,我发布了一个事件
this.eventAggregator.GetEvent<ReportAddedEvent>().Publish(report);
Run Code Online (Sandbox Code Playgroud)
该报告是一个对象
在我的控制器中,我订阅了此事件
this.eventAggregator.GetEvent<ReportAddedEvent>().Subscribe(this.OnReportAdded);
Run Code Online (Sandbox Code Playgroud)
我的问题是事件触发两次。整个代码中没有其他地方可以发布该事件,因此可以确定该事件不会在其他地方触发,我可以看到它仅触发一次。
任何人都有建议或解决问题的方法,或者知道问题出在哪里。