EasMe.Core
1.0.0
dotnet add package EasMe.Core --version 1.0.0
NuGet\Install-Package EasMe.Core -Version 1.0.0
<PackageReference Include="EasMe.Core" Version="1.0.0" />
<PackageVersion Include="EasMe.Core" Version="1.0.0" />
<PackageReference Include="EasMe.Core" />
paket add EasMe.Core --version 1.0.0
#r "nuget: EasMe.Core, 1.0.0"
#:package EasMe.Core@1.0.0
#addin nuget:?package=EasMe.Core&version=1.0.0
#tool nuget:?package=EasMe.Core&version=1.0.0
Introduction
Collection of classes that will save you time and help you avoid repetitive code in CSharp.
Getting Started
//Add reference to your project
//Add library reference in the class you want to use and define EasMe classes
using EasMe;
EasQL
EasQL helps you with basic SQL commands. Execute queries, get tables, shrink and backup database features.
Setting up
EaSQL _easql = new EasQL();
GetTable Usage
//Timeout set to 0 by default meaning there is no timeout
public DataTable GetTable(string Connection, SqlCommand cmd, int Timeout = 0){};
//Get Table without parameter
SqlCommand cmd = new SqlCommand("SELECT * FROM Users");
DataTable dt = _easql.GetTable("YOUR-CONNECTION-STRING",cmd);
//Get Table with parameter
SqlCommand cmd = new SqlCommand("SELECT * FROM Users WHERE Id = @id");
cmd.Parameters.AddWithValue("@id",1);
DataTable dt = _easql.GetTable("YOUR-CONNECTION-STRING",cmd);
ExecNonQuery, ExecScalar, ExecStoredProcedure Usage
//Timeout set to 0 by default meaning there is no timeout
public int ExecNonQuery(string Connection, SqlCommand cmd, int Timeout = 0){};
public object ExecScalar(string Connection, SqlCommand cmd, int Timeout = 0){};
public int ExecStoredProcedure(string Connection, SqlCommand cmd, int Timeout = 0){};
//ExecNonQuery executes query and returnes affected rows as int value
SqlCommand cmd = new SqlCommand("UPDATE Users SET Email = @email WHERE Id = @id");
cmd.Parameters.AddWithValue("@email","example@mail.com");
cmd.Parameters.AddWithValue("@id",1);
int affectedRows = _easql.ExecNonQuery("YOUR-CONNECTION-STRING",cmd);
//ExecScalar will return an object, convert it depending on what value you are expecting from query
SqlCommand cmd = new SqlCommand("SELECT Email FROM Users WHERE Id = @id");
cmd.Parameters.AddWithValue("@id",1);
object obj = _easql.ExecScalar("YOUR-CONNECTION-STRING",cmd);
//ExecStoredProcedure will return int value which will depends on the procedure
SqlCommand cmd = new SqlCommand("sendMail");
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Username", "exampleusername");
int result = _sql.ExecStoredProcedure("YOUR-CONNECTION-STRING", cmd);
BackupDatabase and ShrinkDatabase Usage
//Timeout set to 0 by default meaning there is no timeout
public void BackupDatabase(string Connection, string DatabaseName, string BackupPath, int Timeout = 0){};
public void ShrinkDatabase(string Connection, string DatabaseName, string DatabaseLogName = "_log"){};
//BackupDatabase will create a backup of your database in the given path and will add date in file name
//Backup Path must be a folder also if database is big you might want to consider running this on another thread
_easql.BackupDatabase("YOUR-CONNECTION-STRING","DATABASE-NAME","BACKUP-PATH");
//ShrinkDatabase will shrink your database and logs, this will not delete your data only will reduce the disk space of SQL logs
_easql.ShrinkDatabase("YOUR-CONNECTION-STRING","DATABASE-NAME");
//Database log default name is set DATABASENAME_log but you can change it in SQL management studio if its default you only need to "_log" string after database name
//If you don't give paramete dblogname it will set dblogname to default
_easql.ShrinkDatabase("YOUR-CONNECTION-STRING","DATABASE-NAME","DATABASE-LOG-NAME");
TruncateTable, DropTable, DropDatabase Usage
public void TruncateTable(string Connection, string TableName){};
public void DropTable(string Connection, string TableName){};
public void DropDatabase(string Connection, string DatabaseName){};
_easql.TruncateTable("YOUR-CONNECTION-STRING","TABLE-NAME");
_easql.DropTable("YOUR-CONNECTION-STRING","TABLE-NAME");
_easql.DropDatabase("YOUR-CONNECTION-STRING", "DATABASE-NAME");
GetAllTableName Usage
public List<string> GetAllTableName(string Connection){};
List<string> TableList = _easql.GetAllTableName("YOUR-CONNECTION-STRING");
EasBox
EasBox helps you with message boxes. Show easy and simple Message Boxes with your WinForm project.
Usage
if(_easbox.Confirm("Are you sure you want to do this ?"))
{
//ACTION
}
_easbox.Show("Are you sure you want to do this ?");
_easbox.Warn("You should run this app on administrator mode");
_easbox.Info("Successfully updated list");
_easbox.Error("An interal error occured");
_easbox.Stop("This action is not allowed");
EasINI
EasINI helps you with reading and writing .ini files.
Set ini file path
EasINI _easini = new EasINI();
//To specify ini file path
EasINI _easini = new EasINI("FILE-PATH");
.ini file structure
[SETTINGS]
URL="www.github.com"
Read Usage
public string Read(string Section, string Key){};
string url = _easini.Read("SETTINGS","APIURL");
Write Usage
public void Write(string Section, string Key, string Value){};
_easini.Write("SETTINGS","APIURL","www.google.com");
EasLog
EasLog helps you with creating logs with your application with interval options.
Set log file path
public EasLog(int Interval = 0){};
public EasLog(string FilePath, int Interval = 0){};
//If you don't specify path it will take current directory and create Logs folder
EasLog _easlog = new EasLog();
//To specify logging file path
EasLog _easlog = new EasLog("FILE-PATH");
//Intervals
//0 (Default) => Daily
//1 => Hourly
//2 => Minutely
//Interval with file path
EasLog _easlog = new EasLog("FILE-PATH",2);
//Interval without file path, logs will be created in current directory
EasLog _easlog = new EasLog(2);
Create Log Usage
public void Create(string LogContent){};
_easlog.Create("LOG-CONTENT");
EasDel
EasDel helps you with deleting files, directories and sub directories with logging feature.
Enabling logging and setting file path
public EasDel(string LogPath){};
public EasDel(bool isEnableLogging = false){};
EasDel _easdel = new EasDel();
//Logging is disabled by default so enable it like this, will create logs in current directory
EasDel _easdel = new EasDel(true);
//If you specify log file path, logging automaticly will be enabled
EasDel _easdel = new EasDel("FILE-PATH");
Usage
public void DeleteAllFiles(string FilePath){};
//You can give file path as one one file or a folder it will work either way
_easdel.DeleteAllFiles("FILE-PATH");
EasAPI
EasAPI helps you with send get and post requests to APIs.
APIResponse Class
//Status is true when response is 200 (OK)
//Content is Json string
public class APIResponse
{
public bool Status { get; set; }
public string Content { get; set; }
}
Get Usage
public APIResponse Get(string URL, string TOKEN = null){};
//Request without authentication header
APIResponse Response = _easapi.Get("API-URL");
//Request with authentication header
APIResponse Response = _easapi.Get("API-URL","AUTHENTICATION-HEADER-TOKEN");
PostAsJson Usage
public APIResponse PostAsJson(string URL, object Data, string TOKEN = null){};
//Request without authentication header
//obj can be anonymous abject or a class
var obj = new { message = "EasMe makes this so much easier!"};
APIResponse Response = _easapi.PostAsJson("API-URL",obj);
//Request with authentication header
APIResponse Response = _easapi.PostAsJson("API-URL",obj,"AUTHENTICATION-HEADER-TOKEN");
ParsefromAPIResponse Usage
public string ParsefromAPIResponse(string Response, string Parse,bool isThrow = false){};
//This will parse JObject string and return the value from API response
//If can't find value it will return empty string
string ParsedResponse = _easapi.ParsefromAPIResponse(Response.Content,"message");
//If you want function to throw error if can't find the value, give another parameter as true
string ParsedResponse = _easapi.ParsefromAPIResponse(Response.Content,"message",true);
EasMail
EasMail helps you with SMTP, it makes sending mails a lot faster.
Setting up
EasMail _easmail = new EasMail(string Host, string MailAddress, string Password, int Port, bool isSSL = false);
MailSend Usage
public void SendMail(string Body, string SendTo, string Subject){};
_easmail.MailSend("YOUR-BODY-CONTENT","TO-EMAIL-ADDRESS","SUBJECT");
EasReCaptcha
EasReCaptcha helps you with validating Google ReCaptcha with your web app.
CaptchaResponse Class
public class CaptchaResponse
{
public bool Success { get; set; }
public DateTime ChallengeTS { get; set; }
public string ApkPackageName { get; set; }
public string ErrorCodes { get; set; }
}
Requirements
Newtonsoft.Json
System.Net
Program.cs
builder.Services.AddReCaptcha(builder.Configuration);
appsettings.json
"ReCaptcha": {
"SiteKey": "YOUR-SITE-KEY",
"SecretKey": "YOUR-SECRET-KEY",
"Version": "v2"
}
View
<div class="g-recaptcha" data-sitekey="YOUR-SITE-KEY"></div>
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
Validating ReCaptcha Response from View
var CaptchaResponse = HttpContext.Request.Form["g-recaptcha-response"];
string Secret = "your-secret-key";
var Captcha = _easrecaptcha.Validate(Secret, CaptchaResponse);
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net6.0
- Newtonsoft.Json (>= 13.0.1)
- System.Data.SqlClient (>= 4.8.3)
- System.IdentityModel.Tokens.Jwt (>= 6.18.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 389 | 5/27/2022 |