update 20260522
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace OnDocAPI_NetFramework.Helper
|
||||
{
|
||||
public class DBHelper
|
||||
{
|
||||
string connectionstring = "";
|
||||
public DBHelper(string connectionstring)
|
||||
{
|
||||
this.connectionstring = connectionstring;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
|
||||
namespace OnDocAPI_NetFramework.Helper
|
||||
{
|
||||
public static class Helper
|
||||
{
|
||||
public static void CopyProperties(object source, object target)
|
||||
{
|
||||
var sourceProps = source.GetType().GetProperties();
|
||||
var targetProps = target.GetType().GetProperties();
|
||||
|
||||
foreach (var prop in sourceProps)
|
||||
{
|
||||
var targetProp = targetProps.FirstOrDefault(p => p.Name == prop.Name && p.PropertyType == prop.PropertyType);
|
||||
if (targetProp != null && targetProp.CanWrite)
|
||||
{
|
||||
targetProp.SetValue(target, prop.GetValue(source));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly Random _random = new Random();
|
||||
|
||||
public static string RandomString(int size, bool lowerCase = false)
|
||||
{
|
||||
var builder = new StringBuilder(size);
|
||||
|
||||
char offset = lowerCase ? 'a' : 'A';
|
||||
const int lettersOffset = 26; // A...Z or a..z: length=26
|
||||
|
||||
for (var i = 0; i < size; i++)
|
||||
{
|
||||
var @char = (char)_random.Next(offset, offset + lettersOffset);
|
||||
builder.Append(@char);
|
||||
}
|
||||
|
||||
return lowerCase ? builder.ToString().ToLower() : builder.ToString();
|
||||
}
|
||||
|
||||
public static string NormalizeDateToSystemFormat(string input)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(input))
|
||||
return input;
|
||||
|
||||
var culture = CultureInfo.GetCultureInfo("de-CH");
|
||||
|
||||
string[] knownFormats =
|
||||
{
|
||||
"yyyy-MM-dd",
|
||||
"yyyyMMdd",
|
||||
"dd.MM.yyyy",
|
||||
"d.M.yyyy",
|
||||
"dd/MM/yyyy",
|
||||
"d/MM/yyyy",
|
||||
"d/M/yyyy",
|
||||
"MM/dd/yyyy",
|
||||
"yyyy-MM-ddTHH:mm:ss",
|
||||
"yyyy-MM-dd HH:mm:ss",
|
||||
"dd.MM.yyyy HH:mm:ss",
|
||||
"d.M.yyyy HH:mm:ss"
|
||||
};
|
||||
|
||||
DateTime date;
|
||||
|
||||
// 1. Exakte Formate
|
||||
if (DateTime.TryParseExact(
|
||||
input.Trim(),
|
||||
knownFormats,
|
||||
culture,
|
||||
DateTimeStyles.AllowWhiteSpaces | DateTimeStyles.AssumeLocal,
|
||||
out date))
|
||||
{
|
||||
return date.ToString(culture.DateTimeFormat.ShortDatePattern, culture);
|
||||
}
|
||||
|
||||
// 2. Fallback: freie Erkennung
|
||||
if (DateTime.TryParse(input, culture, DateTimeStyles.AssumeLocal, out date))
|
||||
{
|
||||
return date.ToString(culture.DateTimeFormat.ShortDatePattern, culture);
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using DataMatrix.net;
|
||||
|
||||
namespace OnDocAPI_NetFramework.Helper
|
||||
{
|
||||
public class ImageHelper
|
||||
{
|
||||
public void CalculateImageSize(System.Drawing.Image img, out double targetHeight, out double targetWidth)
|
||||
{
|
||||
targetHeight = 0;
|
||||
targetWidth = 0;
|
||||
|
||||
}
|
||||
|
||||
public System.Drawing.Image Datamatrix(int width, int heigth, int left, int top, List<string>values)
|
||||
{
|
||||
//int imageWidth = 304; // 250; // 142;
|
||||
//int imageHeight = 45; // 37; // 31;
|
||||
|
||||
|
||||
//JToken jObject = JToken.Parse(value);
|
||||
//bool show = jObject.Value<bool>("Show");
|
||||
//if (show)
|
||||
//{
|
||||
// string dokumentId = jObject.Value<string>("DokumentId");
|
||||
// if (dokumentId == null)
|
||||
// {
|
||||
// dokumentId = "123456Edoka Dok Id fehlt!";
|
||||
// }
|
||||
// string avqAuthExtlRef = jObject.Value<string>("AvqAuthExtlRef");
|
||||
// string PartnerNr = jObject.Value<string>("PartnerNr");
|
||||
// string PersonNr = jObject.Value<string>("PersonNr");
|
||||
// string PersonNr1 = jObject.Value<string>("PersonNr1");
|
||||
|
||||
// string text = "imaq$" + dokumentId.Substring(6) + "$0002$" + avqAuthExtlRef + "$" + PartnerNr + "$" + PersonNr + "$" + PersonNr1;
|
||||
// Bitmap dataMatrixBitmap = new DmtxImageEncoder().EncodeImage(text); //.Save("test1.png");
|
||||
|
||||
// Bitmap textBitmap = new Bitmap(4000, 600);
|
||||
// using (Graphics g = Graphics.FromImage(textBitmap))
|
||||
// {
|
||||
// g.DrawImage(dataMatrixBitmap, 0, 0, 600, 600);
|
||||
// g.DrawString(dokumentId.Substring(6) + " U", new Font("Futura Book", 84), Brushes.Black, 650, 360);
|
||||
// }
|
||||
// byte[] textPng = null;
|
||||
// using (MemoryStream m = new MemoryStream())
|
||||
// {
|
||||
// textBitmap.Save(m, System.Drawing.Imaging.ImageFormat.Png);
|
||||
// textPng = m.GetBuffer();
|
||||
// }
|
||||
//}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user