我有以下型号:
public class ViewDataItem
{
public string viewName { get; set; }
public UpdateIndicator updateIndicator { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
使用以下枚举:
public enum UpdateIndicator
{
Original,
Update,
Delete
}
Run Code Online (Sandbox Code Playgroud)
以下验证者:
public class ViewValidator : AbstractValidator<ViewDataItem>
{
public ViewValidator()
{
RuleFor(x => x.viewName).NotEmpty().WithMessage("View name must be specified");
RuleFor(x => x.updateIndicator).SetValidator(new UpdateIndicatorEnumValidator<UpdateIndicator>());
}
}
public class UpdateIndicatorEnumValidator<T> : PropertyValidator
{
public UpdateIndicatorEnumValidator() : base("Invalid update indicator") {}
protected override bool IsValid(PropertyValidatorContext context)
{
UpdateIndicator enumVal = (UpdateIndicator)Enum.Parse(typeof(UpdateIndicator), context.PropertyValue.ToString());
if (!Enum.IsDefined(typeof(UpdateIndicator), enumVal))
return …Run Code Online (Sandbox Code Playgroud) 我正在尝试设置一个 SignalR 集线器,以便能够通过网络将通知推送到一堆 WPF 客户端。我尝试遵循基本指南和教程,并创建了一个 WPF SignalR 服务器(仅用于测试目的)。它已放在我局域网中的服务器上,它的外观如下:
启动文件
class Startup
{
public void Configuration(IAppBuilder app)
{
HubConfiguration hc = new HubConfiguration();
hc.EnableDetailedErrors = true;
app.UseCors(CorsOptions.AllowAll);
app.MapSignalR(hc);
}
}
Run Code Online (Sandbox Code Playgroud)
主窗口.xaml.cs
public IDisposable SignalR { get; set; }
const string ServerURI = "http://localhost:8554";
private void StartServer()
{
try
{
SignalR = WebApp.Start(ServerURI);
}
catch (TargetInvocationException)
{
WriteToConsole("A server is already running at " + ServerURI);
return;
}
this.Dispatcher.Invoke(() => btnStopHub.IsEnabled = true);
}
Run Code Online (Sandbox Code Playgroud)
临时集线器
public class AdHocHub : Hub
{
public …Run Code Online (Sandbox Code Playgroud) 我正在尝试运行一个执行hive脚本的简单工作流程.这个hive脚本只调用join(表非常大); 一旦hive脚本执行结束,我就希望看到工作流状态从RUNNING变为成功,但这不会发生.
这是工作流日志的内容:
2016-05-31 15:52:34,590 WARN
org.apache.oozie.action.hadoop.HiveActionExecutor:
SERVER[hadoop02] U
SER[scapp]
GROUP[-]
TOKEN[]
APP[wf-sqoop-hive-agreement]
JOB[0000001-160531143657136-oozie-oozi-W]
ACTION[0000001-160531143657136-oozie-oozi-W@hive-query-agreement] Launcher
ERROR, reason: Main class [org.apache.oozie.action.hadoop.HiveMain], exception invoking main(), Output data exceeds its limit [2048] 2016-05-31 15:52:34,591
WARN org.apache.oozie.action.hadoop.HiveActionExecutor:
SERVER[hadoop02]
USER[scapp]
GROUP[-]
TOKEN[]
APP[wf-sqoop-hive-agreement]
JOB[0000001-160531143657136-oozie-oozi-W]
ACTION[0000001-160531143657136-oozie-oozi-W@hive-query-agreement]
Launcher exception: Output data exceeds its limit [2048]
org.apache.oozie.action.hadoop.LauncherException: Output data exceeds its limit [2048]
at org.apache.oozie.action.hadoop.LauncherMapper.getLocalFileContentStr(LauncherMapper.java:415)
at org.apache.oozie.action.hadoop.LauncherMapper.handleActionData(LauncherMapper.java:391)
at org.apache.oozie.action.hadoop.LauncherMapper.map(LauncherMapper.java:275) at org.apache.hadoop.mapred.MapRunner.run(MapRunner.java:54)
at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:453)
at org.apache.hadoop.mapred.MapTask.run(MapTask.java:343)
at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:163)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:415)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1671)
at …Run Code Online (Sandbox Code Playgroud) 我有一个SQL Server表,其中我有一个列,我想选择当前值并递增1,有没有办法在单个查询中执行此操作?这是为了减少其他人得到相同数字的机会,无论多么小.
这段伪代码的内容:
SELECT NumSeriesCurrent
FROM NumSeries
(UPDATE NumSeries SET NumSeriesCurrent = NumSeriesCurrent+1)
WHERE NumSeriesKey='X'
Run Code Online (Sandbox Code Playgroud) 我正在使用iTextSharp中的PdfStamper创建一个PDF文件,并将PDF作为内存流对象返回到调用函数,然后用于在WinForms的Teleriks PDF Viewer Component中显示PDF.
这是目标.
现在,创建PDF可以正常工作,并将数据返回给Calling函数,在Calling函数中,我应该将memorystream内容写入文件流,然后在Adobe Reader中打开它看起来很好.
但是,如果我选择在PDF查看器控件中显示PDF,我只会收到"不支持的流类型"错误.
现在,我认为PDF数据有问题所以我决定创建PDF文件,将其保存到磁盘,然后在Calling函数中将其读取到内存流,并在PDF Viewer中显示该内存流,对于我来说不明原因,作品....
我真的无法理解这一点并需要一些帮助.
所以,这将无法正常工作:
//The Calling function
private void dlgViewPDF_Load(object sender, EventArgs e)
{
MemoryStream ms = PDFcreator.GeneratePDFdata(id);
rPdfView.LoadDocument(ms);
}
//The PDF generator
public static MemoryStream GeneratePDFdata(string id)
{
MemoryStream ms = new MemoryStream();
string sTemplate = string.Concat(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "\\template.pdf");
PdfReader pdfReader = new PdfReader(sTemplate);
PdfStamper pdfStamper = new PdfStamper(pdfReader, ms);
PdfContentByte cb = pdfStamper.GetOverContent(1);
BaseFont baseFont = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.EMBEDDED);
BaseFont baseFontBold = BaseFont.CreateFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.EMBEDDED);
cb.SetColorFill(iTextSharp.text.Color.BLACK);
cb.SetFontAndSize(baseFontBold, 14);
cb.BeginText(); …Run Code Online (Sandbox Code Playgroud) 我有一个看起来像这样的属性类
ZipStart | ZipEnd | Acode
10000 | 13999 | BEK
14000 | 14999 | ATE
Run Code Online (Sandbox Code Playgroud)
现在,我有一个值,例如11332,我想查找该号码所属的Acode,为此我有以下代码:
var res = from o in ListOfDataClass
where iCode >= o.ZipStart && o.ZipEnd <= iCode
select o;
var c = res.FirstOrDefault();
return c.Acode;
Run Code Online (Sandbox Code Playgroud)
然而,这不时会导致null,但我还是找不到一个模式,但是由于问题出现在这个方法中,我已经能够从调试器中扣除iCode IS实际上是11332但是LINQ查询不会产生任何结果.
有任何想法吗?