This commit is contained in:
backuppc
2025-07-11 11:30:52 +09:00
parent ed0db28b1f
commit 4f54a97ace
13 changed files with 1187 additions and 131 deletions

View File

@@ -9,6 +9,10 @@ using System.Net.NetworkInformation;
using System.Net;
using System.Data.SqlClient;
using System.Data;
using Microsoft.Web.WebView2.Core;
using Microsoft.Web.WebView2.WinForms;
using System.Drawing;
using System.Windows.Forms;
namespace Project
{
@@ -19,14 +23,14 @@ namespace Project
public static UserSetting uSetting; //user setting
public static Setting setting; //global setting
public static arUtil.Log log; //global logging system
public static DateTime LastInputTime = DateTime.Now;
public static CResult Result = new CResult();
public static DatabaseConnectionString.DatabaseInfo dbinfo = null;
public static void init()
public static void init()
{
FCOMMON.info.Path = Util.CurrentPath;
if (Util.isLocalApplication())
@@ -48,67 +52,116 @@ namespace Project
//log
log = new arUtil.Log();
//clear login info
//clear login info
FCOMMON.info.Login = new FCOMMON.info.sUserInfo();
//language
Lang.Loading(Pub.setting.Language + ".ini");
}
private static WebView2 webView21;
public static void InitializeWebView2()
{
// 수동으로 WebView2 컨트롤 생성
webView21 = new WebView2();
// 기본 속성 설정
webView21.CreationProperties = null;
webView21.DefaultBackgroundColor = Color.White;
webView21.Dock = System.Windows.Forms.DockStyle.Fill;
webView21.Location = new Point(0, 0);
webView21.Name = "webView21";
webView21.Size = new Size(800, 600);
webView21.TabIndex = 0;
webView21.ZoomFactor = 1D;
// 비동기 초기화
InitializeAsync();
}
async private static void InitializeAsync()
{
try
{
// Fixed Version 경로 설정
string runtimePath = System.IO.Path.Combine(Application.StartupPath, "WebView2Runtime");
if (System.IO.Directory.Exists(runtimePath))
{
var env = await CoreWebView2Environment.CreateAsync(runtimePath);
await webView21.EnsureCoreWebView2Async(env);
}
else
{
// 시스템에 설치된 WebView2 사용
await webView21.EnsureCoreWebView2Async();
}
// OWIN 서버의 Login 페이지로 연결
//webView21.Source = new Uri("http://127.0.0.1:9000/Home/Login");
InitWebView = 1;
}
catch (Exception ex)
{
InitWebView = 2;
}
}
public static byte InitWebView = 0;
public static string MakePasswordEnc(string data)
{
var sha1 = new System.Security.Cryptography.SHA1CryptoServiceProvider();
var buffer = System.Text.Encoding.Default.GetBytes(data);
var hashbuf = sha1.ComputeHash(buffer);
var encpass = hashbuf.GetHexString();
var ta = new dsMSSQLTableAdapters.UsersTableAdapter();
encpass = encpass.Replace(" ", "");
return encpass;
}
public static void SetFormStatus(ref System.Windows.Forms.Form f, string formid,Boolean read)
{
var fi = new System.IO.FileInfo(Util.CurrentPath + "formSetting\\" + formid + ".xml");
if (fi.Directory.Exists == false) fi.Directory.Create();
arUtil.XMLHelper xml = new arUtil.XMLHelper(fi.FullName);
if (!xml.Exist())
{
xml.CreateFile();
if (read) return; //읽기인데 파일이 없으므로 넘어간다.
}
if (read)
{
var leftStr = xml.get_Data("position", "left");
var topStr = xml.get_Data("position", "top");
int l = 0;
int t = 0;
if (!int.TryParse(leftStr, out l)) l = 0;
if (!int.TryParse(topStr, out t)) t = 0;
if (l != 0 || t != 0)
{
f.Location = new System.Drawing.Point(l, t);
}
{
var sha1 = new System.Security.Cryptography.SHA1CryptoServiceProvider();
var buffer = System.Text.Encoding.Default.GetBytes(data);
var hashbuf = sha1.ComputeHash(buffer);
var encpass = hashbuf.GetHexString();
var ta = new dsMSSQLTableAdapters.UsersTableAdapter();
encpass = encpass.Replace(" ", "");
return encpass;
}
public static void SetFormStatus(ref System.Windows.Forms.Form f, string formid, Boolean read)
{
var fi = new System.IO.FileInfo(Util.CurrentPath + "formSetting\\" + formid + ".xml");
if (fi.Directory.Exists == false) fi.Directory.Create();
arUtil.XMLHelper xml = new arUtil.XMLHelper(fi.FullName);
if (!xml.Exist())
{
xml.CreateFile();
if (read) return; //읽기인데 파일이 없으므로 넘어간다.
}
if (read)
{
var leftStr = xml.get_Data("position", "left");
var topStr = xml.get_Data("position", "top");
int l = 0;
int t = 0;
if (!int.TryParse(leftStr, out l)) l = 0;
if (!int.TryParse(topStr, out t)) t = 0;
if (l != 0 || t != 0)
{
f.Location = new System.Drawing.Point(l, t);
}
var wStr = xml.get_Data("size", "width");
var hStr = xml.get_Data("size", "height");
int w = 0;
int h = 0;
if (!int.TryParse(wStr, out w)) w = 0;
if (!int.TryParse(hStr, out h)) h = 0;
if (w != 0 || h != 0)
{
f.Size = new System.Drawing.Size(w, h);
}
}
else
{
xml.set_Data("position", "left", f.Left.ToString());
xml.set_Data("position", "top", f.Top.ToString());
xml.set_Data("size", "width", f.Width.ToString());
xml.set_Data("size", "height", f.Height.ToString());
xml.Save();
}
var wStr = xml.get_Data("size", "width");
var hStr = xml.get_Data("size", "height");
int w = 0;
int h = 0;
if (!int.TryParse(wStr, out w)) w = 0;
if (!int.TryParse(hStr, out h)) h = 0;
if (w != 0 || h != 0)
{
f.Size = new System.Drawing.Size(w, h);
}
}
else
{
xml.set_Data("position", "left", f.Left.ToString());
xml.set_Data("position", "top", f.Top.ToString());
xml.set_Data("size", "width", f.Width.ToString());
xml.set_Data("size", "height", f.Height.ToString());
xml.Save();
}
}
}
public static void CheckNRegister3(string prgmName, string develop, string prgmVersion)
{
if (prgmName.Length > 50) prgmName = prgmName.Substring(0, 50); //길이제한