Posts

Donate

Check Email Exists In Active Directory Using C#

Good afternoon gents! Here's a method on checking if an email exists in an Active Directory Domain given the format of an email FirstName.LastName@yourcompanyname.com . If the format of your company email is different from the one presented, just change the logic of the code to extract the family name. /* Email Format: Gregory.Esguerra@abcbusiness.com */ private bool CheckIfEmailExistsInDomain ( string email) { string searchName = string .Empty; searchName = email.Substring(email.IndexOf( '.' ) + 1 , (email.IndexOf( '@' )- 1 ) - email.IndexOf( '.' )); using ( var context = new PrincipalContext(ContextType.Domain, "abcbusiness.corp" )) { using ( var searcher = new PrincipalSearcher( new UserPrincipal(context))) { PrincipalSearchResult<Principal> allPrincipal = searcher.FindAll(); List<Principal> principalObjects = allPrincipal.Where(t => t.Name.Contains(ToUpperFirstLetter(searchName))).ToList(); if ...

Spatial types and functions are not available for this provider because the assembly 'Microsoft.SqlServer.Types' version 10 or higher could not be found.

Hello, While working with an ASP.NET MVC app using SQL Server 2016, this error appears in the browser "Spatial types and functions are not available for this provider because the assembly 'Microsoft.SqlServer.Types' version 10 or higher could not be found. ". After searching the forums, the solution that worked for me was to add Microsoft.SqlServer.Types dependentAssembly element inside the assemblyBinding node in the web.config. <dependentAssembly> <assemblyIdentity name= "Microsoft.SqlServer.Types" publicKeyToken= "89845dcd8080cc91" culture= "neutral" /> <bindingRedirect oldVersion= "10.0.0.0-11.0.0.0" newVersion= "14.0.0.0" /> </dependentAssembly>

Chrome Script Debugging In Visual Studio Is Enabled Hangs Up

Image
Good morning! While using the Visual Studio 2017 to debug ASP.NET MVC applications targeting the Chrome browser, one might encounter that both the IDE and browser hangs up. The workaround is to uncheck the Enable JavaScript debugging for ASP.NET (Chrome and IE) .

Match Item That Exists In A List Using Regular Expression And LINQ

Hi! Using Any() in LINQ, we can match/find an item that exists in a List<T> or IEnumerable using Regular Expressions. if (Products.Any(t => Regex.IsMatch(t, ProductsFromFrance.FrenchProdPattern)) { //true statement here.. } Where Products is the List object and ProductsFromFrance.FrenchProdPattern is the Regular Expression pattern.

Match Network Path In A String Using Regular Expression

Hello, While working on a project, I was confronted with an issue on how to match or extract a network path. Normally, you can use string functions or built-in .NET code to check the validity of a path, but since I'm also refreshing my skills in Regular Expression. I prefer the latter as the solution. So the pattern to match the server path is presented below: ((\\\\)?((?<Folder>[a-zA-Z0-9- _]+)(\\.*[a-zA-Z0-9-_ \\])(?="))) And to declare that pattern in your C# code, you have to escape the back slash characters. string ServerPath = "((\\\\\\\\)?((?<Folder>[a-zA-Z0-9- _]+)(\\\\.*[a-zA-Z0-9-_ \\\\])(?=\")))" ; The input strings tested are as follows. Const ImagesPath As String = "\\ImagesServer\Logo Files\InetPub\TempProjects\" Const docsPath As String = "\\docsPathServer15\Health\Physicians\" Const vsPath As String = "\\vsServer909\vs2017\Projects" string manual = "\\manualServer\CompanyRules\EmployeeFiles\Cebu...

How To Update Multiple Rows In SQL Server Using One SQL Statement

Here's how to update multiple rows in one SQL statement using MSSQL. UPDATE tblEmp SET empSalary = empSrc.empSalary, empLevel = empSrc.empLevel FROM dbo.tblEmployees AS tblEmp INNER JOIN ( VALUES ( 001 , 10000 . 00 , 10 ), ( 002 , 32000 . 00 , 15 ), ( 003 , 9500 . 00 , 3 ) ) AS empSrc (empID, empSalary, empLevel) ON tblEmp.empID = empSrc.empID; Reference: How to update multiple columns of multiple rows in one SQL statement

MVVM RelayCommand And ViewModelBase Classes in VB.NET

Good evening! Here's a conversion of the RelayCommand and VewModelBase classes to VB.NET as reference for VB.NET programmers. RelayCommand Imports System.Windows.Input Public Class RelayCommand : Implements ICommand Private ReadOnly _execute As Action( Of Object ) Private ReadOnly _canExecute As Predicate( Of Object ) Public Sub New ( ByVal execute As Action( Of Object )) End Sub Public Sub New ( ByVal execute As Action( Of Object ), ByVal canExecute As Predicate( Of Object )) If execute Is Nothing Then Throw New ArgumentNullException( "execute" ) _execute = execute _canExecute = canExecute End Sub Public Function CanExecute ( ByVal parameter As Object ) As Boolean Implements ICommand.CanExecute Return (_canExecute Is Nothing ) OrElse _canExecute(parameter) End Function Public Custom Event CanExecuteChanged As EventHandler Implements ICommand...

Refactor An MVVM ViewModel Class

Good afternoon! I recently asked the forums on how to refactor a ViewModel class given that in the future additional features or functionalities will be added, so the ViewModel class becomes bloated and hard to trace. All the commands, database operations and properties are declared in this class. So, the option I was thinking was segregation but I also need inputs from other experienced developers in the community. Sample ViewModel Class namespace MVVM.MainApplication.ViewModel { public class EmployeeViewModel : ViewModelBase { private ICommand _saveCommand; private ICommand _resetCommand; private ICommand _editCommand; private ICommand _deleteCommand; private Employee _employeeEntity; private EmployeeRepository _repository; private EmployeeModel _employeeModel; public EmployeeModel EmployeeModel { get { return _employeeModel; } ...

View Attendees Or Participants Of A Meeting In Outlook 365

Image
Hello! While familiarizing myself with Outlook 365, I had difficulty in viewing the attendees of a specific meeting. The layout of Outlook 365 has changed and I didn't see the Tracking button under Meeting Occurrence tab. After doing some research, the solution to show the attendees is to check the Normal option of People Pane under View tab.

WPF CRUD With DataGrid, Entity Framework And VB.NET

Image
Good morning! Here's the VB.NET version of this post WPF CRUD with DataGrid and Entity Framework C# . The steps to accomplish basing from the C# post are: a. Run the create table script assuming that you haven't created the Students table. b. Create a VB.NET WPF project. c. Replace the XAML markup of the window control. Once done, the scripts for the repository class and window code-behind are as follows: Repository Class Public Class StudentRepository Private studentContext As StudentEntities = Nothing Public Sub New () studentContext = New StudentEntities() End Sub Public Function GetStudent ( ByVal id As Integer ) As Student Return studentContext.Students.Find(id) End Function Public Function GetAll () As List( Of Student) Return studentContext.Students.ToList() End Function Public Sub AddStudent ( ByVal student As Student) If student IsNot Nothing Then ...

Donate