我有一个UI前端,可以与SQL Server数据库进行对话和操作,它可以做的一件事是运行数据库中数据的报告.
这个UI可以安装在多台计算机上,到目前为止我只是将报告保存在安装文件夹中,但这意味着每次添加新报告时都必须手动复制到每个安装的UI中.那里.
我正在考虑将.rpt文件存储在数据库本身(As Blobs)中,并在需要时使用某种机制让UI获取它们,以此作为集中报告和消除此问题的方法.
有没有人试过这个,并且做得好吗?或者,如果你还没有,你能想到在继续前进之前我应该考虑的任何事情吗?您能想到的任何提示,技巧或警告可能对我有帮助吗?
假设我要为%edit -x创建别名%xed。我该怎么办?
当使用Task.WaitAll等待任务并在WaitAll超时时指定超时时,我还必须单独观察任何未完成的任务(例如通过注册延续)?
这个帖子让我觉得答案是肯定的,但我还没有找到其他证实这一点的东西.
var random = new Random();
var tasks = Enumerable.Range(0, 10).Select((i) => Task.Factory.StartNew(() => {
// Sleep 5-15 seconds
Thread.Sleep(random.Next(5000, 15000));
throw new Exception("Some exception.");
}
)).ToArray();
try {
// Wait for 10 seconds
Task.WaitAll(tasks, 10000);
} catch (AggregateException) {
// Swallow
}
// Check to see how many tasks were unfinished
tasks.Where(t => !t.IsCompleted).Count().Dump("Unfinished count: ");
// Is this neccessary to avoid exceptions being thrown on the finalizer?
foreach (Task task in tasks) {
task.ContinueWith(t => t.Exception, …Run Code Online (Sandbox Code Playgroud) // Compiler Error当在所有其他情况下正确推断出类型时,为什么不能在下面的代码中标记的行上推断出要调用的正确重载?
public static class Code {
private static void Main() {
OverloadedMethod<string>(() => new Wrapper<string>()); // OK
OverloadedMethod<string>(() => MethodReturningWrappedString()); // OK
OverloadedMethod<string>((Func<Wrapper<string>>)MethodReturningWrappedString); // OK
OverloadedMethod<string>(MethodReturningWrappedString); // Compiler Error
}
public static Wrapper<string> MethodReturningWrappedString() {
return new Wrapper<string>();
}
public static void OverloadedMethod<T>(Func<Wrapper<T>> func) where T : class {
}
public static void OverloadedMethod<T>(Func<T> func) where T : class {
}
public struct Wrapper<T> where T : class {
}
}
Run Code Online (Sandbox Code Playgroud)
这是编译器错误:
The call is ambiguous between …Run Code Online (Sandbox Code Playgroud) 所以假设我使用Python的ftplib从FTP服务器检索日志文件列表.我如何解析该文件列表以获取列表中的文件名(最后一列)?请参阅上面的链接,例如输出.
所以我有一个案例,我希望能够将属性应用于派生类中的(虚拟)方法,但我希望能够提供一个在我的基类中使用这些属性的默认实现.
我这样做的最初计划是覆盖派生类中的方法,然后调用基本实现,此时应用所需的属性,如下所示:
public class Base {
[MyAttribute("A Base Value For Testing")]
public virtual void GetAttributes() {
MethodInfo method = typeof(Base).GetMethod("GetAttributes");
Attribute[] attributes = Attribute.GetCustomAttributes(method, typeof(MyAttribute), true);
foreach (Attibute attr in attributes) {
MyAttribute ma = attr as MyAttribute;
Console.Writeline(ma.Value);
}
}
}
public class Derived : Base {
[MyAttribute("A Value")]
[MyAttribute("Another Value")]
public override void GetAttributes() {
return base.GetAttributes();
}
}
Run Code Online (Sandbox Code Playgroud)
这只打印"测试的基本值",而不是我真正想要的其他值.
有没有人建议如何修改它以获得所需的行为?
我正在创建一个主要的GUI Cocoa应用程序,但我想创建一个命令行前端,打印相同的数据,以便我可以使用geektool显示它.
我猜我需要在我的Xcode项目中创建一个额外的命令行自定义可执行文件,并将其与GUI可执行文件一起构建?有没有关于如何做到这一点的教程?
是否有指导模仿锁定/解锁按钮和安全Apple偏好窗格的行为?(例如网络)
我正在尝试将此 WSE3.0 代码转换为 WCF:
// we use Microsoft WSE 3.0 to insert the username token in the soap header.
// This strategy takes care of creating and inserting the Nonce and Created elements
// for us, as well as creating a password digest based on Nonce, Created, and
// the password itself. Refer to the WS-Secutiry UsernameToken Profile 1.1
// specification at http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=wss.
Microsoft.Web.Services3.Security.Tokens.UsernameToken nametoken;
nametoken = new Microsoft.Web.Services3.Security.Tokens.UsernameToken(username, password, Microsoft.Web.Services3.Security.Tokens.PasswordOption.SendHashed);
Microsoft.Web.Services3.Design.Policy ClientPolicy = new Microsoft.Web.Services3.Design.Policy();
ClientPolicy.Assertions.Add(new UsernameOverTransportAssertion());
this._proxy.SetPolicy(ClientPolicy);
this._proxy.SetClientCredential<UsernameToken>(nametoken); …Run Code Online (Sandbox Code Playgroud) 如果向我的Web API服务发出请求Content-Type,该服务的标头包含该服务不支持的类型,则会返回500 Internal Server Error状态代码,其中包含类似于以下内容的消息:
{"Message":"An error has occurred.","ExceptionMessage":"No MediaTypeFormatter is available to read an object of type 'MyDto' from content with media type 'application/UnsupportedContentType'.","ExceptionType":"System.InvalidOperationException","StackTrace":" at System.Net.Http.HttpContentExtensions.ReadAsAsync[T](HttpContent content, Type type, IEnumerable`1 formatters, IFormatterLogger formatterLogger)
at System.Net.Http.HttpContentExtensions.ReadAsAsync(HttpContent content, Type type, IEnumerable`1 formatters, IFormatterLogger formatterLogger)
at System.Web.Http.ModelBinding.FormatterParameterBinding.ReadContentAsync(HttpRequestMessage request, Type type, IEnumerable`1 formatters, IFormatterLogger formatterLogger)
at System.Web.Http.ModelBinding.FormatterParameterBinding.ExecuteBindingAsync(ModelMetadataProvider metadataProvider, HttpActionContext actionContext, CancellationToken cancellationToken)
at System.Web.Http.Controllers.HttpActionBinding.<>c__DisplayClass1.<ExecuteBindingAsync>b__0(HttpParameterBinding parameterBinder)
at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
at System.Threading.Tasks.TaskHelpers.IterateImpl(IEnumerator`1 enumerator, CancellationToken cancellationToken)"}
Run Code Online (Sandbox Code Playgroud)
我宁愿415 Unsupported Media Type按照建议返回状态代码,例如,这里 …
c# ×4
cocoa ×2
alias ×1
attributes ×1
blob ×1
command-line ×1
ftp ×1
ftplib ×1
ipython ×1
lambda ×1
macos ×1
method-group ×1
overloading ×1
parsing ×1
python ×1
scripting ×1
security ×1
sql-server ×1
wcf ×1
ws-security ×1
wse ×1
xcode ×1