Some thoughts on programming stuff

Tag: C#

Publish messages to RabbitMQ with .NET Core

RabbitMQ has became one of the most used message brokers in the world, so this is not a surprise if you come to a situation where you need to publish messages to RabbitMQ with .NET Core. This approach allows you to create asynchronous communication and better scalability depending on your architecture. But before we move ahead, it is important to explain a few things.

As per Wikipedia, “RabbitMQ is an open-source message-broker software that originally implemented the Advanced Message Queuing Protocol and has since been extended with a plug-in architecture to support Streaming Text Oriented Messaging Protocol, MQ Telemetry Transport, and other protocols”. It works mostly as a middleware for message handling.

RabbitMQ Logo - Publish messages to RabbitMQ with .NET Core
RabbitMQ Logo

The post will explore the features published and maintained in the RabbitMQ Client library. This library can be found in GitHub. The client, of course, is integrated or imported using NuGet via Visual Studio or NuGet CLI.

Continue reading

Read work item data from Azure DevOps with C#

Azure DevOps is a powerful tool for managing and tracking software development progress. Even more than that, it also does a bunch of other useful things like the Azure Boards feature that, in my opinion, are among the best. Consequently, focusing on the work item design, this blog post discusses how to read work item data from Azure DevOps with C#. This might be useful to you if you want to consume data from Azure DevOps and use it to integrate with other systems.

Add, update, & follow stories, issues, bugs, & other work items - Azure  Boards | Microsoft Docs
Work items in Azure DevOps (Microsoft Docs)
Continue reading

Execute non-query on Sybase database in C#

This post will help you if you want to execute non-query on Sybase database in C# like an UPDATE, CREATE, DELETE or others. The idea here is to explore the NuGet package AdoNetCore.AseClient as the connection driver for the database.

For some historical background, as per Wikipedia: “Sybase, Inc. was an enterprise software and services company that produced software to manage and analyze information in relational databases, with facilities located in California and Massachusetts. Sybase was acquired by SAP in 2010; SAP ceased using the Sybase name in 2014. “

Sybase Logo - Run query on Sybase database with C#
Enterprise software for managing relational databases (Wikimedia Commons)
Continue reading

Run query on Sybase database with C#

This post will help you if you want to run query on Sybase database with C# like common SELECT scripts. The idea here is to explore the NuGet package AdoNetCore.AseClient as the connection driver for the database since this is extremely similar to other common database access libraries.

Nowadays, with more and more different applications coexisting and integrating between themselves, the technology you work is not barrier. You can connect to different datasource with the language you prefer thanks to the community!

Sybase Logo - Run query on Sybase database with C#
Enterprise software for managing relational databases (Wikimedia Commons)

List operations with CSOM and C# in SharePoint

Sometimes we have to query a SharePoint list through remote connections using C#. It can happen in a SharePoint App, a Console Application or maybe on an Azure Function. This post will help on performing list operations with CSOM and C# in SharePoint.

Below you can find some code snippets that will help you on integrating SharePoint lists with your application.

Basically, you will have to add the Microsoft.SharePoint.Client namespace.

using Microsoft.SharePoint.Client;
using SP = Microsoft.SharePoint.Client;

The required DLLs for programming these type of solution are:

Microsoft.SharePoint.Client.dll
Microsoft.SharePoint.Client.Runtime.dll

You can find them inside those folders:

SharePoint 2010: 14 Hive -> Folder: ISAPI

SharePoint 2013: 15 Hive -> Folder: ISAPI

Or just download it from MSDN, inside the SharePoint Server 2013 Client Components SDK!

After adding these references to our project, we can start coding and accessing the data in the SharePoint List you want!

A custom list creation screen

Soon you will notice that everything depends on the ClientContext object, which manages the requests and the data that will be loaded.

In our examples we are going to use the variable siteUrl, that represents the URL for the Site Collection. The variable listTitle will also be used and it represents the Title of the list being used.

string siteUrl = "http://sitesharepoint";
string listTitle = "SharePointList";

So, let’s do some real stuff here:

Read operation in SharePoint lists

Filtering and selecting specific fields

The example below presents a simple code that queries only one list item from the List and specifies some specific columns to be returned. It’s important to say that exists lots of best practices to build good queries in SharePoint.

Creation operation in SharePoint lists

 Update operation in SharePoint lists

 Delete operation in SharePoint lists

I believe these are the basics for consuming SharePoint lists. In the future I’m planning to show some complex examples, more focused on Office 365 and Azure integrations. Thanks for reading and I hope it can be useful to you when you need to perform list operations with CSOM and C# in SharePoint.

References:
MSDN

Get user info programmatically in SharePoint

Sometimes when we are developing a custom solution, we need to get user info programmatically in SharePoint. It doesn’t matter if you need to show a special message to an specific user using its Personal Name or maybe just fill a SPFieldUser column in a specific list, you’ll probably need one of those code snippets to do the trick.

I’m going to split it into Server-side object model for C# developers, REST API (for SharePoint 2013 projects or newer) and the old-fashioned JavaScript object model introduced in SharePoint 2010. Each one wil let you capture the current user or get an user by its ID or login name. After that it’s up to you what you are going to do with the data.

SharePoint users inside the User Information List (hidden)
Continue reading

© 2024 wiliammbr's blog

Theme by Anders NorenUp ↑