Showing posts with label C#. Show all posts
Showing posts with label C#. Show all posts
Friday, February 15, 2019
Linux Mono C#
$mono-csc searchmono.cs /out:seachmono -r:/usr/lib/mono/4.5/System.Web.dll
Compiling with mySql connector library
$mono-csc mysqlmono.cs /out:mysqlmono -r:System.Data.dll -r:/path/.nuget/packages/mysql.data/8.0.13/lib/net452/MySql.Data.dll
References:
[1] Example https://www.codeproject.com/Articles/9407/Introduction-to-Mono-Your-first-Mono-app
[2] Converter tools
http://converter.telerik.com/
https://codeconverter.icsharpcode.net/
https://www.carlosag.net/tools/codetranslator/
[3] Mysql Connection https://www.mono-project.com/docs/database-access/providers/mysql/
Tuesday, November 27, 2018
ASP.NET MVC Mono
Settings at 11/2018
.Net Framework 4.5.2 using project properties
Mysql.Data.Entity using NuGet(6.10.8)
Setup Web.config
<!--Added-->
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.2.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<add name="ferredb" connectionString="server=127.0.0.1;Port=3306;Database=ferre;Uid=root;Pwd=Microsoft;" providerName="MySql.Data.MySqlClient"/>
</connectionStrings>
<!--Added-->
<entityFramework>
<providers>
<provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6, Version=6.10.8.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d">
</provider>
</providers>
</entityFramework>
<!--Added-->
<system.data>
<DbProviderFactories>
<remove invariant="MySql.Data.MySqlClient" />
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.10.8.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/>
</DbProviderFactories>
</system.data>
Fix version of entry System.Web.Mvc.MvcWebRazorHostFactory at views/Web.config
Classes
//Ado
using System;
using System.Data.Entity;
using MySQLEntity.Models;
namespace MySQLEntity.Entity
{
public class MyDb : DbContext
{
public MyDb() : base("ferredb")
//public MyDb() : base(nameOrConnectionString: "ferredb")
{
}
public DbSet<Usuario> Usuarios { get; set; }
}
}
//Entity
using System;
//Added
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
namespace MySQLEntity.Models
{
[Table("Users")]
public class Usuario
{
[Key]
public string usuario { get; set; }
public string apenom { get; set; }
}
}
Controller Snippet code
public ActionResult Index()
{
MyDb db = new MyDb();
var Model=db.Usuarios.ToList();
return View(Model);
}
View Snippet code
@foreach (var item in Model)
{
<div> @item.usuario @item.apenom </div>
Action results
References:
[1] MySQL EntityFramework web.config https://iyalovoi.wordpress.com/2015/04/06/entity-framework-with-mysql-on-mac-os/
[2] Action results
https://www.c-sharpcorner.com/article/different-types-of-action-results-in-asp-net-mvc/
[3] ViewBag better than DataView http://www.tutorialsteacher.com/mvc/viewbag-in-asp.net-mvc
.Net Framework 4.5.2 using project properties
Mysql.Data.Entity using NuGet(6.10.8)
Setup Web.config
Fix version of entry System.Web.Mvc.MvcWebRazorHostFactory at views/Web.config
Classes
//Ado
using System;
using System.Data.Entity;
using MySQLEntity.Models;
namespace MySQLEntity.Entity
{
public class MyDb : DbContext
{
public MyDb() : base("ferredb")
//public MyDb() : base(nameOrConnectionString: "ferredb")
{
}
public DbSet
}
}
//Entity
using System;
//Added
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
namespace MySQLEntity.Models
{
[Table("Users")]
public class Usuario
{
[Key]
public string usuario { get; set; }
public string apenom { get; set; }
}
}
Controller Snippet code
public ActionResult Index()
{
MyDb db = new MyDb();
var Model=db.Usuarios.ToList();
return View(Model);
}
View Snippet code
@foreach (var item in Model)
{
<div> @item.usuario @item.apenom </div>
}
Action results
References:
[1] MySQL EntityFramework web.config https://iyalovoi.wordpress.com/2015/04/06/entity-framework-with-mysql-on-mac-os/
[2] Action results
https://www.c-sharpcorner.com/article/different-types-of-action-results-in-asp-net-mvc/
[3] ViewBag better than DataView http://www.tutorialsteacher.com/mvc/viewbag-in-asp.net-mvc
Labels:
ASP.NET,
ASP.NET MVC,
C#,
Web.Developer
Wednesday, February 12, 2014
C# Todo sobre puertos Serial(COM) y Paralelo(LPT )
How to program Read,Write parallel port in C#?
http://sandeep-aparajit.blogspot.com/2008/08/io-how-to-program-readwrite-parallel.html
Parallel port
http://www.epanorama.net/circuits/parallel_output.html
http://www.epanorama.net/circuits/parallel_output_es.html
I/O Ports Uncensored - 1 - Controlling LEDs (Light Emiting Diodes) with Parallel Port
http://www.codeproject.com/KB/cs/csppleds.aspx?df=100&forumid=21021&exp=0&select=974134
I/O Ports Uncensored Part 2 - Controlling LCDs (Liquid Crystal Displays) and VFDs (Vacuum Fluorescent Displays) with Parallel Port
http://www.codeproject.com/KB/cs/cspplcds.aspx
How to Capture LPT Port(s) to Intercept DOS Print Requests
http://www.codeproject.com/KB/system/LPTCapture.aspx
Recursos:
Lpt Monitor y muchos otros muy útiles
http://neil.fraser.name/software/
Com Monitor
http://www.serial-port-monitor.com/
Drivers para dispositivos varios controlados por puertos LPT o COM
http://www.kitsrus.com/software.html
http://sandeep-aparajit.blogspot.com/2008/08/io-how-to-program-readwrite-parallel.html
Parallel port
http://www.epanorama.net/circuits/parallel_output.html
http://www.epanorama.net/circuits/parallel_output_es.html
I/O Ports Uncensored - 1 - Controlling LEDs (Light Emiting Diodes) with Parallel Port
http://www.codeproject.com/KB/cs/csppleds.aspx?df=100&forumid=21021&exp=0&select=974134
I/O Ports Uncensored Part 2 - Controlling LCDs (Liquid Crystal Displays) and VFDs (Vacuum Fluorescent Displays) with Parallel Port
http://www.codeproject.com/KB/cs/cspplcds.aspx
How to Capture LPT Port(s) to Intercept DOS Print Requests
http://www.codeproject.com/KB/system/LPTCapture.aspx
Recursos:
Lpt Monitor y muchos otros muy útiles
http://neil.fraser.name/software/
Com Monitor
http://www.serial-port-monitor.com/
Drivers para dispositivos varios controlados por puertos LPT o COM
http://www.kitsrus.com/software.html
Wednesday, June 19, 2013
C# Windows Services and Logs
References:
[1] http://www.codeproject.com/Articles/14353/Creating-a-Basic-Windows-Service-in-C
[1.1] http://www.codeproject.com/Articles/3990/Simple-Windows-Service-Sample
[2] http://blog.themobilebrand.com/technology/tutorial-building-a-windows-service-application/
[3] http://www.c-sharpcorner.com/UploadFile/mahesh/window_service11262005045007AM/window_service.aspx
[4] C# log4net http://www.eyecatch.no/blog/2012/08/logging-with-log4net-in-c-sharp/
[5] C# log4net http://www.codeproject.com/Questions/377372/Log4net-not-working-No-Logs-created
[6] Windows event log http://msdn.microsoft.com/en-us/library/6s7642se.aspx
Wednesday, June 12, 2013
C# Send/Read SMS using MT6225(Chine) Cellular
Code works over Windows XP/Sp2 + VS2008, problem is on Windows 7/x64
First you need download/install driver for Windows 7 from [1], after that download c# sample from [2].
for understand code, you need know At commands, that code only send AT command to Comx for interchange information with the cellular phone.
Same usually commands:
AT
(if result is OK, then connection is good)
AT+CMGF=1
(Set message format 0:New/1:Read)
AT+CMGF?
(Read current setting)
AT+CMGF=?
(Show list possible values)
AT+CMGL="ALL"
(List of all messages)
Classic sequence:
AT+CMGF=1
AT+CMGL="ALL"
References:
[1] MT6225 for W7/x64 Driver http://hotfile.com/dl/42358552/cb0f022/MTK6227_Driver__For_XP__Vista.rar
[2] C# Source Code for test http://www.elguille.info/colabora/NET2006/mauro_melgar_envio_sms.htm
[3] AT Commands http://www.telit.com/module/infopool/download.php?id=542
First you need download/install driver for Windows 7 from [1], after that download c# sample from [2].
for understand code, you need know At commands, that code only send AT command to Comx for interchange information with the cellular phone.
Same usually commands:
AT
(if result is OK, then connection is good)
AT+CMGF=1
(Set message format 0:New/1:Read)
AT+CMGF?
(Read current setting)
AT+CMGF=?
(Show list possible values)
AT+CMGL="ALL"
(List of all messages)
Classic sequence:
AT+CMGF=1
AT+CMGL="ALL"
References:
[1] MT6225 for W7/x64 Driver http://hotfile.com/dl/42358552/cb0f022/MTK6227_Driver__For_XP__Vista.rar
[2] C# Source Code for test http://www.elguille.info/colabora/NET2006/mauro_melgar_envio_sms.htm
[3] AT Commands http://www.telit.com/module/infopool/download.php?id=542
Thursday, March 07, 2013
C# Export to Excel
References:
[1] EPPlus is a .net library that reads and writes Excel 2007/2010 files using the Open Office Xml format (xlsx). http://epplus.codeplex.com/
[2] C# Class for Export DataTable To Excel with Interop http://alandjackson.wordpress.com/2011/01/07/c-export-to-excel-with-interop/
[3] Version of POI Java project at http://poi.apache.org/. POI is an open source project which can help you read/write xls, doc, ppt files. http://npoi.codeplex.com/releases
[4] Sample of NPOI http://www.leniel.net/2009/07/creating-excel-spreadsheets-xls-xlsx-c.html#sthash.5qgu3AiY.dpbs
[5] Good sample for export to excel file http://www.codeproject.com/Articles/20228/Using-C-to-Create-an-Excel-Document
Wednesday, December 28, 2011
Caller ID
References:
http://www.compartir-tecnologias.es/call-id-y-c-ayuda-206872292.html
Code
http://www.codeproject.com/KB/dotnet/CShart_TAPI_3x.aspx
http://stackoverflow.com/questions/3128204/how-detect-caller-id-from-phone-line
http://www.forosdelweb.com/f29/modem-con-identificador-llamadas-caller-id-con-c-694795/
http://intellitechture.com/The-basics-of-System-IO-Ports-SerialPort/
http://www.tech-archive.net/Archive/Development/microsoft.public.win32.programmer.tapi/2006-06/msg00106.html
Test Modem
http://stackoverflow.com/questions/1200921/how-to-get-caller-id-in-c
http://www.compartir-tecnologias.es/call-id-y-c-ayuda-206872292.html
Code
http://www.codeproject.com/KB/dotnet/CShart_TAPI_3x.aspx
http://stackoverflow.com/questions/3128204/how-detect-caller-id-from-phone-line
http://www.forosdelweb.com/f29/modem-con-identificador-llamadas-caller-id-con-c-694795/
http://intellitechture.com/The-basics-of-System-IO-Ports-SerialPort/
http://www.tech-archive.net/Archive/Development/microsoft.public.win32.programmer.tapi/2006-06/msg00106.html
Test Modem
http://stackoverflow.com/questions/1200921/how-to-get-caller-id-in-c
Thursday, November 24, 2011
Servicios Windows
[1] ¿Cómo hacer un Servicio Windows en C#?
http://www.cjorellana.net/2009/07/como-hacer-un-servicio-windows-en-c.html
[2] Crear un servicio windows y un instalador de un servicio windows.
http://www.onglasses.net/Default.aspx?id=4450
http://www.cjorellana.net/2009/07/como-hacer-un-servicio-windows-en-c.html
[2] Crear un servicio windows y un instalador de un servicio windows.
http://www.onglasses.net/Default.aspx?id=4450
Wednesday, September 28, 2011
Track visitors using ASP.NET & C#
References:
[0]Getting The Real IP Of Your Users
http://thepcspy.com/read/getting_the_real_ip_of_your_users/
[1] How to track visitors to your site in ASP.NET & C#
http://www.mycsharpcorner.com/Post.aspx?postID=27
[2] Server variables http://www.aspnetcenter.com/cliktoprogram/asp/serverVariables.asp
[0]Getting The Real IP Of Your Users
http://thepcspy.com/read/getting_the_real_ip_of_your_users/
[1] How to track visitors to your site in ASP.NET & C#
http://www.mycsharpcorner.com/Post.aspx?postID=27
[2] Server variables http://www.aspnetcenter.com/cliktoprogram/asp/serverVariables.asp
Labels:
C#,
Web.Developer,
Windows.Developer
Wednesday, September 14, 2011
Creating .XLS and .XLSX with C#
Code samples:
Visual Studio 2008 C# ASP.NET MVC Web Application
http://sites.google.com/site/leniel/blog/ExcelWriterMvcProject.zip
References:
ExcelPackage: Office Open XML Format file creation
http://excelpackage.codeplex.com/
ExcelPackage binaries download
http://excelpackage.codeplex.com/Release/ProjectReleases.aspx
NPOI
http://npoi.codeplex.com/
Visual Studio 2008 C# ASP.NET MVC Web Application
http://sites.google.com/site/leniel/blog/ExcelWriterMvcProject.zip
References:
ExcelPackage: Office Open XML Format file creation
http://excelpackage.codeplex.com/
ExcelPackage binaries download
http://excelpackage.codeplex.com/Release/ProjectReleases.aspx
NPOI
http://npoi.codeplex.com/
Friday, July 22, 2011
Thursday, April 21, 2011
Thursday, March 31, 2011
Wednesday, December 15, 2010
ASP.NET C# Upload from URL
using System.Net;
WebClient wc = new WebClient();
wc.DownloadFile("http://sourcefile.ext", "drive:\\path\\targetfile.ext");
References:
[1] http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=115
WebClient wc = new WebClient();
wc.DownloadFile("http://sourcefile.ext", "drive:\\path\\targetfile.ext");
References:
[1] http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=115
Labels:
ASP.NET MVC,
C#,
Windows.Developer
Thursday, December 02, 2010
SQL Server Analysis Service
Working with Microsoft Analysis Services (SSAS) / MSOLAP / MDX Queries
http://developer.klipfolio.com/developer/cookbook_item/item-64
Running the Analysis Services Deployment Wizard
http://msdn.microsoft.com/en-us/library/ms174817.aspx
Building a SQL Server Analysis Services .ASDatabase file from a Visual Studio SSAS Project
http://agilebi.com/ddarden/2009/05/31/building-a-sql-server-analysis-services-asdatabase-file-from-a-as-project/
Resources
[1] http://sqlsrvanalysissrvcs.codeplex.com/
[2] SQL Server software
http://www.todotegusta.com/2010/05/microsoft-sql-server-2008-r2-standard-edition-x86-y-x64/
http://developer.klipfolio.com/developer/cookbook_item/item-64
Running the Analysis Services Deployment Wizard
http://msdn.microsoft.com/en-us/library/ms174817.aspx
Building a SQL Server Analysis Services .ASDatabase file from a Visual Studio SSAS Project
http://agilebi.com/ddarden/2009/05/31/building-a-sql-server-analysis-services-asdatabase-file-from-a-as-project/
Resources
[1] http://sqlsrvanalysissrvcs.codeplex.com/
[2] SQL Server software
http://www.todotegusta.com/2010/05/microsoft-sql-server-2008-r2-standard-edition-x86-y-x64/
Wednesday, December 01, 2010
Data Mining with C#
Data Mining with C# and ADO.NET
http://www.devsource.com/c/a/Languages/Data-Mining-with-C-and-ADONET/
Data Mining SDK
http://datamining.codeplex.com/
http://www.sqldev.org/sql-server-analysis-services/c-using-adomd-to-connect-to-olap-cube-10707.shtml
Another plataform
http://www.cs.waikato.ac.nz/ml/weka/
Other references:
Spanish
http://bernardorobelo.blogspot.com/2010/02/modelos-y-ejemplos-de-data-mining.html
http://alejandroesteban.wordpress.com/
http://www.devsource.com/c/a/Languages/Data-Mining-with-C-and-ADONET/
Data Mining SDK
http://datamining.codeplex.com/
http://www.sqldev.org/sql-server-analysis-services/c-using-adomd-to-connect-to-olap-cube-10707.shtml
Another plataform
http://www.cs.waikato.ac.nz/ml/weka/
Other references:
Spanish
http://bernardorobelo.blogspot.com/2010/02/modelos-y-ejemplos-de-data-mining.html
http://alejandroesteban.wordpress.com/
Wednesday, November 24, 2010
C# Smtp Client using gmail account
using System;
using System.Collections.Generic;
using System.Text;
using System.Net.Mail;
using System.Net;
namespace SmtpMail
{
class Program
{
static void Main(string[] args)
{
try
{
var client = new SmtpClient("smtp.gmail.com", 587)
{
Credentials = new NetworkCredential("compelligencelocal@gmail.com", "xxxxx"),
EnableSsl = true
};
client.Send("myusername@gmail.com", "manager_27@hotmail.com", "test", "testbody");
Console.WriteLine("Sent");
Console.ReadLine();
}
catch (Exception ex)
{
Console.WriteLine( ex.Message );
}
}
}
}
Monday, May 24, 2010
C# Resize image
public void ResizeImage(string OriginalFile, string NewFile, int NewWidth, int MaxHeight, bool OnlyResizeIfWider)
{
System.Drawing.Image FullsizeImage = System.Drawing.Image.FromFile(OriginalFile);
// Prevent using images internal thumbnail
FullsizeImage.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipNone);
FullsizeImage.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipNone);
if (OnlyResizeIfWider)
{
if (FullsizeImage.Width <= NewWidth)
{
NewWidth = FullsizeImage.Width;
}
}
int NewHeight = FullsizeImage.Height * NewWidth / FullsizeImage.Width;
if (NewHeight > MaxHeight)
{
// Resize with height instead
NewWidth = FullsizeImage.Width * MaxHeight / FullsizeImage.Height;
NewHeight = MaxHeight;
}
System.Drawing.Image NewImage = FullsizeImage.GetThumbnailImage(NewWidth, NewHeight, null, IntPtr.Zero);
// Clear handle to original file so that we can overwrite it if necessary
FullsizeImage.Dispose();
// Save resized picture
NewImage.Save(NewFile);
}
Resources
=========
C#: Resize An Image While Maintaining Aspect Ratio and Maximum Height
http://www.switchonthecode.com/tutorials/csharp-tutorial-image-editing-saving-cropping-and-resizing
Thursday, May 13, 2010
Trabajando con Delegados en C#
Codigo 1
==========================================
public delegate void DelegateType(string message);
Codigo 2
==========================================
public static void Method(string message)
{
System.Console.WriteLine(message);
}
Función cualquiera con la misma firma que DelegateType es decir void xxx(string yyy)
Codigo 3
==========================================
DelegateType handler = Method; //Esto es posible xq DelegateType es una referencia
//a funciones con la firma void xxx(string yyy).
handler("Hello World"); //Llama a Method
Codigo 4
==========================================
public void MethodWithCallback(int param1, int param2, DelegateType callback)
{
callback("The number is: " + (param1 + param2).ToString());
}
Codigo 5
==========================================
MethodWithCallback(1, 2, handler); //Llamada enviando una referencia a Method
Codigo 6
==========================================
public void Method1(string message) { }
public void Method2(string message) { }
DelegateType d1 = Method1;
DelegateType d2 = Method2;
DelegateType d3 = Method;
DelegateType allMethodsDelegate = d1 + d2;//assigna referencia a d1 y d2
allMethodsDelegate += d3; //agrega referencia a una tercera funcion
Codigo 8
==========================================
allMethodsDelegate -= d1; //elimina d1 de la lista de referencias
DelegateType oneMethodDelegate = allMethodsDelegate - d2; //Copia todos menos d2
Codigo 9
==========================================
int invocationCount = d1.GetInvocationList().GetLength(0); //Cantidad de referencias
Codigo 10
==========================================
using System.Reflection;
namespace DemoDelegate
{
public delegate void D();
public class ComprobaciónDelegados
{
public static void Main()
{
Type t = typeof(ComprobaciónDelegados);
MethodInfo m = t.GetMethod("Metodo1");
D obj = (D) Delegate.CreateDelegate(typeof(D), m);
obj();
}
public static void Metodo1()
{ Console.WriteLine("Ejecutado Método1"); }
public static void Metodo2(string s)
{ Console.WriteLine("Ejecutado Método2");
}
}
}
==========================================
public delegate void DelegateType(string message);
Codigo 2
==========================================
public static void Method(string message)
{
System.Console.WriteLine(message);
}
Función cualquiera con la misma firma que DelegateType es decir void xxx(string yyy)
Codigo 3
==========================================
DelegateType handler = Method; //Esto es posible xq DelegateType es una referencia
//a funciones con la firma void xxx(string yyy).
handler("Hello World"); //Llama a Method
Codigo 4
==========================================
public void MethodWithCallback(int param1, int param2, DelegateType callback)
{
callback("The number is: " + (param1 + param2).ToString());
}
Codigo 5
==========================================
MethodWithCallback(1, 2, handler); //Llamada enviando una referencia a Method
Codigo 6
==========================================
public void Method1(string message) { }
public void Method2(string message) { }
DelegateType d1 = Method1;
DelegateType d2 = Method2;
DelegateType d3 = Method;
DelegateType allMethodsDelegate = d1 + d2;//assigna referencia a d1 y d2
allMethodsDelegate += d3; //agrega referencia a una tercera funcion
Codigo 8
==========================================
allMethodsDelegate -= d1; //elimina d1 de la lista de referencias
DelegateType oneMethodDelegate = allMethodsDelegate - d2; //Copia todos menos d2
Codigo 9
==========================================
int invocationCount = d1.GetInvocationList().GetLength(0); //Cantidad de referencias
Codigo 10
==========================================
using System.Reflection;
namespace DemoDelegate
{
public delegate void D();
public class ComprobaciónDelegados
{
public static void Main()
{
Type t = typeof(ComprobaciónDelegados);
MethodInfo m = t.GetMethod("Metodo1");
D obj = (D) Delegate.CreateDelegate(typeof(D), m);
obj();
}
public static void Metodo1()
{ Console.WriteLine("Ejecutado Método1"); }
public static void Metodo2(string s)
{ Console.WriteLine("Ejecutado Método2");
}
}
}
Subscribe to:
Posts (Atom)
-
Resources: [1] Hela https://ome.grc.nia.nih.gov/iicbu2008/hela/index.html
-
en inglés se llama “A potentially dangerous Request.Form value was detected from the client”. varias páginas indican dos cosas: 1. agrega...
-
mas plugins http://devsnippets.com/reviews/using-jquery-to-style-design-elements-20-impressive-plugins.html http://www.extjs.com/deploy/dev/...
Odoo 17 - Custom adds
[1] Diario/Seq https://apps.odoo.com/apps/modules/17.0/sequence_for_journal