Merge branch 'feature/MP-CORE-LAND' into develop
This commit is contained in:
+1
-1
@@ -5,7 +5,7 @@ VisualStudioVersion = 16.0.31229.75
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MP.Land", "MP.Land\MP.Land.csproj", "{D949AB45-9B65-4594-A97E-182BC3831707}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MP.AppAuth", "MP.AppAuth\MP.AppAuth.csproj", "{E8B1E617-87BC-4638-A8B6-04EEBA3B8F47}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MP.AppAuth", "MP.AppAuth\MP.AppAuth.csproj", "{E8B1E617-87BC-4638-A8B6-04EEBA3B8F47}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
||||
@@ -58,10 +58,11 @@ namespace MP.AppAuth
|
||||
|
||||
#region Public Properties
|
||||
|
||||
//public virtual DbSet<MacchinaModel> DbSetMacchine { get; set; }
|
||||
//public virtual DbSet<FileModel> DbSetProgFile { get; set; }
|
||||
public virtual DbSet<AnagraficaOperatori> DbSetAnagOpr { get; set; }
|
||||
public virtual DbSet<UpdMan> DbSetUpdMan { get; set; }
|
||||
|
||||
public virtual DbSet<Vocabolario> DbSetVocabolario { get; set; }
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Private Methods
|
||||
@@ -92,6 +93,21 @@ namespace MP.AppAuth
|
||||
{
|
||||
modelBuilder.HasAnnotation("Relational:Collation", "SQL_Latin1_General_CP1_CI_AS");
|
||||
|
||||
modelBuilder.Entity<Vocabolario>(entity =>
|
||||
{
|
||||
entity.HasKey(e => new { e.Lingua, e.Lemma });
|
||||
|
||||
entity.ToTable("Vocabolario");
|
||||
|
||||
entity.Property(e => e.Lingua).HasMaxLength(3);
|
||||
|
||||
entity.Property(e => e.Lemma).HasMaxLength(50);
|
||||
|
||||
entity.Property(e => e.Traduzione)
|
||||
.IsRequired()
|
||||
.HasMaxLength(500);
|
||||
});
|
||||
|
||||
//
|
||||
modelBuilder.Seed();
|
||||
|
||||
|
||||
@@ -31,6 +31,27 @@ namespace MP.AppAuth.Controllers
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public List<Models.AnagraficaOperatori> AnagOpGetAll(string searchVal)
|
||||
{
|
||||
List<Models.AnagraficaOperatori> dbResult = new List<Models.AnagraficaOperatori>();
|
||||
|
||||
if (!string.IsNullOrEmpty(searchVal))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetAnagOpr
|
||||
.Where(x => x.Cognome.Contains(searchVal) || x.Nome.Contains(searchVal))
|
||||
.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetAnagOpr
|
||||
.ToList();
|
||||
}
|
||||
// ritorno
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Clear database context
|
||||
@@ -75,7 +96,21 @@ namespace MP.AppAuth.Controllers
|
||||
|
||||
dbResult = dbCtx
|
||||
.DbSetUpdMan
|
||||
//.Where(x => !string.IsNullOrEmpty(x.AppName))
|
||||
.ToList();
|
||||
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Record x gestione Update
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<Models.Vocabolario> VocabolarioGetAll()
|
||||
{
|
||||
List<Models.Vocabolario> dbResult = new List<Models.Vocabolario>();
|
||||
|
||||
dbResult = dbCtx
|
||||
.DbSetVocabolario
|
||||
.ToList();
|
||||
|
||||
return dbResult;
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MP.AppAuth.Models
|
||||
{
|
||||
public partial class AnagraficaGruppi
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public AnagraficaGruppi()
|
||||
{
|
||||
Gruppi2Macchines = new HashSet<Gruppi2Macchine>();
|
||||
Gruppi2Operatoris = new HashSet<Gruppi2Operatori>();
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public string CodGruppo { get; set; }
|
||||
public string DescrGruppo { get; set; }
|
||||
public virtual ICollection<Gruppi2Macchine> Gruppi2Macchines { get; set; }
|
||||
public virtual ICollection<Gruppi2Operatori> Gruppi2Operatoris { get; set; }
|
||||
public bool SelEnabled { get; set; }
|
||||
public string TipoGruppo { get; set; }
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
}
|
||||
@@ -1,29 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MP.AppAuth.Models
|
||||
{
|
||||
[Table("AnagraficaOperatori")]
|
||||
public partial class AnagraficaOperatori
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public AnagraficaOperatori()
|
||||
{
|
||||
Gruppi2Operatoris = new HashSet<Gruppi2Operatori>();
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public string AuthKey { get; set; }
|
||||
public string CodOprExt { get; set; }
|
||||
public string Cognome { get; set; }
|
||||
public virtual ICollection<Gruppi2Operatori> Gruppi2Operatoris { get; set; }
|
||||
public bool? IsAdmin { get; set; }
|
||||
|
||||
[Key]
|
||||
public int MatrOpr { get; set; }
|
||||
|
||||
public string Nome { get; set; }
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MP.AppAuth.Models
|
||||
{
|
||||
public partial class Gruppi2Macchine
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
public string CodGruppo { get; set; }
|
||||
public virtual AnagraficaGruppi CodGruppoNavigation { get; set; }
|
||||
public string IdxMacchina { get; set; }
|
||||
public virtual Macchine IdxMacchinaNavigation { get; set; }
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MP.AppAuth.Models
|
||||
{
|
||||
public partial class Gruppi2Operatori
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
public string CodGruppo { get; set; }
|
||||
public virtual AnagraficaGruppi CodGruppoNavigation { get; set; }
|
||||
public int MatrOpr { get; set; }
|
||||
public virtual AnagraficaOperatori MatrOprNavigation { get; set; }
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
}
|
||||
@@ -7,22 +7,12 @@ namespace MP.AppAuth.Models
|
||||
{
|
||||
public partial class Macchine
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public Macchine()
|
||||
{
|
||||
Gruppi2Macchines = new HashSet<Gruppi2Macchine>();
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public string CodMacchina { get; set; }
|
||||
public int ColNum { get; set; }
|
||||
public string Css { get; set; }
|
||||
public string Descrizione { get; set; }
|
||||
public virtual ICollection<Gruppi2Macchine> Gruppi2Macchines { get; set; }
|
||||
public string IdxMacchina { get; set; }
|
||||
public string Locazione { get; set; }
|
||||
public string Nome { get; set; }
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace MP.AppAuth.Models
|
||||
public string AppName { get; set; }
|
||||
|
||||
public string AppUrl { get; set; }
|
||||
public bool? IsAuth { get; set; }
|
||||
public bool IsAuth { get; set; } = false;
|
||||
public string LicenseKey { get; set; }
|
||||
public string LocalRepo { get; set; }
|
||||
public string ManifestUrl { get; set; }
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.AppAuth.Models
|
||||
{
|
||||
[Table("Vocabolario")]
|
||||
public partial class Vocabolario
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
public string Lemma { get; set; }
|
||||
public string Lingua { get; set; }
|
||||
public string Traduzione { get; set; }
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,6 @@ namespace MP.AppAuth
|
||||
public virtual DbSet<AnagKeyValue> AnagKeyValues { get; set; }
|
||||
public virtual DbSet<AnagraficaCausaliScarto> AnagraficaCausaliScartos { get; set; }
|
||||
public virtual DbSet<AnagraficaFlussi> AnagraficaFlussis { get; set; }
|
||||
public virtual DbSet<AnagraficaGruppi> AnagraficaGruppis { get; set; }
|
||||
public virtual DbSet<AnagraficaIngressi> AnagraficaIngressis { get; set; }
|
||||
public virtual DbSet<AnagraficaMicroStati> AnagraficaMicroStatis { get; set; }
|
||||
public virtual DbSet<AnagraficaOperatori> AnagraficaOperatoris { get; set; }
|
||||
@@ -37,13 +36,12 @@ namespace MP.AppAuth
|
||||
public virtual DbSet<DatiMacchine> DatiMacchines { get; set; }
|
||||
public virtual DbSet<FamigliaTipoIngressi> FamigliaTipoIngressis { get; set; }
|
||||
public virtual DbSet<FamiglieMacchine> FamiglieMacchines { get; set; }
|
||||
public virtual DbSet<Gruppi2Macchine> Gruppi2Macchines { get; set; }
|
||||
public virtual DbSet<Gruppi2Operatori> Gruppi2Operatoris { get; set; }
|
||||
public virtual DbSet<KeepAlive> KeepAlives { get; set; }
|
||||
public virtual DbSet<LinkMenuJqm> LinkMenuJqms { get; set; }
|
||||
public virtual DbSet<ListValue> ListValues { get; set; }
|
||||
public virtual DbSet<Macchine> Macchines { get; set; }
|
||||
public virtual DbSet<UpdMan> UpdMen { get; set; }
|
||||
public virtual DbSet<UpdMan> UpdMan { get; set; }
|
||||
public virtual DbSet<Vocabolario> Vocabolario { get; set; }
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
@@ -183,28 +181,6 @@ namespace MP.AppAuth
|
||||
entity.Property(e => e.DescrFlux).HasMaxLength(50);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<AnagraficaGruppi>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.CodGruppo);
|
||||
|
||||
entity.ToTable("AnagraficaGruppi");
|
||||
|
||||
entity.Property(e => e.CodGruppo).HasMaxLength(50);
|
||||
|
||||
entity.Property(e => e.DescrGruppo)
|
||||
.IsRequired()
|
||||
.HasMaxLength(250)
|
||||
.HasDefaultValueSql("('')");
|
||||
|
||||
entity.Property(e => e.SelEnabled).HasComment("Indica se sia selezionabile a livello di tendina x inserimento BCode");
|
||||
|
||||
entity.Property(e => e.TipoGruppo)
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasDefaultValueSql("('REPARTO')")
|
||||
.HasComment("tipo gruppo: reparto (es x gestione operatori assegnati), GRUPPO FASE (es macchien che fanno lo stesso tipo di lavoro), ...");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<AnagraficaIngressi>(entity =>
|
||||
{
|
||||
entity.HasKey(e => new { e.IdxFamigliaIngresso, e.ValoreIngresso });
|
||||
@@ -352,50 +328,6 @@ namespace MP.AppAuth
|
||||
.HasComment("Indica se la famiglia macchina prevede UserDataInput ovvero inserimento MANUALE informazioni");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Gruppi2Macchine>(entity =>
|
||||
{
|
||||
entity.HasKey(e => new { e.IdxMacchina, e.CodGruppo });
|
||||
|
||||
entity.ToTable("Gruppi2Macchine");
|
||||
|
||||
entity.Property(e => e.IdxMacchina).HasMaxLength(50);
|
||||
|
||||
entity.Property(e => e.CodGruppo).HasMaxLength(50);
|
||||
|
||||
entity.HasOne(d => d.CodGruppoNavigation)
|
||||
.WithMany(p => p.Gruppi2Macchines)
|
||||
.HasForeignKey(d => d.CodGruppo)
|
||||
.OnDelete(DeleteBehavior.ClientSetNull)
|
||||
.HasConstraintName("FK_Gruppi2Macchine_AnagraficaGruppi");
|
||||
|
||||
entity.HasOne(d => d.IdxMacchinaNavigation)
|
||||
.WithMany(p => p.Gruppi2Macchines)
|
||||
.HasForeignKey(d => d.IdxMacchina)
|
||||
.OnDelete(DeleteBehavior.ClientSetNull)
|
||||
.HasConstraintName("FK_Gruppi2Macchine_Macchine");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Gruppi2Operatori>(entity =>
|
||||
{
|
||||
entity.HasKey(e => new { e.MatrOpr, e.CodGruppo });
|
||||
|
||||
entity.ToTable("Gruppi2Operatori");
|
||||
|
||||
entity.Property(e => e.CodGruppo).HasMaxLength(50);
|
||||
|
||||
entity.HasOne(d => d.CodGruppoNavigation)
|
||||
.WithMany(p => p.Gruppi2Operatoris)
|
||||
.HasForeignKey(d => d.CodGruppo)
|
||||
.OnDelete(DeleteBehavior.ClientSetNull)
|
||||
.HasConstraintName("FK_Gruppi2Operatori_AnagraficaGruppi");
|
||||
|
||||
entity.HasOne(d => d.MatrOprNavigation)
|
||||
.WithMany(p => p.Gruppi2Operatoris)
|
||||
.HasForeignKey(d => d.MatrOpr)
|
||||
.OnDelete(DeleteBehavior.ClientSetNull)
|
||||
.HasConstraintName("FK_Gruppi2Operatori_AnagraficaOperatori");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<KeepAlive>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.IdxMacchina);
|
||||
@@ -518,6 +450,21 @@ namespace MP.AppAuth
|
||||
.HasDefaultValueSql("('')");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Vocabolario>(entity =>
|
||||
{
|
||||
entity.HasKey(e => new { e.Lingua, e.Lemma });
|
||||
|
||||
entity.ToTable("Vocabolario");
|
||||
|
||||
entity.Property(e => e.Lingua).HasMaxLength(3);
|
||||
|
||||
entity.Property(e => e.Lemma).HasMaxLength(50);
|
||||
|
||||
entity.Property(e => e.Traduzione)
|
||||
.IsRequired()
|
||||
.HasMaxLength(500);
|
||||
});
|
||||
|
||||
OnModelCreatingPartial(modelBuilder);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,270 @@
|
||||
using NLog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml;
|
||||
|
||||
namespace MP.AppAuth
|
||||
{
|
||||
/// <summary>
|
||||
/// Object of this class gives you all the details about the update useful in handling the update logic yourself.
|
||||
/// </summary>
|
||||
public class UpdateInfoEventArgs : EventArgs
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// URL of the webpage specifying changes in the new update.
|
||||
/// </summary>
|
||||
public string ChangelogURL { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns newest version of the application available to download.
|
||||
/// </summary>
|
||||
public Version CurrentVersion { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Download URL of the update file.
|
||||
/// </summary>
|
||||
public string DownloadURL { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns version of the application currently installed on the user's PC.
|
||||
/// </summary>
|
||||
public Version InstalledVersion { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// If new update is available then returns true otherwise false.
|
||||
/// </summary>
|
||||
public bool IsUpdateAvailable { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Shows if the update is required or optional.
|
||||
/// </summary>
|
||||
public bool Mandatory { get; set; }
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gestione update applicazioni
|
||||
/// </summary>
|
||||
public class UpdateMan
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected bool doAuth = false;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Public Fields
|
||||
|
||||
/// <summary>
|
||||
/// Init classe
|
||||
/// </summary>
|
||||
public static UpdateMan obj = new UpdateMan();
|
||||
|
||||
#endregion Public Fields
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Init classe
|
||||
/// </summary>
|
||||
public UpdateMan()
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Init classe
|
||||
/// </summary>
|
||||
/// <param name="user"></param>
|
||||
/// <param name="pwd"></param>
|
||||
public UpdateMan(string user, string pwd)
|
||||
{
|
||||
userName = user;
|
||||
passwd = pwd;
|
||||
doAuth = !string.IsNullOrEmpty($"{userName}{passwd}");
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
protected string passwd { get; set; } = "";
|
||||
protected string userName { get; set; } = "";
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Effettua download ultima versione applicativo
|
||||
/// </summary>
|
||||
/// <param name="remoteUrl"></param>
|
||||
/// <param name="localRepo"></param>
|
||||
/// <param name="packName"></param>
|
||||
public long downloadLatest(string remoteUrl, string localRepo, string packName)
|
||||
{
|
||||
long size = 0;
|
||||
// verifico directory
|
||||
if (!Directory.Exists(localRepo))
|
||||
{
|
||||
Directory.CreateDirectory(localRepo);
|
||||
}
|
||||
string localFile = "";
|
||||
string localLast = "";
|
||||
string DownloadURL = "";
|
||||
try
|
||||
{
|
||||
// in primis scarico update info...
|
||||
UpdateInfoEventArgs updateData = getUpdateInfo(remoteUrl);
|
||||
if (updateData.IsUpdateAvailable)
|
||||
{
|
||||
DownloadURL = updateData.DownloadURL;
|
||||
localFile = string.Format(@"{0}\{1}_Build_{2}.zip", localRepo, packName, updateData.CurrentVersion);
|
||||
localLast = string.Format(@"{0}\{1}.zip", localRepo, packName);
|
||||
// scarica file e salva in directory locale...
|
||||
using (var http = new HttpClient())
|
||||
{
|
||||
//var client = new WebClient();
|
||||
//bool doAuth = !string.IsNullOrEmpty($"{userName}{passwd}");
|
||||
if (doAuth)
|
||||
{
|
||||
//client.Credentials = new System.Net.NetworkCredential(userName, passwd);
|
||||
http.DefaultRequestHeaders.Accept.Clear();
|
||||
var byteArray = System.Text.ASCIIEncoding.UTF8.GetBytes($"{userName}:{passwd}");
|
||||
http.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray));
|
||||
}
|
||||
//client.DownloadFile(updateData.DownloadURL, localFile);
|
||||
|
||||
// url da chiamare
|
||||
http.BaseAddress = new Uri(DownloadURL);
|
||||
// lettura
|
||||
var data = http.GetAsync(DownloadURL).Result;
|
||||
using (var myReader = data.Content.ReadAsStreamAsync())
|
||||
{
|
||||
//var myReader = data.Content.ReadAsStreamAsync();
|
||||
if (data.StatusCode != HttpStatusCode.OK)
|
||||
{
|
||||
Log.Info($"Errore in chiamata getUpdateInfo per URL {remoteUrl}: status code: {data.StatusCode}");
|
||||
}
|
||||
else
|
||||
{
|
||||
using (Stream outStream = File.OpenWrite(localFile))
|
||||
{
|
||||
myReader.Result.CopyTo(outStream);
|
||||
}
|
||||
// ora lo copio come latest...
|
||||
File.Copy(localFile, localLast, true);
|
||||
// indico come fatto!
|
||||
var thisFile = new FileInfo(localLast);
|
||||
size = thisFile.Length;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
localFile = string.Format(@"{0}\Error.log", localRepo);
|
||||
// scrivo file in area target...
|
||||
using (StreamWriter sw = File.AppendText(localFile))
|
||||
{
|
||||
sw.WriteLine($"{DateTime.Now:yyyy-MM-dd HH:mm:ss} ATTENZIONE! Installer NON disponibile | {remoteUrl}");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
localFile = string.Format(@"{0}\Error.log", localRepo);
|
||||
// scrivo file in area target...
|
||||
using (StreamWriter sw = File.AppendText(localFile))
|
||||
{
|
||||
sw.WriteLine($"{DateTime.Now:yyyy-MM-dd HH:mm:ss} Errore in fase di download installers{Environment.NewLine}XML: {remoteUrl}{Environment.NewLine}URL: {DownloadURL}");
|
||||
sw.WriteLine(exc.ToString());
|
||||
}
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupera l'ultima versione disponibile
|
||||
/// </summary>
|
||||
/// <param name="remoteUrl"></param>
|
||||
/// <returns></returns>
|
||||
public UpdateInfoEventArgs getUpdateInfo(string remoteUrl)
|
||||
{
|
||||
//bool doAuth = !string.IsNullOrEmpty($"{userName}{passwd}");
|
||||
|
||||
UpdateInfoEventArgs args = new UpdateInfoEventArgs();
|
||||
Version CurrentVersion;
|
||||
bool Mandatory;
|
||||
XmlDocument recXml = new XmlDocument();
|
||||
try
|
||||
{
|
||||
// recupero dati
|
||||
using (var http = new HttpClient())
|
||||
{
|
||||
if (doAuth)
|
||||
{
|
||||
http.DefaultRequestHeaders.Accept.Clear();
|
||||
var byteArray = System.Text.ASCIIEncoding.UTF8.GetBytes($"{userName}:{passwd}");
|
||||
http.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray));
|
||||
}
|
||||
// url da chiamare
|
||||
http.BaseAddress = new Uri(remoteUrl);
|
||||
// lettura
|
||||
var data = http.GetAsync(remoteUrl).Result;
|
||||
var myReader = data.Content.ReadAsStreamAsync();
|
||||
if (data.StatusCode != HttpStatusCode.OK)
|
||||
{
|
||||
Log.Info($"Errore in chiamata getUpdateInfo per URL {remoteUrl}: status code: {data.StatusCode}");
|
||||
}
|
||||
else
|
||||
{
|
||||
recXml.Load(myReader.Result);
|
||||
|
||||
XmlNodeList recData = recXml.SelectNodes("item");
|
||||
if (recData != null)
|
||||
{
|
||||
foreach (XmlNode item in recData)
|
||||
{
|
||||
XmlNode appCastVersion = item.SelectSingleNode("version");
|
||||
Version.TryParse(appCastVersion?.InnerText, out CurrentVersion);
|
||||
args.CurrentVersion = CurrentVersion;
|
||||
XmlNode appCastChangeLog = item.SelectSingleNode("changelog");
|
||||
args.ChangelogURL = appCastChangeLog?.InnerText;
|
||||
XmlNode appCastUrl = item.SelectSingleNode("url");
|
||||
args.DownloadURL = appCastUrl?.InnerText;
|
||||
XmlNode mandatory = item.SelectSingleNode("mandatory");
|
||||
Boolean.TryParse(mandatory?.InnerText, out Mandatory);
|
||||
args.Mandatory = Mandatory;
|
||||
args.IsUpdateAvailable = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Info($"Eccezione in getUpdateInfo:{Environment.NewLine}{exc}");
|
||||
// metto versione = 0 + errore...
|
||||
args.IsUpdateAvailable = false;
|
||||
args.CurrentVersion = new Version("0.0.0.0");
|
||||
}
|
||||
return args;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
<div class="row">
|
||||
<div class="col-4">
|
||||
<button id="btnForceCheck" class="btn btn-primary btn-sm btn-block" @onclick="() => ForceCheck(0)" title="Forza verifica archivio (totale)">
|
||||
<i class="fas fa-sync-alt"></i> Update Completo Archivio <i class="far fa-folder-open"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="col-8 py-2">
|
||||
@if (showProgress)
|
||||
{
|
||||
<div class="progress">
|
||||
<div class="progress-bar progress-bar-striped progress-bar-animated" style="width:@percLoading%;"></div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<div class="col-12 mt-2">
|
||||
@if (ListRecords == null)
|
||||
{
|
||||
<div class="row">
|
||||
<div class="col-4">
|
||||
@if (showProgress)
|
||||
{
|
||||
<div class="col-12 mt-2">
|
||||
<div class="alert alert-primary">
|
||||
@if (setupMessages.Count > 0)
|
||||
{
|
||||
<ul>
|
||||
@foreach (var item in setupMessages)
|
||||
{
|
||||
<li>@item</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<div class="col-8">
|
||||
<LoadingData></LoadingData>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
else if (totalCount == 0)
|
||||
{
|
||||
<div class="alert alert-warning text-center display-4">Nessun record trovato</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
<table class="table table-sm table-striped table-responsive-lg">
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th>Macchina</th>
|
||||
<th>Path</th>
|
||||
<th class="text-right">Tags</th>
|
||||
<th class="text-right">Senza Tag</th>
|
||||
<th class="text-right">Modificati</th>
|
||||
<th class="text-right">Tot File</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var record in ListRecords)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@if (!string.IsNullOrEmpty(record.BasePath))
|
||||
{
|
||||
<button id="btnForceCheck" class="btn btn-warning btn-sm" @onclick="() => ForceCheckMacchina(record.IdxMacchina)" title="Forza verifica Archivio singola macchina">
|
||||
<i class="fas fa-sync-alt"></i>
|
||||
</button>
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
@record.Nome
|
||||
</td>
|
||||
<td>
|
||||
<div class="small">@record.BasePath</div>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
@record.TotalTags
|
||||
</td>
|
||||
<td class="text-right">
|
||||
@record.NoTags
|
||||
</td>
|
||||
<td class="text-right">
|
||||
@record.NumChanged
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<b>
|
||||
@record.TotFile
|
||||
</b>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,133 +0,0 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MP.FileData.DTO;
|
||||
using MP.Land.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.Land.Components
|
||||
{
|
||||
public partial class ArchiveStatus
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private List<ArchiveStatusDTO> ListRecords;
|
||||
|
||||
private int numChecks = 0;
|
||||
|
||||
private int totalCount = 0;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Properties
|
||||
|
||||
private List<string> setupMessages { get; set; } = new List<string>();
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
[Inject]
|
||||
protected FileArchDataService DataService { get; set; }
|
||||
|
||||
protected int percLoading { get; set; } = 0;
|
||||
protected bool showProgress { get; set; } = false;
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private async Task verificaSingola(string idxMacchina, int numDays, int numMacchine)
|
||||
{
|
||||
// recupero elenco macchine
|
||||
percLoading += 100 / numMacchine;
|
||||
numChecks = await DataService.updateMachineArchive(idxMacchina, numDays, true, false);
|
||||
await Task.Delay(1);
|
||||
setupMessages.Add($"{idxMacchina}: {numChecks} files");
|
||||
StateHasChanged();
|
||||
await Task.Delay(1);
|
||||
}
|
||||
|
||||
private async Task verificaTutte(int numDays)
|
||||
{
|
||||
// recupero elenco macchine
|
||||
var listaMacchine = await DataService.MacchineGetAll();
|
||||
int numMacchine = listaMacchine.Count();
|
||||
foreach (var item in listaMacchine.Where(x => !string.IsNullOrEmpty(x.BasePath)).ToList())
|
||||
{
|
||||
await verificaSingola(item.IdxMacchina, numDays, numMacchine);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected async Task ArchiveCheck(int maxHour)
|
||||
{
|
||||
showProgress = true;
|
||||
percLoading = 0;
|
||||
await verificaTutte(maxHour);
|
||||
|
||||
setupMessages.Add($"Effettuata verifica e rilettura di {numChecks} files!");
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
protected async Task ArchiveSingleCheck(string idxMacchina, int maxHour)
|
||||
{
|
||||
showProgress = true;
|
||||
percLoading = 0;
|
||||
await verificaSingola(idxMacchina, maxHour, 2);
|
||||
|
||||
setupMessages.Add($"Effettuata verifica e rilettura di {numChecks} files!");
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
protected async Task ClearMessage()
|
||||
{
|
||||
await Task.Delay(10);
|
||||
setupMessages = new List<string>();
|
||||
}
|
||||
|
||||
protected async Task ForceCheck(int maxHour)
|
||||
{
|
||||
setupMessages.Add("Inizio Analisi Archivio...");
|
||||
ListRecords = null;
|
||||
await Task.Delay(1);
|
||||
await ArchiveCheck(maxHour);
|
||||
await ClearMessage();
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
protected async Task ForceCheckMacchina(string idxMacchina)
|
||||
{
|
||||
setupMessages.Add("Inizio Analisi Archivio...");
|
||||
ListRecords = null;
|
||||
await Task.Delay(1);
|
||||
await ArchiveSingleCheck(idxMacchina, 0);
|
||||
await ClearMessage();
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
ListRecords = null;
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
protected async Task ReloadData()
|
||||
{
|
||||
await Task.Delay(1);
|
||||
numChecks = 0;
|
||||
ListRecords = await DataService.GetArchiveStatus();
|
||||
totalCount = ListRecords.Count;
|
||||
await Task.Delay(1);
|
||||
setupMessages = new List<string>();
|
||||
showProgress = false;
|
||||
percLoading = 0;
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
}
|
||||
}
|
||||
@@ -1,110 +0,0 @@
|
||||
@using MP.FileData.DatabaseModels
|
||||
@using MP.Prog.Data
|
||||
|
||||
@inject FileArchDataService DataService
|
||||
@inject MessageService AppMService
|
||||
|
||||
@if (ArtList == null)
|
||||
{
|
||||
<LoadingData></LoadingData>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text">
|
||||
<span class="fas fa-search" aria-hidden="true"></span>
|
||||
</span>
|
||||
</div>
|
||||
<input type="text" class="form-control form-control-sm" placeholder="Ricerca Articolo" @bind-value="@SearchArt" />
|
||||
<select @bind="@SelCodArt" class="form-control form-control-sm">
|
||||
@if (ArtList != null)
|
||||
{
|
||||
foreach (var item in ArtList)
|
||||
{
|
||||
<option value="@item.CodArticolo">@item.Disegno | @item.DescArticolo [@item.CodArticolo]</option>
|
||||
}
|
||||
}
|
||||
</select>
|
||||
<div class="input-group-append">
|
||||
<button id="searchReset" class="btn btn-sm btn-secondary" @onclick="() => ResetSearchArt()" title="Reset ricerca articolo"><i class="fas fa-ban"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@code {
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<string> searchUpdated { get; set; }
|
||||
[Parameter]
|
||||
public string SelCodArt
|
||||
{
|
||||
get
|
||||
{
|
||||
string answ = "";
|
||||
if (AppMService.File_Filter != null)
|
||||
{
|
||||
answ = AppMService.File_Filter.CodArticolo;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!AppMService.File_Filter.CodArticolo.Equals(value))
|
||||
{
|
||||
AppMService.File_Filter.CodArticolo = value;
|
||||
}
|
||||
reportChange();
|
||||
}
|
||||
}
|
||||
|
||||
private void reportChange()
|
||||
{
|
||||
searchUpdated.InvokeAsync(SelCodArt);
|
||||
}
|
||||
|
||||
protected string _SearchArt;
|
||||
protected string defCodArt = "";
|
||||
protected List<ArticoloModel> ArtList;
|
||||
|
||||
protected string SearchArt
|
||||
{
|
||||
get
|
||||
{
|
||||
return _SearchArt;
|
||||
}
|
||||
set
|
||||
{
|
||||
_SearchArt = value;
|
||||
// se son > 3 char... debounce...
|
||||
if (string.IsNullOrEmpty(value))
|
||||
{
|
||||
_SearchArt = defCodArt;
|
||||
}
|
||||
if (value.Length >= defCodArt.Length)
|
||||
{
|
||||
var pUpd = Task.Run(async () =>
|
||||
{
|
||||
ArtList = await DataService.ArticoliGetFilt(SearchArt);
|
||||
});
|
||||
pUpd.Wait();
|
||||
}
|
||||
}
|
||||
}
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await ReloadAllData();
|
||||
_SearchArt = defCodArt;
|
||||
}
|
||||
|
||||
protected async Task ReloadAllData()
|
||||
{
|
||||
SelCodArt = defCodArt;
|
||||
ArtList = await DataService.ArticoliGetFilt(SearchArt);
|
||||
}
|
||||
|
||||
protected void ResetSearchArt()
|
||||
{
|
||||
SearchArt = defCodArt;
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
<div class="card">
|
||||
<div class="card-header bg-secondary text-light">
|
||||
<div class="row">
|
||||
<div class="col-4">
|
||||
<h5>Dettaglio modifiche</h5>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
@if (_currItem.DiskStatus != FileData.FileState.Ok)
|
||||
{
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<button type="button" class="btn btn-success btn-block" value="Cancel" @onclick="RejectChange">Mantieni Archivio <i class="fas fa-file-download"></i></button>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<button type="button" class="btn btn-danger btn-block" value="Cancel" @onclick="ApproveChange">Accetta Attuale <i class="fas fa-file-upload"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<div class="col-2">
|
||||
@numDiff
|
||||
</div>
|
||||
<div class="col-2 text-right">
|
||||
<button type="button" class="btn btn-primary btn-block" value="Cancel" @onclick="cancelUpdate" title="Chiudi">Chiudi <i class="fas fa-window-close"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body small py-1">
|
||||
<MP.Land.Components.DiffView oldText="@_currItem.FileStringContent" newText="@(CurrFileContent(_currItem.Path))"></MP.Land.Components.DiffView>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,161 +0,0 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.JSInterop;
|
||||
using MP.FileData.DatabaseModels;
|
||||
using MP.Land.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.Land.Components
|
||||
{
|
||||
public partial class FileEditor : ComponentBase
|
||||
{
|
||||
#region Protected Fields
|
||||
|
||||
protected int numDiff = 0;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Public Fields
|
||||
|
||||
public FileModel _currItem = new FileModel();
|
||||
|
||||
#endregion Public Fields
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
[Inject]
|
||||
protected FileArchDataService DataService { get; set; }
|
||||
|
||||
[Inject]
|
||||
protected IJSRuntime JSRuntime { get; set; }
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Public Properties
|
||||
|
||||
[Parameter]
|
||||
public FileModel currItem
|
||||
{
|
||||
get
|
||||
{
|
||||
return _currItem = null;
|
||||
}
|
||||
set
|
||||
{
|
||||
_currItem = value;
|
||||
}
|
||||
}
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<int> DataReset { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<int> DataUpdated { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public List<MacchinaModel> MacList { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public List<TagModel> TagList { get; set; }
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private async Task ApproveChange()
|
||||
{
|
||||
if (!await JSRuntime.InvokeAsync<bool>("confirm", "Sicuro di voler asccettare la modifica del file selezionato generando una nuova revisione?"))
|
||||
return;
|
||||
|
||||
if (_currItem != null)
|
||||
{
|
||||
await DataService.FileApprove(_currItem);
|
||||
await DataUpdated.InvokeAsync(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("File null!");
|
||||
}
|
||||
}
|
||||
|
||||
private async Task cancelUpdate()
|
||||
{
|
||||
await DataReset.InvokeAsync(0);
|
||||
}
|
||||
|
||||
private async Task deleteRecord()
|
||||
{
|
||||
if (!await JSRuntime.InvokeAsync<bool>("confirm", "Sicuro di voler eliminare il file selezionato??"))
|
||||
return;
|
||||
|
||||
if (_currItem != null)
|
||||
{
|
||||
await DataService.FileDelete(_currItem);
|
||||
await DataUpdated.InvokeAsync(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("File null!");
|
||||
}
|
||||
}
|
||||
|
||||
private async Task RejectChange()
|
||||
{
|
||||
if (!await JSRuntime.InvokeAsync<bool>("confirm", "Sicuro di voler eliminare la modifica del file selezionato e sovrascrivere la versione in rete?"))
|
||||
return;
|
||||
|
||||
if (_currItem != null)
|
||||
{
|
||||
await DataService.FileReject(_currItem);
|
||||
await DataUpdated.InvokeAsync(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("File null!");
|
||||
}
|
||||
}
|
||||
|
||||
private async Task saveUpdate()
|
||||
{
|
||||
if (_currItem != null)
|
||||
{
|
||||
await DataService.FileUpdate(_currItem);
|
||||
await DataUpdated.InvokeAsync(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("File null!");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected void diffDoneHandler(int numChanges)
|
||||
{
|
||||
#if false
|
||||
numDiff = numChanges;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public string CurrFileContent(string fullPath)
|
||||
{
|
||||
string answ = "";
|
||||
if (File.Exists(fullPath))
|
||||
{
|
||||
answ = File.ReadAllText(fullPath);
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
@using MP.AppAuth.Models
|
||||
@using MP.Land.Data
|
||||
@using Microsoft.Extensions.Configuration
|
||||
|
||||
@inject IConfiguration Configuration
|
||||
|
||||
@inject AppAuthService DataService
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
@if (authOk())
|
||||
{
|
||||
<a target="_blank" href="@(fullUrl(CurrItem.AppUrl))" class="text-info" title="Apri">
|
||||
<h3 class="mb-0">@CurrItem.AppName <i class="fas fa-link"></i></h3>
|
||||
</a>
|
||||
}
|
||||
else
|
||||
{
|
||||
<del>
|
||||
<h3 class="mb-0 text-secondary">@CurrItem.AppName</h3>
|
||||
</del>
|
||||
}
|
||||
</div>
|
||||
<div class="card-body pb-0">
|
||||
<div class="row">
|
||||
@if (authOk())
|
||||
{
|
||||
<div class="col-3 text-info">
|
||||
<i class="@(traduci($"{CurrItem.AppName}-ICON"))"></i>
|
||||
</div>
|
||||
<div class="col-9" style="overflow-y: auto; height: 8em;">
|
||||
<b>@(traduci($"{CurrItem.AppName}-TITLE"))</b>
|
||||
<ul style="mb-0">
|
||||
@(traduci($"{CurrItem.AppName}-LIST"))
|
||||
</ul>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="col-3 text-secondary">
|
||||
<i class="@(traduci($"{CurrItem.AppName}-ICON"))"></i>
|
||||
</div>
|
||||
<div class="col-9 text-secondary" style="overflow-y: auto; height: 8em;">
|
||||
<b>@(traduci($"{CurrItem.AppName}-TITLE"))</b>
|
||||
<ul style="mb-0">
|
||||
@(traduci($"{CurrItem.AppName}-LIST"))
|
||||
</ul>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer text-danger py-1">
|
||||
@if (authOk())
|
||||
{
|
||||
<span class="text-success">Programma Attivato</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span class="text-danger">Licenza non attivata!</span>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
@code {
|
||||
|
||||
[Parameter]
|
||||
public UpdMan CurrItem { get; set; }
|
||||
|
||||
protected bool authOk()
|
||||
{
|
||||
bool answ = !string.IsNullOrEmpty(CurrItem.LicenseKey);
|
||||
return answ;
|
||||
}
|
||||
|
||||
protected string fullUrl(string relUrl)
|
||||
{
|
||||
return $"{Configuration["BaseUrl"]}{relUrl}";
|
||||
}
|
||||
|
||||
protected MarkupString traduci(string lemma)
|
||||
{
|
||||
MarkupString answ;
|
||||
string rawHtml = DataService.Traduci(lemma, "IT");
|
||||
answ = new MarkupString(rawHtml);
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<div class="row text-center">
|
||||
@if (authOk())
|
||||
{
|
||||
<div class="col-12 mt-2">
|
||||
<h3 class="mb-0">@CurrItem.AppName <i class="fas fa-download"></i></h3>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<button class="btn btn-block btn-outline-secondary" @onclick="() => DownloadPack()">@updArgs.CurrentVersion</button>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
@outMessage
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
@@ -0,0 +1,111 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MP.AppAuth;
|
||||
using MP.AppAuth.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using MP.Land.Data;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace MP.Land.Components
|
||||
{
|
||||
public partial class SingleDownload
|
||||
{
|
||||
#region Protected Fields
|
||||
|
||||
protected string outMessage = "";
|
||||
protected UpdateInfoEventArgs updArgs = new UpdateInfoEventArgs();
|
||||
protected UpdateMan updateManAuth = new UpdateMan("SWDownloader", "viaD@nte16");
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
[Inject]
|
||||
protected IConfiguration Configuration { get; set; }
|
||||
|
||||
[Inject]
|
||||
protected AppAuthService DataService { get; set; }
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Public Properties
|
||||
|
||||
[Parameter]
|
||||
public UpdMan CurrItem { get; set; }
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected bool authOk()
|
||||
{
|
||||
bool answ = !string.IsNullOrEmpty(CurrItem.LicenseKey);
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// effettua download del pacchetto indicato
|
||||
/// </summary>
|
||||
protected void DownloadPack()
|
||||
{
|
||||
long size = 0;
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
if (CurrItem.IsAuth)
|
||||
{
|
||||
size = updateManAuth.downloadLatest(CurrItem.ManifestUrl, localPath(CurrItem.LocalRepo), CurrItem.PackName);
|
||||
}
|
||||
else
|
||||
{
|
||||
size = UpdateMan.obj.downloadLatest(CurrItem.ManifestUrl, localPath(CurrItem.LocalRepo), CurrItem.PackName);
|
||||
}
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
|
||||
if (size > 0)
|
||||
{
|
||||
outMessage = $"Scaricati {(double)size / (1024 * 1024):N2} Mb in {ts.TotalSeconds:N2} s";
|
||||
}
|
||||
else
|
||||
{
|
||||
outMessage = $"Download non riuscito per {CurrItem.AppName}";
|
||||
}
|
||||
}
|
||||
|
||||
protected string fullUrl(string relUrl)
|
||||
{
|
||||
return $"{Configuration["BaseUrl"]}{relUrl}";
|
||||
}
|
||||
|
||||
protected string localPath(string localRepo)
|
||||
{
|
||||
return @$"{Configuration["downloadPath"]}\{localRepo}\{Configuration["appVers"]}"; ;
|
||||
}
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
// Recupero info ADM...
|
||||
if (CurrItem.IsAuth)
|
||||
{
|
||||
updArgs = updateManAuth.getUpdateInfo(CurrItem.ManifestUrl);
|
||||
}
|
||||
else
|
||||
{
|
||||
updArgs = UpdateMan.obj.getUpdateInfo(CurrItem.ManifestUrl);
|
||||
}
|
||||
}
|
||||
|
||||
protected MarkupString traduci(string lemma)
|
||||
{
|
||||
MarkupString answ;
|
||||
string rawHtml = DataService.Traduci(lemma, "IT");
|
||||
answ = new MarkupString(rawHtml);
|
||||
return answ;
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
<div class="modal fade show" id="myModal" style="display:block; background-color: rgba(10,10,10,.8);"
|
||||
aria-modal="true" role="dialog">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">@Title</h4>
|
||||
<button type="button" class="close" @onclick="@ModalCancel">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text">
|
||||
<span class="fas fa-search" aria-hidden="true"></span>
|
||||
</span>
|
||||
</div>
|
||||
<input type="text" class="form-control form-control-sm" placeholder="Ricerca Tag" @bind-value="@SearchTag" />
|
||||
<select @bind="@SelTag" class="form-control form-control-sm">
|
||||
@if (TagList != null)
|
||||
{
|
||||
foreach (var item in TagList)
|
||||
{
|
||||
<option value="@item.ValueField">@item.LabelField</option>
|
||||
}
|
||||
}
|
||||
</select>
|
||||
<div class="input-group-append">
|
||||
<button id="searchReset" class="btn btn-sm btn-secondary" @onclick="() => ResetSearchTag()" title="Reset ricerca articolo"><i class="fas fa-ban"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-primary" @onclick=@ModalOk>OK</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,142 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MP.FileData.DatabaseModels;
|
||||
using MP.Land;
|
||||
using MP.Land.Data;
|
||||
|
||||
namespace MP.Land.Components
|
||||
{
|
||||
public partial class TagSearch
|
||||
{
|
||||
#region Protected Fields
|
||||
|
||||
protected string _SearchTag;
|
||||
protected string defTag = "###";
|
||||
|
||||
protected string LastSelTag = "";
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
[Inject]
|
||||
protected MessageService AppMService { get; set; }
|
||||
|
||||
[Inject]
|
||||
protected FileArchDataService DataService { get; set; }
|
||||
|
||||
protected string SearchTag
|
||||
{
|
||||
get
|
||||
{
|
||||
return _SearchTag;
|
||||
}
|
||||
set
|
||||
{
|
||||
_SearchTag = value;
|
||||
// se son > 3 char... debounce...
|
||||
if (string.IsNullOrEmpty(value))
|
||||
{
|
||||
_SearchTag = defTag;
|
||||
}
|
||||
if (value.Length >= defTag.Length)
|
||||
{
|
||||
var pUpd = Task.Run(async () =>
|
||||
{
|
||||
TagList = await DataService.TagGetSearch(_SearchTag, 50);
|
||||
});
|
||||
pUpd.Wait();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected List<AutocompleteModel> TagList { get; set; } = new List<AutocompleteModel>();
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Public Properties
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<bool> OnClose { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<string> searchUpdated { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string SelTag
|
||||
{
|
||||
get
|
||||
{
|
||||
string answ = "";
|
||||
if (AppMService.File_Filter != null)
|
||||
{
|
||||
answ = AppMService.File_Filter.Tag;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!AppMService.File_Filter.Tag.Equals(value))
|
||||
{
|
||||
AppMService.File_Filter.Tag = value;
|
||||
}
|
||||
reportChange();
|
||||
}
|
||||
}
|
||||
|
||||
[Parameter]
|
||||
public string Text { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string Title { get; set; }
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private Task ModalCancel()
|
||||
{
|
||||
// resetto ricerca
|
||||
SelTag = LastSelTag;
|
||||
return OnClose.InvokeAsync(false);
|
||||
}
|
||||
|
||||
private Task ModalOk()
|
||||
{
|
||||
return OnClose.InvokeAsync(true);
|
||||
}
|
||||
|
||||
private void reportChange()
|
||||
{
|
||||
searchUpdated.InvokeAsync(SelTag);
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
LastSelTag = SelTag;
|
||||
await ReloadAllData();
|
||||
_SearchTag = defTag;
|
||||
}
|
||||
|
||||
protected async Task ReloadAllData()
|
||||
{
|
||||
SelTag = defTag;
|
||||
TagList = await DataService.TagGetSearch(SearchTag, 20);
|
||||
}
|
||||
|
||||
protected async Task ResetSearchTag()
|
||||
{
|
||||
SearchTag = defTag;
|
||||
await Task.Delay(1);
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
@using MP.AppAuth.Models
|
||||
|
||||
@inject IJSRuntime JSRuntime
|
||||
|
||||
<div class="card border-secondary">
|
||||
<div class="card-header py-2 font-weight-bold bg-secondary">
|
||||
<div class="row">
|
||||
<div class="col-4 col-md-4">
|
||||
<div class="badge badge-pill badge-light px-2 py-1">
|
||||
<div class="px-1">
|
||||
<span>EgalWare <img width="24" class="img-fluid" src="img/LogoBluGreen.png" /></span>
|
||||
</div>
|
||||
</div>
|
||||
@*<img src="img/LogoBluGreen.png" class="img-fluid" width="32" /> EgalWare*@
|
||||
</div>
|
||||
<div class="col-8 text-right text-light">
|
||||
<h4 class="py-0 mb-0">@Environment</h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body px-3">
|
||||
<div class="row">
|
||||
<div class="col-6 col-md-4">
|
||||
<div id="qrCodeImg_@(CurrItem.MatrOpr)"></div>
|
||||
</div>
|
||||
<div class="col-6 col-md-8">
|
||||
<h2><b>@CurrItem.Cognome</b> @CurrItem.Nome</h2>
|
||||
matr: @CurrItem.MatrOpr
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer text-muted py-1 bg-secondary">
|
||||
Card login MAPO-TAB
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
|
||||
[Parameter]
|
||||
public AnagraficaOperatori CurrItem { get; set; }
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
await JSRuntime.InvokeVoidAsync("displayQr", $"qrCodeImg_{CurrItem.MatrOpr}", rawCode);
|
||||
}
|
||||
|
||||
[Parameter]
|
||||
public string BaseUrl { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string Environment { get; set; }
|
||||
|
||||
protected string rawCode
|
||||
{
|
||||
get
|
||||
{
|
||||
string answ = "";
|
||||
if (CurrItem != null)
|
||||
{
|
||||
answ = $"{BaseUrl}&MatrOpr={CurrItem.MatrOpr}&UserAuthKey={CurrItem.AuthKey}";
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,8 @@ using NLog;
|
||||
using Microsoft.Extensions.Caching.Distributed;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace MP.Land.Data
|
||||
{
|
||||
@@ -38,6 +40,8 @@ namespace MP.Land.Data
|
||||
/// </summary>
|
||||
private int chSliExp = 5;
|
||||
|
||||
private Dictionary<string, string> Vocabolario = new Dictionary<string, string>();
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Public Fields
|
||||
@@ -90,11 +94,68 @@ namespace MP.Land.Data
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected void CheckVoc()
|
||||
{
|
||||
string cacheKey = ":MP:VOCAB";
|
||||
string rawData;
|
||||
if (Vocabolario.Count == 0)
|
||||
{
|
||||
var redisDataList = distributedCache.Get(cacheKey);
|
||||
if (redisDataList != null)
|
||||
{
|
||||
rawData = Encoding.UTF8.GetString(redisDataList);
|
||||
Vocabolario = JsonConvert.DeserializeObject<Dictionary<string, string>>(rawData);
|
||||
}
|
||||
else
|
||||
{
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
Vocabolario = dbController.VocabolarioGetAll().ToDictionary(x => $"{x.Lingua}#{x.Lemma}", x => x.Traduzione);
|
||||
rawData = JsonConvert.SerializeObject(Vocabolario);
|
||||
redisDataList = Encoding.UTF8.GetBytes(rawData);
|
||||
distributedCache.Set(cacheKey, redisDataList, cacheOptLong);
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"Effettuato rilettura da DB + caching per Vocabolario: {ts.TotalMilliseconds} ms");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public async Task<List<AppAuth.Models.AnagraficaOperatori>> AnagOperList()
|
||||
{
|
||||
List<AppAuth.Models.AnagraficaOperatori> dbResult = new List<AppAuth.Models.AnagraficaOperatori>();
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
dbResult = dbController.AnagOpGetAll("");
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"Effettuata lettura da DB per AnagOperList: {ts.TotalMilliseconds} ms");
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
// Clear database controller
|
||||
dbController.Dispose();
|
||||
}
|
||||
|
||||
public string Traduci(string lemma, string lingua = "IT")
|
||||
{
|
||||
string answ = $"__{lemma}__";
|
||||
string keyReq = $"{lingua}#{lemma}";
|
||||
CheckVoc();
|
||||
// cerco in vocabolario...
|
||||
if (Vocabolario.ContainsKey(keyReq))
|
||||
{
|
||||
answ = Vocabolario[keyReq];
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
public async Task<List<AppAuth.Models.UpdMan>> UpdManList()
|
||||
|
||||
+11
-2
@@ -3,7 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<RootNamespace>MP.Land</RootNamespace>
|
||||
<Version>1.1.2109.1812</Version>
|
||||
<Version>1.1.2109.2019</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -24,6 +24,15 @@
|
||||
<Content Remove="Pages\Setup.razor" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="wwwroot\lib\index.svg" />
|
||||
<None Include="wwwroot\lib\jquery.min.js" />
|
||||
<None Include="wwwroot\lib\LICENSE" />
|
||||
<None Include="wwwroot\lib\qrcode.js" />
|
||||
<None Include="wwwroot\lib\qrcode.min.js" />
|
||||
<None Include="wwwroot\lib\README.md" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DiffMatchPatch" Version="1.0.3" />
|
||||
<PackageReference Include="Majorsoft.Blazor.Components.Debounce" Version="1.5.0" />
|
||||
@@ -31,7 +40,7 @@
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="5.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="5.0.0" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="5.0.2" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
<PackageReference Include="NLog.Web.AspNetCore" Version="4.14.0" />
|
||||
|
||||
@@ -1,208 +0,0 @@
|
||||
@page "/Archive"
|
||||
|
||||
@using MP.Land.Components
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header table-primary">
|
||||
<div class="row">
|
||||
<div class="col-12 col-lg-4">
|
||||
<div class="d-flex">
|
||||
<div class="px-2">
|
||||
<h3>Elenco Programmi</h3>
|
||||
</div>
|
||||
<div class="px-2">
|
||||
<div class="form-group mb-0">
|
||||
<button id="btnForceCheck" class="btn btn-warning btn-sm" @onclick="() => ForceCheck(30)" title="Analisi Modifiche ultimi 30gg">
|
||||
<i class="fas fa-sync-alt"></i> Update (30gg) <i class="far fa-folder-open"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 col-lg-8 text-right">
|
||||
<div class="d-flex flex-row-reverse">
|
||||
<div class="px-2">
|
||||
<div class="form-group mb-0">
|
||||
<button id="btnReset" class="btn btn-info btn-sm" @onclick="() => ResetFilter()" title="Reset Filter"><span class="oi oi-loop-circular"></span></button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="px-2">
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text">
|
||||
<span class="fas fa-industry" aria-hidden="true"></span>
|
||||
</span>
|
||||
</div>
|
||||
<select @bind="@SelIdxMacc" class="form-control form-control-sm">
|
||||
@if (MacList != null)
|
||||
{
|
||||
foreach (var item in MacList)
|
||||
{
|
||||
<option value="@item.IdxMacchina">@item.Descrizione (@item.RuleName)</option>
|
||||
}
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="px-2">
|
||||
<div class="input-group input-group-sm">
|
||||
<div class="custom-control custom-switch">
|
||||
<input type="checkbox" class="custom-control-input" id="togModificati" title="Solo Aperti / Mostra tutti" @bind-value="@OnlyMod" checked="@OnlyMod" />
|
||||
<label class="custom-control-label" for="togModificati"><sub>Mod</sub></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="px-2">
|
||||
<div class="input-group input-group-sm">
|
||||
<div class="custom-control custom-switch">
|
||||
<input type="checkbox" class="custom-control-input" id="togAttivi" title="Solo Attivi / Mostra tutti" @bind-value="@OnlyActive" checked="@OnlyActive" />
|
||||
<label class="custom-control-label" for="togAttivi"><sub>Attivi</sub></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="px-2">
|
||||
<div class="input-group input-group-sm">
|
||||
<div class="custom-control custom-switch">
|
||||
<input type="checkbox" class="custom-control-input" id="togNoTag" title="Solo senza Tag / Mostra tutti" @bind-value="@OnlyNoTag" checked="@OnlyNoTag" />
|
||||
<label class="custom-control-label" for="togNoTag"><sub>No Tag</sub></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="px-2">
|
||||
@if (!string.IsNullOrEmpty(SelFileName))
|
||||
{
|
||||
<span class="badge badge-secondary">@SelFileName</span>
|
||||
}
|
||||
</div>
|
||||
<div class="px-2">
|
||||
<div class="input-group input-group-sm">
|
||||
<div class="input-group-prepend">
|
||||
<button type="button" class="btn btn-sm btn-primary" @onclick="() => OpenDialog()" title="Aggiunta Tag">
|
||||
<i class="fas fa-search"></i>
|
||||
</button>
|
||||
<span class="input-group-text">Tags</span>
|
||||
</div>
|
||||
<div class="form-control form-control-sm">
|
||||
@if (!string.IsNullOrEmpty(SelTag))
|
||||
{
|
||||
<span class="badge badge-info">@SelTag</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span> ... </span>
|
||||
}
|
||||
</div>
|
||||
<div class="input-group-append">
|
||||
<button type="button" class="btn btn-sm btn-secondary" @onclick="() => ResetTag()" title="Reset Tag">
|
||||
<i class="fas fa-sync"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@if (DeleteDialogOpen)
|
||||
{
|
||||
<MP.Land.Components.TagSearch Title="Ricerca Tag" OnClose="@OnDialogClose"></MP.Land.Components.TagSearch>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body p-1">
|
||||
@if (currRecord != null)
|
||||
{
|
||||
<FileEditor currItem="@currRecord" DataReset="ResetData" DataUpdated="UpdateData" TagList="@TagList" MacList="@MacList"></FileEditor>
|
||||
}
|
||||
@if (ListRecords == null)
|
||||
{
|
||||
<LoadingData></LoadingData>
|
||||
}
|
||||
else if (totalCount == 0)
|
||||
{
|
||||
<div class="alert alert-warning text-center display-4">Nessun record trovato</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<table class="table table-sm table-striped table-responsive-lg">
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th>File</th>
|
||||
<th>Rev</th>
|
||||
<th>Size</th>
|
||||
<th class="text-center">State</th>
|
||||
<th>Macchina</th>
|
||||
<th>Tags</th>
|
||||
<th class="text-right">Modificato</th>
|
||||
@*<th>Controllo</th>*@
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var record in ListRecords)
|
||||
{
|
||||
<tr class="@checkSelect(record.FileId)">
|
||||
<td class="text-nowrap">
|
||||
@if (currRecord == null && record.Active)
|
||||
{
|
||||
<button class="btn btn-sm btn-info" @onclick="() => Edit(record)" title="Edit record #@record.FileId">
|
||||
<i class="oi oi-pencil"></i>
|
||||
</button>
|
||||
}
|
||||
else
|
||||
{
|
||||
<button class="btn btn-sm btn-secondary disabled">
|
||||
<i class="oi oi-pencil"></i>
|
||||
</button>
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
<div class="@(cssActive(record.Active))">
|
||||
<div>@record.Name</div>
|
||||
<button class="btn btn-sm btn-outline-secondary px-1 py-0" @onclick="() => FilterPath(record.Path)" title="Filtra per FilePath">
|
||||
<div class="small">@record.Path</div>
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div>@record.Rev</div>
|
||||
</td>
|
||||
<td>
|
||||
<div>@((((double)record.Size)/1024).ToString("N2")) k</div>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<span title="@record.DiskStatus | Ultimo controllo: @record.LastCheck.ToString(" yyyy.MM.dd HH:mm:ss")">
|
||||
<span class="@(cssStatusByCod(record.DiskStatus))">
|
||||
@record.DiskStatus
|
||||
</span>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<div>@record.Macchina.Nome</div>
|
||||
<div class="small">@record.Macchina.Descrizione</div>
|
||||
</td>
|
||||
<td>
|
||||
@foreach (var item in record.Tags)
|
||||
{
|
||||
<button class="btn btn-sm btn-outline-info px-1 py-0 mr-1" @onclick="() => FilterTag(item.TagId)" title="Filtra Tag">
|
||||
<div class="small">@item.TagId</div>
|
||||
</button>
|
||||
}
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<div>@record.LastMod.ToString("yyyy.MM.dd")</div>
|
||||
<div class="small">@record.LastMod.ToString("ddd HH:mm.ss")</div>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<div class="card-footer p-1">
|
||||
<DataPager PageSize="numRecord" currPage="currPage" numRecordChanged="PagerReloadNum" numPageChanged="PagerReloadPage" totalCount="totalCount" showLoading="isLoading" />
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,523 +0,0 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.JSInterop;
|
||||
using MP.FileData.DatabaseModels;
|
||||
using MP.Land.Data;
|
||||
using NLog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.Land.Pages
|
||||
{
|
||||
public partial class Archive : ComponentBase, IDisposable
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
||||
private FileModel currRecord = null;
|
||||
private List<FileModel> ListRecords;
|
||||
private List<MacchinaModel> MacList;
|
||||
private List<TagModel> TagList;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected string _SearchTag;
|
||||
|
||||
protected string defTag = "";
|
||||
|
||||
protected int totalCount = 0;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Private Properties
|
||||
|
||||
private int currPage
|
||||
{
|
||||
get
|
||||
{
|
||||
return AppMService.File_Filter.PageNum;
|
||||
}
|
||||
set
|
||||
{
|
||||
AppMService.File_Filter.PageNum = value;
|
||||
}
|
||||
}
|
||||
|
||||
private bool isLoading { get; set; } = false;
|
||||
|
||||
private int numRecord
|
||||
{
|
||||
get
|
||||
{
|
||||
return AppMService.File_Filter.PageSize;
|
||||
}
|
||||
set
|
||||
{
|
||||
AppMService.File_Filter.PageSize = value;
|
||||
}
|
||||
}
|
||||
|
||||
private bool OnlyActive
|
||||
{
|
||||
get
|
||||
{
|
||||
bool answ = false;
|
||||
if (AppMService.File_Filter != null)
|
||||
{
|
||||
answ = AppMService.File_Filter.OnlyActive;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!AppMService.File_Filter.OnlyActive.Equals(value))
|
||||
{
|
||||
AppMService.File_Filter.OnlyActive = value;
|
||||
var pUpd = Task.Run(async () =>
|
||||
{
|
||||
await AsyncReload();
|
||||
});
|
||||
pUpd.Wait();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool OnlyMod
|
||||
{
|
||||
get
|
||||
{
|
||||
bool answ = false;
|
||||
if (AppMService.File_Filter != null)
|
||||
{
|
||||
answ = AppMService.File_Filter.OnlyMod;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!AppMService.File_Filter.OnlyMod.Equals(value))
|
||||
{
|
||||
AppMService.File_Filter.OnlyMod = value;
|
||||
var pUpd = Task.Run(async () =>
|
||||
{
|
||||
await AsyncReload();
|
||||
});
|
||||
pUpd.Wait();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool OnlyNoTag
|
||||
{
|
||||
get
|
||||
{
|
||||
bool answ = false;
|
||||
if (AppMService.File_Filter != null)
|
||||
{
|
||||
answ = AppMService.File_Filter.OnlyNoTag;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!AppMService.File_Filter.OnlyNoTag.Equals(value))
|
||||
{
|
||||
AppMService.File_Filter.OnlyNoTag = value;
|
||||
var pUpd = Task.Run(async () =>
|
||||
{
|
||||
await AsyncReload();
|
||||
});
|
||||
pUpd.Wait();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string SearchVal
|
||||
{
|
||||
get
|
||||
{
|
||||
string answ = "";
|
||||
if (AppMService.File_Filter != null)
|
||||
{
|
||||
answ = AppMService.File_Filter.SearchVal;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!AppMService.File_Filter.SearchVal.Equals(value))
|
||||
{
|
||||
AppMService.File_Filter.SearchVal = value;
|
||||
var pUpd = Task.Run(async () =>
|
||||
{
|
||||
await AsyncReload();
|
||||
});
|
||||
pUpd.Wait();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string SelFileName
|
||||
{
|
||||
get
|
||||
{
|
||||
string answ = "";
|
||||
if (AppMService.File_Filter != null)
|
||||
{
|
||||
answ = AppMService.File_Filter.FileName;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!AppMService.File_Filter.FileName.Equals(value))
|
||||
{
|
||||
AppMService.File_Filter.FileName = value;
|
||||
var pUpd = Task.Run(async () =>
|
||||
{
|
||||
await AsyncReload();
|
||||
});
|
||||
pUpd.Wait();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string SelIdxMacc
|
||||
{
|
||||
get
|
||||
{
|
||||
string answ = "";
|
||||
if (AppMService.File_Filter != null)
|
||||
{
|
||||
answ = AppMService.File_Filter.IdxMacchina;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!AppMService.File_Filter.IdxMacchina.Equals(value))
|
||||
{
|
||||
AppMService.File_Filter.IdxMacchina = value;
|
||||
var pUpd = Task.Run(async () =>
|
||||
{
|
||||
await AsyncReload();
|
||||
});
|
||||
pUpd.Wait();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string SelTag
|
||||
{
|
||||
get
|
||||
{
|
||||
string answ = "";
|
||||
if (AppMService.File_Filter != null)
|
||||
{
|
||||
answ = AppMService.File_Filter.Tag;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!AppMService.File_Filter.Tag.Equals(value))
|
||||
{
|
||||
AppMService.File_Filter.Tag = value;
|
||||
var pUpd = Task.Run(async () =>
|
||||
{
|
||||
await AsyncReload();
|
||||
});
|
||||
pUpd.Wait();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
[Inject]
|
||||
protected MessageService AppMService { get; set; }
|
||||
|
||||
[Inject]
|
||||
protected FileArchDataService DataService { get; set; }
|
||||
|
||||
[Inject]
|
||||
protected IJSRuntime JSRuntime { get; set; }
|
||||
|
||||
[Inject]
|
||||
protected NavigationManager NavManager { get; set; }
|
||||
|
||||
protected string SearchTag
|
||||
{
|
||||
get
|
||||
{
|
||||
return _SearchTag;
|
||||
}
|
||||
set
|
||||
{
|
||||
_SearchTag = value;
|
||||
// se son > 3 char... debounce...
|
||||
if (string.IsNullOrEmpty(value))
|
||||
{
|
||||
_SearchTag = defTag;
|
||||
}
|
||||
if (value.Length >= defTag.Length)
|
||||
{
|
||||
var pUpd = Task.Run(async () =>
|
||||
{
|
||||
TagList = await DataService.TagGetFilt(SearchTag);
|
||||
});
|
||||
pUpd.Wait();
|
||||
}
|
||||
isLoading = false;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public bool DeleteDialogOpen { get; set; }
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private string cssActive(bool active)
|
||||
{
|
||||
string answ = active ? "text-dark" : "text-secondary textStriked";
|
||||
return answ;
|
||||
}
|
||||
|
||||
private string cssStatusByCod(FileData.FileState currStatus)
|
||||
{
|
||||
string answ = "badge";
|
||||
switch (currStatus)
|
||||
{
|
||||
case FileData.FileState.Changed:
|
||||
answ += " badge-warning";
|
||||
break;
|
||||
|
||||
case FileData.FileState.Deleted:
|
||||
answ += " badge-danger";
|
||||
break;
|
||||
|
||||
case FileData.FileState.Ok:
|
||||
answ += " badge-success";
|
||||
break;
|
||||
|
||||
case FileData.FileState.ND:
|
||||
default:
|
||||
answ += " badge-light";
|
||||
break;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
private async Task OnDialogClose(bool accepted)
|
||||
{
|
||||
DeleteDialogOpen = false;
|
||||
currPage = 1;
|
||||
await AsyncReload();
|
||||
//StateHasChanged();
|
||||
}
|
||||
|
||||
private void OpenDialog()
|
||||
{
|
||||
DeleteDialogOpen = true;
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected async Task AsyncReload()
|
||||
{
|
||||
isLoading = true;
|
||||
currRecord = null;
|
||||
ListRecords = null;
|
||||
await ReloadData();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
protected void Edit(FileModel selRecord)
|
||||
{
|
||||
// rileggo dal DB il record corrente...
|
||||
var pUpd = Task.Run(async () => currRecord = await DataService.FileGetByKey(selRecord.FileId));
|
||||
pUpd.Wait();
|
||||
}
|
||||
|
||||
protected async Task FilterPath(string searchVal)
|
||||
{
|
||||
SelFileName = searchVal;
|
||||
OnlyActive = false;
|
||||
await ReloadAllData();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
protected async Task FilterTag(string searchVal)
|
||||
{
|
||||
SelTag = searchVal;
|
||||
await ReloadAllData();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
protected async Task ForceCheck(int numDays)
|
||||
{
|
||||
currRecord = null;
|
||||
ListRecords = null;
|
||||
// importante altrimenti NON mostra update UI
|
||||
await Task.Delay(1);
|
||||
//AppMService.File_Filter = SelectData.Init(5, 10);
|
||||
var numCheck = await DataService.updateAllArchive(numDays, false);
|
||||
await ReloadAllData();
|
||||
await Task.Delay(1);
|
||||
await RefreshDisplayLoading();
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
SearchTag = defTag;
|
||||
AppMService.ShowSearch = true;
|
||||
AppMService.PageName = "Archivio File Programmi";
|
||||
AppMService.PageIcon = "fas fa-folder pr-2";
|
||||
AppMService.EA_SearchUpdated += OnSeachUpdated;
|
||||
AppMService.EA_FilterUpdated += OnFilterUpdated;
|
||||
await ReloadAllData();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
protected async Task PagerReloadNum(int newNum)
|
||||
{
|
||||
numRecord = newNum;
|
||||
await ReloadData();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
protected async Task PagerReloadPage(int newNum)
|
||||
{
|
||||
currPage = newNum;
|
||||
await ReloadData();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
protected async Task RefreshDisplayLoading()
|
||||
{
|
||||
await Task.Delay(1);
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
protected async Task ReloadAllData()
|
||||
{
|
||||
isLoading = true;
|
||||
MacList = await DataService.MacchineGetAll();
|
||||
SelIdxMacc = "0";
|
||||
SearchTag = defTag;
|
||||
TagList = await DataService.TagGetFilt(SearchTag);
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
protected async Task ReloadData()
|
||||
{
|
||||
isLoading = true;
|
||||
// importante altrimenti NON mostra update UI
|
||||
await Task.Delay(1);
|
||||
totalCount = await DataService.FileCountFilt(AppMService.File_Filter);
|
||||
//SearchRecords = await DataService.FileGetFilt(AppMService.File_Filter);
|
||||
//// faccio paginazione SOLO NELLA DECINA attuale... (quindi non tutte le pagine ma solo subset)
|
||||
//ListRecords = SearchRecords.Skip(numRecord * (currPage % 10 - 1)).Take(numRecord).ToList();
|
||||
|
||||
ListRecords = await DataService.FileGetFilt(AppMService.File_Filter);
|
||||
await Task.Delay(1);
|
||||
}
|
||||
|
||||
protected void ResetData()
|
||||
{
|
||||
DataService.rollBackEdit(currRecord);
|
||||
currRecord = null;
|
||||
}
|
||||
|
||||
protected async Task ResetFilter()
|
||||
{
|
||||
currRecord = null;
|
||||
ListRecords = null;
|
||||
AppMService.File_Filter = SelectData.Init(5, 10);
|
||||
AppMService.SearchVal = "";
|
||||
SearchTag = defTag;
|
||||
await ReloadAllData();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
protected void ResetSearchTag()
|
||||
{
|
||||
SearchTag = defTag;
|
||||
}
|
||||
|
||||
protected void Select(FileModel selRecord)
|
||||
{
|
||||
// applico filtro da selezione
|
||||
currRecord = selRecord;
|
||||
}
|
||||
|
||||
protected async Task UpdateData()
|
||||
{
|
||||
currRecord = null;
|
||||
ListRecords = null;
|
||||
DataService.ResetController();
|
||||
await ReloadData();
|
||||
await Task.Delay(1);
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public string checkSelect(int FileId)
|
||||
{
|
||||
string answ = "";
|
||||
if (currRecord != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
answ = (currRecord.FileId == FileId) ? "table-info" : "";
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
AppMService.EA_SearchUpdated -= OnSeachUpdated;
|
||||
AppMService.EA_FilterUpdated -= OnFilterUpdated;
|
||||
}
|
||||
|
||||
public async void OnFilterUpdated()
|
||||
{
|
||||
await ReloadData();
|
||||
//StateHasChanged();
|
||||
}
|
||||
|
||||
public async void OnSeachUpdated()
|
||||
{
|
||||
SearchVal = AppMService.SearchVal;
|
||||
//await ReloadData();
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
public void ResetTag()
|
||||
{
|
||||
SelTag = "";
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
+19
-31
@@ -3,27 +3,28 @@
|
||||
@using MP.Land.Data
|
||||
@using MP.Land.Components
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<div class="row">
|
||||
<div class="col-12 col-md-9">
|
||||
<h1>MAPO Land</h1>
|
||||
<div>
|
||||
Pannello di gestione della <a href="https://steamware.net/prodotti/iot/" target="_blank">suite MAPO MES</a>: l'integrazione di MES + SCADA + IOT + Gestione Commesse
|
||||
</div>
|
||||
<div class="alert alert-secondary">
|
||||
<div class="row">
|
||||
<div class="col-12 col-md-9">
|
||||
<h1>MAPO Land</h1>
|
||||
<div>
|
||||
Pannello di gestione della <a href="https://steamware.net/prodotti/iot/" target="_blank">suite MAPO MES</a>: l'integrazione di MES + SCADA + IOT + Gestione Commesse
|
||||
</div>
|
||||
<div class="col-12 col-md-3 text-center">
|
||||
<div class="h2">
|
||||
MES Suite
|
||||
</div>
|
||||
<div class="badge badge-pill badge-dark px-4 py-2">
|
||||
<div class="px-1">
|
||||
<a class="text-light" href="https://www.egalware.com/" target="_blank">powered by EgalWare <img width="24" class="img-fluid" src="img/LogoBlu.svg" /></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 col-md-3 text-center">
|
||||
<div class="h2">
|
||||
MES Suite
|
||||
</div>
|
||||
<div class="badge badge-pill badge-dark px-4 py-2">
|
||||
<div class="px-1">
|
||||
<a class="text-light" href="https://www.egalware.com/" target="_blank">powered by EgalWare <img width="24" class="img-fluid" src="img/LogoBluGreen.png" /></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
@if (ListRecords == null)
|
||||
{
|
||||
@@ -38,21 +39,8 @@
|
||||
<div class="row">
|
||||
@foreach (var item in ListRecords)
|
||||
{
|
||||
<div class="col-3 mb-3">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h3>@item.AppName</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
detttagli
|
||||
</div>
|
||||
@if (string.IsNullOrEmpty(item.LicenseKey))
|
||||
{
|
||||
<div class="card-footer text-danger py-1">
|
||||
Licenza non attivata!
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<div class="col-4 mb-2">
|
||||
<HomeLink CurrItem="@item"></HomeLink>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
@@ -5,6 +5,8 @@ using System.Threading.Tasks;
|
||||
using MP.Land.Data;
|
||||
using MP.Land.Components;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using MP.AppAuth.Models;
|
||||
|
||||
namespace MP.Land.Pages
|
||||
{
|
||||
@@ -22,12 +24,6 @@ namespace MP.Land.Pages
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Private Properties
|
||||
|
||||
private bool isLoading { get; set; } = false;
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
[Inject]
|
||||
@@ -45,8 +41,6 @@ namespace MP.Land.Pages
|
||||
AppMService.ShowSearch = false;
|
||||
AppMService.PageName = "Home";
|
||||
AppMService.PageIcon = "fas fa-home pr-2";
|
||||
//AppMService.EA_SearchUpdated += OnSeachUpdated;
|
||||
//AppMService.EA_FilterUpdated += OnFilterUpdated;
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
@@ -56,14 +50,11 @@ namespace MP.Land.Pages
|
||||
|
||||
protected async Task ReloadAllData()
|
||||
{
|
||||
isLoading = true;
|
||||
//MacList = await DataService.MacchineGetAll();
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
protected async Task ReloadData()
|
||||
{
|
||||
isLoading = true;
|
||||
// importante altrimenti NON mostra update UI
|
||||
await Task.Delay(1);
|
||||
ListRecords = await DataService.UpdManList();
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
@page "/Setup"
|
||||
|
||||
@using MP.Land.Data
|
||||
@using System.Text
|
||||
@using DiffMatchPatch
|
||||
|
||||
@inject MessageService AppMService
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h4>Setup</h4>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<MP.Land.Components.ArchiveStatus></MP.Land.Components.ArchiveStatus>
|
||||
</div>
|
||||
@*<div class="card-footer">Footer</div>*@
|
||||
</div>
|
||||
@@ -1,21 +0,0 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MP.Land.Data;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.Land.Pages
|
||||
{
|
||||
public partial class Setup : ComponentBase
|
||||
{
|
||||
#region Protected Methods
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
AppMService.ShowSearch = false;
|
||||
AppMService.PageName = "Setup";
|
||||
AppMService.PageIcon = "fas fa-wrench pr-2";
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
@page "/UpdateManager"
|
||||
|
||||
@using MP.Land.Data
|
||||
@using MP.Land.Components
|
||||
|
||||
<div class="alert alert-secondary">
|
||||
<div class="row">
|
||||
<div class="col-12 col-md-3">
|
||||
<img src="img/LogoMapoFull.png" class="img-fluid" width="200" />
|
||||
</div>
|
||||
<div class="col-12 col-md-6 text-center">
|
||||
<h1>Aggiornamento Moduli</h1>
|
||||
<div>
|
||||
<b>Ultime release applicazioni</b>
|
||||
</div>
|
||||
<p>Scaricare uno o più pacchetti selezionando dall'elenco riportato.</p>
|
||||
</div>
|
||||
<div class="col-12 col-md-3 text-center">
|
||||
<div class="h2">
|
||||
ALL Packages <i class="fas fa-download"></i>
|
||||
</div>
|
||||
<button class="btn btn-success btn-block">Download ALL Latest</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
@if (ListRecords == null)
|
||||
{
|
||||
<LoadingData></LoadingData>
|
||||
}
|
||||
else if (totalCount == 0)
|
||||
{
|
||||
<div class="alert alert-warning text-center display-4">Nessun record trovato</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="row">
|
||||
@foreach (var item in ListRecords)
|
||||
{
|
||||
<div class="col-4 mb-2">
|
||||
<SingleDownload CurrItem="@item"></SingleDownload>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,64 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MP.Land.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.Land.Pages
|
||||
{
|
||||
public partial class UpdateManager
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private List<MP.AppAuth.Models.UpdMan> ListRecords;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected int totalCount = 0;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
[Inject]
|
||||
protected MessageService AppMService { get; set; }
|
||||
|
||||
[Inject]
|
||||
protected AppAuthService DataService { get; set; }
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
AppMService.ShowSearch = false;
|
||||
AppMService.PageName = "Update Manager";
|
||||
AppMService.PageIcon = "fas fa-download pr-2";
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await ReloadAllData();
|
||||
}
|
||||
|
||||
protected async Task ReloadAllData()
|
||||
{
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
protected async Task ReloadData()
|
||||
{
|
||||
// importante altrimenti NON mostra update UI
|
||||
await Task.Delay(1);
|
||||
ListRecords = await DataService.UpdManList();
|
||||
totalCount = ListRecords.Count();
|
||||
await Task.Delay(1);
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
@page "/UserQr"
|
||||
|
||||
@using MP.Land.Data
|
||||
@using MP.Land.Components
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
@if (ListRecords == null)
|
||||
{
|
||||
<LoadingData></LoadingData>
|
||||
}
|
||||
else if (totalCount == 0)
|
||||
{
|
||||
<div class="alert alert-warning text-center display-4">Nessun record trovato</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="row">
|
||||
@foreach (var item in ListRecords)
|
||||
{
|
||||
<div class="col-6 my-2 userCard">
|
||||
<UserCard CurrItem="@item" BaseUrl="@BaseUrl" Environment="@Environment"></UserCard>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,101 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using MP.AppAuth.Models;
|
||||
using MP.Land.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.Land.Pages
|
||||
{
|
||||
public partial class UserQr
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private List<AnagraficaOperatori> ListRecords;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected string CardMessage = "User Card";
|
||||
protected int totalCount = 0;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Private Properties
|
||||
|
||||
[Inject]
|
||||
private IConfiguration Configuration { get; set; }
|
||||
|
||||
private bool isLoading { get; set; } = false;
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
[Inject]
|
||||
protected MessageService AppMService { get; set; }
|
||||
|
||||
protected string BaseUrl
|
||||
{
|
||||
get => Configuration["BaseUrl"];
|
||||
}
|
||||
|
||||
[Inject]
|
||||
protected AppAuthService DataService { get; set; }
|
||||
|
||||
protected string Environment
|
||||
{
|
||||
get => Configuration["Environment"];
|
||||
}
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
AppMService.ShowSearch = false;
|
||||
AppMService.PageName = "User Card";
|
||||
AppMService.PageIcon = "fas fa-qrcode pr-2";
|
||||
//AppMService.EA_SearchUpdated += OnSeachUpdated;
|
||||
//AppMService.EA_FilterUpdated += OnFilterUpdated;
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await ReloadAllData();
|
||||
}
|
||||
|
||||
protected async Task ReloadAllData()
|
||||
{
|
||||
isLoading = true;
|
||||
//MacList = await DataService.MacchineGetAll();
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
protected async Task ReloadData()
|
||||
{
|
||||
isLoading = true;
|
||||
// importante altrimenti NON mostra update UI
|
||||
await Task.Delay(1);
|
||||
ListRecords = await DataService.AnagOperList();
|
||||
totalCount = ListRecords.Count();
|
||||
await Task.Delay(1);
|
||||
}
|
||||
|
||||
protected MarkupString traduci(string lemma)
|
||||
{
|
||||
MarkupString answ;
|
||||
//string rawHtml = "<li>primo</li><li>secondo</li>";
|
||||
string rawHtml = DataService.Traduci(lemma, "IT");
|
||||
answ = new MarkupString(rawHtml);
|
||||
// cerco nella cache Redis
|
||||
return answ;
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
}
|
||||
}
|
||||
@@ -36,12 +36,34 @@
|
||||
<a class="dismiss">🗙</a>
|
||||
</div>
|
||||
|
||||
<!-- inside of body section and after the div/app tag -->
|
||||
<!-- inside of body section and after the div/app tag -->
|
||||
<script src="jquery/jquery.min.js"></script>
|
||||
<script src="popper.js/umd/popper.min.js"></script>
|
||||
<script src="bootstrap/js/bootstrap.min.js"></script>
|
||||
|
||||
<script src="font-awesome/js/all.min.js"></script>
|
||||
<script src="_framework/blazor.server.js"></script>
|
||||
|
||||
<script type="text/javascript" src="~/lib/qrcode.js"></script>
|
||||
<script type="text/javascript">
|
||||
// gestione qrcode... da https://docs.microsoft.com/en-us/aspnet/core/security/authentication/identity-enable-qrcodes?view=aspnetcore-5.0
|
||||
//var qrcode = new QRCode("qrCodeImg");
|
||||
function displayQr(elementName, rawData) {
|
||||
try {
|
||||
if (elementName != "" && rawData != "") {
|
||||
//qrcode = new QRCode(document.getElementById(elementName));
|
||||
new QRCode(document.getElementById(elementName),
|
||||
{
|
||||
text: rawData,
|
||||
width: 300,
|
||||
height: 300
|
||||
});
|
||||
//qrcode.makeCode(rawData);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>Modulo gestione Programmi MAPO</i>
|
||||
<h4>Versione: 1.1.2109.1812</h4>
|
||||
<h4>Versione: 1.1.2109.2019</h4>
|
||||
<br />
|
||||
Note di rilascio:
|
||||
<ul>
|
||||
|
||||
@@ -1 +1 @@
|
||||
1.1.2109.1812
|
||||
1.1.2109.2019
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>1.1.2109.1812</version>
|
||||
<version>1.1.2109.2019</version>
|
||||
<url>https://nexus.steamware.net/repository/SWS/MP-PROG/stable/LAST/MP.Land.zip</url>
|
||||
<changelog>https://nexus.steamware.net/repository/SWS/MP-PROG/stable/LAST/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
@@ -7,13 +7,13 @@
|
||||
@implements IDisposable
|
||||
|
||||
<div class="page">
|
||||
<div class="sidebar">
|
||||
<div class="sidebar d-print-none">
|
||||
<NavMenu />
|
||||
</div>
|
||||
|
||||
<CascadingValue Name="ShowSearch" Value=@ShowSearch>
|
||||
<div class="main mr-1">
|
||||
<div class="top-row">
|
||||
<div class="top-row d-print-none">
|
||||
<CmpTop></CmpTop>
|
||||
</div>
|
||||
<div class="content pt-1 pt-lg-2 mb-5">
|
||||
|
||||
@@ -13,13 +13,33 @@
|
||||
</NavLink>
|
||||
</li>
|
||||
<li class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="Archive">
|
||||
<span class="far fa-folder fa-2x pr-2" aria-hidden="true"></span> Archivio File
|
||||
<NavLink class="nav-link" href="UserQr">
|
||||
<span class="fas fa-qrcode fa-2x pr-2" aria-hidden="true"></span> QR Card User
|
||||
</NavLink>
|
||||
</li>
|
||||
<li class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="Setup">
|
||||
<span class="fas fa-wrench fa-2x pr-2" aria-hidden="true"></span> Setup
|
||||
<NavLink class="nav-link" href="UpdateManager">
|
||||
<span class="fas fa-download fa-2x pr-2" aria-hidden="true"></span> Update Manager
|
||||
</NavLink>
|
||||
</li>
|
||||
<li class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="ConfImport">
|
||||
<span class="fas fa-file-import fa-2x pr-2" aria-hidden="true"></span> Config Import
|
||||
</NavLink>
|
||||
</li>
|
||||
<li class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="About">
|
||||
<span class="fas fa-info-circle fa-2x pr-2" aria-hidden="true"></span> About
|
||||
</NavLink>
|
||||
</li>
|
||||
<li class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="Contacts">
|
||||
<span class="fas fa-envelope fa-2x pr-2" aria-hidden="true"></span> Contacts
|
||||
</NavLink>
|
||||
</li>
|
||||
<li class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="SysInfo">
|
||||
<span class="fas fa-wrench fa-2x pr-2" aria-hidden="true"></span> System Info
|
||||
</NavLink>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
+2
-2
@@ -105,8 +105,8 @@ namespace MP.Land
|
||||
|
||||
services.AddStackExchangeRedisCache(options =>
|
||||
{
|
||||
//options.Configuration = "localhost:6379";
|
||||
options.ConfigurationOptions = new StackExchange.Redis.ConfigurationOptions() { KeepAlive = 180, DefaultDatabase = 5, EndPoints = { { "localhost", 6379 } } };
|
||||
//options.ConfigurationOptions = new StackExchange.Redis.ConfigurationOptions() { KeepAlive = 180, DefaultDatabase = 1, EndPoints = { { "localhost", 6379 } } };
|
||||
options.Configuration = Configuration["ConnectionStrings:Redis"];
|
||||
options.InstanceName = "MP:Land";
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
//"DetailedErrors": true,
|
||||
"DetailedErrors": true,
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"BaseUrl": "IIS02",
|
||||
"ConnectionStrings": {
|
||||
"DefaultConnection": "Server=localhost\\SQLEXPRESS;Database=MoonPro_PROG;Trusted_Connection=True;MultipleActiveResultSets=true",
|
||||
"MP.Land": "Server=localhost\\SQLEXPRESS;Database=MoonPro_PROG;User ID=sa;Password=keyhammer16;integrated security=False;MultipleActiveResultSets=True;App=MP.Land;"
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"BaseUrl": "IIS01",
|
||||
"ConnectionStrings": {
|
||||
"DefaultConnection": "Server=SQL2016DEV;Database=MoonPro_PROG;Trusted_Connection=True;MultipleActiveResultSets=true",
|
||||
"MP.Land": "Server=SQL2016DEV;Database=MoonPro_PROG;User ID=sa;Password=keyhammer16;integrated security=False;MultipleActiveResultSets=True;App=MP.Land;"
|
||||
|
||||
@@ -14,9 +14,13 @@
|
||||
//}
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"BaseUrl": "https://localhost:44309/",
|
||||
"Environment": "Steam DEV",
|
||||
"downloadPath": "C:\\Steamware\\installers\\MP",
|
||||
"appVers": "stable",
|
||||
"ConnectionStrings": {
|
||||
"DefaultConnection": "Server=SQL2016DEV;Database=MoonPro;Trusted_Connection=True;MultipleActiveResultSets=true",
|
||||
"MP.Land": "Server=SQL2016DEV;Database=MoonPro;User ID=sa;Password=keyhammer16;integrated security=False;MultipleActiveResultSets=True;App=MP.Land;",
|
||||
"Redis": "localhost:6379"
|
||||
"Redis": "localhost:6379,defaultDatabase=1,keepAlive=180,asyncTimeout=5000"
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 85 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 154 KiB |
@@ -0,0 +1,14 @@
|
||||
The MIT License (MIT)
|
||||
---------------------
|
||||
Copyright (c) 2012 davidshimjs
|
||||
|
||||
Permission is hereby granted, free of charge,
|
||||
to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction,
|
||||
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@@ -0,0 +1,46 @@
|
||||
# QRCode.js
|
||||
QRCode.js is javascript library for making QRCode. QRCode.js supports Cross-browser with HTML5 Canvas and table tag in DOM.
|
||||
QRCode.js has no dependencies.
|
||||
|
||||
## Basic Usages
|
||||
```
|
||||
<div id="qrcode"></div>
|
||||
<script type="text/javascript">
|
||||
new QRCode(document.getElementById("qrcode"), "http://jindo.dev.naver.com/collie");
|
||||
</script>
|
||||
```
|
||||
|
||||
or with some options
|
||||
|
||||
```
|
||||
<div id="qrcode"></div>
|
||||
<script type="text/javascript">
|
||||
var qrcode = new QRCode(document.getElementById("qrcode"), {
|
||||
text: "http://jindo.dev.naver.com/collie",
|
||||
width: 128,
|
||||
height: 128,
|
||||
colorDark : "#000000",
|
||||
colorLight : "#ffffff",
|
||||
correctLevel : QRCode.CorrectLevel.H
|
||||
});
|
||||
</script>
|
||||
```
|
||||
|
||||
and you can use some methods
|
||||
|
||||
```
|
||||
qrcode.clear(); // clear the code.
|
||||
qrcode.makeCode("http://naver.com"); // make another code.
|
||||
```
|
||||
|
||||
## Browser Compatibility
|
||||
IE6~10, Chrome, Firefox, Safari, Opera, Mobile Safari, Android, Windows Mobile, ETC.
|
||||
|
||||
## License
|
||||
MIT License
|
||||
|
||||
## Contact
|
||||
twitter @davidshimjs
|
||||
|
||||
[](https://bitdeli.com/free "Bitdeli Badge")
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "qrcode.js",
|
||||
"version": "0.0.1",
|
||||
"homepage": "https://github.com/davidshimjs/qrcodejs",
|
||||
"authors": [
|
||||
"Sangmin Shim", "Sangmin Shim <ssm0123@gmail.com> (http://jaguarjs.com)"
|
||||
],
|
||||
"description": "Cross-browser QRCode generator for javascript",
|
||||
"main": "qrcode.js",
|
||||
"ignore": [
|
||||
"bower_components",
|
||||
"node_modules",
|
||||
"index.html",
|
||||
"index.svg",
|
||||
"jquery.min.js",
|
||||
"qrcode.min.js"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ko" lang="ko">
|
||||
<head>
|
||||
<title>Cross-Browser QRCode generator for Javascript</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no" />
|
||||
<script type="text/javascript" src="jquery.min.js"></script>
|
||||
<script type="text/javascript" src="qrcode.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<input id="text" type="text" value="http://jindo.dev.naver.com/collie" style="width:80%" />
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<g id="qrcode"/>
|
||||
</svg>
|
||||
<script type="text/javascript">
|
||||
var qrcode = new QRCode(document.getElementById("qrcode"), {
|
||||
width : 100,
|
||||
height : 100,
|
||||
useSVG: true
|
||||
});
|
||||
|
||||
function makeCode () {
|
||||
var elText = document.getElementById("text");
|
||||
|
||||
if (!elText.value) {
|
||||
alert("Input a text");
|
||||
elText.focus();
|
||||
return;
|
||||
}
|
||||
|
||||
qrcode.makeCode(elText.value);
|
||||
}
|
||||
|
||||
makeCode();
|
||||
|
||||
$("#text").
|
||||
on("blur", function () {
|
||||
makeCode();
|
||||
}).
|
||||
on("keydown", function (e) {
|
||||
if (e.keyCode == 13) {
|
||||
makeCode();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,44 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ko" lang="ko">
|
||||
<head>
|
||||
<title>Cross-Browser QRCode generator for Javascript</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no" />
|
||||
<script type="text/javascript" src="jquery.min.js"></script>
|
||||
<script type="text/javascript" src="qrcode.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<input id="text" type="text" value="http://jindo.dev.naver.com/collie" style="width:80%" /><br />
|
||||
<div id="qrcode" style="width:100px; height:100px; margin-top:15px;"></div>
|
||||
|
||||
<script type="text/javascript">
|
||||
var qrcode = new QRCode(document.getElementById("qrcode"), {
|
||||
width : 100,
|
||||
height : 100
|
||||
});
|
||||
|
||||
function makeCode () {
|
||||
var elText = document.getElementById("text");
|
||||
|
||||
if (!elText.value) {
|
||||
alert("Input a text");
|
||||
elText.focus();
|
||||
return;
|
||||
}
|
||||
|
||||
qrcode.makeCode(elText.value);
|
||||
}
|
||||
|
||||
makeCode();
|
||||
|
||||
$("#text").
|
||||
on("blur", function () {
|
||||
makeCode();
|
||||
}).
|
||||
on("keydown", function (e) {
|
||||
if (e.keyCode == 13) {
|
||||
makeCode();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" standalone="yes"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="-50 0 200 100">
|
||||
<g id="qrcode"/>
|
||||
<foreignObject x="-50" y="0" width="100" height="100">
|
||||
<body xmlns="http://www.w3.org/1999/xhtml" style="padding:0; margin:0">
|
||||
<div style="padding:inherit; margin:inherit; height:100%">
|
||||
<textarea id="text" style="height:100%; width:100%; position:absolute; margin:inherit; padding:inherit">james</textarea>
|
||||
</div>
|
||||
<script type="application/ecmascript" src="qrcode.js"></script>
|
||||
<script type="application/ecmascript">
|
||||
var elem = document.getElementById("qrcode");
|
||||
var qrcode = new QRCode(elem, {
|
||||
width : 100,
|
||||
height : 100
|
||||
});
|
||||
|
||||
function makeCode () {
|
||||
var elText = document.getElementById("text");
|
||||
|
||||
if (elText.value === "") {
|
||||
//alert("Input a text");
|
||||
//elText.focus();
|
||||
return;
|
||||
}
|
||||
|
||||
qrcode.makeCode(elText.value);
|
||||
}
|
||||
|
||||
makeCode();
|
||||
|
||||
document.getElementById("text").onkeyup = function (e) {
|
||||
makeCode();
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
</foreignObject>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
Vendored
+2
File diff suppressed because one or more lines are too long
@@ -0,0 +1,702 @@
|
||||
/**
|
||||
* @fileoverview
|
||||
* - Using the 'QRCode for Javascript library'
|
||||
* - Fixed dataset of 'QRCode for Javascript library' for support full-spec.
|
||||
* - this library has no dependencies.
|
||||
*
|
||||
* @author davidshimjs
|
||||
* @see <a href="http://www.d-project.com/" target="_blank">http://www.d-project.com/</a>
|
||||
* @see <a href="http://jeromeetienne.github.com/jquery-qrcode/" target="_blank">http://jeromeetienne.github.com/jquery-qrcode/</a>
|
||||
*/
|
||||
var QRCode;
|
||||
|
||||
(function () {
|
||||
//---------------------------------------------------------------------
|
||||
// QRCode for JavaScript
|
||||
//
|
||||
// Copyright (c) 2009 Kazuhiko Arase
|
||||
//
|
||||
// URL: http://www.d-project.com/
|
||||
//
|
||||
// Licensed under the MIT license:
|
||||
// http://www.opensource.org/licenses/mit-license.php
|
||||
//
|
||||
// The word "QR Code" is registered trademark of
|
||||
// DENSO WAVE INCORPORATED
|
||||
// http://www.denso-wave.com/qrcode/faqpatent-e.html
|
||||
//
|
||||
//---------------------------------------------------------------------
|
||||
function QR8bitByte(data) {
|
||||
this.mode = QRMode.MODE_8BIT_BYTE;
|
||||
this.data = data;
|
||||
this.parsedData = [];
|
||||
|
||||
// Added to support UTF-8 Characters
|
||||
for (var i = 0, l = this.data.length; i < l; i++) {
|
||||
var byteArray = [];
|
||||
var code = this.data.charCodeAt(i);
|
||||
|
||||
if (code > 0x10000) {
|
||||
byteArray[0] = 0xF0 | ((code & 0x1C0000) >>> 18);
|
||||
byteArray[1] = 0x80 | ((code & 0x3F000) >>> 12);
|
||||
byteArray[2] = 0x80 | ((code & 0xFC0) >>> 6);
|
||||
byteArray[3] = 0x80 | (code & 0x3F);
|
||||
} else if (code > 0x800) {
|
||||
byteArray[0] = 0xE0 | ((code & 0xF000) >>> 12);
|
||||
byteArray[1] = 0x80 | ((code & 0xFC0) >>> 6);
|
||||
byteArray[2] = 0x80 | (code & 0x3F);
|
||||
} else if (code > 0x80) {
|
||||
byteArray[0] = 0xC0 | ((code & 0x7C0) >>> 6);
|
||||
byteArray[1] = 0x80 | (code & 0x3F);
|
||||
} else {
|
||||
byteArray[0] = code;
|
||||
}
|
||||
|
||||
this.parsedData.push(byteArray);
|
||||
}
|
||||
|
||||
this.parsedData = Array.prototype.concat.apply([], this.parsedData);
|
||||
|
||||
if (this.parsedData.length != this.data.length) {
|
||||
this.parsedData.unshift(191);
|
||||
this.parsedData.unshift(187);
|
||||
this.parsedData.unshift(239);
|
||||
}
|
||||
}
|
||||
|
||||
QR8bitByte.prototype = {
|
||||
getLength: function (buffer) {
|
||||
return this.parsedData.length;
|
||||
},
|
||||
write: function (buffer) {
|
||||
for (var i = 0, l = this.parsedData.length; i < l; i++) {
|
||||
buffer.put(this.parsedData[i], 8);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function QRCodeModel(typeNumber, errorCorrectLevel) {
|
||||
this.typeNumber = typeNumber;
|
||||
this.errorCorrectLevel = errorCorrectLevel;
|
||||
this.modules = null;
|
||||
this.moduleCount = 0;
|
||||
this.dataCache = null;
|
||||
this.dataList = [];
|
||||
}
|
||||
|
||||
QRCodeModel.prototype = {
|
||||
addData: function (data) { var newData = new QR8bitByte(data); this.dataList.push(newData); this.dataCache = null; }, isDark: function (row, col) {
|
||||
if (row < 0 || this.moduleCount <= row || col < 0 || this.moduleCount <= col) { throw new Error(row + "," + col); }
|
||||
return this.modules[row][col];
|
||||
}, getModuleCount: function () { return this.moduleCount; }, make: function () { this.makeImpl(false, this.getBestMaskPattern()); }, makeImpl: function (test, maskPattern) {
|
||||
this.moduleCount = this.typeNumber * 4 + 17; this.modules = new Array(this.moduleCount); for (var row = 0; row < this.moduleCount; row++) { this.modules[row] = new Array(this.moduleCount); for (var col = 0; col < this.moduleCount; col++) { this.modules[row][col] = null; } }
|
||||
this.setupPositionProbePattern(0, 0); this.setupPositionProbePattern(this.moduleCount - 7, 0); this.setupPositionProbePattern(0, this.moduleCount - 7); this.setupPositionAdjustPattern(); this.setupTimingPattern(); this.setupTypeInfo(test, maskPattern); if (this.typeNumber >= 7) { this.setupTypeNumber(test); }
|
||||
if (this.dataCache == null) { this.dataCache = QRCodeModel.createData(this.typeNumber, this.errorCorrectLevel, this.dataList); }
|
||||
this.mapData(this.dataCache, maskPattern);
|
||||
}, setupPositionProbePattern: function (row, col) { for (var r = -1; r <= 7; r++) { if (row + r <= -1 || this.moduleCount <= row + r) continue; for (var c = -1; c <= 7; c++) { if (col + c <= -1 || this.moduleCount <= col + c) continue; if ((0 <= r && r <= 6 && (c == 0 || c == 6)) || (0 <= c && c <= 6 && (r == 0 || r == 6)) || (2 <= r && r <= 4 && 2 <= c && c <= 4)) { this.modules[row + r][col + c] = true; } else { this.modules[row + r][col + c] = false; } } } }, getBestMaskPattern: function () {
|
||||
var minLostPoint = 0; var pattern = 0; for (var i = 0; i < 8; i++) { this.makeImpl(true, i); var lostPoint = QRUtil.getLostPoint(this); if (i == 0 || minLostPoint > lostPoint) { minLostPoint = lostPoint; pattern = i; } }
|
||||
return pattern;
|
||||
}, createMovieClip: function (target_mc, instance_name, depth) {
|
||||
var qr_mc = target_mc.createEmptyMovieClip(instance_name, depth); var cs = 1; this.make(); for (var row = 0; row < this.modules.length; row++) { var y = row * cs; for (var col = 0; col < this.modules[row].length; col++) { var x = col * cs; var dark = this.modules[row][col]; if (dark) { qr_mc.beginFill(0, 100); qr_mc.moveTo(x, y); qr_mc.lineTo(x + cs, y); qr_mc.lineTo(x + cs, y + cs); qr_mc.lineTo(x, y + cs); qr_mc.endFill(); } } }
|
||||
return qr_mc;
|
||||
}, setupTimingPattern: function () {
|
||||
for (var r = 8; r < this.moduleCount - 8; r++) {
|
||||
if (this.modules[r][6] != null) { continue; }
|
||||
this.modules[r][6] = (r % 2 == 0);
|
||||
}
|
||||
for (var c = 8; c < this.moduleCount - 8; c++) {
|
||||
if (this.modules[6][c] != null) { continue; }
|
||||
this.modules[6][c] = (c % 2 == 0);
|
||||
}
|
||||
}, setupPositionAdjustPattern: function () {
|
||||
var pos = QRUtil.getPatternPosition(this.typeNumber); for (var i = 0; i < pos.length; i++) {
|
||||
for (var j = 0; j < pos.length; j++) {
|
||||
var row = pos[i]; var col = pos[j]; if (this.modules[row][col] != null) { continue; }
|
||||
for (var r = -2; r <= 2; r++) { for (var c = -2; c <= 2; c++) { if (r == -2 || r == 2 || c == -2 || c == 2 || (r == 0 && c == 0)) { this.modules[row + r][col + c] = true; } else { this.modules[row + r][col + c] = false; } } }
|
||||
}
|
||||
}
|
||||
}, setupTypeNumber: function (test) {
|
||||
var bits = QRUtil.getBCHTypeNumber(this.typeNumber); for (var i = 0; i < 18; i++) { var mod = (!test && ((bits >> i) & 1) == 1); this.modules[Math.floor(i / 3)][i % 3 + this.moduleCount - 8 - 3] = mod; }
|
||||
for (var i = 0; i < 18; i++) { var mod = (!test && ((bits >> i) & 1) == 1); this.modules[i % 3 + this.moduleCount - 8 - 3][Math.floor(i / 3)] = mod; }
|
||||
}, setupTypeInfo: function (test, maskPattern) {
|
||||
var data = (this.errorCorrectLevel << 3) | maskPattern; var bits = QRUtil.getBCHTypeInfo(data); for (var i = 0; i < 15; i++) { var mod = (!test && ((bits >> i) & 1) == 1); if (i < 6) { this.modules[i][8] = mod; } else if (i < 8) { this.modules[i + 1][8] = mod; } else { this.modules[this.moduleCount - 15 + i][8] = mod; } }
|
||||
for (var i = 0; i < 15; i++) { var mod = (!test && ((bits >> i) & 1) == 1); if (i < 8) { this.modules[8][this.moduleCount - i - 1] = mod; } else if (i < 9) { this.modules[8][15 - i - 1 + 1] = mod; } else { this.modules[8][15 - i - 1] = mod; } }
|
||||
this.modules[this.moduleCount - 8][8] = (!test);
|
||||
}, mapData: function (data, maskPattern) {
|
||||
var inc = -1; var row = this.moduleCount - 1; var bitIndex = 7; var byteIndex = 0; for (var col = this.moduleCount - 1; col > 0; col -= 2) {
|
||||
if (col == 6) col--; while (true) {
|
||||
for (var c = 0; c < 2; c++) {
|
||||
if (this.modules[row][col - c] == null) {
|
||||
var dark = false; if (byteIndex < data.length) { dark = (((data[byteIndex] >>> bitIndex) & 1) == 1); }
|
||||
var mask = QRUtil.getMask(maskPattern, row, col - c); if (mask) { dark = !dark; }
|
||||
this.modules[row][col - c] = dark; bitIndex--; if (bitIndex == -1) { byteIndex++; bitIndex = 7; }
|
||||
}
|
||||
}
|
||||
row += inc; if (row < 0 || this.moduleCount <= row) { row -= inc; inc = -inc; break; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}; QRCodeModel.PAD0 = 0xEC; QRCodeModel.PAD1 = 0x11; QRCodeModel.createData = function (typeNumber, errorCorrectLevel, dataList) {
|
||||
var rsBlocks = QRRSBlock.getRSBlocks(typeNumber, errorCorrectLevel); var buffer = new QRBitBuffer(); for (var i = 0; i < dataList.length; i++) { var data = dataList[i]; buffer.put(data.mode, 4); buffer.put(data.getLength(), QRUtil.getLengthInBits(data.mode, typeNumber)); data.write(buffer); }
|
||||
var totalDataCount = 0; for (var i = 0; i < rsBlocks.length; i++) { totalDataCount += rsBlocks[i].dataCount; }
|
||||
if (buffer.getLengthInBits() > totalDataCount * 8) {
|
||||
throw new Error("code length overflow. ("
|
||||
+ buffer.getLengthInBits()
|
||||
+ ">"
|
||||
+ totalDataCount * 8
|
||||
+ ")");
|
||||
}
|
||||
if (buffer.getLengthInBits() + 4 <= totalDataCount * 8) { buffer.put(0, 4); }
|
||||
while (buffer.getLengthInBits() % 8 != 0) { buffer.putBit(false); }
|
||||
while (true) {
|
||||
if (buffer.getLengthInBits() >= totalDataCount * 8) { break; }
|
||||
buffer.put(QRCodeModel.PAD0, 8); if (buffer.getLengthInBits() >= totalDataCount * 8) { break; }
|
||||
buffer.put(QRCodeModel.PAD1, 8);
|
||||
}
|
||||
return QRCodeModel.createBytes(buffer, rsBlocks);
|
||||
}; QRCodeModel.createBytes = function (buffer, rsBlocks) {
|
||||
var offset = 0; var maxDcCount = 0; var maxEcCount = 0; var dcdata = new Array(rsBlocks.length); var ecdata = new Array(rsBlocks.length); for (var r = 0; r < rsBlocks.length; r++) {
|
||||
var dcCount = rsBlocks[r].dataCount; var ecCount = rsBlocks[r].totalCount - dcCount; maxDcCount = Math.max(maxDcCount, dcCount); maxEcCount = Math.max(maxEcCount, ecCount); dcdata[r] = new Array(dcCount); for (var i = 0; i < dcdata[r].length; i++) { dcdata[r][i] = 0xff & buffer.buffer[i + offset]; }
|
||||
offset += dcCount; var rsPoly = QRUtil.getErrorCorrectPolynomial(ecCount); var rawPoly = new QRPolynomial(dcdata[r], rsPoly.getLength() - 1); var modPoly = rawPoly.mod(rsPoly); ecdata[r] = new Array(rsPoly.getLength() - 1); for (var i = 0; i < ecdata[r].length; i++) { var modIndex = i + modPoly.getLength() - ecdata[r].length; ecdata[r][i] = (modIndex >= 0) ? modPoly.get(modIndex) : 0; }
|
||||
}
|
||||
var totalCodeCount = 0; for (var i = 0; i < rsBlocks.length; i++) { totalCodeCount += rsBlocks[i].totalCount; }
|
||||
var data = new Array(totalCodeCount); var index = 0; for (var i = 0; i < maxDcCount; i++) { for (var r = 0; r < rsBlocks.length; r++) { if (i < dcdata[r].length) { data[index++] = dcdata[r][i]; } } }
|
||||
for (var i = 0; i < maxEcCount; i++) { for (var r = 0; r < rsBlocks.length; r++) { if (i < ecdata[r].length) { data[index++] = ecdata[r][i]; } } }
|
||||
return data;
|
||||
}; var QRMode = { MODE_NUMBER: 1 << 0, MODE_ALPHA_NUM: 1 << 1, MODE_8BIT_BYTE: 1 << 2, MODE_KANJI: 1 << 3 }; var QRErrorCorrectLevel = { L: 1, M: 0, Q: 3, H: 2 }; var QRMaskPattern = { PATTERN000: 0, PATTERN001: 1, PATTERN010: 2, PATTERN011: 3, PATTERN100: 4, PATTERN101: 5, PATTERN110: 6, PATTERN111: 7 }; var QRUtil = {
|
||||
PATTERN_POSITION_TABLE: [[], [6, 18], [6, 22], [6, 26], [6, 30], [6, 34], [6, 22, 38], [6, 24, 42], [6, 26, 46], [6, 28, 50], [6, 30, 54], [6, 32, 58], [6, 34, 62], [6, 26, 46, 66], [6, 26, 48, 70], [6, 26, 50, 74], [6, 30, 54, 78], [6, 30, 56, 82], [6, 30, 58, 86], [6, 34, 62, 90], [6, 28, 50, 72, 94], [6, 26, 50, 74, 98], [6, 30, 54, 78, 102], [6, 28, 54, 80, 106], [6, 32, 58, 84, 110], [6, 30, 58, 86, 114], [6, 34, 62, 90, 118], [6, 26, 50, 74, 98, 122], [6, 30, 54, 78, 102, 126], [6, 26, 52, 78, 104, 130], [6, 30, 56, 82, 108, 134], [6, 34, 60, 86, 112, 138], [6, 30, 58, 86, 114, 142], [6, 34, 62, 90, 118, 146], [6, 30, 54, 78, 102, 126, 150], [6, 24, 50, 76, 102, 128, 154], [6, 28, 54, 80, 106, 132, 158], [6, 32, 58, 84, 110, 136, 162], [6, 26, 54, 82, 110, 138, 166], [6, 30, 58, 86, 114, 142, 170]], G15: (1 << 10) | (1 << 8) | (1 << 5) | (1 << 4) | (1 << 2) | (1 << 1) | (1 << 0), G18: (1 << 12) | (1 << 11) | (1 << 10) | (1 << 9) | (1 << 8) | (1 << 5) | (1 << 2) | (1 << 0), G15_MASK: (1 << 14) | (1 << 12) | (1 << 10) | (1 << 4) | (1 << 1), getBCHTypeInfo: function (data) {
|
||||
var d = data << 10; while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15) >= 0) { d ^= (QRUtil.G15 << (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15))); }
|
||||
return ((data << 10) | d) ^ QRUtil.G15_MASK;
|
||||
}, getBCHTypeNumber: function (data) {
|
||||
var d = data << 12; while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18) >= 0) { d ^= (QRUtil.G18 << (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18))); }
|
||||
return (data << 12) | d;
|
||||
}, getBCHDigit: function (data) {
|
||||
var digit = 0; while (data != 0) { digit++; data >>>= 1; }
|
||||
return digit;
|
||||
}, getPatternPosition: function (typeNumber) { return QRUtil.PATTERN_POSITION_TABLE[typeNumber - 1]; }, getMask: function (maskPattern, i, j) { switch (maskPattern) { case QRMaskPattern.PATTERN000: return (i + j) % 2 == 0; case QRMaskPattern.PATTERN001: return i % 2 == 0; case QRMaskPattern.PATTERN010: return j % 3 == 0; case QRMaskPattern.PATTERN011: return (i + j) % 3 == 0; case QRMaskPattern.PATTERN100: return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 == 0; case QRMaskPattern.PATTERN101: return (i * j) % 2 + (i * j) % 3 == 0; case QRMaskPattern.PATTERN110: return ((i * j) % 2 + (i * j) % 3) % 2 == 0; case QRMaskPattern.PATTERN111: return ((i * j) % 3 + (i + j) % 2) % 2 == 0; default: throw new Error("bad maskPattern:" + maskPattern); } }, getErrorCorrectPolynomial: function (errorCorrectLength) {
|
||||
var a = new QRPolynomial([1], 0); for (var i = 0; i < errorCorrectLength; i++) { a = a.multiply(new QRPolynomial([1, QRMath.gexp(i)], 0)); }
|
||||
return a;
|
||||
}, getLengthInBits: function (mode, type) { if (1 <= type && type < 10) { switch (mode) { case QRMode.MODE_NUMBER: return 10; case QRMode.MODE_ALPHA_NUM: return 9; case QRMode.MODE_8BIT_BYTE: return 8; case QRMode.MODE_KANJI: return 8; default: throw new Error("mode:" + mode); } } else if (type < 27) { switch (mode) { case QRMode.MODE_NUMBER: return 12; case QRMode.MODE_ALPHA_NUM: return 11; case QRMode.MODE_8BIT_BYTE: return 16; case QRMode.MODE_KANJI: return 10; default: throw new Error("mode:" + mode); } } else if (type < 41) { switch (mode) { case QRMode.MODE_NUMBER: return 14; case QRMode.MODE_ALPHA_NUM: return 13; case QRMode.MODE_8BIT_BYTE: return 16; case QRMode.MODE_KANJI: return 12; default: throw new Error("mode:" + mode); } } else { throw new Error("type:" + type); } }, getLostPoint: function (qrCode) {
|
||||
var moduleCount = qrCode.getModuleCount(); var lostPoint = 0; for (var row = 0; row < moduleCount; row++) {
|
||||
for (var col = 0; col < moduleCount; col++) {
|
||||
var sameCount = 0; var dark = qrCode.isDark(row, col); for (var r = -1; r <= 1; r++) {
|
||||
if (row + r < 0 || moduleCount <= row + r) { continue; }
|
||||
for (var c = -1; c <= 1; c++) {
|
||||
if (col + c < 0 || moduleCount <= col + c) { continue; }
|
||||
if (r == 0 && c == 0) { continue; }
|
||||
if (dark == qrCode.isDark(row + r, col + c)) { sameCount++; }
|
||||
}
|
||||
}
|
||||
if (sameCount > 5) { lostPoint += (3 + sameCount - 5); }
|
||||
}
|
||||
}
|
||||
for (var row = 0; row < moduleCount - 1; row++) { for (var col = 0; col < moduleCount - 1; col++) { var count = 0; if (qrCode.isDark(row, col)) count++; if (qrCode.isDark(row + 1, col)) count++; if (qrCode.isDark(row, col + 1)) count++; if (qrCode.isDark(row + 1, col + 1)) count++; if (count == 0 || count == 4) { lostPoint += 3; } } }
|
||||
for (var row = 0; row < moduleCount; row++) { for (var col = 0; col < moduleCount - 6; col++) { if (qrCode.isDark(row, col) && !qrCode.isDark(row, col + 1) && qrCode.isDark(row, col + 2) && qrCode.isDark(row, col + 3) && qrCode.isDark(row, col + 4) && !qrCode.isDark(row, col + 5) && qrCode.isDark(row, col + 6)) { lostPoint += 40; } } }
|
||||
for (var col = 0; col < moduleCount; col++) { for (var row = 0; row < moduleCount - 6; row++) { if (qrCode.isDark(row, col) && !qrCode.isDark(row + 1, col) && qrCode.isDark(row + 2, col) && qrCode.isDark(row + 3, col) && qrCode.isDark(row + 4, col) && !qrCode.isDark(row + 5, col) && qrCode.isDark(row + 6, col)) { lostPoint += 40; } } }
|
||||
var darkCount = 0; for (var col = 0; col < moduleCount; col++) { for (var row = 0; row < moduleCount; row++) { if (qrCode.isDark(row, col)) { darkCount++; } } }
|
||||
var ratio = Math.abs(100 * darkCount / moduleCount / moduleCount - 50) / 5; lostPoint += ratio * 10; return lostPoint;
|
||||
}
|
||||
}; var QRMath = {
|
||||
glog: function (n) {
|
||||
if (n < 1) { throw new Error("glog(" + n + ")"); }
|
||||
return QRMath.LOG_TABLE[n];
|
||||
}, gexp: function (n) {
|
||||
while (n < 0) { n += 255; }
|
||||
while (n >= 256) { n -= 255; }
|
||||
return QRMath.EXP_TABLE[n];
|
||||
}, EXP_TABLE: new Array(256), LOG_TABLE: new Array(256)
|
||||
}; for (var i = 0; i < 8; i++) { QRMath.EXP_TABLE[i] = 1 << i; }
|
||||
for (var i = 8; i < 256; i++) { QRMath.EXP_TABLE[i] = QRMath.EXP_TABLE[i - 4] ^ QRMath.EXP_TABLE[i - 5] ^ QRMath.EXP_TABLE[i - 6] ^ QRMath.EXP_TABLE[i - 8]; }
|
||||
for (var i = 0; i < 255; i++) { QRMath.LOG_TABLE[QRMath.EXP_TABLE[i]] = i; }
|
||||
function QRPolynomial(num, shift) {
|
||||
if (num.length == undefined) { throw new Error(num.length + "/" + shift); }
|
||||
var offset = 0; while (offset < num.length && num[offset] == 0) { offset++; }
|
||||
this.num = new Array(num.length - offset + shift); for (var i = 0; i < num.length - offset; i++) { this.num[i] = num[i + offset]; }
|
||||
}
|
||||
QRPolynomial.prototype = {
|
||||
get: function (index) { return this.num[index]; }, getLength: function () { return this.num.length; }, multiply: function (e) {
|
||||
var num = new Array(this.getLength() + e.getLength() - 1); for (var i = 0; i < this.getLength(); i++) { for (var j = 0; j < e.getLength(); j++) { num[i + j] ^= QRMath.gexp(QRMath.glog(this.get(i)) + QRMath.glog(e.get(j))); } }
|
||||
return new QRPolynomial(num, 0);
|
||||
}, mod: function (e) {
|
||||
if (this.getLength() - e.getLength() < 0) { return this; }
|
||||
var ratio = QRMath.glog(this.get(0)) - QRMath.glog(e.get(0)); var num = new Array(this.getLength()); for (var i = 0; i < this.getLength(); i++) { num[i] = this.get(i); }
|
||||
for (var i = 0; i < e.getLength(); i++) { num[i] ^= QRMath.gexp(QRMath.glog(e.get(i)) + ratio); }
|
||||
return new QRPolynomial(num, 0).mod(e);
|
||||
}
|
||||
}; function QRRSBlock(totalCount, dataCount) { this.totalCount = totalCount; this.dataCount = dataCount; }
|
||||
QRRSBlock.RS_BLOCK_TABLE = [[1, 26, 19], [1, 26, 16], [1, 26, 13], [1, 26, 9], [1, 44, 34], [1, 44, 28], [1, 44, 22], [1, 44, 16], [1, 70, 55], [1, 70, 44], [2, 35, 17], [2, 35, 13], [1, 100, 80], [2, 50, 32], [2, 50, 24], [4, 25, 9], [1, 134, 108], [2, 67, 43], [2, 33, 15, 2, 34, 16], [2, 33, 11, 2, 34, 12], [2, 86, 68], [4, 43, 27], [4, 43, 19], [4, 43, 15], [2, 98, 78], [4, 49, 31], [2, 32, 14, 4, 33, 15], [4, 39, 13, 1, 40, 14], [2, 121, 97], [2, 60, 38, 2, 61, 39], [4, 40, 18, 2, 41, 19], [4, 40, 14, 2, 41, 15], [2, 146, 116], [3, 58, 36, 2, 59, 37], [4, 36, 16, 4, 37, 17], [4, 36, 12, 4, 37, 13], [2, 86, 68, 2, 87, 69], [4, 69, 43, 1, 70, 44], [6, 43, 19, 2, 44, 20], [6, 43, 15, 2, 44, 16], [4, 101, 81], [1, 80, 50, 4, 81, 51], [4, 50, 22, 4, 51, 23], [3, 36, 12, 8, 37, 13], [2, 116, 92, 2, 117, 93], [6, 58, 36, 2, 59, 37], [4, 46, 20, 6, 47, 21], [7, 42, 14, 4, 43, 15], [4, 133, 107], [8, 59, 37, 1, 60, 38], [8, 44, 20, 4, 45, 21], [12, 33, 11, 4, 34, 12], [3, 145, 115, 1, 146, 116], [4, 64, 40, 5, 65, 41], [11, 36, 16, 5, 37, 17], [11, 36, 12, 5, 37, 13], [5, 109, 87, 1, 110, 88], [5, 65, 41, 5, 66, 42], [5, 54, 24, 7, 55, 25], [11, 36, 12], [5, 122, 98, 1, 123, 99], [7, 73, 45, 3, 74, 46], [15, 43, 19, 2, 44, 20], [3, 45, 15, 13, 46, 16], [1, 135, 107, 5, 136, 108], [10, 74, 46, 1, 75, 47], [1, 50, 22, 15, 51, 23], [2, 42, 14, 17, 43, 15], [5, 150, 120, 1, 151, 121], [9, 69, 43, 4, 70, 44], [17, 50, 22, 1, 51, 23], [2, 42, 14, 19, 43, 15], [3, 141, 113, 4, 142, 114], [3, 70, 44, 11, 71, 45], [17, 47, 21, 4, 48, 22], [9, 39, 13, 16, 40, 14], [3, 135, 107, 5, 136, 108], [3, 67, 41, 13, 68, 42], [15, 54, 24, 5, 55, 25], [15, 43, 15, 10, 44, 16], [4, 144, 116, 4, 145, 117], [17, 68, 42], [17, 50, 22, 6, 51, 23], [19, 46, 16, 6, 47, 17], [2, 139, 111, 7, 140, 112], [17, 74, 46], [7, 54, 24, 16, 55, 25], [34, 37, 13], [4, 151, 121, 5, 152, 122], [4, 75, 47, 14, 76, 48], [11, 54, 24, 14, 55, 25], [16, 45, 15, 14, 46, 16], [6, 147, 117, 4, 148, 118], [6, 73, 45, 14, 74, 46], [11, 54, 24, 16, 55, 25], [30, 46, 16, 2, 47, 17], [8, 132, 106, 4, 133, 107], [8, 75, 47, 13, 76, 48], [7, 54, 24, 22, 55, 25], [22, 45, 15, 13, 46, 16], [10, 142, 114, 2, 143, 115], [19, 74, 46, 4, 75, 47], [28, 50, 22, 6, 51, 23], [33, 46, 16, 4, 47, 17], [8, 152, 122, 4, 153, 123], [22, 73, 45, 3, 74, 46], [8, 53, 23, 26, 54, 24], [12, 45, 15, 28, 46, 16], [3, 147, 117, 10, 148, 118], [3, 73, 45, 23, 74, 46], [4, 54, 24, 31, 55, 25], [11, 45, 15, 31, 46, 16], [7, 146, 116, 7, 147, 117], [21, 73, 45, 7, 74, 46], [1, 53, 23, 37, 54, 24], [19, 45, 15, 26, 46, 16], [5, 145, 115, 10, 146, 116], [19, 75, 47, 10, 76, 48], [15, 54, 24, 25, 55, 25], [23, 45, 15, 25, 46, 16], [13, 145, 115, 3, 146, 116], [2, 74, 46, 29, 75, 47], [42, 54, 24, 1, 55, 25], [23, 45, 15, 28, 46, 16], [17, 145, 115], [10, 74, 46, 23, 75, 47], [10, 54, 24, 35, 55, 25], [19, 45, 15, 35, 46, 16], [17, 145, 115, 1, 146, 116], [14, 74, 46, 21, 75, 47], [29, 54, 24, 19, 55, 25], [11, 45, 15, 46, 46, 16], [13, 145, 115, 6, 146, 116], [14, 74, 46, 23, 75, 47], [44, 54, 24, 7, 55, 25], [59, 46, 16, 1, 47, 17], [12, 151, 121, 7, 152, 122], [12, 75, 47, 26, 76, 48], [39, 54, 24, 14, 55, 25], [22, 45, 15, 41, 46, 16], [6, 151, 121, 14, 152, 122], [6, 75, 47, 34, 76, 48], [46, 54, 24, 10, 55, 25], [2, 45, 15, 64, 46, 16], [17, 152, 122, 4, 153, 123], [29, 74, 46, 14, 75, 47], [49, 54, 24, 10, 55, 25], [24, 45, 15, 46, 46, 16], [4, 152, 122, 18, 153, 123], [13, 74, 46, 32, 75, 47], [48, 54, 24, 14, 55, 25], [42, 45, 15, 32, 46, 16], [20, 147, 117, 4, 148, 118], [40, 75, 47, 7, 76, 48], [43, 54, 24, 22, 55, 25], [10, 45, 15, 67, 46, 16], [19, 148, 118, 6, 149, 119], [18, 75, 47, 31, 76, 48], [34, 54, 24, 34, 55, 25], [20, 45, 15, 61, 46, 16]]; QRRSBlock.getRSBlocks = function (typeNumber, errorCorrectLevel) {
|
||||
var rsBlock = QRRSBlock.getRsBlockTable(typeNumber, errorCorrectLevel); if (rsBlock == undefined) { throw new Error("bad rs block @ typeNumber:" + typeNumber + "/errorCorrectLevel:" + errorCorrectLevel); }
|
||||
var length = rsBlock.length / 3; var list = []; for (var i = 0; i < length; i++) { var count = rsBlock[i * 3 + 0]; var totalCount = rsBlock[i * 3 + 1]; var dataCount = rsBlock[i * 3 + 2]; for (var j = 0; j < count; j++) { list.push(new QRRSBlock(totalCount, dataCount)); } }
|
||||
return list;
|
||||
}; QRRSBlock.getRsBlockTable = function (typeNumber, errorCorrectLevel) { switch (errorCorrectLevel) { case QRErrorCorrectLevel.L: return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 0]; case QRErrorCorrectLevel.M: return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 1]; case QRErrorCorrectLevel.Q: return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 2]; case QRErrorCorrectLevel.H: return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 3]; default: return undefined; } }; function QRBitBuffer() { this.buffer = []; this.length = 0; }
|
||||
QRBitBuffer.prototype = {
|
||||
get: function (index) { var bufIndex = Math.floor(index / 8); return ((this.buffer[bufIndex] >>> (7 - index % 8)) & 1) == 1; }, put: function (num, length) { for (var i = 0; i < length; i++) { this.putBit(((num >>> (length - i - 1)) & 1) == 1); } }, getLengthInBits: function () { return this.length; }, putBit: function (bit) {
|
||||
var bufIndex = Math.floor(this.length / 8); if (this.buffer.length <= bufIndex) { this.buffer.push(0); }
|
||||
if (bit) { this.buffer[bufIndex] |= (0x80 >>> (this.length % 8)); }
|
||||
this.length++;
|
||||
}
|
||||
}; var QRCodeLimitLength = [[17, 14, 11, 7], [32, 26, 20, 14], [53, 42, 32, 24], [78, 62, 46, 34], [106, 84, 60, 44], [134, 106, 74, 58], [154, 122, 86, 64], [192, 152, 108, 84], [230, 180, 130, 98], [271, 213, 151, 119], [321, 251, 177, 137], [367, 287, 203, 155], [425, 331, 241, 177], [458, 362, 258, 194], [520, 412, 292, 220], [586, 450, 322, 250], [644, 504, 364, 280], [718, 560, 394, 310], [792, 624, 442, 338], [858, 666, 482, 382], [929, 711, 509, 403], [1003, 779, 565, 439], [1091, 857, 611, 461], [1171, 911, 661, 511], [1273, 997, 715, 535], [1367, 1059, 751, 593], [1465, 1125, 805, 625], [1528, 1190, 868, 658], [1628, 1264, 908, 698], [1732, 1370, 982, 742], [1840, 1452, 1030, 790], [1952, 1538, 1112, 842], [2068, 1628, 1168, 898], [2188, 1722, 1228, 958], [2303, 1809, 1283, 983], [2431, 1911, 1351, 1051], [2563, 1989, 1423, 1093], [2699, 2099, 1499, 1139], [2809, 2213, 1579, 1219], [2953, 2331, 1663, 1273]];
|
||||
|
||||
function _isSupportCanvas() {
|
||||
return typeof CanvasRenderingContext2D != "undefined";
|
||||
}
|
||||
|
||||
// android 2.x doesn't support Data-URI spec
|
||||
function _getAndroid() {
|
||||
var android = false;
|
||||
var sAgent = navigator.userAgent;
|
||||
|
||||
if (/android/i.test(sAgent)) { // android
|
||||
android = true;
|
||||
var aMat = sAgent.toString().match(/android ([0-9]\.[0-9])/i);
|
||||
|
||||
if (aMat && aMat[1]) {
|
||||
android = parseFloat(aMat[1]);
|
||||
}
|
||||
}
|
||||
|
||||
return android;
|
||||
}
|
||||
|
||||
var svgDrawer = (function () {
|
||||
var Drawing = function (el, htOption) {
|
||||
this._el = el;
|
||||
this._htOption = htOption;
|
||||
};
|
||||
|
||||
Drawing.prototype.draw = function (oQRCode) {
|
||||
var _htOption = this._htOption;
|
||||
var _el = this._el;
|
||||
var nCount = oQRCode.getModuleCount();
|
||||
var nWidth = Math.floor(_htOption.width / nCount);
|
||||
var nHeight = Math.floor(_htOption.height / nCount);
|
||||
|
||||
this.clear();
|
||||
|
||||
function makeSVG(tag, attrs) {
|
||||
var el = document.createElementNS('http://www.w3.org/2000/svg', tag);
|
||||
for (var k in attrs)
|
||||
if (attrs.hasOwnProperty(k)) el.setAttribute(k, attrs[k]);
|
||||
return el;
|
||||
}
|
||||
|
||||
var svg = makeSVG("svg", { 'viewBox': '0 0 ' + String(nCount) + " " + String(nCount), 'width': '100%', 'height': '100%', 'fill': _htOption.colorLight });
|
||||
svg.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:xlink", "http://www.w3.org/1999/xlink");
|
||||
_el.appendChild(svg);
|
||||
|
||||
svg.appendChild(makeSVG("rect", { "fill": _htOption.colorLight, "width": "100%", "height": "100%" }));
|
||||
svg.appendChild(makeSVG("rect", { "fill": _htOption.colorDark, "width": "1", "height": "1", "id": "template" }));
|
||||
|
||||
for (var row = 0; row < nCount; row++) {
|
||||
for (var col = 0; col < nCount; col++) {
|
||||
if (oQRCode.isDark(row, col)) {
|
||||
var child = makeSVG("use", { "x": String(col), "y": String(row) });
|
||||
child.setAttributeNS("http://www.w3.org/1999/xlink", "href", "#template")
|
||||
svg.appendChild(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
Drawing.prototype.clear = function () {
|
||||
while (this._el.hasChildNodes())
|
||||
this._el.removeChild(this._el.lastChild);
|
||||
};
|
||||
return Drawing;
|
||||
})();
|
||||
|
||||
var useSVG = document.documentElement.tagName.toLowerCase() === "svg";
|
||||
|
||||
// Drawing in DOM by using Table tag
|
||||
var Drawing = useSVG ? svgDrawer : !_isSupportCanvas() ? (function () {
|
||||
var Drawing = function (el, htOption) {
|
||||
this._el = el;
|
||||
this._htOption = htOption;
|
||||
};
|
||||
|
||||
/**
|
||||
* Draw the QRCode
|
||||
*
|
||||
* @param {QRCode} oQRCode
|
||||
*/
|
||||
Drawing.prototype.draw = function (oQRCode) {
|
||||
var _htOption = this._htOption;
|
||||
var _el = this._el;
|
||||
var nCount = oQRCode.getModuleCount();
|
||||
var nWidth = Math.floor(_htOption.width / nCount);
|
||||
var nHeight = Math.floor(_htOption.height / nCount);
|
||||
var aHTML = ['<table style="border:0;border-collapse:collapse;">'];
|
||||
|
||||
for (var row = 0; row < nCount; row++) {
|
||||
aHTML.push('<tr>');
|
||||
|
||||
for (var col = 0; col < nCount; col++) {
|
||||
aHTML.push('<td style="border:0;border-collapse:collapse;padding:0;margin:0;width:' + nWidth + 'px;height:' + nHeight + 'px;background-color:' + (oQRCode.isDark(row, col) ? _htOption.colorDark : _htOption.colorLight) + ';"></td>');
|
||||
}
|
||||
|
||||
aHTML.push('</tr>');
|
||||
}
|
||||
|
||||
aHTML.push('</table>');
|
||||
_el.innerHTML = aHTML.join('');
|
||||
|
||||
// Fix the margin values as real size.
|
||||
var elTable = _el.childNodes[0];
|
||||
var nLeftMarginTable = (_htOption.width - elTable.offsetWidth) / 2;
|
||||
var nTopMarginTable = (_htOption.height - elTable.offsetHeight) / 2;
|
||||
|
||||
if (nLeftMarginTable > 0 && nTopMarginTable > 0) {
|
||||
elTable.style.margin = nTopMarginTable + "px " + nLeftMarginTable + "px";
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Clear the QRCode
|
||||
*/
|
||||
Drawing.prototype.clear = function () {
|
||||
this._el.innerHTML = '';
|
||||
};
|
||||
|
||||
return Drawing;
|
||||
})() : (function () { // Drawing in Canvas
|
||||
function _onMakeImage() {
|
||||
this._elImage.src = this._elCanvas.toDataURL("image/png");
|
||||
this._elImage.style.display = "block";
|
||||
this._elCanvas.style.display = "none";
|
||||
this._elImage.className = "img-fluid";
|
||||
}
|
||||
|
||||
// Android 2.1 bug workaround
|
||||
// http://code.google.com/p/android/issues/detail?id=5141
|
||||
if (this._android && this._android <= 2.1) {
|
||||
var factor = 1 / window.devicePixelRatio;
|
||||
var drawImage = CanvasRenderingContext2D.prototype.drawImage;
|
||||
CanvasRenderingContext2D.prototype.drawImage = function (image, sx, sy, sw, sh, dx, dy, dw, dh) {
|
||||
if (("nodeName" in image) && /img/i.test(image.nodeName)) {
|
||||
for (var i = arguments.length - 1; i >= 1; i--) {
|
||||
arguments[i] = arguments[i] * factor;
|
||||
}
|
||||
} else if (typeof dw == "undefined") {
|
||||
arguments[1] *= factor;
|
||||
arguments[2] *= factor;
|
||||
arguments[3] *= factor;
|
||||
arguments[4] *= factor;
|
||||
}
|
||||
|
||||
drawImage.apply(this, arguments);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the user's browser supports Data URI or not
|
||||
*
|
||||
* @private
|
||||
* @param {Function} fSuccess Occurs if it supports Data URI
|
||||
* @param {Function} fFail Occurs if it doesn't support Data URI
|
||||
*/
|
||||
function _safeSetDataURI(fSuccess, fFail) {
|
||||
var self = this;
|
||||
self._fFail = fFail;
|
||||
self._fSuccess = fSuccess;
|
||||
|
||||
// Check it just once
|
||||
if (self._bSupportDataURI === null) {
|
||||
var el = document.createElement("img");
|
||||
var fOnError = function () {
|
||||
self._bSupportDataURI = false;
|
||||
|
||||
if (self._fFail) {
|
||||
self._fFail.call(self);
|
||||
}
|
||||
};
|
||||
var fOnSuccess = function () {
|
||||
self._bSupportDataURI = true;
|
||||
|
||||
if (self._fSuccess) {
|
||||
self._fSuccess.call(self);
|
||||
}
|
||||
};
|
||||
|
||||
el.onabort = fOnError;
|
||||
el.onerror = fOnError;
|
||||
el.onload = fOnSuccess;
|
||||
el.src = "data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="; // the Image contains 1px data.
|
||||
return;
|
||||
} else if (self._bSupportDataURI === true && self._fSuccess) {
|
||||
self._fSuccess.call(self);
|
||||
} else if (self._bSupportDataURI === false && self._fFail) {
|
||||
self._fFail.call(self);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Drawing QRCode by using canvas
|
||||
*
|
||||
* @constructor
|
||||
* @param {HTMLElement} el
|
||||
* @param {Object} htOption QRCode Options
|
||||
*/
|
||||
var Drawing = function (el, htOption) {
|
||||
this._bIsPainted = false;
|
||||
this._android = _getAndroid();
|
||||
|
||||
this._htOption = htOption;
|
||||
this._elCanvas = document.createElement("canvas");
|
||||
this._elCanvas.width = htOption.width;
|
||||
this._elCanvas.height = htOption.height;
|
||||
el.appendChild(this._elCanvas);
|
||||
this._el = el;
|
||||
this._oContext = this._elCanvas.getContext("2d");
|
||||
this._bIsPainted = false;
|
||||
this._elImage = document.createElement("img");
|
||||
this._elImage.alt = "Scan me!";
|
||||
this._elImage.style.display = "none";
|
||||
this._elImage.className = "img-fluid";
|
||||
this._el.appendChild(this._elImage);
|
||||
this._bSupportDataURI = null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Draw the QRCode
|
||||
*
|
||||
* @param {QRCode} oQRCode
|
||||
*/
|
||||
Drawing.prototype.draw = function (oQRCode) {
|
||||
var _elImage = this._elImage;
|
||||
var _oContext = this._oContext;
|
||||
var _htOption = this._htOption;
|
||||
|
||||
var nCount = oQRCode.getModuleCount();
|
||||
var nWidth = _htOption.width / nCount;
|
||||
var nHeight = _htOption.height / nCount;
|
||||
var nRoundedWidth = Math.round(nWidth);
|
||||
var nRoundedHeight = Math.round(nHeight);
|
||||
|
||||
_elImage.style.display = "none";
|
||||
_elImage.className = "img-fluid";
|
||||
this.clear();
|
||||
|
||||
for (var row = 0; row < nCount; row++) {
|
||||
for (var col = 0; col < nCount; col++) {
|
||||
var bIsDark = oQRCode.isDark(row, col);
|
||||
var nLeft = col * nWidth;
|
||||
var nTop = row * nHeight;
|
||||
_oContext.strokeStyle = bIsDark ? _htOption.colorDark : _htOption.colorLight;
|
||||
_oContext.lineWidth = 1;
|
||||
_oContext.fillStyle = bIsDark ? _htOption.colorDark : _htOption.colorLight;
|
||||
_oContext.fillRect(nLeft, nTop, nWidth, nHeight);
|
||||
|
||||
// 안티 앨리어싱 방지 처리
|
||||
_oContext.strokeRect(
|
||||
Math.floor(nLeft) + 0.5,
|
||||
Math.floor(nTop) + 0.5,
|
||||
nRoundedWidth,
|
||||
nRoundedHeight
|
||||
);
|
||||
|
||||
_oContext.strokeRect(
|
||||
Math.ceil(nLeft) - 0.5,
|
||||
Math.ceil(nTop) - 0.5,
|
||||
nRoundedWidth,
|
||||
nRoundedHeight
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
this._bIsPainted = true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Make the image from Canvas if the browser supports Data URI.
|
||||
*/
|
||||
Drawing.prototype.makeImage = function () {
|
||||
if (this._bIsPainted) {
|
||||
_safeSetDataURI.call(this, _onMakeImage);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Return whether the QRCode is painted or not
|
||||
*
|
||||
* @return {Boolean}
|
||||
*/
|
||||
Drawing.prototype.isPainted = function () {
|
||||
return this._bIsPainted;
|
||||
};
|
||||
|
||||
/**
|
||||
* Clear the QRCode
|
||||
*/
|
||||
Drawing.prototype.clear = function () {
|
||||
this._oContext.clearRect(0, 0, this._elCanvas.width, this._elCanvas.height);
|
||||
this._bIsPainted = false;
|
||||
};
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {Number} nNumber
|
||||
*/
|
||||
Drawing.prototype.round = function (nNumber) {
|
||||
if (!nNumber) {
|
||||
return nNumber;
|
||||
}
|
||||
|
||||
return Math.floor(nNumber * 1000) / 1000;
|
||||
};
|
||||
|
||||
return Drawing;
|
||||
})();
|
||||
|
||||
/**
|
||||
* Get the type by string length
|
||||
*
|
||||
* @private
|
||||
* @param {String} sText
|
||||
* @param {Number} nCorrectLevel
|
||||
* @return {Number} type
|
||||
*/
|
||||
function _getTypeNumber(sText, nCorrectLevel) {
|
||||
var nType = 1;
|
||||
var length = _getUTF8Length(sText);
|
||||
|
||||
for (var i = 0, len = QRCodeLimitLength.length; i <= len; i++) {
|
||||
var nLimit = 0;
|
||||
|
||||
switch (nCorrectLevel) {
|
||||
case QRErrorCorrectLevel.L:
|
||||
nLimit = QRCodeLimitLength[i][0];
|
||||
break;
|
||||
case QRErrorCorrectLevel.M:
|
||||
nLimit = QRCodeLimitLength[i][1];
|
||||
break;
|
||||
case QRErrorCorrectLevel.Q:
|
||||
nLimit = QRCodeLimitLength[i][2];
|
||||
break;
|
||||
case QRErrorCorrectLevel.H:
|
||||
nLimit = QRCodeLimitLength[i][3];
|
||||
break;
|
||||
}
|
||||
|
||||
if (length <= nLimit) {
|
||||
break;
|
||||
} else {
|
||||
nType++;
|
||||
}
|
||||
}
|
||||
|
||||
if (nType > QRCodeLimitLength.length) {
|
||||
throw new Error("Too long data");
|
||||
}
|
||||
|
||||
return nType;
|
||||
}
|
||||
|
||||
function _getUTF8Length(sText) {
|
||||
var replacedText = encodeURI(sText).toString().replace(/\%[0-9a-fA-F]{2}/g, 'a');
|
||||
return replacedText.length + (replacedText.length != sText ? 3 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @class QRCode
|
||||
* @constructor
|
||||
* @example
|
||||
* new QRCode(document.getElementById("test"), "http://jindo.dev.naver.com/collie");
|
||||
*
|
||||
* @example
|
||||
* var oQRCode = new QRCode("test", {
|
||||
* text : "http://naver.com",
|
||||
* width : 128,
|
||||
* height : 128
|
||||
* });
|
||||
*
|
||||
* oQRCode.clear(); // Clear the QRCode.
|
||||
* oQRCode.makeCode("http://map.naver.com"); // Re-create the QRCode.
|
||||
*
|
||||
* @param {HTMLElement|String} el target element or 'id' attribute of element.
|
||||
* @param {Object|String} vOption
|
||||
* @param {String} vOption.text QRCode link data
|
||||
* @param {Number} [vOption.width=256]
|
||||
* @param {Number} [vOption.height=256]
|
||||
* @param {String} [vOption.colorDark="#000000"]
|
||||
* @param {String} [vOption.colorLight="#ffffff"]
|
||||
* @param {QRCode.CorrectLevel} [vOption.correctLevel=QRCode.CorrectLevel.H] [L|M|Q|H]
|
||||
*/
|
||||
QRCode = function (el, vOption) {
|
||||
this._htOption = {
|
||||
width: 256,
|
||||
height: 256,
|
||||
typeNumber: 4,
|
||||
colorDark: "#000000",
|
||||
colorLight: "#ffffff",
|
||||
correctLevel: QRErrorCorrectLevel.H
|
||||
};
|
||||
|
||||
if (typeof vOption === 'string') {
|
||||
vOption = {
|
||||
text: vOption
|
||||
};
|
||||
}
|
||||
|
||||
// Overwrites options
|
||||
if (vOption) {
|
||||
for (var i in vOption) {
|
||||
this._htOption[i] = vOption[i];
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof el == "string") {
|
||||
el = document.getElementById(el);
|
||||
}
|
||||
|
||||
if (this._htOption.useSVG) {
|
||||
Drawing = svgDrawer;
|
||||
}
|
||||
|
||||
this._android = _getAndroid();
|
||||
this._el = el;
|
||||
this._oQRCode = null;
|
||||
this._oDrawing = new Drawing(this._el, this._htOption);
|
||||
|
||||
if (this._htOption.text) {
|
||||
this.makeCode(this._htOption.text);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Make the QRCode
|
||||
*
|
||||
* @param {String} sText link data
|
||||
*/
|
||||
QRCode.prototype.makeCode = function (sText) {
|
||||
this._oQRCode = new QRCodeModel(_getTypeNumber(sText, this._htOption.correctLevel), this._htOption.correctLevel);
|
||||
this._oQRCode.addData(sText);
|
||||
this._oQRCode.make();
|
||||
this._el.title = sText;
|
||||
this._oDrawing.draw(this._oQRCode);
|
||||
this.makeImage();
|
||||
};
|
||||
|
||||
/**
|
||||
* Make the Image from Canvas element
|
||||
* - It occurs automatically
|
||||
* - Android below 3 doesn't support Data-URI spec.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
QRCode.prototype.makeImage = function () {
|
||||
if (typeof this._oDrawing.makeImage == "function" && (!this._android || this._android >= 3)) {
|
||||
this._oDrawing.makeImage();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Clear the QRCode
|
||||
*/
|
||||
QRCode.prototype.clear = function () {
|
||||
this._oDrawing.clear();
|
||||
};
|
||||
|
||||
/**
|
||||
* @name QRCode.CorrectLevel
|
||||
*/
|
||||
QRCode.CorrectLevel = QRErrorCorrectLevel;
|
||||
})();
|
||||
Vendored
+1
File diff suppressed because one or more lines are too long
@@ -15,7 +15,7 @@
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"ConnectionStrings": {
|
||||
"DefaultConnection": "Server=SQL2016DEV;Database=MoonPro_PROG;Trusted_Connection=True;MultipleActiveResultSets=true",
|
||||
"DefaultConnection": "Server=SQL2016DEV;Database=MoonPro_PROG;User ID=sa;Password=keyhammer16;integrated security=False;MultipleActiveResultSets=True;App=MP.Prog;",
|
||||
"Mp.Prog": "Server=SQL2016DEV;Database=MoonPro_PROG;User ID=sa;Password=keyhammer16;integrated security=False;MultipleActiveResultSets=True;App=MP.Prog;",
|
||||
"Redis": "localhost:6379"
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<RootNamespace>MP.Stats</RootNamespace>
|
||||
<UserSecretsId>826e877c-ba70-4253-84cb-d0b1cafd4440</UserSecretsId>
|
||||
<Version>1.1.2109.1617</Version>
|
||||
<Version>1.1.2109.2010</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>Modulo statistiche MAPO</i>
|
||||
<h4>Versione: 1.1.2109.1617</h4>
|
||||
<h4>Versione: 1.1.2109.2010</h4>
|
||||
<br />
|
||||
Note di rilascio:
|
||||
<ul>
|
||||
|
||||
@@ -1 +1 @@
|
||||
1.1.2109.1617
|
||||
1.1.2109.2010
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>1.1.2109.1617</version>
|
||||
<url>https://nexus.steamware.net/repository/SWS/MP-STATS/stable/0/MP.Stats.zip</url>
|
||||
<changelog>https://nexus.steamware.net/repository/SWS/MP-STATS/stable/0/ChangeLog.html</changelog>
|
||||
<version>1.1.2109.2010</version>
|
||||
<url>https://nexus.steamware.net/repository/SWS/MP-STATS/stable/LAST/MP.Stats.zip</url>
|
||||
<changelog>https://nexus.steamware.net/repository/SWS/MP-STATS/stable/LAST/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
</item>
|
||||
|
||||
Reference in New Issue
Block a user