我在C#中很新,我的英语不太好 - 如果我错过了一点,请提前抱歉.
我试图用ReportService
控件构建一个ASP.NET网站.您可能已经知道,SSRS 2008不允许匿名登录.因此,我尝试将Credentials传递给SSRS,SSRS将存储在我的网页中,以便用户无需登录即可查看报告.
我找到了下面的代码并将其放在我的上面WebForm
,但是我的报告参数有问题.
如果报告参数有默认值,则以下代码可以正常工作.
但是,如果我尝试更改参数的值,则会
刷新整个页面,在单击"查看报告"按钮之前,所有
参数都将重置为默认值或空值.
有关如何避免刷新整个页面的任何建议,或将登录信息传递给SSRS的其他方法?非常感谢提前.
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Net;
using Microsoft.Reporting.WebForms;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ReportViewer1.Width = 800;
ReportViewer1.Height = 600;
ReportViewer1.ProcessingMode = ProcessingMode.Remote;
IReportServerCredentials irsc =new CustomReportCredentials("administrator", "MYpassworw", "domena");
ReportViewer1.ServerReport.ReportServerCredentials = irsc;
ReportViewer1.ServerReport.ReportServerUrl = new Uri("http://192.168.0.1/ReportServer/");
ReportViewer1.ServerReport.ReportPath = "/autonarudzba/listanarudzbi"; …
Run Code Online (Sandbox Code Playgroud) 在早期版本的Microsoft Visual Studio产品中,如果用户在文本编辑器中按CTRL + W编辑器,则会选择单词where where指针.Visual Studio 2010中是否仍存在该键盘快捷键?
使用英语查询部署SQL Server 2000.那时,我还年轻,不熟悉SQL,所以我跳过那一章.现在,经过多年的努力,我们再次想出了一个可以理解简单用户问题的逻辑程序.
还有其他选择吗?英语查询现在在哪里?
虽然我一直在尝试使用C#在Excel 2007的Microsoft Visual Studio项目中设置Excel页面缩放页面
代码看起来像这样
private void Sheet1_Startup(object sender, System.EventArgs e)
{
PageSetup.FitToPagesWide = 1;
PageSetup.FitToPagesTall = 1;
PageSetup.Orientation = Microsoft.Office.Interop.Excel.XlPageOrientation.xlLandscape;
PageSetup.PaperSize = Microsoft.Office.Interop.Excel.XlPaperSize.xlPaperA4;
}
Run Code Online (Sandbox Code Playgroud)
PaperSise和Orientation的线条运行良好,但我无法将Excel数据拟合到一个页面上.
难道我做错了什么 ?
MSDN没有多大帮助,因为他们还没有这种语言的代码示例.
在我的控制台应用程序中,我有类似的代码
Process DKU = new Process();
DKU.StartInfo.FileName = "MSSQLExecutor.exe";
DKU.Start();
DKU.WaitForExit();
Console.WriteLine("lets move on ");
Run Code Online (Sandbox Code Playgroud)
这工作正常,它等待MSSQLExecutor.exe完成其工作,然后应用程序继续.
我的问题是,有时MSSQLExecutor.exe崩溃,Windows默认显示一个用于结束程序的对话框.此时,我的应用程序将永远等待用户单击"关闭"按钮.
我想避免这种情况,因为我的应用程序将在没有用户交互的情况下作为服务运行.
因为我试图使用PetaPoco调用SQL Server 2008 R2存储过程.
我的存储过程接受表值参数.
如何使用表值param调用petapoco中的存储过程?
这是我想要做的:
var db = new PetaPoco.Database("repikaciskaBaza");
DataTable table = new DataTable();
DataColumn id = table.Columns.Add("id", type: typeof(Int32));
for (int i = 0; i < 10;i++ )
{
DataRow row = table.NewRow();
row["id"] = i;
table.Rows.Add(row);
}
var param = new SqlParameter();
param.DbType = DbType.Object;
param.ParameterName = "@art_id";
param.SqlValue = table;
var lista = db.Query<pocoArts>(";exec dbo.test_sporc_param @0", param);
Run Code Online (Sandbox Code Playgroud)
这段代码给了我一个例外:
传入的表格数据流(TDS)远程过程调用(RPC)协议流不正确.
参数3("@ 0"):数据类型0x62(sql_variant)具有类型特定元数据的无效类型.
如果我设置了parametar ty值
param.SqlDbType = SqlDbType.Structured;
Run Code Online (Sandbox Code Playgroud)
然后我得到例外
The table type parameter '@0' must have …
Run Code Online (Sandbox Code Playgroud) stored-procedures table-valued-parameters sql-server-2008-r2 c#-4.0 petapoco
有没有办法跟踪文件上载进度到Azure存储容器?
我正在尝试使用C#创建一个用于将数据上传到azure的控制台应用程序.
我的coode现在看起来像:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Auth;
using Microsoft.WindowsAzure.Storage.Blob;
using System.Configuration;
using System.IO;
using System.Threading;
namespace AdoAzure
{
class Program
{
static void Main(string[] args)
{
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString);
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer container = blobClient.GetContainerReference("adokontajnerneki");
container.CreateIfNotExists();
CloudBlobClient myBlobClient = storageAccount.CreateCloudBlobClient();
CloudBlockBlob myBlob = container.GetBlockBlobReference("racuni.adt");
CancellationToken ca = new CancellationToken();
var ado = myBlob.UploadFromFileAsync(@"c:\bo\racuni.adt", FileMode.Open, ca);
Console.WriteLine(ado.Status); //Does Not Help Much
ado.ContinueWith(t =>
{
Console.WriteLine("It is over"); //this is …
Run Code Online (Sandbox Code Playgroud) 我正在尝试构建Windows服务,它需要某种并行性来汇集来自不同ftp源的文件.为了启动多个ftp下载,我正在寻找TPL库来轻松地进行foreach循环并使并行性变得非常容易.但是,当我搜索如何启动或停止我的服务时,我最好的资金是在OnStart()
方法中创建新线程,如下所述/sf/answers/340612541/
阅读TPL总是注意到TPL比手动线程和手动停止线程更先进.
我没有找到任何描述如何在WindowsService中进行TPL循环的示例帖子?
我的代码:
protected override void OnStart(string[] args)
{
_thread = new Thread(WorkerThreadFunc);
_thread.Name = "My Worker Thread";
_thread.IsBackground = true;
_thread.Start();
}
Run Code Online (Sandbox Code Playgroud)
并在里面WorkerThreadFunc
做了一些TPL
private void WorkerThreadFunc()
{
foreach (string path in paths)
{
string pathCopy = path;
var task = Task.Factory.StartNew(() =>
{
Boolean taskResult = ProcessPicture(pathCopy);
return taskResult;
});
task.ContinueWith(t => result &= t.Result);
tasks.Add(task);
}
}
Run Code Online (Sandbox Code Playgroud)
或者我应该开始我的WorkerThreadFunc作为TASK?
在我的MVC .NET核心2.2应用程序中,有HostedService进行后台工作.
它是在Startap类的ConfigureServices方法中注册的
services.AddHostedService<Engines.KontolerTimer>();
Run Code Online (Sandbox Code Playgroud)
由于这是独立于用户请求的后台服务,因此我想在应用启动时立即启动后台服务.现在是我的HostedService在第一次用户请求后盯着的情况.
在MVC Core应用程序启动时启动HostedService的正确方法是什么
我的服务看起来像这个https://docs.microsoft.com/en-us/aspnet/core/fundamentals/host/hosted-services?view=aspnetcore-2.2
internal class TimedHostedService : IHostedService, IDisposable
{
private readonly ILogger _logger;
private Timer _timer;
public TimedHostedService(ILogger<TimedHostedService> logger)
{
_logger = logger;
}
public Task StartAsync(CancellationToken cancellationToken)
{
_logger.LogInformation("Timed Background Service is starting.");
_timer = new Timer(DoWork, null, TimeSpan.Zero,
TimeSpan.FromSeconds(5));
return Task.CompletedTask;
}
private void DoWork(object state)
{
_logger.LogInformation("Timed Background Service is working.");
}
public Task StopAsync(CancellationToken cancellationToken)
{
_logger.LogInformation("Timed Background Service is stopping.");
_timer?.Change(Timeout.Infinite, 0);
return Task.CompletedTask;
}
public void Dispose() …
Run Code Online (Sandbox Code Playgroud) c# ×6
asp.net ×1
asp.net-core ×1
asp.net-core-hosted-services ×1
azure ×1
blazor ×1
c#-4.0 ×1
console ×1
debugging ×1
excel ×1
file-upload ×1
petapoco ×1
sql ×1
sql-server ×1
ssrs-2008 ×1