Spostato metodi in altra clase (CodGen) + parametri x size esposti

This commit is contained in:
Samuele E. Locatelli
2020-02-18 11:44:38 +01:00
parent 0f5cc4bf0a
commit 95279f840b
9 changed files with 282 additions and 355 deletions
Vendored
-199
View File
@@ -10,12 +10,6 @@ pipeline {
stage('Checkout') {
agent any
steps {
/* build delle SteamWare libs! */
/* build 'SteamWare/SteamWareLib' */
/* copio le libs...*/
// mirroring directory x SteamWare Libs
bat "robocopy /MIR ..\\..\\SteamWare\\SteamWareLib ..\\SteamWare\\SteamWareLib || EXIT /B 0"
/* calcolo numero versione... diverso x branch MASTER/DEVELOP */
script {
withEnv(['NEXT_BUILD_NUMBER=17']) {
@@ -38,176 +32,6 @@ pipeline {
bat "e:\\nuget.exe restore ${WORKSPACE}\\QR-GEN.sln"
}
}
// stage('Build') {
// agent any
// steps {
// script {
// properties([buildDiscarder(logRotator(artifactDaysToKeepStr: '180', artifactNumToKeepStr: '30', daysToKeepStr: '360', numToKeepStr: '30')), pipelineTriggers([])])
// // CAMBIO numero versione + checkout NuGet in file sorgente!!!
// bat "fart.exe VersGen\\MoonPro.cs 1.0.0.0 ${env.versionNumber} || EXIT /B 0"
// bat "e:\\nuget.exe restore ${WORKSPACE}\\QR-GEN.sln"
// }
// script {
// /* compilo installers in base al BRANCH del cliente... */
// if (env.BRANCH_NAME == "develop") {
// parallel (
// ADM_IO: {
// sleep 2
// bat "\"${tool 'MSBuild-15.0'}\" MP-ADM/MP-ADM.csproj -target:Build /p:Configuration=Release /p:Platform=\"Any CPU\" /p:OutputPath=bin/ /m"
// bat "\"${tool 'MSBuild-15.0'}\" MP-IO/MP-IO.csproj -target:Build /p:Configuration=Release /p:Platform=\"Any CPU\" /p:OutputPath=bin/ /m"
// },
// LAND_MON: {
// sleep 1
// bat "\"${tool 'MSBuild-15.0'}\" MP-LAND/MP-LAND.csproj -target:Build /p:Configuration=Release /p:Platform=\"Any CPU\" /p:OutputPath=bin/ /m"
// bat "\"${tool 'MSBuild-15.0'}\" MP-MON/MP-MON.csproj -target:Build /p:Configuration=Release /p:Platform=\"Any CPU\" /p:OutputPath=bin/ /m"
// },
// SITE_TAB: {
// sleep 0
// bat "\"${tool 'MSBuild-15.0'}\" MP-SITE/MP-SITE.csproj -target:Build /p:Configuration=Release /p:Platform=\"Any CPU\" /p:OutputPath=bin/ /m"
// bat "\"${tool 'MSBuild-15.0'}\" MP-TAB/MP-TAB.csproj -target:Build /p:Configuration=Release /p:Platform=\"Any CPU\" /p:OutputPath=bin/ /m"
// },
// failFast: false)
// }
// else {
// echo 'Niente x Build (limitata a develop)...'
// }
// }
// }
// }
// stage('Deploy') {
// agent any
// steps {
// script {
// // CAMBIO numero versione + checkout NuGet in file sorgente!!!
// bat "fart.exe VersGen\\MoonPro.cs 1.0.0.0 ${env.versionNumber} || EXIT /B 0"
// bat "e:\\nuget.exe restore ${WORKSPACE}\\QR-GEN.sln"
// }
// script {
// /* DEPLOY condizionale: master (Ufficio Seriate) / demo_ovh (Demo Online) */
// if (env.BRANCH_NAME == "master") {
// parallel (
// ADM_IO: {
// sleep 2
// if(env.enableIIS01 == "Y")
// {
// // ADM
// bat "\"${tool 'MSBuild-15.0'}\" \"/p:AspnetMergePath=C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.6.2 Tools\" /p:DeployOnBuild=true /p:Targets=Publish /p:PublishProfile=IIS02.pubxml /p:VisualStudioVersion=14.0 /p:RunCodeAnalysis=false /p:Configuration=IIS02 /p:username=jenkins /p:Password=viadante16 /p:AllowUntrustedCertificate=true /p:OutputPath=bin/ MP-ADM/MP-ADM.csproj"
// // IO
// bat "\"${tool 'MSBuild-15.0'}\" \"/p:AspnetMergePath=C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.6.2 Tools\" /p:DeployOnBuild=true /p:Targets=Publish /p:PublishProfile=IIS02.pubxml /p:VisualStudioVersion=14.0 /p:RunCodeAnalysis=false /p:Configuration=IIS02 /p:username=jenkins /p:Password=viadante16 /p:AllowUntrustedCertificate=true /p:OutputPath=bin/ MP-IO/MP-IO.csproj"
// }
// if(env.enableIIS02 == "Y")
// {
// // ADM
// bat "\"${tool 'MSBuild-15.0'}\" \"/p:AspnetMergePath=C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.6.2 Tools\" /p:DeployOnBuild=true /p:Targets=Publish /p:PublishProfile=IIS01.pubxml /p:VisualStudioVersion=14.0 /p:RunCodeAnalysis=false /p:Configuration=IIS01 /p:username=jenkins /p:Password=viadante16 /p:AllowUntrustedCertificate=true /p:OutputPath=bin/ MP-ADM/MP-ADM.csproj"
// // IO
// bat "\"${tool 'MSBuild-15.0'}\" \"/p:AspnetMergePath=C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.6.2 Tools\" /p:DeployOnBuild=true /p:Targets=Publish /p:PublishProfile=IIS01.pubxml /p:VisualStudioVersion=14.0 /p:RunCodeAnalysis=false /p:Configuration=IIS01 /p:username=jenkins /p:Password=viadante16 /p:AllowUntrustedCertificate=true /p:OutputPath=bin/ MP-IO/MP-IO.csproj"
// }
// },
// LAND_MON: {
// sleep 1
// if(env.enableIIS02 == "Y")
// {
// //LAND
// bat "\"${tool 'MSBuild-15.0'}\" \"/p:AspnetMergePath=C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.6.2 Tools\" /p:DeployOnBuild=true /p:Targets=Publish /p:PublishProfile=IIS02.pubxml /p:VisualStudioVersion=14.0 /p:RunCodeAnalysis=false /p:Configuration=Release /p:username=jenkins /p:Password=viadante16 /p:AllowUntrustedCertificate=true /p:OutputPath=bin/ MP-LAND/MP-LAND.csproj"
// // MON
// bat "\"${tool 'MSBuild-15.0'}\" \"/p:AspnetMergePath=C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.6.2 Tools\" /p:DeployOnBuild=true /p:Targets=Publish /p:PublishProfile=IIS02.pubxml /p:VisualStudioVersion=14.0 /p:RunCodeAnalysis=false /p:Configuration=IIS02 /p:username=jenkins /p:Password=viadante16 /p:AllowUntrustedCertificate=true /p:OutputPath=bin/ MP-MON/MP-MON.csproj"
// }
// if(env.enableIIS01 == "Y")
// {
// // LAND
// bat "\"${tool 'MSBuild-15.0'}\" \"/p:AspnetMergePath=C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.6.2 Tools\" /p:DeployOnBuild=true /p:Targets=Publish /p:PublishProfile=IIS01.pubxml /p:VisualStudioVersion=14.0 /p:RunCodeAnalysis=false /p:Configuration=Release /p:username=jenkins /p:Password=viadante16 /p:AllowUntrustedCertificate=true /p:OutputPath=bin/ MP-LAND/MP-LAND.csproj"
// // MON
// bat "\"${tool 'MSBuild-15.0'}\" \"/p:AspnetMergePath=C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.6.2 Tools\" /p:DeployOnBuild=true /p:Targets=Publish /p:PublishProfile=IIS01.pubxml /p:VisualStudioVersion=14.0 /p:RunCodeAnalysis=false /p:Configuration=IIS01 /p:username=jenkins /p:Password=viadante16 /p:AllowUntrustedCertificate=true /p:OutputPath=bin/ MP-MON/MP-MON.csproj"
// }
// },
// SITE_TAB: {
// sleep 0
// if(env.enableIIS01 == "Y")
// {
// // SITE
// bat "\"${tool 'MSBuild-15.0'}\" \"/p:AspnetMergePath=C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.6.2 Tools\" /p:DeployOnBuild=true /p:Targets=Publish /p:PublishProfile=IIS01.pubxml /p:VisualStudioVersion=14.0 /p:RunCodeAnalysis=false /p:Configuration=IIS01 /p:username=jenkins /p:Password=viadante16 /p:AllowUntrustedCertificate=true /p:OutputPath=bin/ MP-SITE/MP-SITE.csproj"
// // TAB
// bat "\"${tool 'MSBuild-15.0'}\" \"/p:AspnetMergePath=C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.6.2 Tools\" /p:DeployOnBuild=true /p:Targets=Publish /p:PublishProfile=IIS01.pubxml /p:VisualStudioVersion=14.0 /p:RunCodeAnalysis=false /p:Configuration=IIS01 /p:username=jenkins /p:Password=viadante16 /p:AllowUntrustedCertificate=true /p:OutputPath=bin/ MP-TAB/MP-TAB.csproj"
// }
// if(env.enableIIS02 == "Y")
// {
// // SITE
// bat "\"${tool 'MSBuild-15.0'}\" \"/p:AspnetMergePath=C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.6.2 Tools\" /p:DeployOnBuild=true /p:Targets=Publish /p:PublishProfile=IIS02.pubxml /p:VisualStudioVersion=14.0 /p:RunCodeAnalysis=false /p:Configuration=IIS02 /p:username=jenkins /p:Password=viadante16 /p:AllowUntrustedCertificate=true /p:OutputPath=bin/ MP-SITE/MP-SITE.csproj"
// // TAB
// bat "\"${tool 'MSBuild-15.0'}\" \"/p:AspnetMergePath=C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.6.2 Tools\" /p:DeployOnBuild=true /p:Targets=Publish /p:PublishProfile=IIS02.pubxml /p:VisualStudioVersion=14.0 /p:RunCodeAnalysis=false /p:Configuration=IIS02 /p:username=jenkins /p:Password=viadante16 /p:AllowUntrustedCertificate=true /p:OutputPath=bin/ MP-TAB/MP-TAB.csproj"
// }
// },
// failFast: false)
// }
// if (env.BRANCH_NAME == "OVH-DEMO") {
// parallel (
// // da fare!!!
// failFast: false)
// }
// else {
// echo 'Nothing to deploy...'
// }
// }
// }
// }
// stage('Installers') {
// // da rivedere: creare branch = versioni LEGACY, STABLE (LTS), INSIDER (ULTIMATE), e NON pubblicare DOCS (ex branch Giancarlo)... impostare filtro?
// agent any
// steps {
// // in primis cambio versione e NuGet
// script {
// // CAMBIO numero versione + checkout NuGet in file sorgente!!!
// bat "fart.exe VersGen\\MoonPro.cs 1.0.0.0 ${env.versionNumber} || EXIT /B 0"
// bat "e:\\nuget.exe restore ${WORKSPACE}\\QR-GEN.sln"
// }
// // ora mi occupo delle operazioni di compressione e copia...
// script {
// /* compilo installers SOLO stable / beta */
// if (env.BRANCH_NAME == "stable" || env.BRANCH_NAME.contains("beta") ) {
// parallel (
// ADM_IO: {
// sleep 2
// // ADM
// bat "\"${tool 'MSBuild-15.0'}\" \"/p:AspnetMergePath=C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.6.2 Tools\" /T:Package /P:Configuration=Prod /p:PublishProfile=${env.BRANCH_NAME}.pubxml /p:VisualStudioVersion=14.0 /p:RunCodeAnalysis=false /p:PackageLocation=ReleaseClienti/${env.BRANCH_NAME}/ADM.zip /p:DeployIisAppPath=\"Default Web Site/MP/ADM\" /p:PackageAsSingleFile=True /p:OutputPath=bin/ MP-ADM/MP-ADM.csproj"
// // pubblico su server deploy!
// publishToDeployServer("MP-ADM\\", "c:\\inetpub\\wwwroot\\SWS\\MAPO\\", "ADM")
// // IO
// bat "\"${tool 'MSBuild-15.0'}\" \"/p:AspnetMergePath=C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.6.2 Tools\" /T:Package /P:Configuration=Prod /p:PublishProfile=${env.BRANCH_NAME}.pubxml /p:VisualStudioVersion=14.0 /p:RunCodeAnalysis=false /p:PackageLocation=ReleaseClienti/${env.BRANCH_NAME}/IO.zip /p:DeployIisAppPath=\"Default Web Site/MP/IO\" /p:PackageAsSingleFile=True /p:OutputPath=bin/ MP-IO/MP-IO.csproj"
// // pubblico su server deploy!
// publishToDeployServer("MP-IO\\", "c:\\inetpub\\wwwroot\\SWS\\MAPO\\", "IO")
// },
// LAND_MON: {
// sleep 1
// // LAND
// bat "\"${tool 'MSBuild-15.0'}\" \"/p:AspnetMergePath=C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.6.2 Tools\" /T:Package /P:Configuration=Prod /p:PublishProfile=${env.BRANCH_NAME}.pubxml /p:VisualStudioVersion=14.0 /p:RunCodeAnalysis=false /p:PackageLocation=ReleaseClienti/${env.BRANCH_NAME}/LAND.zip /p:DeployIisAppPath=\"Default Web Site/MP/LAND\" /p:PackageAsSingleFile=True /p:OutputPath=bin/ MP-LAND/MP-LAND.csproj"
// // pubblico su server deploy!
// publishToDeployServer("MP-LAND\\", "c:\\inetpub\\wwwroot\\SWS\\MAPO\\", "LAND")
// // MON
// bat "\"${tool 'MSBuild-15.0'}\" \"/p:AspnetMergePath=C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.6.2 Tools\" /T:Package /P:Configuration=Prod /p:PublishProfile=${env.BRANCH_NAME}.pubxml /p:VisualStudioVersion=14.0 /p:RunCodeAnalysis=false /p:PackageLocation=ReleaseClienti/${env.BRANCH_NAME}/MON.zip /p:DeployIisAppPath=\"Default Web Site/MP/MON\" /p:PackageAsSingleFile=True /p:OutputPath=bin/ MP-MON/MP-MON.csproj"
// // pubblico su server deploy!
// publishToDeployServer("MP-MON\\", "c:\\inetpub\\wwwroot\\SWS\\MAPO\\", "MON")
// },
// SITE_TAB: {
// sleep 0
// // SITE
// bat "\"${tool 'MSBuild-15.0'}\" \"/p:AspnetMergePath=C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.6.2 Tools\" /T:Package /P:Configuration=Prod /p:PublishProfile=${env.BRANCH_NAME}.pubxml /p:VisualStudioVersion=14.0 /p:RunCodeAnalysis=false /p:PackageLocation=ReleaseClienti/${env.BRANCH_NAME}/SITE.zip /p:DeployIisAppPath=\"Default Web Site/MP/SITE\" /p:PackageAsSingleFile=True /p:OutputPath=bin/ MP-SITE/MP-SITE.csproj"
// // pubblico su server deploy!
// publishToDeployServer("MP-SITE\\", "c:\\inetpub\\wwwroot\\SWS\\MAPO\\", "SITE")
// // TAB
// sleep 2
// bat "\"${tool 'MSBuild-15.0'}\" \"/p:AspnetMergePath=C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.6.2 Tools\" /T:Package /P:Configuration=Prod /p:PublishProfile=${env.BRANCH_NAME}.pubxml /p:VisualStudioVersion=14.0 /p:RunCodeAnalysis=false /p:PackageLocation=ReleaseClienti/${env.BRANCH_NAME}/TAB.zip /p:DeployIisAppPath=\"Default Web Site/MP/TAB\" /p:PackageAsSingleFile=True /p:OutputPath=bin/ MP-TAB/MP-TAB.csproj"
// // pubblico su server deploy!
// publishToDeployServer("MP-TAB\\", "c:\\inetpub\\wwwroot\\SWS\\MAPO\\", "TAB")
// },
// failFast: false)
// }
// else
// {
// echo 'Questo BRANCH non necessita di installer...'
// }
// }
// }
// }
}
post {
success {
@@ -222,29 +46,6 @@ pipeline {
}
}
// // Funzione x pubblicazione su server IIS di deploy
// def publishToDeployServer(prjPath, iisPath, packName) {
// echo "Richiesto esecuzione publishToDeployServer con parametri: " + prjPath + " | " + iisPath + " | " + packName
// // inizio copiando files di base da area VersGen...
// bat "xcopy /y VersGen\\ChangeLog.html " + prjPath + "Resources\\ChangeLog.html "
// bat "xcopy /y VersGen\\logoSteamware.png " + prjPath + "Resources\\logoSteamware.png "
// bat "xcopy /y VersGen\\manifest.xml " + prjPath + "Resources\\manifest.xml "
// // manifest.xml: aggiorno versNumber ed URL del branch di update...
// bat "fart.exe " + prjPath + "Resources\\manifest.xml 1.0.0.0 ${env.versionNumber} || EXIT /B 0"
// bat "fart.exe " + prjPath + "Resources\\manifest.xml {{BRANCHNAME}} ${env.BRANCH_NAME} || EXIT /B 0"
// bat "fart.exe " + prjPath + "Resources\\manifest.xml {{PACKNAME}} " + packName + " || EXIT /B 0"
// bat "fart.exe " + prjPath + "Resources\\ChangeLog.html {{CURRENT-REL}} ${env.versionNumber} || EXIT /B 0"
// writeFile file: prjPath + 'changeLog.log', text: "${getChangeString()}"
// powershell '(Get-Content ' + prjPath + 'Resources\\ChangeLog.html) | ForEach-Object { $_ -replace \"{{LAST-CHANGES}}\", \"${getChangeString()}\" } | Set-Content ' + prjPath + 'Resources\\ChangeLog.html'
// // copio ed esporto in IIS02 i vari files .xml, .html, .zip
// bat "xcopy /y " + prjPath + "Resources\\manifest.xml " + iisPath + packName + "\\${env.BRANCH_NAME}\\ "
// bat "xcopy /y " + prjPath + "Resources\\ChangeLog.html " + iisPath + packName + "\\${env.BRANCH_NAME}\\ "
// bat "xcopy /y " + prjPath + "Resources\\logoSteamware.png " + iisPath + packName + "\\${env.BRANCH_NAME}\\ "
// // salvo copia della versione...
// bat "xcopy /y " + prjPath + "\\ReleaseClienti\\${env.BRANCH_NAME}\\* E:\\Staging\\byProd\\MP\\${env.BRANCH_NAME}\\" + packName + "\\${env.versionNumber}\\ "
// // copio x AutoUpdate deploy
// bat "xcopy /y " + prjPath + "\\ReleaseClienti\\${env.BRANCH_NAME}\\" + packName + ".zip " + iisPath + packName + "\\${env.BRANCH_NAME}\\ "
// }
@NonCPS
// Funzione x recupero changeLog
def getChangeString() {
+94
View File
@@ -0,0 +1,94 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ZXing;
using ZXing.QrCode;
namespace QR_GEN.Controllers
{
public class CodGenController : Controller
{
// GET: CodGen
public ActionResult Index()
{
return View();
}
/// <summary>
/// Restituisce un QR code dato valore
/// </summary>
/// <param name="id"></param>
/// <param name="hSize">Altezza immagine</param>
/// <param name="wSize">Larghezza immagine</param>
/// <returns></returns>
public ActionResult QR(string id, int hSize = 600, int wSize = 600)
{
BarcodeFormat formato = BarcodeFormat.QR_CODE;
return utils.getImage2D(ref id, hSize, wSize, formato);
}
/// <summary>
/// Restituisce un DataMatrix code dato valore
/// </summary>
/// <param name="id"></param>
/// <param name="hSize">Altezza immagine</param>
/// <param name="wSize">Larghezza immagine</param>
/// <returns></returns>
public ActionResult DataMatrix(string id, int hSize = 300, int wSize = 600)
{
BarcodeFormat formato = BarcodeFormat.DATA_MATRIX;
return utils.getImage2D(ref id, hSize, wSize, formato);
}
/// <summary>
/// Restituisce un Aztec code dato valore
/// </summary>
/// <param name="id"></param>
/// <param name="hSize">Altezza immagine</param>
/// <param name="wSize">Larghezza immagine</param>
/// <returns></returns>
public ActionResult Aztec(string id, int hSize = 600, int wSize = 600)
{
BarcodeFormat formato = BarcodeFormat.AZTEC;
return utils.getImage2D(ref id, hSize, wSize, formato);
}
/// <summary>
/// Restituisce un Aztec code dato valore
/// </summary>
/// <param name="id"></param>
/// <param name="hSize">Altezza immagine</param>
/// <param name="wSize">Larghezza immagine</param>
/// <returns></returns>
public ActionResult Pdf417(string id, int hSize = 300, int wSize = 600)
{
BarcodeFormat formato = BarcodeFormat.PDF_417;
return utils.getImage2D(ref id, hSize, wSize, formato);
}
/// <summary>
/// Restituisce un Code39 1D dato valore
/// </summary>
/// <param name="id"></param>
/// <param name="pureBarcode">mostrare valore SOLO come codice (false --> testo sotto)</param>
/// <param name="hSize">Altezza immagine</param>
/// <returns></returns>
public ActionResult code39(string id, bool pureBarcode = false, int hSize = 70)
{
BarcodeFormat formato = BarcodeFormat.CODE_39;
return utils.getImage(id, hSize, formato, pureBarcode);
}
/// <summary>
/// Restituisce un Code128 1D dato valore
/// </summary>
/// <param name="id"></param>
/// <param name="pureBarcode">mostrare valore SOLO come codice (false --> testo sotto)</param>
/// <param name="hSize">Altezza immagine</param>
/// <returns></returns>
public ActionResult Code128(string id, bool pureBarcode = false, int hSize = 70)
{
BarcodeFormat formato = BarcodeFormat.CODE_128;
return utils.getImage(id, hSize, formato, pureBarcode);
}
}
}
-137
View File
@@ -37,67 +37,6 @@ namespace QR_GEN.Controllers
{
return Redirect("https://www.steamware.net");
}
/// <summary>
/// Restituisce un QR code dato valore
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public ActionResult QR(string id)
{
int hSize = 600;
int wSize = 600;
BarcodeFormat formato = BarcodeFormat.QR_CODE;
return getImage2D(ref id, hSize, wSize, formato);
}
/// <summary>
/// Restituisce un DataMatrix code dato valore
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public ActionResult DataMatrix(string id)
{
int hSize = 600;
int wSize = 600;
BarcodeFormat formato = BarcodeFormat.DATA_MATRIX;
return getImage2D(ref id, hSize, wSize, formato);
}
/// <summary>
/// Restituisce un Aztec code dato valore
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public ActionResult Aztec(string id)
{
int hSize = 600;
int wSize = 600;
BarcodeFormat formato = BarcodeFormat.AZTEC;
return getImage2D(ref id, hSize, wSize, formato);
}
/// <summary>
/// Restituisce un Code39 1D dato valore
/// </summary>
/// <param name="id"></param>
/// <param name="pureBarcode">mostrare valore SOLO come codice (false --> testo sotto)</param>
/// <returns></returns>
public ActionResult code39(string id, bool pureBarcode = false)
{
int hSize = 70;
BarcodeFormat formato = BarcodeFormat.CODE_39;
return getImage(id, hSize, formato, pureBarcode);
}
/// <summary>
/// Restituisce un Code128 1D dato valore
/// </summary>
/// <param name="id"></param>
/// <param name="pureBarcode">mostrare valore SOLO come codice (false --> testo sotto)</param>
/// <returns></returns>
public ActionResult Code128(string id, bool pureBarcode = false)
{
int hSize = 70;
BarcodeFormat formato = BarcodeFormat.CODE_128;
return getImage(id, hSize, formato, pureBarcode);
}
/// <summary>
/// Restituisce un QR code dato valore
/// </summary>
@@ -179,81 +118,5 @@ namespace QR_GEN.Controllers
}
/// <summary>
/// Genera immagina barcode richeista secondo dimensioni e formato
/// </summary>
/// <param name="dataStr"></param>
/// <param name="hSize">altezza</param>
/// <param name="formato">formati 1D di ZXing</param>
/// <param name="pureBarcode">indica se SOLO barcode</param>
/// <returns></returns>
private static ActionResult getImage(string dataStr, int hSize, BarcodeFormat formato, bool pureBarcode)
{
// se vuoto steamware...
if (dataStr == null || dataStr == "")
{
dataStr = "www.steamware.net";
}
dataStr = dataStr.ToUpper();
// url decode...
dataStr = HttpUtility.UrlDecode(dataStr);
// creo!
EncodingOptions options = new EncodingOptions
{
Height = hSize,
Margin = 0,
PureBarcode= pureBarcode
};
BarcodeWriter writer = new BarcodeWriter();
writer.Format = formato;
writer.Options = options;
// scrivo bitmap
System.Drawing.Bitmap pixelData = writer.Write(dataStr);
// Return Image
MemoryStream ms = new MemoryStream();
pixelData.Save(ms, ImageFormat.Png);
ms.Position = 0;
return new FileStreamResult(ms, "image/png");
}
/// <summary>
/// Genera immagina barcode richeista secondo dimensioni e formato
/// </summary>
/// <param name="id"></param>
/// <param name="hSize"></param>
/// <param name="wSize"></param>
/// <param name="formato"></param>
/// <returns></returns>
private static ActionResult getImage2D(ref string id, int hSize, int wSize, BarcodeFormat formato)
{
// se vuoto steamware...
if (id == null || id == "")
{
id = "www.steamware.net";
}
id = id.ToUpper();
// url decode...
id = HttpUtility.UrlDecode(id);
// creo!
QrCodeEncodingOptions options = new QrCodeEncodingOptions
{
DisableECI = true,
CharacterSet = "UTF-8",
Width = 600,
Height = 600,
Margin = 0
};
BarcodeWriter writer = new BarcodeWriter();
writer.Format = formato;
writer.Options = options;
// scrivo bitmap
System.Drawing.Bitmap pixelData = writer.Write(id);
// Return Image
MemoryStream ms = new MemoryStream();
pixelData.Save(ms, ImageFormat.Png);
ms.Position = 0;
return new FileStreamResult(ms, "image/png");
}
}
}
+2 -2
View File
@@ -30,5 +30,5 @@ using System.Runtime.InteropServices;
//
// È possibile specificare tutti i valori o lasciare i valori predefiniti per Revisione e Numeri build
// utilizzando l'asterisco (*) come illustrato di seguito:
[assembly: AssemblyVersion("1.1.1812.17")]
[assembly: AssemblyFileVersion("1.1.1812.17")]
[assembly: AssemblyVersion("1.1.2002.27")]
[assembly: AssemblyFileVersion("1.1.2002.27")]
+3 -1
View File
@@ -123,11 +123,13 @@
<Compile Include="App_Start\BundleConfig.cs" />
<Compile Include="App_Start\FilterConfig.cs" />
<Compile Include="App_Start\RouteConfig.cs" />
<Compile Include="Controllers\CodGenController.cs" />
<Compile Include="Controllers\HomeController.cs" />
<Compile Include="Global.asax.cs">
<DependentUpon>Global.asax</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="utils.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Content\bootstrap-grid.css" />
@@ -202,11 +204,11 @@
<Content Include="Scripts\popper.js.map" />
<Content Include="Scripts\popper-utils.min.js.map" />
<Content Include="Scripts\popper-utils.js.map" />
<Content Include="Views\CodGen\Index.cshtml" />
</ItemGroup>
<ItemGroup>
<Folder Include="App_Data\" />
<Folder Include="Models\" />
<Folder Include="Views\Code1D\" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
+55
View File
@@ -0,0 +1,55 @@
@{
ViewBag.Title = "Home Page";
}
@{
string QrTextBox = "www.steamware.net";
if (IsPost)
{
QrTextBox = Request.Form["QrTextBox"];
}
}
<div class="jumbotron">
<h1>Multi-format CODE GENERATOR</h1>
<p class="lead">Generatore Barcode 1D / 2D by Steamware</p>
</div>
<div class="row">
<div class="col-md-4">
<form method="post">
<fieldset>
<h2>Text</h2>
<p>
@Html.TextBox("QrTextBox", @QrTextBox, new { @class = "form-control" })
<input type="submit" value="Submit" class="submit btn btn-block btn-success" />
</p>
</fieldset>
</form>
</div>
<div class="col-md-8 text-center">
<div class="row p-2">
<div class="col">
<h4>QR Code</h4>
<img src="@Url.Action("QR", new { id = System.Net.WebUtility.UrlEncode(@QrTextBox) })" alt="QRImage" class="img-fluid mx-auto d-block" />
</div>
<div class="col">
<h4>DataMatrix</h4>
<img src="@Url.Action("DataMatrix", new { id = System.Net.WebUtility.UrlEncode(@QrTextBox) })" alt="DmtxImage" class="img-fluid mx-auto d-block" />
</div>
<div class="col">
<h4>Aztec</h4>
<img src="@Url.Action("Aztec", new { id = System.Net.WebUtility.UrlEncode(@QrTextBox) })" alt="AztecImage" class="img-fluid mx-auto d-block" />
</div>
</div>
<div class="row p-2">
<div class="col-6">
<h4>Code 39</h4>
<img src="@Url.Action("Code39", new { id = System.Net.WebUtility.UrlEncode(@QrTextBox) })" alt="Code39Image" class="img-fluid mx-auto d-block" />
</div>
<div class="col">
<h4>Code 128</h4>
<img src="@Url.Action("Code128", new { id = System.Net.WebUtility.UrlEncode(@QrTextBox) })" alt="Code128Image" class="img-fluid mx-auto d-block" />
</div>
</div>
</div>
</div>
+31 -15
View File
@@ -15,40 +15,56 @@
</div>
<div class="row">
<div class="col-md-4">
<div class="col-md-12">
<form method="post">
<fieldset>
<h2>Text</h2>
<p>
<div class="row text-center border border-success p-1 rounded mx-0">
<div class="col">
<b>Value</b> &rarr;
</div>
<div class="col">
@Html.TextBox("QrTextBox", @QrTextBox, new { @class = "form-control" })
</div>
<div class="col">
<input type="submit" value="Submit" class="submit btn btn-block btn-success" />
</p>
</fieldset>
</div>
</div>
</form>
</div>
<div class="col-md-8 text-center">
<div class="col-md-12 text-center">
<div class="row p-2">
<div class="col">
<h4>QR Code</h4>
<img src="@Url.Action("QR", new { id = System.Net.WebUtility.UrlEncode(@QrTextBox) })" alt="QRImage" class="img-fluid mx-auto d-block" />
</div>
<div class="col">
<h4>DataMatrix</h4>
<img src="@Url.Action("DataMatrix", new { id = System.Net.WebUtility.UrlEncode(@QrTextBox) })" alt="DmtxImage" class="img-fluid mx-auto d-block" />
<img src="@Url.Action("QR", "CodGen", new { id = System.Net.WebUtility.UrlEncode(@QrTextBox) })" alt="QRImage" class="img-fluid mx-auto d-block" />
</div>
<div class="col">
<h4>Aztec</h4>
<img src="@Url.Action("Aztec", new { id = System.Net.WebUtility.UrlEncode(@QrTextBox) })" alt="AztecImage" class="img-fluid mx-auto d-block" />
<img src="@Url.Action("Aztec", "CodGen", new { id = System.Net.WebUtility.UrlEncode(@QrTextBox) })" alt="AztecImage" class="img-fluid mx-auto d-block" />
</div>
<div class="col">
<h4>DataMatrix</h4>
<img src="@Url.Action("DataMatrix", "CodGen", new { id = System.Net.WebUtility.UrlEncode(@QrTextBox) })" alt="DmtxImage" class="img-fluid mx-auto d-block" />
<h4>Pdf417</h4>
<img src="@Url.Action("Pdf417", "CodGen", new { id = System.Net.WebUtility.UrlEncode(@QrTextBox) })" alt="AztecImage" class="img-fluid mx-auto d-block" />
</div>
</div>
<div class="row p-2">
<div class="col-6">
<h4>Code 39</h4>
<img src="@Url.Action("Code39", new { id = System.Net.WebUtility.UrlEncode(@QrTextBox) })" alt="Code39Image" class="img-fluid mx-auto d-block" />
<img src="@Url.Action("Code39", "CodGen", new { id = System.Net.WebUtility.UrlEncode(@QrTextBox) })" alt="Code39Image" class="img-fluid mx-auto d-block" />
</div>
<div class="col">
<h4>Code 128</h4>
<img src="@Url.Action("Code128", new { id = System.Net.WebUtility.UrlEncode(@QrTextBox) })" alt="Code128Image" class="img-fluid mx-auto d-block" />
<img src="@Url.Action("Code128", "CodGen", new { id = System.Net.WebUtility.UrlEncode(@QrTextBox) })" alt="Code128Image" class="img-fluid mx-auto d-block" />
</div>
</div>
<div class="row p-2">
<div class="col-6">
<h4>Code 39 <sub>(pure code)</sub></h4>
<img src="@Url.Action("Code39", "CodGen", new { id = System.Net.WebUtility.UrlEncode(@QrTextBox), pureBarcode=true })" alt="Code39Image" class="img-fluid mx-auto d-block" />
</div>
<div class="col">
<h4>Code 128 <sub>(pure code)</sub></h4>
<img src="@Url.Action("Code128", "CodGen", new { id = System.Net.WebUtility.UrlEncode(@QrTextBox), pureBarcode=true })" alt="Code128Image" class="img-fluid mx-auto d-block" />
</div>
</div>
</div>
+1 -1
View File
@@ -30,7 +30,7 @@
<footer>
<div class="row">
<div class="col text-left">www.steamware.net</div>
<div class="col text-right">v 0.9.1812.15 &copy; @DateTime.Now.Year</div>
<div class="col text-right">v 1.0.2002.27 &copy; @DateTime.Now.Year</div>
</div>
</footer>
</div>
+96
View File
@@ -0,0 +1,96 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ZXing;
using ZXing.QrCode;
using System.Drawing.Imaging;
using System.IO;
using ZXing.Common;
namespace QR_GEN
{
/// <summary>
/// Utility per Code Generator online
/// </summary>
public class utils
{
/// <summary>
/// Genera immagina barcode richeista secondo dimensioni e formato
/// </summary>
/// <param name="dataStr"></param>
/// <param name="hSize">altezza</param>
/// <param name="formato">formati 1D di ZXing</param>
/// <param name="pureBarcode">indica se SOLO barcode</param>
/// <returns></returns>
public static ActionResult getImage(string dataStr, int hSize, BarcodeFormat formato, bool pureBarcode)
{
// se vuoto steamware...
if (dataStr == null || dataStr == "")
{
dataStr = "www.steamware.net";
}
dataStr = dataStr.ToUpper();
// url decode...
dataStr = HttpUtility.UrlDecode(dataStr);
// creo!
EncodingOptions options = new EncodingOptions
{
Height = hSize,
Margin = 0,
PureBarcode = pureBarcode
};
BarcodeWriter writer = new BarcodeWriter();
writer.Format = formato;
writer.Options = options;
// scrivo bitmap
System.Drawing.Bitmap pixelData = writer.Write(dataStr);
// Return Image
MemoryStream ms = new MemoryStream();
pixelData.Save(ms, ImageFormat.Png);
ms.Position = 0;
return new FileStreamResult(ms, "image/png");
}
/// <summary>
/// Genera immagina barcode richeista secondo dimensioni e formato
/// </summary>
/// <param name="id"></param>
/// <param name="hSize"></param>
/// <param name="wSize"></param>
/// <param name="formato"></param>
/// <returns></returns>
public static ActionResult getImage2D(ref string id, int hSize, int wSize, BarcodeFormat formato)
{
// se vuoto steamware...
if (id == null || id == "")
{
id = "www.steamware.net";
}
id = id.ToUpper();
// url decode...
id = HttpUtility.UrlDecode(id);
// creo!
QrCodeEncodingOptions options = new QrCodeEncodingOptions
{
DisableECI = true,
CharacterSet = "UTF-8",
Width = wSize,
Height = hSize,
Margin = 0
};
BarcodeWriter writer = new BarcodeWriter();
writer.Format = formato;
writer.Options = options;
// scrivo bitmap
System.Drawing.Bitmap pixelData = writer.Write(id);
// Return Image
MemoryStream ms = new MemoryStream();
pixelData.Save(ms, ImageFormat.Png);
ms.Position = 0;
return new FileStreamResult(ms, "image/png");
}
}
}