我们有一个电子邮件帐户emailName@companyDomain.in,这是在Office365中配置的。我们想要使用 C# 中的emailName@companyDomain.in发送电子邮件。下面的代码有时有效,有时无效(大多数时候无效)。给出错误“无法从传输连接读取数据:net_io_connectionclose”。代码是
public static void SendEmail(string toEmailId, string subject, string mailMessage)
{
string fromEmail = "emailName@companyDomain.in";
MailMessage msg = new MailMessage();
msg.To.Add(toEmailId);
msg.From = new MailAddress(fromEmail, "Sender Name");
msg.Subject = subject;
msg.Body = mailMessage;
msg.IsBodyHtml = true;
SmtpClient client = new SmtpClient();
client.UseDefaultCredentials = false; // Tried by commenting this too
client.Credentials = new System.Net.NetworkCredential(fromEmail, "password");
client.Port = 587; // Tried port number 25
client.Host = "smtp.office365.com";
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.TargetName …
Run Code Online (Sandbox Code Playgroud) 我们有两个 xml 文件,需要找到它的差异。为此,我们使用 XMLDiff 库。我们能够得到差异,但现在想要一个显示修改节点的 UI。所以使用 XmlDiffView 类。代码如下
XmlDiffView dv = new XmlDiffView();
//Load the original file again and the diff file.
XmlTextReader orig = new XmlTextReader(oldXML);
XmlTextReader diffGram = new XmlTextReader(diffXML);
dv.Load(orig,
diffGram);
//Wrap the HTML file with necessary html and
//body tags and prepare it before passing it to the GetHtml method.
string tempFile = @"C:\Users\ABC\Desktop\diffView.html";
StreamWriter sw1 = new StreamWriter(tempFile);
sw1.Write("<html><body><table width='100%'>");
dv.GetHtml(sw1);
sw1.Write("</table></body></html>");
sw1.Close();
dv = null;
orig.Close();
diffGram.Close();
Run Code Online (Sandbox Code Playgroud)
从上面的代码中, dv.GetHtml(sw1);
该语句给出了显示所有修改和未修改节点的 html 文件,但我们只需要获取修改节点信息。
我们如何才能只获得修改后的模式信息?任何提示,参考都会有很大帮助。谢谢你!
我创建了 Azure 函数应用程序来执行 powershell 脚本。想先在我的本地运行它来测试它。当我运行它时,无论有没有调试选项,都会出现一个弹出窗口,其中显示:“您必须安装 azure 函数核心工具才能调试本地函数。” 当我单击此弹出窗口上的“安装”时,它似乎自动开始安装 Azure 函数核心工具。
但它停留在某一点 -尝试获取“ https://functionscdn.azureedge.net/public/3.0.2534/Azure.Functions.Cli.win-x64.3.0.2534.zip ”
确认我的网络良好,尝试重新启动电脑并再次按照步骤操作,但没有成功。
其他观察结果是,即使我使用以下命令使用命令提示符手动安装它,
npm install -g azure-functions-core-tools@3
Run Code Online (Sandbox Code Playgroud)
它仍然显示“您必须安装 azure 函数核心工具才能调试本地函数。”
powershell azure azure-functions azure-functions-core-tools azure-function-app
我们正在将现有的 REST API 服务转换为 gRPC 核心。在迁移现有类时,我们知道 gRPC 没有十进制数据类型。我们在 C# 中有一个类,其定义为
public class SalarySchedule
{
public decimal Salary { get; set; }
public DateTime? SalaryDate { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我们在 proto 文件中将其实现为
message SalarySchedule
{
// TODO: How to define this double to decimal
double Salary = 1;
google.protobuf.Timestamp SalaryDate =2;
}
Run Code Online (Sandbox Code Playgroud)
目前,我们使用double作为Salary数据类型。但这导致内部计算出现问题。
您能否指导我们,我们如何将其定义为gRPC 中的小数?
我想邀请我们的 Active Directory/租户中的用户。为此,请使用 Microsoft Graph API。代码使用如下
IConfidentialClientApplication confidentialClientApplication = ConfidentialClientApplicationBuilder
.Create(clientId)
.WithTenantId(tenantID)
.WithClientSecret(clientSecret)
.Build();
ClientCredentialProvider authProvider = new ClientCredentialProvider(confidentialClientApplication);
GraphServiceClient graphClient = new GraphServiceClient(authProvider);
var invitation = new Invitation
{
InvitedUserEmailAddress = "myemailaddress@gmail.com",
InviteRedirectUrl = "https://myapp.com"
};
await graphClient.Invitations
.Request()
.AddAsync(invitation);
Run Code Online (Sandbox Code Playgroud)
之后,我可以在 Azure 的 Active Directory 门户中看到该用户。但没有收到邀请电子邮件。
但是,当我从 Azure 门户单击“重新发送邀请”时,就会收到邀请电子邮件。
请您指导一下,为什么从 API 发送邀请时没有收到邀请电子邮件?
c# azure-active-directory microsoft-graph-sdks microsoft-graph-api
我们有一个巨大的列表(比如100,000),需要转换DataTable
为SqlBulkcopy
.
你能指导什么是最快的方法,而不使用for循环?现在我们这样做 - 在下面的代码listDos
是对象列表
using (var dataTable = new DataTable(dataTableName))
{
dataTable.Locale = CultureInfo.CurrentCulture;
var columns = new[]
{
new DataColumn("Id", typeof(int)),
new DataColumn("FkId", typeof(int)),
new DataColumn("Status", typeof(string)),
new DataColumn("RecordFrom", typeof(DateTime))
};
dataTable.Columns.AddRange(columns);
foreach (ObjectDo listDo in listDos)
{
var row = dataTable.NewRow();
if (rebuildDo.Id != null) row["Id"] = rebuildDo.Id;
if (rebuildDo.FkId!= null) row["FkId"] = rebuildDo.FkId;
row["Status"] = rebuildDo.Status;
row["RecordFrom"] = rebuildDo.RecordFrom;
dataTable.Rows.Add(row);
}
return dataTable;
}
Run Code Online (Sandbox Code Playgroud) 我们在Azure存储上创建了一个文件夹结构,如下所示:
parentcontainer -> childcontainer -> {pdffiles are uploaded here}
Run Code Online (Sandbox Code Playgroud)
我们有存储.pdf
文件的URL 。我们不想硬编码任何容器名称,只需使用其URL下载文件即可。
我们当前的尝试是:
CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(StorageConnectionString);
CloudBlobClient blobClient = cloudStorageAccount.CreateCloudBlobClient();
CloudBlobContainer cloudBlobContainer = blobClient.GetRootContainerReference();
CloudBlockBlob blockBlob = cloudBlobContainer.GetBlockBlobReference(pdfFileUrl);
var blobRequestOptions = new BlobRequestOptions
{
RetryPolicy = new NoRetry()
};
// Read content
using (MemoryStream ms = new MemoryStream())
{
blockBlob.DownloadToStream(ms, null, blobRequestOptions);
var array = ms.ToArray();
return ms.ToArray();
}
Run Code Online (Sandbox Code Playgroud)
但是我们在这里收到“ 400错误请求”:
blockBlob.DownloadToStream(ms, null, blobRequestOptions);
Run Code Online (Sandbox Code Playgroud)
我们如何仅使用URL下载Azure BLOB存储文件?
c# ×6
azure ×2
.net ×1
datacontext ×1
grpc ×1
linq ×1
office365 ×1
powershell ×1
smtpclient ×1
sqlbulkcopy ×1
xml ×1
xmldiff ×1