forked from Cecypo-Tech/ERPNext-PowerPlay
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
68 lines (64 loc) · 2.58 KB
/
Program.cs
File metadata and controls
68 lines (64 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using DevExpress.Diagram.Core.Native;
using DevExpress.XtraEditors;
using DevExpress.XtraReports.Security;
using DevExpress.XtraWaitForm;
using Serilog;
using Serilog.Sinks.WinForms.Base;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Runtime.InteropServices;
using System.Windows.Documents;
namespace ERPNext_PowerPlay
{
internal static class Program
{
public static string FrappeURL = "";
public static string FrappeUser = "";
public static string MyAppDir = "";
public static CookieContainer Cookies = new CookieContainer();
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
if (PriorProcess() != null)
{
XtraMessageBox.Show("Another instance of the app is already running.", "ERPNext PowerPlay", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ConfigureSerilog();
ScriptPermissionManager.GlobalInstance = new ScriptPermissionManager(ExecutionMode.Unrestricted);
ApplicationConfiguration.Initialize();
Application.Run(new frmMain());
}
public static Process PriorProcess()
// Returns a System.Diagnostics.Process pointing to
// a pre-existing process with the same name as the
// current one, if any; or null if the current process
// is unique.
{
Process curr = Process.GetCurrentProcess();
Process[] procs = Process.GetProcessesByName(curr.ProcessName);
foreach (Process p in procs)
{
if ((p.Id != curr.Id) &&
(p.MainModule.FileName == curr.MainModule.FileName))
return p;
}
return null;
}
private static void ConfigureSerilog()
{
MyAppDir = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + Path.DirectorySeparatorChar + Application.ProductName;
Log.Logger = new LoggerConfiguration()
.Enrich.FromLogContext()
.WriteToGridView()
.WriteTo.File(path: Program.MyAppDir + @"\\log.txt", rollingInterval: RollingInterval.Day, rollOnFileSizeLimit: true, retainedFileCountLimit: 90)
.CreateLogger();
}
}
}