This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Extension()> _ | |
Public Function ToCsvValue(ByVal source As Object, Optional ByVal addDelimiter As Boolean = True) As String | |
Dim csvValue As String | |
If source Is Nothing Then | |
csvValue = "" | |
Else | |
csvValue = CStr(source).Trim | |
End If | |
If addDelimiter Then | |
Return If(csvValue.IndexOf(",") > -1, String.Format("""{0}"",", csvValue), String.Format("{0},", csvValue)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link rel="import" href="../core-icon-button/core-icon-button.html"> | |
<link rel="import" href="../core-toolbar/core-toolbar.html"> | |
<link rel="import" href="../core-header-panel/core-header-panel.html"> | |
<link rel="import" href="../core-drawer-panel/core-drawer-panel.html"> | |
<polymer-element name="my-element"> | |
<template> | |
<style> | |
:host { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link rel="import" href="../core-scaffold/core-scaffold.html"> | |
<link rel="import" href="../core-header-panel/core-header-panel.html"> | |
<link rel="import" href="../core-menu/core-menu.html"> | |
<link rel="import" href="../core-item/core-item.html"> | |
<link rel="import" href="../core-icon-button/core-icon-button.html"> | |
<link rel="import" href="../core-toolbar/core-toolbar.html"> | |
<link rel="import" href="../core-menu/core-submenu.html"> | |
<polymer-element name="my-element"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public Sub WaitForFileToBeAccessible(ByVal fileWaitingOn As String) | |
Try | |
Using fs As FileStream = New FileStream(fileWaitingOn, FileMode.Open, FileAccess.ReadWrite, FileShare.None, 100) | |
fs.ReadByte() | |
End Using | |
Catch ex As Exception | |
System.Threading.Thread.Sleep(10000) | |
WaitForFileToBeAccessible(fileWaitingOn) | |
End Try | |
End Sub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Imports System.Net.Sockets | |
Public Function SmtpAlive(ByVal hostName As String, ByVal port As Integer) | |
Using tcp As New TcpClient | |
Try | |
tcp.Connect(hostName, port) | |
Return True | |
Catch ex As Exception | |
' server not found | |
Return False | |
End Try |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Imports Microsoft.VisualBasic.FileIO | |
Public Class FileParser | |
Public Shared Sub ParseDelimitedFile(ByVal sourceFileName As String, ByVal dataReadAction As Action(Of String(), Long), Optional ByVal delimiter As String = ",") | |
Dim csvReader As TextFieldParser = New TextFieldParser(sourceFileName) | |
csvReader.SetDelimiters(delimiter) | |
csvReader.HasFieldsEnclosedInQuotes = True | |
csvReader.TrimWhiteSpace = True | |
ParseFile(csvReader, dataReadAction) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Imports System.Data.SqlClient | |
Public Function IsMsSqlServerAvailable(ByVal dbCnxStr As String) As Boolean | |
Try | |
Using srvrConnection = New SqlConnection(dbCnxStr) | |
Try | |
srvrConnection.Open() | |
Return True | |
Catch ex As SqlException | |
Return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Imports MySql.Data.MySqlClient | |
Public Function IsMySqlServerAvailable(ByVal dbCnxStr As String) As Boolean | |
Try | |
Using srvrConnection = New MySqlConnection(dbCnxStr) | |
Try | |
srvrConnection.Open() | |
Return True | |
Catch ex As MySqlException | |
Return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Credit goes to this blog post https://dotnettips.wordpress.com/2017/02/20/net-framework-core-getting-the-app-data-folder/ | |
//For .Net Core | |
public static string AppDataFolder() | |
{ | |
var userPath = Environment.GetEnvironmentVariable( | |
RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? | |
"LOCALAPPDATA" : "Home"); | |
var assy = System.Reflection.Assembly.GetEntryAssembly(); | |
var companyName = assy.GetCustomAttributes<AssemblyCompanyAttribute>() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Credit goes to this blog post https://dotnettips.wordpress.com/2013/03/07/retrieving-application-settings/ | |
//USAGE: int serverPort = GetAppSetting<int>("server_port"); | |
public static T GetAppSetting<T>(string key) | |
{ | |
if (ConfigurationManager.AppSettings.AllKeys.Contains(key)) | |
{ | |
return (T)System.Convert.ChangeType(ConfigurationManager.AppSettings[key], | |
typeof(T), CultureInfo.InvariantCulture); | |
} | |
else |
OlderNewer