小编ado*_*lot的帖子

将凭据传递给Sql Report Server 2008

我在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)

c# asp.net reporting-services ssrs-2008

19
推荐指数
1
解决办法
5万
查看次数

在visual studio中如何使用键盘在文本编辑器中选择单词

在早期版本的Microsoft Visual Studio产品中,如果用户在文本编辑器中按CTRL + W编辑器,则会选择单词where where指针.Visual Studio 2010中是否仍存在该键盘快捷键?

keyboard-shortcuts visual-studio-2010 visual-studio

19
推荐指数
2
解决办法
1万
查看次数

SQL英文查询怎么了?

使用英语查询部署SQL Server 2000.那时,我还年轻,不熟悉SQL,所以我跳过那一章.现在,经过多年的努力,我们再次想出了一个可以理解简单用户问题的逻辑程序.

还有其他选择吗?英语查询现在在哪里?

sql sql-server sql-server-2000

15
推荐指数
3
解决办法
4443
查看次数

Excel 2007 PageSetup.FitToPagesWide问题

虽然我一直在尝试使用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没有多大帮助,因为他们还没有这种语言的代码示例.

c# excel

11
推荐指数
1
解决办法
1万
查看次数

如何知道Process已崩溃

在我的控制台应用程序中,我有类似的代码

    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默认显示一个用于结束程序的对话框.此时,我的应用程序将永远等待用户单击"关闭"按钮.

我想避免这种情况,因为我的应用程序将在没有用户交互的情况下作为服务运行.

在此之后,我想继续我的应用程序

c# debugging console

10
推荐指数
2
解决办法
8826
查看次数

使用PetaPoco将表值param传递给存储过程

因为我试图使用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

8
推荐指数
1
解决办法
6876
查看次数

如何跟踪异步文件上传到azure存储的进度

有没有办法跟踪文件上载进度到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)

c# file-upload azure azure-storage azure-storage-blobs

8
推荐指数
1
解决办法
7915
查看次数

在C#内部使用TPL内部服务的基本设计模式

我正在尝试构建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?

c# multithreading windows-services task-parallel-library

8
推荐指数
1
解决办法
6800
查看次数

如何在没有http请求的MVC Core应用程序中启动HostedService

在我的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# asp.net-core asp.net-core-hosted-services

7
推荐指数
1
解决办法
3041
查看次数

双屏VS开发Blazor Razor组件

有没有办法在具有双屏环境的 Visual Studio 中打开 Razor 组件。我喜欢在一个屏幕上标记,而在另一个屏幕上标记@code {}。MVC 开发通常标记在一个屏幕上,而 JS 在另一个屏幕上。切换到 Blazor C# 取代了 JS,但我的思想仍然映射到从一个读取标记,而在另一个上读取代码。我们可以创建代码与 markp 分离但仍然连接的组件吗? 在此处输入图片说明

visual-studio blazor razor-components

6
推荐指数
1
解决办法
317
查看次数